Skip to content

Commit

Permalink
Fix #3233 -- Simple theme classless semantic HTML
Browse files Browse the repository at this point in the history
  • Loading branch information
Paolo Melchiorre committed Oct 31, 2023
1 parent a20cd8d commit c0e2d4d
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 51 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ samples/output
*.pem
*.lock
.pdm-python
.venv
6 changes: 6 additions & 0 deletions docs/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,12 @@ Following are example ways to specify your preferred theme::
# Specify a customized theme, via absolute path
THEME = "/home/myuser/projects/mysite/themes/mycustomtheme"

The built-in ``simple`` can be customized using the following settings.

.. data:: STYLESHEET_URL

The URL of a theme to use as a style sheet.

The built-in ``notmyidea`` theme can make good use of the following settings.
Feel free to use them in your themes as well.

Expand Down
2 changes: 1 addition & 1 deletion pelican/themes/simple/templates/archives.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% block title %}{{ SITENAME|striptags }} - Archives{% endblock %}

{% block content %}
<h1>Archives for {{ SITENAME }}</h1>
<h2>Archives for {{ SITENAME }}</h2>

<dl>
{% for article in dates %}
Expand Down
32 changes: 16 additions & 16 deletions pelican/themes/simple/templates/article.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,44 +22,44 @@
{% endblock %}

{% block content %}
<article>
<header>
<h1 class="entry-title">
<h2>
<a href="{{ SITEURL }}/{{ article.url }}" rel="bookmark"
title="Permalink to {{ article.title|striptags }}">{{ article.title }}</a></h1>
title="Permalink to {{ article.title|striptags }}">{{ article.title }}</a></h2>
{% import 'translations.html' as translations with context %}
{{ translations.translations_for(article) }}
</header>
<footer class="post-info">
<time class="published" datetime="{{ article.date.isoformat() }}">
{{ article.content }}
<footer>
<p>Published: <time datetime="{{ article.date.isoformat() }}">
{{ article.locale_date }}
</time>
</time></p>
{% if article.modified %}
<time class="modified" datetime="{{ article.modified.isoformat() }}">
<p>Last updated: <time datetime="{{ article.modified.isoformat() }}">
{{ article.locale_modified }}
</time>
</time></p>
{% endif %}
{% if article.authors %}
<address class="vcard author">
<address>
By {% for author in article.authors %}
<a class="url fn" href="{{ SITEURL }}/{{ author.url }}">{{ author }}</a>
<a href="{{ SITEURL }}/{{ author.url }}">{{ author }}</a>
{% endfor %}
</address>
{% endif %}
{% if article.category %}
<div class="category">
<p>
Category: <a href="{{ SITEURL }}/{{ article.category.url }}">{{ article.category }}</a>
</div>
</p>
{% endif %}
{% if article.tags %}
<div class="tags">
<p>
Tags:
{% for tag in article.tags %}
<a href="{{ SITEURL }}/{{ tag.url }}">{{ tag }}</a>
{% endfor %}
</div>
</p>
{% endif %}
</footer><!-- /.post-info -->
<article>
{{ article.content }}
</footer>
</article>
{% endblock %}
2 changes: 1 addition & 1 deletion pelican/themes/simple/templates/author.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
{% block title %}{{ SITENAME|striptags }} - Articles by {{ author }}{% endblock %}

{% block content_title %}
<h1>Articles by {{ author }}</h1>
<h2>Articles by {{ author }}</h2>
{% endblock %}
2 changes: 1 addition & 1 deletion pelican/themes/simple/templates/authors.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% block title %}{{ SITENAME|striptags }} - Authors{% endblock %}

