Skip to content

Commit

Permalink
added back old templates but with warning
Browse files Browse the repository at this point in the history
  • Loading branch information
nabobalis committed Aug 7, 2022
1 parent 66f81bb commit 9abb8c4
Show file tree
Hide file tree
Showing 15 changed files with 449 additions and 8 deletions.
11 changes: 6 additions & 5 deletions ablog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from glob import glob
from pathlib import PurePath

from sphinx.builders.latex import LaTeXBuilder
from sphinx.jinja2glue import BuiltinTemplateLoader, SphinxFileSystemLoader

from .blog import CONFIG, Blog
Expand Down Expand Up @@ -72,12 +73,12 @@ def html_page_context(app, pagename, templatename, context, doctree):
context["feed_title"] = blog.blog_title


def config_inited(app):
def config_inited(app, config):
# Automatically identify any blog posts if a pattern is specified in the config
if isinstance(app.config.blog_post_pattern, str):
app.config.blog_post_pattern = [app.config.blog_post_pattern]
if isinstance(config.blog_post_pattern, str):
config.blog_post_pattern = [config.blog_post_pattern]
matched_patterns = []
for pattern in app.config.blog_post_pattern:
for pattern in config.blog_post_pattern:
pattern = os.path.join(app.srcdir, pattern)
# make sure that blog post paths have forward slashes even on windows
matched_patterns.extend(
Expand All @@ -88,7 +89,7 @@ def config_inited(app):


def builder_inited(app):
if app.config.skip_injecting_base_ablog_templates:
if isinstance(app.builder, LaTeXBuilder) or app.config.skip_injecting_base_ablog_templates:
return
if not isinstance(app.builder.templates, BuiltinTemplateLoader):
raise Exception(
Expand Down
17 changes: 17 additions & 0 deletions ablog/templates/archives.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{ warning("archives.html is an old template path, that is no longer used by ablog. Please use ablog/archives.html instead.") }}
{% if ablog.archive %}
<div class="ablog-sidebar-item ablog__archive">
<h3>
<a href="{{ pathto(ablog.archive.docname) }}">{{ gettext('Archives') }}</a>
</h3>
<ul>
{% for coll in ablog.archive %}
{% if coll %}
<li>
<a href="{{ pathto(coll.docname) }}">{{ coll }} ({{ coll|length }})</a>
</li>
{% endif %}
{% endfor %}
</ul>
</div>
{% endif %}
13 changes: 13 additions & 0 deletions ablog/templates/authors.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{ warning("authors.html is an old template path, that is no longer used by ablog. Please use ablog/authors.html instead.") }}
{% if ablog.author %}
<div class="ablog-sidebar-item ablog__authors">
<h3><a href="{{ pathto(ablog.author.path) }}">{{ gettext('Authors') }}</a></h3>
<ul>
{% for coll in ablog.author %} {% if coll %}
<li>
<a href="{{ pathto(coll.docname) }}">{{ coll }} ({{ coll|length }})</a>
</li>
{% endif %} {% endfor %}
</ul>
</div>
{% endif %}
29 changes: 29 additions & 0 deletions ablog/templates/catalog.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{ warning("catalog.html is an old template path, that is no longer used by ablog. Please use ablog/catalog.html instead.") }}
{%- extends "page.html" %}
{% block body %}
{% for collection in catalog %}
{% if collection %}
<div class="section ablog__catalog_header">
<h2>
{{ header }}
<a href="{{ pathto(collection.docname) }}">{{ collection }}</a>
</h2>
{% for post in collection %}
<div class="section ablog__catalog_post">
<p>
{% if post.published %}
{{ post.date.strftime(ablog.post_date_format) }}
{% else %}
Draft
{% endif %}
-
<a href="{{ pathto(post.docname) }}{{ anchor(post) }}"
>{{ post.title }}</a
>
</p>
</div>
{% endfor %}
</div>
{% endif %}
{% endfor %}
{% endblock %}
17 changes: 17 additions & 0 deletions ablog/templates/categories.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{ warning("category.html is an old template path, that is no longer used by ablog. Please use ablog/category.html instead.") }}
{% if ablog.category %}
<div class="ablog-sidebar-item ablog__category">
<h3>
<a href="{{ pathto(ablog.category.path) }}">{{ gettext('Categories') }}</a>
</h3>
<ul>
{% for coll in ablog.category %}
{% if coll %}
<li>
<a href="{{ pathto(coll.docname) }}">{{ coll }} ({{ coll|length }})</a>
</li>
{% endif %}
{% endfor %}
</ul>
</div>
{% endif %}
63 changes: 63 additions & 0 deletions ablog/templates/collection.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{{ warning("collection.html is an old template path, that is no longer used by ablog. Please use ablog/collection.html instead.") }}
{%- extends "page.html" %} {% block body %}
<div class="section ablog__collection">
<h1>
{% if archive_feed and fa %}
<a href="{{ pathto(collection.path, 1) }}/atom.xml">
<i class="fa fa-rss fa-rotate-270"></i></a>
{% endif %}
{{ header }}
{% if collection.href %}
<a href="{{ collection.href }}">{{ collection }}</a>
{% else %}
{{ collection }}
{% endif %}
</h1>
{% if ablog.blog_archive_titles %}
{% for post in collection %}
<div class="section ablog__collection_meta">
<p>
{% if post.published %}
{{ post.date.strftime(ablog.post_date_format) }}
{% else %}
Draft
{% endif %}
-
<a href="{{ pathto(post.docname) }}{{ anchor(post) }}">{{ post.title }}</a>
</p>
</div>
{% endfor %}
{% else %}
{% for post in collection %}
<div class="section ablog-post">
<h2 class="ablog-post-title">
<a href="{{ pathto(post.docname) }}{{ anchor(post) }}">{{ post.title }}</a>
</h2>
<ul class="ablog-archive">
<li>
{% if post.published %}
{% if fa %}
<i class="fa fa-calendar"></i>
{% endif %}
{{ post.date.strftime(ablog.post_date_format) }}
{% else %}
{% if fa %}
<i class="fa fa-pencil"></i>
{% endif %}
{% if post.date %}
{{ post.date.strftime(ablog.post_date_format) }}
{% else %}
Draft
{% endif %}
{% endif %}
</li>
{% include "ablog/postcard2.html" %}
</ul>
{{ post.to_html(collection.docname) }}
<p class="ablog-post-expand"><a href="{{ pathto(post.docname) }}"><em>{{ _("Read more ...") }}</em></a></p>
<hr/>
</div>
{% endfor %}
{% endif %}
</div>
{% endblock %}
15 changes: 15 additions & 0 deletions ablog/templates/languages.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{ warning("languages.html is an old template path, that is no longer used by ablog. Please use ablog/languages.html instead.") }}
{% if ablog.language %}
<div class="ablog__languages">
<h3>
<a href="{{ pathto(ablog.language.path) }}">{{ gettext('Languages') }}</a>
</h3>
<ul>
{% for coll in ablog.language %} {% if coll %}
<li>
<a href="{{ pathto(coll.docname) }}">{{ coll }} ({{ coll|length }})</a>
</li>
{% endif %} {% endfor %}
</ul>
</div>
{% endif %}
17 changes: 17 additions & 0 deletions ablog/templates/locations.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{ warning("locations.html is an old template path, that is no longer used by ablog. Please use ablog/locations.html instead.") }}
{% if ablog.location %}
<div class="ablog__locations">
<h3>
<a href="{{ pathto(ablog.location.path) }}">{{ gettext('Locations') }}</a>
</h3>
<ul>
{% for coll in ablog.location %}
{% if coll %}
<li>
<a href="{{ pathto(coll.docname) }}">{{ coll }} ({{ coll|length }})</a>
</li>
{% endif %}
{% endfor %}
</ul>
</div>
{% endif %}
27 changes: 27 additions & 0 deletions ablog/templates/postcard.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{ warning("postcard.html is an old template path, that is no longer used by ablog. Please use ablog/postcard.html instead.") }}
{% if pagename in ablog %}
<div class="ablog__postcard">
{% set fa = ablog.fontawesome %}
{% set post = ablog[pagename] %}
<h2>
{% if post.published %}
{% if fa %}
<i class="fa fa-calendar"></i>
{% endif %}
{{ post.date.strftime(ablog.post_date_format) }}
{% else %}
{% if fa %}
<i class="fa fa-pencil"></i>
{% endif %}
{% if post.date %}
{{ post.date.strftime(ablog.post_date_format)}}
{% else %}
Draft
{% endif %}
{% endif %}
</h2>
<ul>
{% include "ablog/postcard2.html" %}
</ul>
</div>
{% endif %}
Loading

0 comments on commit 9abb8c4

Please sign in to comment.