From 77c03dd6e56990bfdc0f6f53d0e37cc435367292 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 23 Aug 2017 13:18:47 +0200 Subject: [PATCH] theme: make the output pretty indented. There will be a minifier step later anyway, but this helps debugging (and my OCD) a lot. --- pelican-theme/templates/archives.html | 43 +++++---- pelican-theme/templates/article.html | 96 ++++++++++--------- pelican-theme/templates/article_header.html | 11 +-- pelican-theme/templates/author.html | 6 +- pelican-theme/templates/base.html | 48 +++++----- .../templates/base_blog_section.html | 29 +++--- pelican-theme/templates/category.html | 6 +- pelican-theme/templates/page.html | 11 ++- pelican-theme/templates/pagination.html | 8 +- pelican-theme/templates/tag.html | 6 +- 10 files changed, 137 insertions(+), 127 deletions(-) diff --git a/pelican-theme/templates/archives.html b/pelican-theme/templates/archives.html index fe744bd5..37a76825 100644 --- a/pelican-theme/templates/archives.html +++ b/pelican-theme/templates/archives.html @@ -1,23 +1,26 @@ {% extends "base_blog.html" %} {% block content %} -
- {% block content_title %} - {% endblock content_title %} - {% for article in articles_page.object_list %} -
- {% include "article_header.html" %} - {% if loop.first and articles_page.number == 1 %} -
- {{ article.content }} - {% endif %} - {% include "article_footer.html" %} - {% if not loop.first or articles_page.number != 1 %} -
- {% endif %} -
- {% endfor %} - {% if articles_page.has_other_pages() %} - {% include 'pagination.html' %} - {% endif %} -
+
+ {% block content_title %} + {% endblock content_title %} + {% for article in articles_page.object_list %} +
+ {% macro header() %}{% include "article_header.html" %}{% endmacro %} + {{ header()|indent(8) }} + {% if loop.first and articles_page.number == 1 %} +
+ {{ article.content|indent(8) }} + {% endif %} + {% macro footer() %}{% include "article_footer.html" %}{% endmacro %} + {{ footer()|indent(8) }} + {% if not loop.first or articles_page.number != 1 %} +
+ {% endif %} +
+ {% endfor %} + {% if articles_page.has_other_pages() %} + {% macro pagination() %}{% include 'pagination.html' %}{% endmacro %} + {{ pagination()|indent(6) }} + {% endif %} +
{% endblock content %} diff --git a/pelican-theme/templates/article.html b/pelican-theme/templates/article.html index 36ebfdc3..7d0956b4 100644 --- a/pelican-theme/templates/article.html +++ b/pelican-theme/templates/article.html @@ -18,58 +18,60 @@ {% endblock %} {% block content %} -{% if article.cover %} -
-
-
-
-
-
-
{{ article.locale_date }}
-
{% for author in article.authors %}{{ author }}{% endfor %}
+ {% if article.cover %} +
+
+
+
+
+
+
{{ article.locale_date }}
+
{% for author in article.authors %}{{ author }}{% endfor %}
+
+
+
+ {% set title = article.title.split(' — ') %} +

+ {{ title[0] }} +

+ {% if title|length >= 2 %}

{{ title[1] }}

{% endif %} +
+
+
+
+
-
- {% set title = article.title.split(' — ') %} -

- {{ title[0] }} -

- {% if title|length >= 2 %}

{{ title[1] }}

{% endif %} +
+ {{ article.summary }}
-
-
-
-
-
- {{ article.summary }} +
+
+
+
+ {{ article.content }} +
- - -
-
-
- {{ article.content }} -
-
-
-
-
-
-

Posted {% if article.authors %}by {% for author in article.authors %}{{ author }}{% endfor %}{% endif %} on in {{ article.category }}.{% if article.tags %} Tags: {% for tag in article.tags %}{{ tag }}{% if not loop.last %}, {% endif %}{% endfor %}.{% endif %}