{% block content %}
<h1>Authors on {{ SITENAME }}</h1>
<h2>Authors on {{ SITENAME }}</h2>
<ul>
{% for author, articles in authors|sort %}
<li><a href="{{ SITEURL }}/{{ author.url }}">{{ author }}</a> ({{ articles|count }})</li>
Expand Down
15 changes: 9 additions & 6 deletions pelican/themes/simple/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<meta charset="utf-8" />
<meta name="generator" content="Pelican" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{% if STYLESHEET_URL %}
<link rel="stylesheet" type="text/css" href="{{ STYLESHEET_URL }}" />
{% endif %}
{% if FEED_ALL_ATOM %}
<link href="{{ FEED_DOMAIN }}/{% if FEED_ALL_ATOM_URL %}{{ FEED_ALL_ATOM_URL }}{% else %}{{ FEED_ALL_ATOM }}{% endif %}" type="application/atom+xml" rel="alternate" title="{{ SITENAME|striptags }} Full Atom Feed" />
{% endif %}
Expand Down Expand Up @@ -35,32 +38,32 @@

<body>
<header>
<h1><a href="{{ SITEURL }}/">{{ SITENAME }}{% if SITESUBTITLE %} <strong>{{ SITESUBTITLE }}</strong>{% endif %}</a></h1>
</header>
<hgroup><h1><a href="{{ SITEURL }}/">{{ SITENAME }}</a></h1>{% if SITESUBTITLE %}<p>{{ SITESUBTITLE }}</p>{% endif %}</hgroup>
<nav><ul>
{% for title, link in MENUITEMS %}
<li><a href="{{ link }}">{{ title }}</a></li>
{% endfor %}
{% if DISPLAY_PAGES_ON_MENU %}
{% for p in pages %}
<li{% if p == page %} class="active"{% endif %}><a href="{{ SITEURL }}/{{ p.url }}">{{ p.title }}</a></li>
<li><a href="{{ SITEURL }}/{{ p.url }}" {% if p==page %} aria-current="page" {% endif %}>{{ p.title }}</a></li>
{% endfor %}
{% endif %}
{% if DISPLAY_CATEGORIES_ON_MENU %}
{% for cat, null in categories %}
<li{% if cat == category %} class="active"{% endif %}><a href="{{ SITEURL }}/{{ cat.url }}">{{ cat }}</a></li>
<li><a href="{{ SITEURL }}/{{ cat.url }}" {% if cat==category %} aria-current="page" {% endif %}>{{ cat}}</a></li>
{% endfor %}
{% endif %}
</ul></nav>
</header>
<main>
{% block content %}
{% endblock %}
</main>
<footer>
<address id="about" class="vcard body">
<address>
Proudly powered by <a rel="nofollow" href="https://getpelican.com/">Pelican</a>,
which takes great advantage of <a rel="nofollow" href="https://www.python.org/">Python</a>.
</address><!-- /#about -->
</address>
</footer>
</body>
</html>
2 changes: 1 addition & 1 deletion pelican/themes/simple/templates/categories.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% block title %}{{ SITENAME|striptags }} - Categories{% endblock %}

{% block content %}
<h1>Categories on {{ SITENAME }}</h1>
<h2>Categories on {{ SITENAME }}</h2>
<ul>
{% for category, articles in categories|sort %}
<li><a href="{{ SITEURL }}/{{ category.url }}">{{ category }}</a> ({{ articles|count }})</li>
Expand Down
2 changes: 1 addition & 1 deletion pelican/themes/simple/templates/category.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
{% block title %}{{ SITENAME|striptags }} - {{ category }} category{% endblock %}

{% block content_title %}
<h1>Articles in the {{ category }} category</h1>
<h2>Articles in the {{ category }} category</h2>
{% endblock %}
25 changes: 12 additions & 13 deletions pelican/themes/simple/templates/index.html
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
{% extends "base.html" %}
{% block content %}
<section id="content">
{% block content_title %}
<h2>All articles</h2>
{% endblock %}

<ol id="post-list">

