Skip to content

Commit

Permalink
Refactor theme
Browse files Browse the repository at this point in the history
Remove useless stuff
Improve dark mode toggle
Improve mobile version
Fix css
Fix search
  • Loading branch information
Juca Crispim committed Nov 11, 2024
1 parent 47f4425 commit 0793923
Show file tree
Hide file tree
Showing 15 changed files with 4,859 additions and 248 deletions.
5 changes: 5 additions & 0 deletions babel.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Extraction from Jinja2 HTML templates
[jinja2: **/**.html]
encoding = utf-8
ignore_tags = script,style
include_attrs = alt title summary placeholder
6 changes: 6 additions & 0 deletions sphinx_pdj_theme/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-

import os


Expand All @@ -6,6 +8,10 @@ def get_html_theme_path():
cur_dir = os.path.abspath(os.path.dirname(__file__))
return cur_dir

def get_locale_path():
return os.path.join(os.path.abspath(os.path.dirname(__file__)), 'locale')


def setup(app):
app.add_message_catalog('sphinx', get_locale_path())
app.add_html_theme('sphinx_pdj_theme', get_html_theme_path())
30 changes: 15 additions & 15 deletions sphinx_pdj_theme/footer.html
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
<footer>
{% if next or prev %}
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
{% if next %}
<a href="{{ next.link|e }}" class="btn btn-neutral float-right" title="{{ next.title|striptags|e }}">Next <span class="fa fa-arrow-circle-right"></span></a>
{% endif %}
{% if prev %}
<a href="{{ prev.link|e }}" class="btn btn-neutral" title="{{ prev.title|striptags|e }}"><span class="fa fa-arrow-circle-left"></span> Previous</a>
{% endif %}
</div>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
{% if next %}
<a href="{{ next.link|e }}" class="btn btn-neutral float-right" title="{{ next.title|striptags|e }}">{{ _('Next') }} <span class="fa fa-arrow-circle-right"></span></a>
{% endif %}
{% if prev %}
<a href="{{ prev.link|e }}" class="btn btn-neutral" title="{{ prev.title|striptags|e }}"><span class="fa fa-arrow-circle-left"></span>{{ _('Previous') }}</a>
{% endif %}
</div>
{% endif %}

<hr/>

<div role="contentinfo">
<p>
{%- if show_copyright %}
{%- if show_copyright %}
{%- if hasdoc('copyright') %}
{% trans path=pathto('copyright'), copyright=copyright|e %}&copy; <a href="{{ path }}">Copyright</a> {{ copyright }}.{% endtrans %}
{% trans path=pathto('copyright'), copyright=copyright|e %}&copy; <a href="{{ path }}">Copyright</a> {{ copyright }}.{% endtrans %}
{%- else %}
{% trans copyright=copyright|e %}&copy; Copyright {{ copyright }}.{% endtrans %}
{% trans copyright=copyright|e %}&copy; Copyright {{ copyright }}.{% endtrans %}
{%- endif %}
{%- endif %}
{%- endif %}

{%- if last_updated %}
{%- if last_updated %}
{% trans last_updated=last_updated|e %}Last updated on {{ last_updated }}.{% endtrans %}
{%- endif %}
{%- endif %}
</p>
</div>

{% trans %}Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/jucacrispim/sphinx_pdj_theme">theme</a> provided by <a href="https://poraodojuca.dev">Porão do Juca</a>{% endtrans %}.
{{_('Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/jucacrispim/sphinx_pdj_theme">theme</a> provided by <a href="https://poraodojuca.dev">Porão do Juca</a>')}}.

</footer>
228 changes: 65 additions & 163 deletions sphinx_pdj_theme/layout.html
Original file line number Diff line number Diff line change
@@ -1,187 +1,89 @@
{%- if not embedded and docstitle %}
{%- set titlesuffix = " &mdash; "|safe + docstitle|e %}
{%- else %}
{%- set titlesuffix = "" %}
{%- endif %}
{% extends "basic/layout.html" %}
{% set script_files = script_files + ["_static/js/pdj.js"] %}

{%- macro script() %}
{%- macro pdjcss() %}
{%- for css in css_files %}
{%- if css|attr("filename") %}
{{ css_tag(css) }}

{%- else %}
<link rel="stylesheet" href="{{ pathto(css, 1)|e }}" type="text/css" />
{%- endif %}
{%- endfor %}

<link rel="stylesheet" href="{{ pathto('_static/css/darker.css', 1)|e }}" type="text/css"
media="(prefers-color-scheme: dark)"/>

{%- endmacro %}

{%- macro pdjscript() %}
{%- for js in script_files %}
{{ js_tag(js) }}
{%- endfor %}
{%- endmacro %}

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xml:lang="{{ LANGUAGE_CODE }}" lang="{{ LANGUAGE_CODE }}" version="-//W3C//DTD XHTML 1.1//EN" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="theme-color" content="">
<link rel="icon" type="image/x-icon" href="{{favicon_url}}">
<script type="module" src="{{ pathto('_static/js/dark-mode-toggle.js', 1)|e }}"></script>
{%- endmacro %}

{% block htmltitle %}
<title>{{ title|striptags|e }}{{ titlesuffix }}</title>
{% endblock %}

{%- block scripts %}
{{- script() }}
{%- endblock %}

{% block body_tag %} <body class="wy-body-for-nav" role="document"> {% endblock %}

{%- block css %}
{{- pdjcss() }}
<link href='https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic|Roboto+Slab:400,700|Inconsolata:400,700' rel='stylesheet' type='text/css'/>
{%- endblock %}

{%- block scripts %}
{{- pdjscript() }}
{%- endblock %}

{% for cssfile in css_files %}
{% if cssfile.filename.endswith('darker.css') %}
<link rel="stylesheet" href="{{ pathto(cssfile, 1) }}" type="text/css"
media="(prefers-color-scheme: dark)"/>
{% else %}
<link rel="stylesheet" href="{{ pathto(cssfile, 1) }}" type="text/css" />
{% endif %}
{% endfor %}

{% for cssfile in extra_css_files %}
<link rel="stylesheet" href="{{ pathto(cssfile, 1) }}" type="text/css" />
{% endfor %}


{%- block linktags %}
{%- if hasdoc('about') %}
<link rel="author" title="{{ _('About these documents') }}"
href="{{ pathto('about') }}"/>
{%- endif %}
{%- if hasdoc('genindex') %}
<link rel="index" title="{{ _('Index') }}"
href="{{ pathto('genindex') }}"/>
{%- endif %}
{%- if hasdoc('search') %}
<link rel="search" title="{{ _('Search') }}" href="{{ pathto('search') }}"/>
{%- endif %}
{%- if hasdoc('copyright') %}
<link rel="copyright" title="{{ _('Copyright') }}" href="{{ pathto('copyright') }}"/>
{%- endif %}
<link rel="top" title="{{ docstitle|e }}" href="{{ pathto('index') }}"/>
{%- if parents %}
<link rel="up" title="{{ parents[-1].title|striptags|e }}" href="{{ parents[-1].link|e }}"/>
{%- endif %}
{%- if next %}
<link rel="next" title="{{ next.title|striptags|e }}" href="{{ next.link|e }}"/>
{%- endif %}
{%- if prev %}
<link rel="prev" title="{{ prev.title|striptags|e }}" href="{{ prev.link|e }}"/>
{%- endif %}
{%- endblock %}
{%- block extrahead %} {%- endblock %}

<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="cache-control" content="public" />
<meta name="robots" content="follow, all" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
{%- block meta %}{%- endblock %}


{%- block link %}{%- endblock %}


<script type="module" src="https://googlechromelabs.github.io/dark-mode-toggle/src/dark-mode-toggle.mjs"></script>
</head>

<body class="wy-body-for-nav" role="document">

<div class="wy-grid-for-nav">
{%- block barralateral %}
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-nav-search {%- if flatpage %} wy-side-nav-search-flat {%- endif %}">
{% if theme_home_link != 'hide' %}
<a href="{{ pathto(master_doc) }}" class="fa fa-home"> {{ project }} </a>
{% endif %}
{% if logo_url %}
<div id="logo-container">
<a href="{{ pathto(master_doc) }}">
<img src="{{logo_url}}"
style="
{% if theme_logo_width %}width:{{theme_logo_width}};{% endif %}
{% if theme_logo_height %}height:{{theme_logo_height}};{% endif %}
"
/>

</a>
</div>
{% endif %}
{%- block searchesquerda %}
<div role="search">
{% if theme_search != "hide" %}
<form id ="rtd-search-form" class="wy-form"
action="{{ pathto('search') }}" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
{% endif %}
</div>
{%- endblock %}
</div>

<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
{% block menu %}
{% set toctree = toctree(maxdepth=2, collapse=False, includehidden=True) %}
{% if toctree %}
{{ toctree }}
{% else %}
<!-- Local TOC -->
<div class="local-toc">{{ toc }}</div>
{% endif %}
{% endblock %}
{%- block relbar1 %}{% endblock %}
{%- block relbar2 %}{% endblock %}

</div>
&nbsp;
</nav>
{%- endblock %}
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap {%- if flatpage %} bkg-escuro {%- endif %}">

<nav class="wy-nav-top" id="barra-mobile" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="#">{{ project }} </a>
</nav>

<div class="wy-nav-content">
{%- block fundoclaro %}
<div class="fundo-claro">
</div>
{%- endblock %}
<div class="fundo-escuro">
</div>
{% block content %}

<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
{# {%- block breadcrumbs %}{%- endblock %} #}
</div>
<div role="main" class="{%- if flatpage %} flatpage {%- endif %}">
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap {%- if flatpage %} bkg-escuro {%- endif %}">

<div id="content" class="hfeed entry-container hentry">
<div id="dark-mode-toggle-container">
<dark-mode-toggle appearance="toggle" dark="{%trans msg=msg|e %}switch to light mode{% endtrans %}" light="{%trans msg=msg|e %}switch to dark mode{% endtrans %}">
</dark-mode-toggle>
</div>
<nav class="wy-nav-top" id="barra-mobile" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="#">{{ project }} </a>
</nav>

{%- block body %}
{%- endblock %}
</div>
{% include "footer.html" %}
</div>
</div>
{% if not embedded %}
<div class="wy-nav-content">
<div class="fundo-claro">
</div>
<div class="fundo-escuro">
</div>

{%- for scriptfile in script_files %}
<script type="text/javascript" src="{{ pathto(scriptfile, 1) }}">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
{%- block breadcrumbs %}{%- endblock %}
</div>
<div role="main" class="">

</script>
{%- endfor %}
<div id="content" class="hfeed entry-container hentry">
<div id="dark-mode-toggle-container">
<dark-mode-toggle appearance="toggle" class="slider" dark="" light="">
</dark-mode-toggle>
</div>
{%- block body %}
{%- endblock %}
</div>
</div>

{% endif %}
{% block innerfooter %}
{% include "footer.html" %}
{% endblock %}

<div class="clearer"></div>
</div>
</div>

</section>

{%- block footer %} {% endblock %}
{% include "sidebar.html" %}
{% endblock %}

</body>
</html>
{%- block footer %}
{%- endblock %}
Binary file added sphinx_pdj_theme/locale/pt/LC_MESSAGES/sphinx.mo
Binary file not shown.
53 changes: 53 additions & 0 deletions sphinx_pdj_theme/locale/pt/LC_MESSAGES/sphinx.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Translations template for PROJECT.
# Copyright (C) 2024 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2024.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-11-09 14:23-0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.16.0\n"

#: sphinx_pdj_theme/footer.html:5
msgid "Next"
msgstr "Próximo"

#: sphinx_pdj_theme/footer.html:8
msgid "Previous"
msgstr "Anterior"

#: sphinx_pdj_theme/footer.html:19
#, python-format
msgid "&copy; <a href=\"%(path)s\">Copyright</a> %(copyright)s."
msgstr ""

#: sphinx_pdj_theme/footer.html:21
#, python-format
msgid "&copy; Copyright %(copyright)s."
msgstr ""

#: sphinx_pdj_theme/footer.html:26
#, python-format
msgid "Last updated on %(last_updated)s."
msgstr "Última atualização em %(last_updated)s."

#: sphinx_pdj_theme/footer.html:31
msgid ""
"Built with <a href=\"http://sphinx-doc.org/\">Sphinx</a> using a <a "
"href=\"https://github.com/jucacrispim/sphinx_pdj_theme\">theme</a> "
"provided by <a href=\"https://poraodojuca.dev\">Porão do Juca</a>"

msgstr "Feito com <a href=\"http://sphinx-doc.org/\">Sphinx</a> usando um <a href=\"https://github.com/jucacrispim/sphinx_pdj_theme\">tema</a> fornecido por <a href=\"https://poraodojuca.dev\">Porão do Juca</a>"

#: sphinx_pdj_theme/searchbox.html:4
msgid "Search"
msgstr "Pesquisa"
2 changes: 1 addition & 1 deletion sphinx_pdj_theme/searchbox.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{%- if builder != 'singlehtml' %}
<div role="search">
<form id="rtd-search-form" class="wy-form" action="{{ pathto('search') }}" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="text" name="q" placeholder="{{_('Search') }}" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
Expand Down
Loading

0 comments on commit 0793923

Please sign in to comment.