-
-
-
-
-{% else %} -
- {% include "article_header.html" %} -
- {{ article.content }} - {% include "article_footer.html" %} -
-{% endif %} + + + {% else %} +
+ {% macro header() %}{% include "article_header.html" %}{% endmacro %} + {{ header()|indent(6) }} +
+ {{ article.content|indent(6) }} + {% macro footer() %}{% include "article_footer.html" %}{% endmacro %} + {{ footer()|indent(6) }} +
+ {% endif %} {% endblock %} diff --git a/pelican-theme/templates/article_header.html b/pelican-theme/templates/article_header.html index 23492071..626ab8f3 100644 --- a/pelican-theme/templates/article_header.html +++ b/pelican-theme/templates/article_header.html @@ -1,11 +1,10 @@
-

+

- {{ article.title }} + {{ article.title }}

- {{ article.summary }} + {{ article.summary|indent(2) }}

diff --git a/pelican-theme/templates/author.html b/pelican-theme/templates/author.html index c69de751..51cf8249 100644 --- a/pelican-theme/templates/author.html +++ b/pelican-theme/templates/author.html @@ -3,7 +3,7 @@ {% block title %}Posts by {{ author }} | {{ BLOGNAME }}{% endblock %} {% block content_title %} -
- Showing only posts by {{ author }}. Show all posts. -
+
+ Showing only posts by {{ author }}. Show all posts. +
{% endblock %} diff --git a/pelican-theme/templates/base.html b/pelican-theme/templates/base.html index f9df7df0..c6e1d952 100644 --- a/pelican-theme/templates/base.html +++ b/pelican-theme/templates/base.html @@ -23,8 +23,8 @@
- {% if SITE_LOGO %}{% endif %} - {{ SITE_LOGO_TEXT }} + {%- if SITE_LOGO %}{% endif -%} + {{- SITE_LOGO_TEXT -}} @@ -33,7 +33,7 @@
    {% for title, link, sub in LINKS_NAVBAR1 %}
  1. - {{ title }} + {{ title }} {% if sub %}
      {% for title, link in sub %} @@ -47,11 +47,11 @@
        {% for title, link, sub in LINKS_NAVBAR2 %}
      1. - {{ title }} + {{ title }} {% if sub %}
          {% for title, link in sub %} -
        1. {{ title }}
        2. +
        3. {{ title }}
        4. {% endfor %}
        {% endif %} @@ -74,39 +74,39 @@

        - {% if LINKS_FOOTER1[0][1] %}{% endif %} - {{ LINKS_FOOTER1[0][0] }} - {% if LINKS_FOOTER1[0][1] %}{% endif %} + {%- if LINKS_FOOTER1[0][1] %}{% endif %} + {{- LINKS_FOOTER1[0][0] -}} + {% if LINKS_FOOTER1[0][1] -%}{% endif -%}

          - {% for title, link in LINKS_FOOTER1 %} - {% if loop.index0 != 0 %}
        • {{ title }}
        • {% endif %} - {% endfor %} + {% for title, link in LINKS_FOOTER1 %}{% if loop.index0 != 0 %} +
        • {{ title }}
        • + {% endif %}{% endfor %}

        - {% if LINKS_FOOTER2[0][1] %}{% endif %} - {{ LINKS_FOOTER2[0][0] }} - {% if LINKS_FOOTER2[0][1] %}{% endif %} + {%- if LINKS_FOOTER2[0][1] %}{% endif %} + {{- LINKS_FOOTER2[0][0] -}} + {% if LINKS_FOOTER2[0][1] %}{% endif -%}

          - {% for title, link in LINKS_FOOTER2 %} - {% if loop.index0 != 0 %}
        • {{ title }}
        • {% endif %} - {% endfor %} + {% for title, link in LINKS_FOOTER2 %}{% if loop.index0 != 0 %} +
        • {{ title }}
        • + {% endif %}{% endfor %}

        - {% if LINKS_FOOTER3[0][1] %}{% endif %} - {{ LINKS_FOOTER3[0][0] }} - {% if LINKS_FOOTER3[0][1] %}{% endif %} + {%- if LINKS_FOOTER3[0][1] %}{% endif %} + {{- LINKS_FOOTER3[0][0] -}} + {% if LINKS_FOOTER3[0][1] %}{% endif -%}

          - {% for title, link in LINKS_FOOTER3 %} - {% if loop.index0 != 0 %}
        • {{ title }}
        • {% endif %} - {% endfor %} + {% for title, link in LINKS_FOOTER3 %}{% if loop.index0 != 0 %} +
        • {{ title }}
        • + {% endif %}{% endfor %}
        @@ -133,7 +133,7 @@
        - {{ FINE_PRINT|render_rst }} + {{ FINE_PRINT|render_rst|indent(10) }}
        diff --git a/pelican-theme/templates/base_blog_section.html b/pelican-theme/templates/base_blog_section.html index 45634a84..72211f17 100644 --- a/pelican-theme/templates/base_blog_section.html +++ b/pelican-theme/templates/base_blog_section.html @@ -1,16 +1,19 @@ {% extends "base_blog.html" %} {% block content %} -
        - {% block content_title %} - {% endblock content_title %} - {% for article in articles_page.object_list %} -
        - {% include "article_header.html" %} - {% include "article_footer.html" %} -
        - {% endfor %} - {% if articles_page.has_other_pages() %} - {% include 'pagination.html' %} - {% endif %} -
        +
        + {% block content_title %} + {% endblock content_title %} + {% for article in articles_page.object_list %} +
        + {% macro header() %}{% include "article_header.html" %}{% endmacro %} + {{ header()|indent(8) }} + {% macro footer() %}{% include "article_footer.html" %}{% endmacro %} + {{ footer()|indent(8) }} +
        + {% endfor %} + {% if articles_page.has_other_pages() %} + {% macro pagination() %}{% include 'pagination.html' %}{% endmacro %} + {{ pagination()|indent(6) }} + {% endif %} +
        {% endblock content %} diff --git a/pelican-theme/templates/category.html b/pelican-theme/templates/category.html index 7c443273..3b91c063 100644 --- a/pelican-theme/templates/category.html +++ b/pelican-theme/templates/category.html @@ -3,7 +3,7 @@ {% block title %}{{ category }} | {{ BLOGNAME }}{% endblock %} {% block content_title %} -
        - Showing only posts in {{ category }}. Show all posts. -
        +
        + Showing only posts in {{ category }}. Show all posts. +
        {% endblock %} diff --git a/pelican-theme/templates/page.html b/pelican-theme/templates/page.html index b3ebd553..19d756f9 100644 --- a/pelican-theme/templates/page.html +++ b/pelican-theme/templates/page.html @@ -1,14 +1,21 @@ {% set page_title = page.title|replace('­', '') %} {% extends "base.html" %} -{% block title %}{{ page.title }} | {{ SITENAME }}{%endblock%} +{% block title %}{{ page.title }} | {{ SITENAME }}{% endblock %} + +{% block head %} + {{- super() -}} + {% if page.css %} + + {% endif %} +{% endblock %} {% block main %}

        {{ page.title }}

        - {{ page.content }} + {{ page.content|indent(6) }}
        diff --git a/pelican-theme/templates/pagination.html b/pelican-theme/templates/pagination.html index ecbb6dfd..c62e8994 100644 --- a/pelican-theme/templates/pagination.html +++ b/pelican-theme/templates/pagination.html @@ -1,11 +1,7 @@ {% if DEFAULT_PAGINATION %}
        - {% if articles_page.has_previous() %} - « newer articles | - {% endif %} + {%- if articles_page.has_previous() %}« newer articles | {% endif -%} page {{ articles_page.number }} - {% if articles_page.has_next() %} - | older articles » - {% endif %} + {%- if articles_page.has_next() %} | older articles »{% endif -%}
        {% endif %} diff --git a/pelican-theme/templates/tag.html b/pelican-theme/templates/tag.html index 24e62040..1dd694c1 100644 --- a/pelican-theme/templates/tag.html +++ b/pelican-theme/templates/tag.html @@ -3,7 +3,7 @@ {% block title %}Posts tagged {{ tag }} | {{ BLOGNAME }}{% endblock %} {% block content_title %} -
        - Showing only posts tagged {{ tag }}. Show all posts. -
        +
        + Showing only posts tagged {{ tag }}. Show all posts. +
        {% endblock %} -- 2.30.2