{% for article in articles_page.object_list %}
<li><article class="hentry">
<header> <h2 class="entry-title"><a href="{{ SITEURL }}/{{ article.url }}" rel="bookmark" title="Permalink to {{ article.title|striptags }}">{{ article.title }}</a></h2> </header>
<footer class="post-info">
<time class="published" datetime="{{ article.date.isoformat() }}"> {{ article.locale_date }} </time>
<address class="vcard author">By
<article>
<header> <h2><a href="{{ SITEURL }}/{{ article.url }}" rel="bookmark" title="Permalink to {{ article.title|striptags }}">{{ article.title }}</a></h2> </header>
<section>{{ article.summary }}</section>
<footer>
<p>Published: <time datetime="{{ article.date.isoformat() }}"> {{ article.locale_date }} </time></p>
<address>By
{% for author in article.authors %}
<a class="url fn" href="{{ SITEURL }}/{{ author.url }}">{{ author }}</a>
<a href="{{ SITEURL }}/{{ author.url }}">{{ author }}</a>
{% endfor %}
</address>
</footer><!-- /.post-info -->
<div class="entry-content"> {{ article.summary }} </div><!-- /.entry-content -->
</article></li>
</footer>
</article>
{% endfor %}
</ol><!-- /#posts-list -->

{% if articles_page.has_other_pages() %}
{% include 'pagination.html' %}
{% endif %}
</section><!-- /#content -->

{% endblock content %}
8 changes: 7 additions & 1 deletion pelican/themes/simple/templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,21 @@
{% endblock %}

{% block content %}
<h1>{{ page.title }}</h1>
<article>
<header>
<h2>{{ page.title }}</h2>
</header>
{% import 'translations.html' as translations with context %}
{{ translations.translations_for(page) }}

{{ page.content }}

{% if page.modified %}
<footer>
<p>
Last updated: {{ page.locale_modified }}
</p>
</footer>
{% endif %}
</article>
{% endblock %}
16 changes: 9 additions & 7 deletions pelican/themes/simple/templates/pagination.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{% if DEFAULT_PAGINATION %}
{% set first_page = articles_paginator.page(1) %}
{% set last_page = articles_paginator.page(articles_paginator.num_pages) %}
<p class="paginator">
<nav>
<ul>
{% if articles_page.has_previous() %}
<a href="{{ SITEURL }}/{{ first_page.url }}">&#8647;</a>
<a href="{{ SITEURL }}/{{ articles_previous_page.url }}">&laquo;</a>
<li><a href="{{ SITEURL }}/{{ first_page.url }}">&Lang;</a></li>
<li><a href="{{ SITEURL }}/{{ articles_previous_page.url }}">&lang;</a></li>
{% endif %}
Page {{ articles_page.number }} / {{ articles_paginator.num_pages }}
<li>Page {{ articles_page.number }} / {{ articles_paginator.num_pages }}</li>
{% if articles_page.has_next() %}
<a href="{{ SITEURL }}/{{ articles_next_page.url }}">&raquo;</a>
<a href="{{ SITEURL }}/{{ last_page.url }}">&#8649;</a>
<li><a href="{{ SITEURL }}/{{ articles_next_page.url }}">&rang;</a></li>
<li><a href="{{ SITEURL }}/{{ last_page.url }}">&Rang;</a></li>
{% endif %}
</p>
</ul>
</nav>
{% endif %}
2 changes: 1 addition & 1 deletion pelican/themes/simple/templates/period_archives.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% block title %}{{ SITENAME|striptags }} - {{ period | reverse | join(' ') }} archives{% endblock %}

{% block content %}
<h1>Archives for {{ period | reverse | join(' ') }}</h1>
<h2>Archives for {{ period | reverse | join(' ') }}</h2>

<dl>
{% for article in dates %}
Expand Down
2 changes: 1 addition & 1 deletion pelican/themes/simple/templates/tag.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
{% block title %}{{ SITENAME|striptags }} - {{ tag }} tag{% endblock %}

{% block content_title %}
<h1>Articles tagged with {{ tag }}</h1>
<h2>Articles tagged with {{ tag }}</h2>
{% endblock %}
2 changes: 1 addition & 1 deletion pelican/themes/simple/templates/tags.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% block title %}{{ SITENAME|striptags }} - Tags{% endblock %}

{% block content %}
<h1>Tags for {{ SITENAME }}</h1>
<h2>Tags for {{ SITENAME }}</h2>
<ul>
{% for tag, articles in tags|sort %}
<li><a href="{{ SITEURL }}/{{ tag.url }}">{{ tag }}</a> ({{ articles|count }})</li>
Expand Down

0 comments on commit c0e2d4d

Please sign in to comment.