From 0f9753c79e4afecbf7d60abcd89d17e0f215e925 Mon Sep 17 00:00:00 2001 From: Nabil Freij Date: Tue, 19 Jul 2022 14:25:58 -0700 Subject: [PATCH 1/9] Templates rework --- ablog/__init__.py | 5 +- ablog/locales/ca/LC_MESSAGES/sphinx.po | 34 ++-- ablog/locales/de/LC_MESSAGES/sphinx.po | 34 ++-- ablog/locales/es/LC_MESSAGES/sphinx.po | 34 ++-- ablog/locales/et/LC_MESSAGES/sphinx.po | 34 ++-- ablog/locales/fr/LC_MESSAGES/sphinx.po | 34 ++-- ablog/locales/ru/LC_MESSAGES/sphinx.po | 34 ++-- ablog/locales/tr/LC_MESSAGES/sphinx.po | 34 ++-- ablog/locales/zh_CN/LC_MESSAGES/sphinx.po | 34 ++-- ablog/post.py | 6 +- ablog/start.py | 2 +- ablog/templates/{ => ablog}/archives.html | 8 +- ablog/templates/{ => ablog}/authors.html | 2 + ablog/templates/ablog/catalog.html | 28 ++++ ablog/templates/{ => ablog}/categories.html | 8 +- ablog/templates/ablog/collection.html | 62 ++++++++ ablog/templates/{ => ablog}/languages.html | 2 + ablog/templates/{ => ablog}/locations.html | 8 +- ablog/templates/ablog/page.html | 60 +++++++ ablog/templates/ablog/postcard.html | 26 +++ ablog/templates/ablog/postcard2.html | 165 ++++++++++++++++++++ ablog/templates/ablog/postnavy.html | 33 ++++ ablog/templates/ablog/recentposts.html | 17 ++ ablog/templates/ablog/redirect.html | 8 + ablog/templates/ablog/tagcloud.html | 14 ++ ablog/templates/catalog.html | 26 --- ablog/templates/collection.html | 52 ------ ablog/templates/page.html | 81 ---------- ablog/templates/postcard.html | 15 -- ablog/templates/postcard2.html | 94 ----------- ablog/templates/postnavy.html | 26 --- ablog/templates/recentposts.html | 15 -- ablog/templates/redirect.html | 8 - ablog/templates/tagcloud.html | 41 ----- docs/release/ablog-v0.11-released.rst | 23 +++ setup.py | 2 +- 36 files changed, 605 insertions(+), 504 deletions(-) rename ablog/templates/{ => ablog}/archives.html (62%) rename ablog/templates/{ => ablog}/authors.html (84%) create mode 100644 ablog/templates/ablog/catalog.html rename ablog/templates/{ => ablog}/categories.html (62%) create mode 100644 ablog/templates/ablog/collection.html rename ablog/templates/{ => ablog}/languages.html (88%) rename ablog/templates/{ => ablog}/locations.html (65%) create mode 100644 ablog/templates/ablog/page.html create mode 100644 ablog/templates/ablog/postcard.html create mode 100644 ablog/templates/ablog/postcard2.html create mode 100644 ablog/templates/ablog/postnavy.html create mode 100644 ablog/templates/ablog/recentposts.html create mode 100644 ablog/templates/ablog/redirect.html create mode 100644 ablog/templates/ablog/tagcloud.html delete mode 100644 ablog/templates/catalog.html delete mode 100644 ablog/templates/collection.html delete mode 100644 ablog/templates/page.html delete mode 100644 ablog/templates/postcard.html delete mode 100644 ablog/templates/postcard2.html delete mode 100644 ablog/templates/postnavy.html delete mode 100644 ablog/templates/recentposts.html delete mode 100644 ablog/templates/redirect.html delete mode 100644 ablog/templates/tagcloud.html create mode 100644 docs/release/ablog-v0.11-released.rst diff --git a/ablog/__init__.py b/ablog/__init__.py index 9252bbf7..43676f97 100755 --- a/ablog/__init__.py +++ b/ablog/__init__.py @@ -22,12 +22,15 @@ ) from .version import version as __version__ +PKGDIR = os.path.abspath(os.path.dirname(__file__)) + + __all__ = ["setup"] def anchor(post): """ - Return anchor string for posts that arepage sections. + Return anchor string for posts that are page sections. """ if post.section: return "#" + post.section diff --git a/ablog/locales/ca/LC_MESSAGES/sphinx.po b/ablog/locales/ca/LC_MESSAGES/sphinx.po index a4330d74..d5b5d0a3 100644 --- a/ablog/locales/ca/LC_MESSAGES/sphinx.po +++ b/ablog/locales/ca/LC_MESSAGES/sphinx.po @@ -22,7 +22,7 @@ msgstr "" msgid "Updated on " msgstr "Actualitzat el " -#: ablog/post.py:601 ablog/templates/authors.html:2 +#: ablog/post.py:601 ablog/templates/ablog/authors.html:2 msgid "Authors" msgstr "Autors" @@ -30,7 +30,7 @@ msgstr "Autors" msgid "Posts by" msgstr "Publicacions de" -#: ablog/post.py:602 ablog/templates/locations.html:3 +#: ablog/post.py:602 ablog/templates/ablog/locations.html:3 msgid "Locations" msgstr "Ubicacions" @@ -38,7 +38,7 @@ msgstr "Ubicacions" msgid "Posts from" msgstr "Publicacions des de" -#: ablog/post.py:603 ablog/templates/languages.html:3 +#: ablog/post.py:603 ablog/templates/ablog/languages.html:3 msgid "Languages" msgstr "Idiomes" @@ -46,7 +46,7 @@ msgstr "Idiomes" msgid "Posts in" msgstr "Publicacions en" -#: ablog/post.py:604 ablog/templates/categories.html:3 +#: ablog/post.py:604 ablog/templates/ablog/categories.html:3 msgid "Categories" msgstr "Categories" @@ -58,8 +58,8 @@ msgstr "Totes les publicacions" msgid "Posted in" msgstr "Publicat al" -#: ablog/post.py:606 ablog/templates/postcard2.html:57 -#: ablog/templates/tagcloud.html:2 +#: ablog/post.py:606 ablog/templates/ablog/postcard2.html:57 +#: ablog/templates/ablog/tagcloud.html:2 msgid "Tags" msgstr "Etiquetes" @@ -79,46 +79,46 @@ msgstr "Totes les" msgid "Drafts" msgstr "Borradors" -#: ablog/templates/archives.html:3 +#: ablog/templates/ablog/archives.html:3 msgid "Archives" msgstr "Arxius" -#: ablog/templates/collection.html:47 +#: ablog/templates/ablog/collection.html:47 msgid "Read more ..." msgstr "Llegir-ne més ..." -#: ablog/templates/postcard2.html:5 +#: ablog/templates/ablog/postcard2.html:5 msgid "Update" msgstr "Actualització" -#: ablog/templates/postcard2.html:12 +#: ablog/templates/ablog/postcard2.html:12 msgid "Author" msgstr "Autor" -#: ablog/templates/postcard2.html:24 +#: ablog/templates/ablog/postcard2.html:24 msgid "Location" msgstr "Ubicació" -#: ablog/templates/postcard2.html:35 +#: ablog/templates/ablog/postcard2.html:35 msgid "Language" msgstr "Idioma" -#: ablog/templates/postcard2.html:46 +#: ablog/templates/ablog/postcard2.html:46 msgid "Category" msgstr "Categoria" -#: ablog/templates/postcard2.html:60 +#: ablog/templates/ablog/postcard2.html:60 msgid "Tag" msgstr "Etiqueta" -#: ablog/templates/postnavy.html:5 +#: ablog/templates/ablog/postnavy.html:5 msgid "Previous" msgstr "Anterior" -#: ablog/templates/postnavy.html:15 +#: ablog/templates/ablog/postnavy.html:15 msgid "Next" msgstr "Següent" -#: ablog/templates/recentposts.html:3 +#: ablog/templates/ablog/recentposts.html:3 msgid "Recent Posts" msgstr "Publicacions recents" diff --git a/ablog/locales/de/LC_MESSAGES/sphinx.po b/ablog/locales/de/LC_MESSAGES/sphinx.po index e763b7c1..f7477264 100644 --- a/ablog/locales/de/LC_MESSAGES/sphinx.po +++ b/ablog/locales/de/LC_MESSAGES/sphinx.po @@ -21,7 +21,7 @@ msgstr "" msgid "Updated on" msgstr "Aktualisiert am" -#: ablog/post.py:387 ablog/templates/authors.html:2 +#: ablog/post.py:387 ablog/templates/ablog/authors.html:2 msgid "Authors" msgstr "Autoren" @@ -29,7 +29,7 @@ msgstr "Autoren" msgid "Posts by" msgstr "Einträge von" -#: ablog/post.py:388 ablog/templates/locations.html:2 +#: ablog/post.py:388 ablog/templates/ablog/locations.html:2 msgid "Locations" msgstr "Orte" @@ -37,7 +37,7 @@ msgstr "Orte" msgid "Posts from" msgstr "Einträge aus" -#: ablog/post.py:389 ablog/templates/languages.html:2 +#: ablog/post.py:389 ablog/templates/ablog/languages.html:2 msgid "Languages" msgstr "Sprachen" @@ -45,7 +45,7 @@ msgstr "Sprachen" msgid "Posts in" msgstr "Einträge in" -#: ablog/post.py:390 ablog/templates/categories.html:2 +#: ablog/post.py:390 ablog/templates/ablog/categories.html:2 msgid "Categories" msgstr "Kategorien" @@ -57,8 +57,8 @@ msgstr "Alle Einträge" msgid "Posted in" msgstr "Einträge in" -#: ablog/post.py:392 ablog/templates/postcard2.html:43 -#: ablog/templates/tagcloud.html:2 +#: ablog/post.py:392 ablog/templates/ablog/postcard2.html:43 +#: ablog/templates/ablog/tagcloud.html:2 msgid "Tags" msgstr "Schlagworte" @@ -70,46 +70,46 @@ msgstr "Einträge mit Schlagwort" msgid "Drafts" msgstr "Entwurf" -#: ablog/templates/archive.html:49 +#: ablog/templates/ablog/archive.html:49 msgid "Read more ..." msgstr "Weiter..." -#: ablog/templates/archives.html:2 +#: ablog/templates/ablog/archives.html:2 msgid "Archives" msgstr "Archive" -#: ablog/templates/postcard2.html:2 +#: ablog/templates/ablog/postcard2.html:2 msgid "Update" msgstr "Aktualisierung" -#: ablog/templates/postcard2.html:7 +#: ablog/templates/ablog/postcard2.html:7 msgid "Author" msgstr "Autor" -#: ablog/templates/postcard2.html:16 +#: ablog/templates/ablog/postcard2.html:16 msgid "Location" msgstr "Ort" -#: ablog/templates/postcard2.html:25 +#: ablog/templates/ablog/postcard2.html:25 msgid "Language" msgstr "Sprache" -#: ablog/templates/postcard2.html:34 +#: ablog/templates/ablog/postcard2.html:34 msgid "Category" msgstr "Kategorie" -#: ablog/templates/postcard2.html:44 +#: ablog/templates/ablog/postcard2.html:44 msgid "Tag" msgstr "Schlagwort" -#: ablog/templates/postnavy.html:7 +#: ablog/templates/ablog/postnavy.html:7 msgid "Previous" msgstr "Vorige" -#: ablog/templates/postnavy.html:17 +#: ablog/templates/ablog/postnavy.html:17 msgid "Next" msgstr "Nächste" -#: ablog/templates/recentposts.html:2 +#: ablog/templates/ablog/recentposts.html:2 msgid "Recent Posts" msgstr "Neue Einträge" diff --git a/ablog/locales/es/LC_MESSAGES/sphinx.po b/ablog/locales/es/LC_MESSAGES/sphinx.po index 850e5620..7c62a61f 100644 --- a/ablog/locales/es/LC_MESSAGES/sphinx.po +++ b/ablog/locales/es/LC_MESSAGES/sphinx.po @@ -22,7 +22,7 @@ msgstr "" msgid "Updated on" msgstr "Actualizado el" -#: ablog/post.py:387 ablog/templates/authors.html:2 +#: ablog/post.py:387 ablog/templates/ablog/authors.html:2 msgid "Authors" msgstr "Autores" @@ -30,7 +30,7 @@ msgstr "Autores" msgid "Posts by" msgstr "Entradas por" -#: ablog/post.py:388 ablog/templates/locations.html:2 +#: ablog/post.py:388 ablog/templates/ablog/locations.html:2 msgid "Locations" msgstr "Lugares" @@ -38,7 +38,7 @@ msgstr "Lugares" msgid "Posts from" msgstr "Entradas desde" -#: ablog/post.py:389 ablog/templates/languages.html:2 +#: ablog/post.py:389 ablog/templates/ablog/languages.html:2 msgid "Languages" msgstr "Idiomas" @@ -46,7 +46,7 @@ msgstr "Idiomas" msgid "Posts in" msgstr "Entradas en" -#: ablog/post.py:390 ablog/templates/categories.html:2 +#: ablog/post.py:390 ablog/templates/ablog/categories.html:2 msgid "Categories" msgstr "Categorías" @@ -58,8 +58,8 @@ msgstr "Todas las entradas" msgid "Posted in" msgstr "Publicado en" -#: ablog/post.py:392 ablog/templates/postcard2.html:43 -#: ablog/templates/tagcloud.html:2 +#: ablog/post.py:392 ablog/templates/ablog/postcard2.html:43 +#: ablog/templates/ablog/tagcloud.html:2 msgid "Tags" msgstr "Etiquetas" @@ -71,46 +71,46 @@ msgstr "Entradas etiquetadas" msgid "Drafts" msgstr "Borradores" -#: ablog/templates/archive.html:49 +#: ablog/templates/ablog/archive.html:49 msgid "Read more ..." msgstr "Leer más ..." -#: ablog/templates/archives.html:2 +#: ablog/templates/ablog/archives.html:2 msgid "Archives" msgstr "Archivos" -#: ablog/templates/postcard2.html:2 +#: ablog/templates/ablog/postcard2.html:2 msgid "Update" msgstr "Actualizado" -#: ablog/templates/postcard2.html:7 +#: ablog/templates/ablog/postcard2.html:7 msgid "Author" msgstr "Autor" -#: ablog/templates/postcard2.html:16 +#: ablog/templates/ablog/postcard2.html:16 msgid "Location" msgstr "Lugar" -#: ablog/templates/postcard2.html:25 +#: ablog/templates/ablog/postcard2.html:25 msgid "Language" msgstr "Idioma" -#: ablog/templates/postcard2.html:34 +#: ablog/templates/ablog/postcard2.html:34 msgid "Category" msgstr "Categoría" -#: ablog/templates/postcard2.html:44 +#: ablog/templates/ablog/postcard2.html:44 msgid "Tag" msgstr "Etiqueta" -#: ablog/templates/postnavy.html:7 +#: ablog/templates/ablog/postnavy.html:7 msgid "Previous" msgstr "Anterior" -#: ablog/templates/postnavy.html:17 +#: ablog/templates/ablog/postnavy.html:17 msgid "Next" msgstr "Siguiente" -#: ablog/templates/recentposts.html:2 +#: ablog/templates/ablog/recentposts.html:2 msgid "Recent Posts" msgstr "Entradas recientes" diff --git a/ablog/locales/et/LC_MESSAGES/sphinx.po b/ablog/locales/et/LC_MESSAGES/sphinx.po index daa43898..579fd266 100644 --- a/ablog/locales/et/LC_MESSAGES/sphinx.po +++ b/ablog/locales/et/LC_MESSAGES/sphinx.po @@ -21,7 +21,7 @@ msgstr "" msgid "Updated on" msgstr "Uuendus" -#: ablog/post.py:387 ablog/templates/authors.html:2 +#: ablog/post.py:387 ablog/templates/ablog/authors.html:2 msgid "Authors" msgstr "Autorid" @@ -29,7 +29,7 @@ msgstr "Autorid" msgid "Posts by" msgstr "Postitused autorilt" -#: ablog/post.py:388 ablog/templates/locations.html:2 +#: ablog/post.py:388 ablog/templates/ablog/locations.html:2 msgid "Locations" msgstr "Kohad" @@ -37,7 +37,7 @@ msgstr "Kohad" msgid "Posts from" msgstr "" -#: ablog/post.py:389 ablog/templates/languages.html:2 +#: ablog/post.py:389 ablog/templates/ablog/languages.html:2 msgid "Languages" msgstr "Keeltes" @@ -45,7 +45,7 @@ msgstr "Keeltes" msgid "Posts in" msgstr "" -#: ablog/post.py:390 ablog/templates/categories.html:2 +#: ablog/post.py:390 ablog/templates/ablog/categories.html:2 msgid "Categories" msgstr "Kategooriad" @@ -57,8 +57,8 @@ msgstr "Kõik postitused" msgid "Posted in" msgstr "Postitused kategoorias" -#: ablog/post.py:392 ablog/templates/postcard2.html:43 -#: ablog/templates/tagcloud.html:2 +#: ablog/post.py:392 ablog/templates/ablog/postcard2.html:43 +#: ablog/templates/ablog/tagcloud.html:2 msgid "Tags" msgstr "Märksõnad" @@ -70,46 +70,46 @@ msgstr "Postitused märksõnaga" msgid "Drafts" msgstr "Eelnõu" -#: ablog/templates/archive.html:49 +#: ablog/templates/ablog/archive.html:49 msgid "Read more ..." msgstr "Edasi..." -#: ablog/templates/archives.html:2 +#: ablog/templates/ablog/archives.html:2 msgid "Archives" msgstr "Arhiiv" -#: ablog/templates/postcard2.html:2 +#: ablog/templates/ablog/postcard2.html:2 msgid "Update" msgstr "Ajakohastama" -#: ablog/templates/postcard2.html:7 +#: ablog/templates/ablog/postcard2.html:7 msgid "Author" msgstr "Autor" -#: ablog/templates/postcard2.html:16 +#: ablog/templates/ablog/postcard2.html:16 msgid "Location" msgstr "Koht" -#: ablog/templates/postcard2.html:25 +#: ablog/templates/ablog/postcard2.html:25 msgid "Language" msgstr "Keel" -#: ablog/templates/postcard2.html:34 +#: ablog/templates/ablog/postcard2.html:34 msgid "Category" msgstr "Kategooria" -#: ablog/templates/postcard2.html:44 +#: ablog/templates/ablog/postcard2.html:44 msgid "Tag" msgstr "Märksõna" -#: ablog/templates/postnavy.html:7 +#: ablog/templates/ablog/postnavy.html:7 msgid "Previous" msgstr "Eelmine" -#: ablog/templates/postnavy.html:17 +#: ablog/templates/ablog/postnavy.html:17 msgid "Next" msgstr "Järgmine" -#: ablog/templates/recentposts.html:2 +#: ablog/templates/ablog/recentposts.html:2 msgid "Recent Posts" msgstr "Viimased postitused" diff --git a/ablog/locales/fr/LC_MESSAGES/sphinx.po b/ablog/locales/fr/LC_MESSAGES/sphinx.po index 09a7e22c..f258d3d8 100644 --- a/ablog/locales/fr/LC_MESSAGES/sphinx.po +++ b/ablog/locales/fr/LC_MESSAGES/sphinx.po @@ -18,7 +18,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.8.0\n" -#: ablog/post.py:525 ablog/templates/authors.html:2 +#: ablog/post.py:525 ablog/templates/ablog/authors.html:2 msgid "Authors" msgstr "Auteurs" @@ -26,7 +26,7 @@ msgstr "Auteurs" msgid "Posts by" msgstr "Billets par" -#: ablog/post.py:526 ablog/templates/locations.html:2 +#: ablog/post.py:526 ablog/templates/ablog/locations.html:2 msgid "Locations" msgstr "Lieux" @@ -34,7 +34,7 @@ msgstr "Lieux" msgid "Posts from" msgstr "Billets depuis" -#: ablog/post.py:527 ablog/templates/languages.html:2 +#: ablog/post.py:527 ablog/templates/ablog/languages.html:2 msgid "Languages" msgstr "Langues" @@ -42,7 +42,7 @@ msgstr "Langues" msgid "Posts in" msgstr "Billets dans" -#: ablog/post.py:528 ablog/templates/categories.html:2 +#: ablog/post.py:528 ablog/templates/ablog/categories.html:2 msgid "Categories" msgstr "Catégories" @@ -54,8 +54,8 @@ msgstr "Tous les billets" msgid "Posted in" msgstr "Publié dans" -#: ablog/post.py:530 ablog/templates/postcard2.html:43 -#: ablog/templates/tagcloud.html:2 +#: ablog/post.py:530 ablog/templates/ablog/postcard2.html:43 +#: ablog/templates/ablog/tagcloud.html:2 msgid "Tags" msgstr "Tags" @@ -75,46 +75,46 @@ msgstr "Tous les billets" msgid "Drafts" msgstr "Brouillons" -#: ablog/templates/archives.html:2 +#: ablog/templates/ablog/archives.html:2 msgid "Archives" msgstr "Archives" -#: ablog/templates/collection.html:48 +#: ablog/templates/ablog/collection.html:48 msgid "Read more ..." msgstr "Lire plus…" -#: ablog/templates/postcard2.html:2 +#: ablog/templates/ablog/postcard2.html:2 msgid "Update" msgstr "Mis à jour" -#: ablog/templates/postcard2.html:7 +#: ablog/templates/ablog/postcard2.html:7 msgid "Author" msgstr "Auteur" -#: ablog/templates/postcard2.html:16 +#: ablog/templates/ablog/postcard2.html:16 msgid "Location" msgstr "Lieu" -#: ablog/templates/postcard2.html:25 +#: ablog/templates/ablog/postcard2.html:25 msgid "Language" msgstr "Langue" -#: ablog/templates/postcard2.html:34 +#: ablog/templates/ablog/postcard2.html:34 msgid "Category" msgstr "Catégorie" -#: ablog/templates/postcard2.html:44 +#: ablog/templates/ablog/postcard2.html:44 msgid "Tag" msgstr "Tag" -#: ablog/templates/postnavy.html:7 +#: ablog/templates/ablog/postnavy.html:7 msgid "Previous" msgstr "Précédent" -#: ablog/templates/postnavy.html:17 +#: ablog/templates/ablog/postnavy.html:17 msgid "Next" msgstr "Suivant" -#: ablog/templates/recentposts.html:2 +#: ablog/templates/ablog/recentposts.html:2 msgid "Recent Posts" msgstr "Billets récents" diff --git a/ablog/locales/ru/LC_MESSAGES/sphinx.po b/ablog/locales/ru/LC_MESSAGES/sphinx.po index 63edab0a..d117a471 100644 --- a/ablog/locales/ru/LC_MESSAGES/sphinx.po +++ b/ablog/locales/ru/LC_MESSAGES/sphinx.po @@ -23,7 +23,7 @@ msgstr "" msgid "Updated on" msgstr "Обновлено" -#: ablog/post.py:387 ablog/templates/authors.html:2 +#: ablog/post.py:387 ablog/templates/ablog/authors.html:2 msgid "Authors" msgstr "Авторы" @@ -31,7 +31,7 @@ msgstr "Авторы" msgid "Posts by" msgstr "Опубликовано" -#: ablog/post.py:388 ablog/templates/locations.html:2 +#: ablog/post.py:388 ablog/templates/ablog/locations.html:2 msgid "Locations" msgstr "" @@ -39,7 +39,7 @@ msgstr "" msgid "Posts from" msgstr "Сообщения из" -#: ablog/post.py:389 ablog/templates/languages.html:2 +#: ablog/post.py:389 ablog/templates/ablog/languages.html:2 msgid "Languages" msgstr "Языки" @@ -47,7 +47,7 @@ msgstr "Языки" msgid "Posts in" msgstr "Сообщений в" -#: ablog/post.py:390 ablog/templates/categories.html:2 +#: ablog/post.py:390 ablog/templates/ablog/categories.html:2 msgid "Categories" msgstr "Категории" @@ -59,8 +59,8 @@ msgstr "Все записи" msgid "Posted in" msgstr "Опубликовано в" -#: ablog/post.py:392 ablog/templates/postcard2.html:43 -#: ablog/templates/tagcloud.html:2 +#: ablog/post.py:392 ablog/templates/ablog/postcard2.html:43 +#: ablog/templates/ablog/tagcloud.html:2 msgid "Tags" msgstr "Теги" @@ -72,46 +72,46 @@ msgstr "Сообщения с тегом" msgid "Drafts" msgstr "Черновик" -#: ablog/templates/archive.html:49 +#: ablog/templates/ablog/archive.html:49 msgid "Read more ..." msgstr "Читать ..." -#: ablog/templates/archives.html:2 +#: ablog/templates/ablog/archives.html:2 msgid "Archives" msgstr "Архив" -#: ablog/templates/postcard2.html:2 +#: ablog/templates/ablog/postcard2.html:2 msgid "Update" msgstr "Обновить" -#: ablog/templates/postcard2.html:7 +#: ablog/templates/ablog/postcard2.html:7 msgid "Author" msgstr "Автор" -#: ablog/templates/postcard2.html:16 +#: ablog/templates/ablog/postcard2.html:16 msgid "Location" msgstr "Расположение" -#: ablog/templates/postcard2.html:25 +#: ablog/templates/ablog/postcard2.html:25 msgid "Language" msgstr "Язык" -#: ablog/templates/postcard2.html:34 +#: ablog/templates/ablog/postcard2.html:34 msgid "Category" msgstr "Категория" -#: ablog/templates/postcard2.html:44 +#: ablog/templates/ablog/postcard2.html:44 msgid "Tag" msgstr "Тег" -#: ablog/templates/postnavy.html:7 +#: ablog/templates/ablog/postnavy.html:7 msgid "Previous" msgstr "Предыдущий" -#: ablog/templates/postnavy.html:17 +#: ablog/templates/ablog/postnavy.html:17 msgid "Next" msgstr "Следующий" -#: ablog/templates/recentposts.html:2 +#: ablog/templates/ablog/recentposts.html:2 msgid "Recent Posts" msgstr "Недавние Записи" diff --git a/ablog/locales/tr/LC_MESSAGES/sphinx.po b/ablog/locales/tr/LC_MESSAGES/sphinx.po index bd79826f..8652d2e5 100644 --- a/ablog/locales/tr/LC_MESSAGES/sphinx.po +++ b/ablog/locales/tr/LC_MESSAGES/sphinx.po @@ -21,7 +21,7 @@ msgstr "" msgid "Updated on" msgstr "Güncelleme" -#: ablog/post.py:387 ablog/templates/authors.html:2 +#: ablog/post.py:387 ablog/templates/ablog/authors.html:2 msgid "Authors" msgstr "Yazarlar" @@ -29,7 +29,7 @@ msgstr "Yazarlar" msgid "Posts by" msgstr "Yazar" -#: ablog/post.py:388 ablog/templates/locations.html:2 +#: ablog/post.py:388 ablog/templates/ablog/locations.html:2 msgid "Locations" msgstr "Mevkiler" @@ -37,7 +37,7 @@ msgstr "Mevkiler" msgid "Posts from" msgstr "Mevki" -#: ablog/post.py:389 ablog/templates/languages.html:2 +#: ablog/post.py:389 ablog/templates/ablog/languages.html:2 msgid "Languages" msgstr "Diller" @@ -45,7 +45,7 @@ msgstr "Diller" msgid "Posts in" msgstr "Kategori" -#: ablog/post.py:390 ablog/templates/categories.html:2 +#: ablog/post.py:390 ablog/templates/ablog/categories.html:2 msgid "Categories" msgstr "Kategoriler" @@ -57,8 +57,8 @@ msgstr "Bütün yazılar" msgid "Posted in" msgstr "Sene" -#: ablog/post.py:392 ablog/templates/postcard2.html:43 -#: ablog/templates/tagcloud.html:2 +#: ablog/post.py:392 ablog/templates/ablog/postcard2.html:43 +#: ablog/templates/ablog/tagcloud.html:2 msgid "Tags" msgstr "Etiketler" @@ -70,46 +70,46 @@ msgstr "Etiket" msgid "Drafts" msgstr "Taslaklar" -#: ablog/templates/archive.html:49 +#: ablog/templates/ablog/archive.html:49 msgid "Read more ..." msgstr "Okumaya devam et ..." -#: ablog/templates/archives.html:2 +#: ablog/templates/ablog/archives.html:2 msgid "Archives" msgstr "Arşiv" -#: ablog/templates/postcard2.html:2 +#: ablog/templates/ablog/postcard2.html:2 msgid "Update" msgstr "Güncelleme" -#: ablog/templates/postcard2.html:7 +#: ablog/templates/ablog/postcard2.html:7 msgid "Author" msgstr "Yazar" -#: ablog/templates/postcard2.html:16 +#: ablog/templates/ablog/postcard2.html:16 msgid "Location" msgstr "Mevki" -#: ablog/templates/postcard2.html:25 +#: ablog/templates/ablog/postcard2.html:25 msgid "Language" msgstr "Dil" -#: ablog/templates/postcard2.html:34 +#: ablog/templates/ablog/postcard2.html:34 msgid "Category" msgstr "Kategori" -#: ablog/templates/postcard2.html:44 +#: ablog/templates/ablog/postcard2.html:44 msgid "Tag" msgstr "Etiket" -#: ablog/templates/postnavy.html:7 +#: ablog/templates/ablog/postnavy.html:7 msgid "Previous" msgstr "Önceki" -#: ablog/templates/postnavy.html:17 +#: ablog/templates/ablog/postnavy.html:17 msgid "Next" msgstr "Sonraki" -#: ablog/templates/recentposts.html:2 +#: ablog/templates/ablog/recentposts.html:2 msgid "Recent Posts" msgstr "Yeni Yazılar" diff --git a/ablog/locales/zh_CN/LC_MESSAGES/sphinx.po b/ablog/locales/zh_CN/LC_MESSAGES/sphinx.po index 588e32d4..7f213e8d 100644 --- a/ablog/locales/zh_CN/LC_MESSAGES/sphinx.po +++ b/ablog/locales/zh_CN/LC_MESSAGES/sphinx.po @@ -18,7 +18,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.7.0\n" -#: ablog/post.py:525 ablog/templates/authors.html:2 +#: ablog/post.py:525 ablog/templates/ablog/authors.html:2 msgid "Authors" msgstr "作者" @@ -26,7 +26,7 @@ msgstr "作者" msgid "Posts by" msgstr "文章" -#: ablog/post.py:526 ablog/templates/locations.html:2 +#: ablog/post.py:526 ablog/templates/ablog/locations.html:2 msgid "Locations" msgstr "地点" @@ -34,7 +34,7 @@ msgstr "地点" msgid "Posts from" msgstr "文章自" -#: ablog/post.py:527 ablog/templates/languages.html:2 +#: ablog/post.py:527 ablog/templates/ablog/languages.html:2 msgid "Languages" msgstr "语言" @@ -42,7 +42,7 @@ msgstr "语言" msgid "Posts in" msgstr "文章:" -#: ablog/post.py:528 ablog/templates/categories.html:2 +#: ablog/post.py:528 ablog/templates/ablog/categories.html:2 msgid "Categories" msgstr "类别" @@ -54,8 +54,8 @@ msgstr "所有文章" msgid "Posted in" msgstr "文章:" -#: ablog/post.py:530 ablog/templates/postcard2.html:43 -#: ablog/templates/tagcloud.html:2 +#: ablog/post.py:530 ablog/templates/ablog/postcard2.html:43 +#: ablog/templates/ablog/tagcloud.html:2 msgid "Tags" msgstr "标签" @@ -75,46 +75,46 @@ msgstr "所有" msgid "Drafts" msgstr "草稿" -#: ablog/templates/archives.html:2 +#: ablog/templates/ablog/archives.html:2 msgid "Archives" msgstr "归档" -#: ablog/templates/collection.html:48 +#: ablog/templates/ablog/collection.html:48 msgid "Read more ..." msgstr "更多 ..." -#: ablog/templates/postcard2.html:2 +#: ablog/templates/ablog/postcard2.html:2 msgid "Update" msgstr "更新" -#: ablog/templates/postcard2.html:7 +#: ablog/templates/ablog/postcard2.html:7 msgid "Author" msgstr "作者" -#: ablog/templates/postcard2.html:16 +#: ablog/templates/ablog/postcard2.html:16 msgid "Location" msgstr "地点" -#: ablog/templates/postcard2.html:25 +#: ablog/templates/ablog/postcard2.html:25 msgid "Language" msgstr "语言" -#: ablog/templates/postcard2.html:34 +#: ablog/templates/ablog/postcard2.html:34 msgid "Category" msgstr "类别" -#: ablog/templates/postcard2.html:44 +#: ablog/templates/ablog/postcard2.html:44 msgid "Tag" msgstr "标签" -#: ablog/templates/postnavy.html:7 +#: ablog/templates/ablog/postnavy.html:7 msgid "Previous" msgstr "上一篇" -#: ablog/templates/postnavy.html:17 +#: ablog/templates/ablog/postnavy.html:17 msgid "Next" msgstr "下一篇" -#: ablog/templates/recentposts.html:2 +#: ablog/templates/ablog/recentposts.html:2 msgid "Recent Posts" msgstr "最近文章" diff --git a/ablog/post.py b/ablog/post.py index 3595302f..3998d5ba 100644 --- a/ablog/post.py +++ b/ablog/post.py @@ -100,6 +100,10 @@ def run(self): return ad +def _split(a): + return {s.strip() for s in a.split(",")} + + class PostListDirective(Directive): """ Handle ``postlist`` directives. @@ -157,7 +161,7 @@ class CheckFrontMatter(SphinxTransform): def apply(self): # Check if page-level metadata has been given - docinfo = list(self.document.traverse(nodes.docinfo)) + docinfo = list(self.document.findall(nodes.docinfo)) if not docinfo: return None docinfo = docinfo[0] diff --git a/ablog/start.py b/ablog/start.py index d0b6d9c7..2f8c579b 100644 --- a/ablog/start.py +++ b/ablog/start.py @@ -216,7 +216,7 @@ def w(t, ls=80): ] # Add any paths that contain templates here, relative to this directory. -templates_path = ["{dot}templates", ablog.get_html_templates_path()] +templates_path = [ablog.get_html_templates_path(), "{dot}templates"] # The suffix(es) of source filenames. source_suffix = "{suffix}" diff --git a/ablog/templates/archives.html b/ablog/templates/ablog/archives.html similarity index 62% rename from ablog/templates/archives.html rename to ablog/templates/ablog/archives.html index 95d4465f..d846d137 100644 --- a/ablog/templates/archives.html +++ b/ablog/templates/ablog/archives.html @@ -1,12 +1,16 @@ {% if ablog.archive %} +

{{ gettext('Archives') }}

+
{% endif %} diff --git a/ablog/templates/authors.html b/ablog/templates/ablog/authors.html similarity index 84% rename from ablog/templates/authors.html rename to ablog/templates/ablog/authors.html index 5ba0c92b..fbf0bf5a 100644 --- a/ablog/templates/authors.html +++ b/ablog/templates/ablog/authors.html @@ -1,4 +1,5 @@ {% if ablog.author %} +

{{ gettext('Authors') }}

+
{% endif %} diff --git a/ablog/templates/ablog/catalog.html b/ablog/templates/ablog/catalog.html new file mode 100644 index 00000000..dc333c60 --- /dev/null +++ b/ablog/templates/ablog/catalog.html @@ -0,0 +1,28 @@ +{%- extends "page.html" %} +{% block body %} +{% for collection in catalog %} +{% if collection %} +
+

+ {{ header }} + {{ collection }} +

+ {% for post in collection %} +
+

+ {% if post.published %} + {{ post.date.strftime(ablog.post_date_format) }} + {% else %} + Draft + {% endif %} + - + {{ post.title }} +

+
+ {% endfor %} +
+{% endif %} +{% endfor %} +{% endblock %} diff --git a/ablog/templates/categories.html b/ablog/templates/ablog/categories.html similarity index 62% rename from ablog/templates/categories.html rename to ablog/templates/ablog/categories.html index 772de52e..5396b0a4 100644 --- a/ablog/templates/categories.html +++ b/ablog/templates/ablog/categories.html @@ -1,12 +1,16 @@ {% if ablog.category %} +

{{ gettext('Categories') }}

+
{% endif %} diff --git a/ablog/templates/ablog/collection.html b/ablog/templates/ablog/collection.html new file mode 100644 index 00000000..4d63718d --- /dev/null +++ b/ablog/templates/ablog/collection.html @@ -0,0 +1,62 @@ +{%- extends "page.html" %} {% block body %} +
+

+ {% if archive_feed and fa %} + + + {% endif %} + {{ header }} + {% if collection.href %} + {{ collection }} + {% else %} + {{ collection }} + {% endif %} +

+ {% if ablog.blog_archive_titles %} + {% for post in collection %} +
+

+ {% if post.published %} + {{ post.date.strftime(ablog.post_date_format) }} + {% else %} + Draft + {% endif %} + - + {{ post.title }} +

+
+ {% endfor %} + {% else %} + {% for post in collection %} +
+

+ {{ post.title }} +

+
    +
  • + {% if post.published %} + {% if fa %} + + {% endif %} + {{ post.date.strftime(ablog.post_date_format) }} + {% else %} + {% if fa %} + + {% endif %} + {% if post.date %} + {{ post.date.strftime(ablog.post_date_format) }} + {% else %} + Draft + {% endif %} + {% endif %} +
  • + {% include "postcard2.html" %} +
+ {{ post.to_html(collection.docname) }} +

{{ _("Read more ...") }}

+
+
+ {% endfor %} + {% endif %} +
+{% endblock %} diff --git a/ablog/templates/languages.html b/ablog/templates/ablog/languages.html similarity index 88% rename from ablog/templates/languages.html rename to ablog/templates/ablog/languages.html index 57f30cf8..fc69e3cd 100644 --- a/ablog/templates/languages.html +++ b/ablog/templates/ablog/languages.html @@ -1,4 +1,5 @@ {% if ablog.language %} +

{{ gettext('Languages') }}

@@ -9,4 +10,5 @@

{% endif %} {% endfor %} +

{% endif %} diff --git a/ablog/templates/locations.html b/ablog/templates/ablog/locations.html similarity index 65% rename from ablog/templates/locations.html rename to ablog/templates/ablog/locations.html index 2ed8c7aa..970593db 100644 --- a/ablog/templates/locations.html +++ b/ablog/templates/ablog/locations.html @@ -1,12 +1,16 @@ {% if ablog.location %} +

{{ gettext('Locations') }}

+
{% endif %} diff --git a/ablog/templates/ablog/page.html b/ablog/templates/ablog/page.html new file mode 100644 index 00000000..08238bae --- /dev/null +++ b/ablog/templates/ablog/page.html @@ -0,0 +1,60 @@ +{%- extends "layout.html" %} +{% set fa = ablog.fontawesome %} +{%- block extrahead %} +{{ super() }} +{% if feed_path %} + +{% endif %} +{% if ablog.fontawesome_link_cdn%} + +{% elif ablog.fontawesome_css_file %} + +{% endif %} +{% endblock %} +{% block body %} +{{ body }} +
+ {% if pagename in ablog %} + {% include "postnavy.html" %} + {% endif %} + {% if ablog.disqus_shortname and ablog.blog_baseurl and (not ablog[pagename].nocomments) and ((pagename in ablog and (ablog[pagename].published or ablog.disqus_drafts)) or (not pagename in ablog and ablog.disqus_pages)) %} +
+

Comments

+
+ + + + comments powered by Disqus + +
+ {% endif %} +
+{% endblock %} diff --git a/ablog/templates/ablog/postcard.html b/ablog/templates/ablog/postcard.html new file mode 100644 index 00000000..92d3a1fe --- /dev/null +++ b/ablog/templates/ablog/postcard.html @@ -0,0 +1,26 @@ +{% if pagename in ablog %} +
+{% set fa = ablog.fontawesome %} +{% set post = ablog[pagename] %} +

+ {% if post.published %} + {% if fa %} + + {% endif %} + {{ post.date.strftime(ablog.post_date_format) }} + {% else %} + {% if fa %} + + {% endif %} + {% if post.date %} + {{ post.date.strftime(ablog.post_date_format)}} + {% else %} + Draft + {% endif %} + {% endif %} +

+ +
+{% endif %} diff --git a/ablog/templates/ablog/postcard2.html b/ablog/templates/ablog/postcard2.html new file mode 100644 index 00000000..163f2cfb --- /dev/null +++ b/ablog/templates/ablog/postcard2.html @@ -0,0 +1,165 @@ +{% if post.published and post.date != post.update %} +
+
  • + + {% if fa %} + + {% else %} + {{gettext('Update') }}: + {% endif %} + + {{ post.update.strftime(ablog.post_date_format) }} +
  • +{% endif %} +{% if post.author %} +
  • + + {% if fa %} + + {% else %} + {{ gettext('Author')}}: + {% endif %} + + {% for coll in post.author %} + {% if coll|length %} + {{ coll }} + {% if loop.index < post.author|length %} + , + {% endif %} + {% else %} + {{ coll }} + {% if loop.index < post.author|length %} + , + {% endif %} + {% endif %} + {% endfor %} +
  • +{% endif %} +{% if post.location %} +
  • + + {% if fa %} + + {% else %} + {{gettext('Location') }}: + {% endif %} + + {% for coll in post.location %} + {% if coll|length %} + {{ coll }} + {% if loop.index < post.location|length %} + , + {% endif %} + {% else %} + {{ coll }} + {% if loop.index < post.location|length %} + , + {% endif %} + {% endif %} + {% endfor %} +
  • +{% endif %} +{% if post.language %} +
  • + + {% if fa %} + + {% else %} + {{gettext('Language') }}: + {% endif %} + + {% for coll in post.language %} + {% if coll|length %} + {{ coll }} + {% if loop.index < post.language|length %} + , + {% endif %} + {% else %} + {{ coll }} + {% if loop.index < post.language|length %} + , + {% endif %} + {% endif %} + {% endfor %} +
  • +{% endif %} +{% if post.category %} +
  • + + {% if fa %} + + {% else %} + {{ gettext('Category') }}: + {% endif %} + + {% for coll in post.category %} + {% if coll|length %} + {{ coll }} + {% if loop.index < post.category|length %} + , + {% endif %} + {% else %} + {{ coll }} + {% if loop.index < post.category|length %} + , + {% endif %} + {% endif %} + {% endfor %} +
  • +{% endif %} +{% if post.tags %} +
  • + + {% if post.tags|length > 1 %} + {% if fa %} + + {% else %} + {{ gettext('Tags') }}: + {% endif %} + {% else %} + {% if fa %} + + {% else %} + {{ gettext('Tag') }}: + {% endif %}{% endif %} + + {% for coll in post.tags %} + {% if coll|length %} + {{ coll }} + {% if loop.index < post.tags|length %} + {% endif %} + {% else %} + {{ coll }} + {% if loop.index < post.tags|length %} + {% endif %} + {% endif %} + {% endfor %} +
  • +{% endif %} +{% if ablog.disqus_shortname and (ablog[pagename].published or ablog.disqus_drafts) %} +
  • + + {% if fa %} + + {% endif %} + + {% if not fa %} + Comments + {% endif %} + +
  • +
    +{% endif %} diff --git a/ablog/templates/ablog/postnavy.html b/ablog/templates/ablog/postnavy.html new file mode 100644 index 00000000..b64898bc --- /dev/null +++ b/ablog/templates/ablog/postnavy.html @@ -0,0 +1,33 @@ +{# prev/next are not set for drafts #} +{% set post = ablog[pagename] %} +{% if post.published and ablog.post_show_prev_next %} +
    + + {% if post.prev %} + {% if not ablog.fontawesome %} + {{ gettext('Previous') }}: + {% endif %} + + {% if ablog.fontawesome %} + + {% endif %} + {{ post.prev.title }} + + {% endif %} + +   + + {% if post.next %} + {% if not ablog.fontawesome %} + {{ gettext('Next') }}: + {% endif %} + + {{ post.next.title }} + {% if ablog.fontawesome %} + + {% endif %} + + {% endif %} + +
    +{% endif %} diff --git a/ablog/templates/ablog/recentposts.html b/ablog/templates/ablog/recentposts.html new file mode 100644 index 00000000..fe49c7b6 --- /dev/null +++ b/ablog/templates/ablog/recentposts.html @@ -0,0 +1,17 @@ +{% if ablog %} +
    +

    + {{ gettext('Recent Posts') }} +

    + +
    +{% endif %} diff --git a/ablog/templates/ablog/redirect.html b/ablog/templates/ablog/redirect.html new file mode 100644 index 00000000..baa3af6a --- /dev/null +++ b/ablog/templates/ablog/redirect.html @@ -0,0 +1,8 @@ +{%- extends "!layout.html" %} +{%- block extrahead %} +{{ super() }} + +{% endblock %} +{% block body %} +You are being redirected to {{ post.title }} in {{ ablog.post_redirect_refresh }} seconds; +{% endblock %} diff --git a/ablog/templates/ablog/tagcloud.html b/ablog/templates/ablog/tagcloud.html new file mode 100644 index 00000000..e3ca32f5 --- /dev/null +++ b/ablog/templates/ablog/tagcloud.html @@ -0,0 +1,14 @@ +{% if ablog.tags %} +
    +

    {{ gettext('Tags') }}

    + +
    +{% endif %} diff --git a/ablog/templates/catalog.html b/ablog/templates/catalog.html deleted file mode 100644 index e2769ec1..00000000 --- a/ablog/templates/catalog.html +++ /dev/null @@ -1,26 +0,0 @@ -{%- extends "page.html" %} {% block body %} {% for collection in catalog %} {% -if collection %} -
    -

    - {{ header }} - {{ collection }} -

    - {% for post in collection %} -
    -

    - {% if fa %}{% endif %} {% if post.published %} {{ - post.date.strftime(ablog.post_date_format) }} {% else %} Draft {% endif %} - - - {{ post.title }} -

    - {% if 0 %} -
      - {% include "postcard2.html" %} -
    - {% endif %} -
    - {% endfor %} -
    -{% endif %} {% endfor %} {% endblock %} diff --git a/ablog/templates/collection.html b/ablog/templates/collection.html deleted file mode 100644 index 8c07b451..00000000 --- a/ablog/templates/collection.html +++ /dev/null @@ -1,52 +0,0 @@ -{%- extends "page.html" %} {% block body %} -
    -

    - {% if archive_feed and fa %} - {% endif %} {{ header }} {% if collection.href %} - {{ collection }} - {% else %} {{ collection }} {% endif %} -

    - {% if ablog.blog_archive_titles %} {% for post in collection %} -
    -

    - {% if fa %}{% endif %} {% if post.published %} {{ - post.date.strftime(ablog.post_date_format) }} {% else %} Draft {% endif %} - - - {{ post.title }} -

    - {% if 0 %} -
      - {% include "postcard2.html" %} -
    - {% endif %} -
    - {% endfor %} {% else %} {% for post in collection %} - -
    -

    - {{ post.title }} -

    - -
      -
    • - {% if post.published %} {% if fa %}{% - endif %} {{ post.date.strftime(ablog.post_date_format) }} {% else %} {% - if fa %}{% endif %} {% if post.date %}{{ - post.date.strftime(ablog.post_date_format) }} {% else %} Draft {% endif - %} {% endif %} -
    • - {% include "postcard2.html" %} -
    - {{ post.to_html(collection.docname) }} -

    {{ _("Read more ...") }}

    -
    -
    - {% endfor %} {% endif %} -
    -{% endblock %} diff --git a/ablog/templates/page.html b/ablog/templates/page.html deleted file mode 100644 index 4c765364..00000000 --- a/ablog/templates/page.html +++ /dev/null @@ -1,81 +0,0 @@ -{%- extends "layout.html" %} {% set fa = ablog.fontawesome %} {%- block -extrahead %} {{ super() }} {% if feed_path %} - -{% endif %} {% if ablog.fontawesome_link_cdn%} - -{% elif ablog.fontawesome_css_file %} - -{% endif %} - -{% endblock %} {% block body %} {{ body }} -
    - {% if pagename in ablog %} {% include "postnavy.html" %} {% endif %} {% if - ablog.disqus_shortname and ablog.blog_baseurl and (not - ablog[pagename].nocomments) and ((pagename in ablog and - (ablog[pagename].published or ablog.disqus_drafts)) or (not pagename in ablog - and ablog.disqus_pages)) %} -
    -

    Comments

    -
    - - - comments powered by Disqus -
    - {% endif %} -
    -{% endblock %} diff --git a/ablog/templates/postcard.html b/ablog/templates/postcard.html deleted file mode 100644 index 2d1ddea4..00000000 --- a/ablog/templates/postcard.html +++ /dev/null @@ -1,15 +0,0 @@ -{% if pagename in ablog %} {% set fa = ablog.fontawesome %} {% set post = -ablog[pagename] %} -

    - {% if post.published %} {% if fa %}{% endif %} - {{ post.date.strftime(ablog.post_date_format) }} {% else %} {% if fa %}{% endif %} {% if post.date %}{{ post.date.strftime(ablog.post_date_format) - }} {% else %} Draft {% endif %} {% endif %} -

    - - -{% endif %} diff --git a/ablog/templates/postcard2.html b/ablog/templates/postcard2.html deleted file mode 100644 index 7329d575..00000000 --- a/ablog/templates/postcard2.html +++ /dev/null @@ -1,94 +0,0 @@ -{% if post.published and post.date != post.update %} -
  • - {% if fa %}{% else %}{{ - gettext('Update') }}:{% endif %} - {{ post.update.strftime(ablog.post_date_format) }} -
  • -{% endif %} {% if post.author %} -
  • - {% if fa %}{% else %}{{ gettext('Author') - }}:{% endif %} - {% for coll in post.author %} {% if coll|length %} - {{ coll }}{% if loop.index < - post.author|length %},{% endif %} {% else %}{{ coll }}{% if loop.index < - post.author|length %},{% endif %}{% endif %} {% endfor %} -
  • -{% endif %} {% if post.location %} -
  • - {% if fa %}{% else %}{{ - gettext('Location') }}:{% endif %} - {% for coll in post.location %} {% if coll|length %} - {{ coll }}{% if loop.index < - post.location|length %},{% endif %} {% else %}{{ coll }}{% if loop.index < - post.location|length %},{% endif %}{% endif %} {% endfor %} -
  • -{% endif %} {% if post.language %} -
  • - {% if fa %}{% else %}{{ - gettext('Language') }}:{% endif %} - {% for coll in post.language %} {% if coll|length %} - {{ coll }}{% if loop.index < - post.language|length %},{% endif %} {% else %}{{ coll }}{% if loop.index < - post.language|length %},{% endif %}{% endif %} {% endfor %} -
  • -{% endif %} {% if post.category %} -
  • - {% if fa %}{% else %}{{ - gettext('Category') }}:{% endif %} - {% for coll in post.category %} {% if coll|length %} - {{ coll }}{% if loop.index < - post.category|length %},{% endif %} {% else %}{{ coll }}{% if loop.index < - post.category|length %},{% endif %}{% endif %} {% endfor %} -
  • -{% endif %} {% if post.tags %} -
  • - {% if post.tags|length > 1 %}{% if fa %}{% - else %}{{ gettext('Tags') }}:{% endif %} {% else %}{% if fa %}{% else %}{{ gettext('Tag') }}:{% endif %}{% endif %} - {% for coll in post.tags %} {% if coll|length %} - {{ coll }}{% if loop.index < - post.tags|length %}{% endif %} {% else %}{{ coll }}{% if loop.index < - post.tags|length %}{% endif %}{% endif %} {% endfor %} -
  • -{% endif %} {% if ablog.disqus_shortname and (ablog[pagename].published or -ablog.disqus_drafts) %} -
  • - - {% if fa %}{% endif %} - - {% if not fa %}Comments{% endif %} -
  • -{% endif %} diff --git a/ablog/templates/postnavy.html b/ablog/templates/postnavy.html deleted file mode 100644 index a39f69ed..00000000 --- a/ablog/templates/postnavy.html +++ /dev/null @@ -1,26 +0,0 @@ -{# prev/next are not set for drafts #} {% set post = ablog[pagename] %} -{% if post.published and ablog.post_show_prev_next %} -
    - - {% if post.prev %} {% if not ablog.fontawesome %}{{ gettext('Previous') }}: - {% endif %} - - {% if ablog.fontawesome %}{% endif - %} {{ post.prev.title }} - - {% endif %} - -   - - {% if post.next %} {% if not ablog.fontawesome %}{{ gettext('Next') }}: {% - endif %} - - {{ post.next.title }} {% if ablog.fontawesome %}{% endif %} - - {% endif %} - -
    -{% endif %} diff --git a/ablog/templates/recentposts.html b/ablog/templates/recentposts.html deleted file mode 100644 index 3f738711..00000000 --- a/ablog/templates/recentposts.html +++ /dev/null @@ -1,15 +0,0 @@ -{% if ablog %} -

    - {{ gettext('Recent Posts') }} -

    - -{% endif %} diff --git a/ablog/templates/redirect.html b/ablog/templates/redirect.html deleted file mode 100644 index f8e25705..00000000 --- a/ablog/templates/redirect.html +++ /dev/null @@ -1,8 +0,0 @@ -{%- extends "!layout.html" %} {%- block extrahead %} {{ super() }} - -{% endblock %} {% block body %} You are being redirected to -{{ post.title }} in {{ -ablog.post_redirect_refresh }} seconds; {% endblock %} diff --git a/ablog/templates/tagcloud.html b/ablog/templates/tagcloud.html deleted file mode 100644 index fac869db..00000000 --- a/ablog/templates/tagcloud.html +++ /dev/null @@ -1,41 +0,0 @@ -{% if ablog.tags %} -

    {{ gettext('Tags') }}

    - - -{% endif %} diff --git a/docs/release/ablog-v0.11-released.rst b/docs/release/ablog-v0.11-released.rst new file mode 100644 index 00000000..33804116 --- /dev/null +++ b/docs/release/ablog-v0.11-released.rst @@ -0,0 +1,23 @@ +ABlog v0.11 released +==================== + +.. post:: july 25, 2022 + :author: Nabil Freij + :category: Release + :location: World + +ABlog v0.11 is released with the main focus being to update and tweak the HTML templates allow themes to override the default templates. +In addition, all ablog elements in the templates wrapped in ``ablog__*`` divs to allow custom CSS rules. + +Added support for external links to be posts. + +There are several breaking changes: + +- 1. The template files are now in the `templates/ablog` folder. +- 2. In theory ablog will now append the tempaltes to the start of the template list, this could break themes without support for it. + +Pull Requests merged in: + +`Template rework `__. + +`Add external links for posts `__ from `Chris Holdgraf `__. diff --git a/setup.py b/setup.py index 323297c5..103e2be3 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ message_extractors={ "ablog": [ ("**.py", "python", None), - ("templates/**.html", "jinja2", None), + ("templates/ablog/**.html", "jinja2", None), ], }, ) From a0d0e1c20b534a2e6e3288fac73702fffd8898ab Mon Sep 17 00:00:00 2001 From: Nabil Freij Date: Tue, 2 Aug 2022 22:17:24 -0700 Subject: [PATCH 2/9] drop older versions of packages --- ablog/blog.py | 2 +- ablog/post.py | 32 ++++++++++++--------------- azure-pipelines.yml | 13 +++++------ docs/release/ablog-v0.11-released.rst | 1 + setup.cfg | 9 ++++---- tox.ini | 3 +-- 6 files changed, 26 insertions(+), 34 deletions(-) diff --git a/ablog/blog.py b/ablog/blog.py index 6eab2822..97493aa1 100644 --- a/ablog/blog.py +++ b/ablog/blog.py @@ -129,7 +129,7 @@ def verify_fn(key, value, config): def revise_pending_xrefs(doctree, docname): - for node in doctree.traverse(addnodes.pending_xref): + for node in doctree.findall(addnodes.pending_xref): node["refdoc"] = docname diff --git a/ablog/post.py b/ablog/post.py index 3998d5ba..26ab28c1 100644 --- a/ablog/post.py +++ b/ablog/post.py @@ -100,10 +100,6 @@ def run(self): return ad -def _split(a): - return {s.strip() for s in a.split(",")} - - class PostListDirective(Directive): """ Handle ``postlist`` directives. @@ -166,7 +162,7 @@ def apply(self): return None docinfo = docinfo[0] # Pull the metadata for the page to check if it is a blog post - metadata = {fn.children[0].astext(): fn.children[1].astext() for fn in docinfo.traverse(nodes.field)} + metadata = {fn.children[0].astext(): fn.children[1].astext() for fn in docinfo.findall(nodes.field)} tags = metadata.get("tags") if isinstance(tags, str): # myst_parser store front-matter field to TextNode in dict_to_fm_field_list. @@ -176,14 +172,14 @@ def apply(self): metadata["tags"] = ",".join( [t.strip().lstrip('"').lstrip("'").rstrip('"').rstrip("'") for t in tags.split(",")] ) - if list(docinfo.traverse(nodes.author)): - metadata["author"] = list(docinfo.traverse(nodes.author))[0].astext() + if list(docinfo.findall(nodes.author)): + metadata["author"] = list(docinfo.findall(nodes.author))[0].astext() # These two fields are special-cased in docutils - if list(docinfo.traverse(nodes.date)): - metadata["date"] = list(docinfo.traverse(nodes.date))[0].astext() + if list(docinfo.findall(nodes.date)): + metadata["date"] = list(docinfo.findall(nodes.date))[0].astext() if "blogpost" not in metadata and self.env.docname not in self.config.matched_blog_posts: return None - if self.document.traverse(PostNode): + if self.document.findall(PostNode): logging.warning(f"Found blog post front-matter as well as post directive, using post directive.") # Iterate through metadata and create a PostNode with relevant fields option_spec = PostDirective.option_spec @@ -201,7 +197,7 @@ def apply(self): if not metadata.get("excerpt"): blog = Blog(self.app) node["excerpt"] = blog.post_auto_excerpt - sections = list(self.document.traverse(nodes.section)) + sections = list(self.document.findall(nodes.section)) if sections: sections[0].children.append(node) node.parent = sections[0] @@ -243,7 +239,7 @@ def _get_section_title(section): """ Return section title as text. """ - for title in section.traverse(nodes.title): + for title in section.findall(nodes.title): return title.astext() raise Exception("Missing title") # A problem with the following is that title may contain pending @@ -254,7 +250,7 @@ def _get_update_dates(section, docname, post_date_format): """ Return list of dates of updates found section. """ - update_nodes = list(section.traverse(UpdateNode)) + update_nodes = list(section.findall(UpdateNode)) update_dates = [] for update_node in update_nodes: try: @@ -287,7 +283,7 @@ def process_posts(app, doctree): env = app.builder.env if not hasattr(env, "ablog_posts"): env.ablog_posts = {} - post_nodes = list(doctree.traverse(PostNode)) + post_nodes = list(doctree.findall(PostNode)) if not post_nodes: return post_date_format = app.config["post_date_format"] @@ -332,7 +328,7 @@ def process_posts(app, doctree): excerpt.append(child.deepcopy()) elif node["excerpt"]: count = 0 - for nod in section.traverse(nodes.paragraph): + for nod in section.findall(nodes.paragraph): excerpt.append(nod.deepcopy()) count += 1 if count >= (node["excerpt"] or 0): @@ -342,7 +338,7 @@ def process_posts(app, doctree): node.replace_self([]) nimg = node["image"] or blog.post_auto_image if nimg: - for img, nod in enumerate(section.traverse(nodes.image), start=1): + for img, nod in enumerate(section.findall(nodes.image), start=1): if img == nimg: excerpt.append(nod.deepcopy()) break @@ -385,7 +381,7 @@ def process_posts(app, doctree): else: section_copy = section.deepcopy() # multiple posting may result having post nodes - for nn in section_copy.traverse(PostNode): + for nn in section_copy.findall(PostNode): if nn["exclude"]: nn.replace_self([]) else: @@ -437,7 +433,7 @@ def process_postlist(app, doctree, docname): blog = Blog(app) if not blog: register_posts(app) - for node in doctree.traverse(PostList): + for node in doctree.findall(PostList): colls = [] for cat in ["tags", "author", "category", "location", "language"]: for coll in node[cat]: diff --git a/azure-pipelines.yml b/azure-pipelines.yml index c19849c1..72356b32 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -67,11 +67,12 @@ stages: - pandoc - graphviz envs: - - macos: py37-sphinx4 - - windows: py37-sphinx4 - - linux: py37-sphinx5 - - linux: py38-sphinx4 - linux: py310-docs + - linux: py38-sphinx5 + - linux: py39-sphinx5 + - linux: py39-sphinx5 + - macos: py38-sphinx4 + - windows: py38-sphinx4 - stage: ThirdPhaseTests displayName: Stage 3 Tests @@ -87,7 +88,3 @@ stages: - graphviz envs: - linux: py310-sphinxdev - - linux: py38-sphinx5 - - linux: py39-sphinx4 - - linux: py39-sphinx5 - - linux: py310-sphinx4 diff --git a/docs/release/ablog-v0.11-released.rst b/docs/release/ablog-v0.11-released.rst index 33804116..21b67b7e 100644 --- a/docs/release/ablog-v0.11-released.rst +++ b/docs/release/ablog-v0.11-released.rst @@ -15,6 +15,7 @@ There are several breaking changes: - 1. The template files are now in the `templates/ablog` folder. - 2. In theory ablog will now append the tempaltes to the start of the template list, this could break themes without support for it. +- 3. Minimum version of Python is 3.8, Sphinx is 5.0 and docutils is 0.19. Pull Requests merged in: diff --git a/setup.cfg b/setup.cfg index 4b624104..8ddbf448 100644 --- a/setup.cfg +++ b/setup.cfg @@ -11,17 +11,17 @@ edit_on_github = True github_project = sunpy/ablog [options] -python_requires = >=3.7 +python_requires = >=3.8 packages = find: include_package_data = True setup_requires = setuptools_scm install_requires = - docutils + docutils>=0.19 feedgen>=0.9.0 invoke>=1.6.0 python-dateutil>=2.8.0 - sphinx>=4.0.0 + sphinx>=5.0.0 watchdog>=2.0.0 [options.extras_require] @@ -50,8 +50,7 @@ filterwarnings = error # Do not fail on pytest config issues (i.e. missing plugins) but do show them always::pytest.PytestConfigWarning - # Update this when we depend on higher levels of Sphinx. - ignore:nodes.Node.traverse\(\) is obsoleted by Node.findall\(\) + [pycodestyle] max_line_length = 110 diff --git a/tox.ini b/tox.ini index d3128491..22f98437 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = - py{37,38,39,310}{-sphinx4,-sphinx5,-sphinxdev,-docs} + py{37,38,39,310}{-sphinx5,-sphinxdev,-docs} codestyle requires = setuptools >= 30.3.0 @@ -16,7 +16,6 @@ whitelist_externals= /usr/bin/make make deps = - sphinx4: sphinx>=4.0,<5.0 sphinx5: sphinx>=5.0,<6.0 sphinx6: sphinx>=6.0,<7.0 sphinxdev: git+https://github.com/sphinx-doc/sphinx From e04b7b69aafd8d0b314f4aa6b9522b9db3d8d437 Mon Sep 17 00:00:00 2001 From: Nabil Freij Date: Tue, 2 Aug 2022 22:25:01 -0700 Subject: [PATCH 3/9] Extra changes to get building again --- .gitignore | 1 - Makefile | 5 +- ablog/__init__.py | 83 ++++++++++++++------- ablog/blog.py | 43 +++++------ ablog/post.py | 10 +-- ablog/start.py | 16 ++-- ablog/templates/ablog/collection.html | 2 +- ablog/templates/ablog/postcard.html | 2 +- ablog/templates/{ablog => }/page.html | 2 +- azure-pipelines.yml | 7 +- docs/conf.py | 37 +++------ docs/manual/ablog-configuration-options.rst | 6 +- docs/release/ablog-v0.11-released.rst | 4 +- setup.cfg | 2 +- setup.py | 1 + 15 files changed, 117 insertions(+), 104 deletions(-) rename ablog/templates/{ablog => }/page.html (98%) diff --git a/.gitignore b/.gitignore index 30172161..3aa51cde 100644 --- a/.gitignore +++ b/.gitignore @@ -224,7 +224,6 @@ tags docs/_build/ docs/.doctrees/ docs/_website/ -docs/_latex/ test/ *.orig .history/ diff --git a/Makefile b/Makefile index 29681cee..ab8907bb 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,4 @@ test3: test4: set -e; mkdir -p testablog; cd testablog; printf "\nABlog\nABlog Team\nhttps://ablog.readthedocs.org" | ablog start; ablog build -W; cd ..; rm -rf testablog -test5: - set -e; cd docs; ablog build -W -b latex -T -d .doctrees -w _latex; git clean -xfd; cd .. - -tests: test test1 test2 test3 test4 test5 +tests: test test1 test2 test3 test4 diff --git a/ablog/__init__.py b/ablog/__init__.py index 43676f97..7a58af8d 100755 --- a/ablog/__init__.py +++ b/ablog/__init__.py @@ -6,6 +6,8 @@ from glob import glob from pathlib import PurePath +from sphinx.jinja2glue import BuiltinTemplateLoader, SphinxFileSystemLoader + from .blog import CONFIG, Blog from .post import ( CheckFrontMatter, @@ -28,6 +30,14 @@ __all__ = ["setup"] +def get_html_templates_path(): + """ + Return path to ABlog templates folder. + """ + pkgdir = os.path.abspath(os.path.dirname(__file__)) + return os.path.join(pkgdir, "templates") + + def anchor(post): """ Return anchor string for posts that are page sections. @@ -62,6 +72,52 @@ def html_page_context(app, pagename, templatename, context, doctree): context["feed_title"] = blog.blog_title +def builder_inited(app): + if not app.config.inject_templates_after_theme: + if not isinstance(app.builder.templates, BuiltinTemplateLoader): + raise Exception( + "Ablog does not know how to inject templates into with custom " + "template bridges. You can use `ablog.get_html_templates_path()` to " + "get the path to add in your custom template bridge and set " + "`inject_templates_after_theme = False` in your " + "`conf.py` file." + ) + if get_html_templates_path() in app.config.templates_path: + raise Exception( + "Found the path from `ablog.get_html_templates_path()` in the " + "`templates_path` variable from `conf.py`. Doing so interferes " + "with Ablog's ability to stay compatible with Sphinx themes that " + "support it out of the box. Please remove `get_html_templates_path` " + "from `templates_path` in your `conf.py` to resolve this." + ) + theme = app.builder.theme + loaders = app.builder.templates.loaders + templatepathlen = app.builder.templates.templatepathlen + if theme.get_config("ablog", "inject_templates_after_theme", False): + # Inject *after* the user templates and the theme templates, + # allowing themes to override the templates provided by this + # extension while those templates still serve as a fallback. + loaders.append(SphinxFileSystemLoader(get_html_templates_path())) + else: + # Inject *after* the user templates and *before* the theme + # templates. This enables ablog to provide support for themes + # that don't support it out-of-the-box, like alabaster. + loaders.insert(templatepathlen, SphinxFileSystemLoader(get_html_templates_path())) + + # 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] + matched_patterns = [] + for pattern in app.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( + PurePath(ii).relative_to(app.srcdir).with_suffix("").as_posix() + for ii in glob(pattern, recursive=True) + ) + app.config.matched_blog_posts = matched_patterns + + def setup(app): """ Setup ABlog extension. @@ -70,7 +126,7 @@ def setup(app): app.add_config_value(*args[:3]) app.add_directive("post", PostDirective) app.add_directive("postlist", PostListDirective) - app.connect("config-inited", config_inited) + app.connect("builder-inited", builder_inited) app.connect("doctree-read", process_posts) app.connect("env-purge-doc", purge_posts) app.connect("doctree-resolved", process_postlist) @@ -83,33 +139,8 @@ def setup(app): app.add_node( UpdateNode, html=(lambda s, n: s.visit_admonition(n), lambda s, n: s.depart_admonition(n)), - latex=(lambda s, n: s.visit_admonition(n), lambda s, n: s.depart_admonition(n)), ) pkgdir = os.path.abspath(os.path.dirname(__file__)) locale_dir = os.path.join(pkgdir, "locales") app.config.locale_dirs.append(locale_dir) return {"version": __version__} # identifies the version of our extension - - -def config_inited(app, config): - app.config.templates_path.append(get_html_templates_path()) - # Automatically identify any blog posts if a pattern is specified in the config - if isinstance(config.blog_post_pattern, str): - config.blog_post_pattern = [config.blog_post_pattern] - matched_patterns = [] - 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( - PurePath(ii).relative_to(app.srcdir).with_suffix("").as_posix() - for ii in glob(pattern, recursive=True) - ) - app.config.matched_blog_posts = matched_patterns - - -def get_html_templates_path(): - """ - Return path to ABlog templates folder. - """ - pkgdir = os.path.abspath(os.path.dirname(__file__)) - return os.path.join(pkgdir, "templates") diff --git a/ablog/blog.py b/ablog/blog.py index 97493aa1..045b3264 100644 --- a/ablog/blog.py +++ b/ablog/blog.py @@ -91,37 +91,38 @@ def verify_fn(key, value, config): CONFIG = [ # name, default, rebuild, verify_fn # where verify_fn is (key, value, app.config) --> value, throwing a KeyError if the value isn't right - ("blog_path", "blog", True, require_config_type(str)), - ("blog_title", "Blog", True, require_config_type(str)), - ("blog_baseurl", "", True, require_config_type(str)), ("blog_archive_titles", None, False, require_config_type(bool)), + ("blog_authors", {}, True, require_config_full_name_link_dict()), + ("blog_baseurl", "", True, require_config_type(str)), + ("blog_default_author", None, True, require_config_str_or_list_lookup("blog_authors")), + ("blog_default_language", None, True, require_config_str_or_list_lookup("blog_languages")), + ("blog_default_location", None, True, require_config_str_or_list_lookup("blog_locations")), ("blog_feed_archives", False, True), ("blog_feed_fulltext", False, True), + ("blog_feed_length", None, None), ("blog_feed_subtitle", None, True), - ("blog_feed_titles", None, False), ("blog_feed_templates", {"atom": {}}, True), - ("blog_feed_length", None, None), - ("blog_authors", {}, True, require_config_full_name_link_dict()), - ("blog_default_author", None, True, require_config_str_or_list_lookup("blog_authors")), - ("blog_locations", {}, True, require_config_full_name_link_dict()), - ("blog_default_location", None, True, require_config_str_or_list_lookup("blog_locations")), + ("blog_feed_titles", None, False), ("blog_languages", {}, True, require_config_full_name_link_dict()), - ("blog_default_language", None, True, require_config_str_or_list_lookup("blog_languages")), - ("fontawesome_link_cdn", None, True), - ("fontawesome_included", False, True, require_config_type(bool)), + ("blog_locations", {}, True, require_config_full_name_link_dict()), + ("blog_path", "blog", True, require_config_type(str)), + ("blog_post_pattern", [], True, require_config_type((str, list))), + ("blog_title", "Blog", True, require_config_type(str)), + ("disqus_drafts", False, True), + ("disqus_pages", False, True), + ("disqus_shortname", None, True), ("fontawesome_css_file", "", True, require_config_type(str)), - ("post_date_format", "%d %B %Y", True, require_config_type(str)), - ("post_date_format_short", "%d %B", True, require_config_type(str)), - ("post_auto_orphan", True, True, require_config_type(bool)), - ("post_auto_image", 0, True), + ("fontawesome_included", False, True, require_config_type(bool)), + ("fontawesome_link_cdn", None, True), + ("post_always_section", False, True), ("post_auto_excerpt", 1, True), + ("post_auto_image", 0, True), + ("post_auto_orphan", True, True, require_config_type(bool)), + ("post_date_format_short", "%d %B", True, require_config_type(str)), + ("post_date_format", "%d %B %Y", True, require_config_type(str)), ("post_redirect_refresh", 5, True), - ("post_always_section", False, True), ("post_show_prev_next", True, True), - ("disqus_shortname", None, True), - ("disqus_drafts", False, True), - ("disqus_pages", False, True), - ("blog_post_pattern", [], True, require_config_type((str, list))), + ("inject_templates_after_theme", False, True), ] TOMORROW = datetime.today() + dtmod.timedelta(1) TOMORROW = TOMORROW.replace(hour=0, minute=0, second=0, microsecond=0) diff --git a/ablog/post.py b/ablog/post.py index 26ab28c1..27a863b6 100644 --- a/ablog/post.py +++ b/ablog/post.py @@ -554,7 +554,7 @@ def generate_archive_pages(app): blog = Blog(app) for post in blog.posts: for redirect in post.redirect: - yield (redirect, {"redirect": post.docname, "post": post}, "redirect.html") + yield (redirect, {"redirect": post.docname, "post": post}, "ablog/redirect.html") found_docs = app.env.found_docs atom_feed = bool(blog.blog_baseurl) feed_archives = blog.blog_feed_archives @@ -571,7 +571,7 @@ def generate_archive_pages(app): continue context = {"parents": [], "title": title, "header": header, "catalog": catalog, "summary": True} if catalog.docname not in found_docs: - yield (catalog.docname, context, "catalog.html") + yield (catalog.docname, context, "ablog/catalog.html") for collection in catalog: if not collection: continue @@ -586,7 +586,7 @@ def generate_archive_pages(app): } context["feed_title"] = context["title"] if collection.docname not in found_docs: - yield (collection.docname, context, "collection.html") + yield (collection.docname, context, "ablog/collection.html") if 1: context = { "parents": [], @@ -598,9 +598,9 @@ def generate_archive_pages(app): "feed_path": blog.blog_path, } docname = blog.posts.docname - yield (docname, context, "collection.html") + yield (docname, context, "ablog/collection.html") context = {"parents": [], "title": _("Drafts"), "collection": blog.drafts, "summary": True} - yield (blog.drafts.docname, context, "collection.html") + yield (blog.drafts.docname, context, "ablog/collection.html") def generate_atom_feeds(app): diff --git a/ablog/start.py b/ablog/start.py index 2f8c579b..486a4a8b 100644 --- a/ablog/start.py +++ b/ablog/start.py @@ -77,6 +77,12 @@ def w(t, ls=80): # 'Earth': ('The Blue Planet', 'https://en.wikipedia.org/wiki/Earth), # }} +# See https://github.com/sunpy/ablog/pull/144 for the full context +# This will prevent ablog from overriding any local templates that you might +# need to use for your project. +# Default is ``False``. +# inject_templates_after_theme = False + # -- Blog Post Related -------------------------------------------------------- # Format date for a post. @@ -123,10 +129,9 @@ def w(t, ls=80): # In addition, there are authors.html, languages.html, and locations.html # sidebars that link to author and location archive pages. html_sidebars = {{ - '**': [ 'about.html', - 'postcard.html', 'navigation.html', - 'recentposts.html', 'tagcloud.html', - 'categories.html', 'archives.html', + '**': [ 'ablog/postcard.html', 'navigation.html', + 'ablog/recentposts.html', 'ablog/tagcloud.html', + 'ablog/categories.html', 'ablog/archives.html', 'searchbox.html', ], }} @@ -215,9 +220,6 @@ def w(t, ls=80): 'ablog', ] -# Add any paths that contain templates here, relative to this directory. -templates_path = [ablog.get_html_templates_path(), "{dot}templates"] - # The suffix(es) of source filenames. source_suffix = "{suffix}" diff --git a/ablog/templates/ablog/collection.html b/ablog/templates/ablog/collection.html index 4d63718d..6816f8a9 100644 --- a/ablog/templates/ablog/collection.html +++ b/ablog/templates/ablog/collection.html @@ -50,7 +50,7 @@

    {% endif %} {% endif %} - {% include "postcard2.html" %} + {% include "ablog/postcard2.html" %} {{ post.to_html(collection.docname) }}

    {{ _("Read more ...") }}

    diff --git a/ablog/templates/ablog/postcard.html b/ablog/templates/ablog/postcard.html index 92d3a1fe..baa51cbc 100644 --- a/ablog/templates/ablog/postcard.html +++ b/ablog/templates/ablog/postcard.html @@ -20,7 +20,7 @@

    {% endif %}

      - {% include "postcard2.html" %} + {% include "ablog/postcard2.html" %}
    {% endif %} diff --git a/ablog/templates/ablog/page.html b/ablog/templates/page.html similarity index 98% rename from ablog/templates/ablog/page.html rename to ablog/templates/page.html index 08238bae..364b202e 100644 --- a/ablog/templates/ablog/page.html +++ b/ablog/templates/page.html @@ -24,7 +24,7 @@ {{ body }}
    {% if pagename in ablog %} - {% include "postnavy.html" %} + {% include "ablog/postnavy.html" %} {% endif %} {% if ablog.disqus_shortname and ablog.blog_baseurl and (not ablog[pagename].nocomments) and ((pagename in ablog and (ablog[pagename].published or ablog.disqus_drafts)) or (not pagename in ablog and ablog.disqus_pages)) %}
    diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 72356b32..6dbae87e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -67,12 +67,10 @@ stages: - pandoc - graphviz envs: - - linux: py310-docs - linux: py38-sphinx5 - linux: py39-sphinx5 - - linux: py39-sphinx5 - - macos: py38-sphinx4 - - windows: py38-sphinx4 + - macos: py38-sphinx5 + - windows: py38-sphinx5 - stage: ThirdPhaseTests displayName: Stage 3 Tests @@ -88,3 +86,4 @@ stages: - graphviz envs: - linux: py310-sphinxdev + - linux: py310-docs diff --git a/docs/conf.py b/docs/conf.py index 2cb7db5d..375c63af 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,6 +1,5 @@ import re -import alabaster from pkg_resources import get_distribution from sphinx import addnodes @@ -14,24 +13,17 @@ "sphinx.ext.ifconfig", "sphinx.ext.extlinks", "sphinx_automodapi.automodapi", + "ablog", "alabaster", "nbsphinx", "myst_parser", - "ablog", ] -# PROJECT versionmod = get_distribution("ablog") -myst_update_mathjax = False -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# The short X.Y version. version = ".".join(versionmod.version.split(".")[:3]) -# The full version, including alpha/beta/rc tags. release = versionmod.version.split("+")[0] -# Is this version a development release is_development = ".dev" in release + project = "ABlog" copyright = "2014-2022, ABlog Team" master_doc = "index" @@ -39,9 +31,8 @@ ".rst": "restructuredtext", ".md": "markdown", } -exclude_patterns = ["_build"] +exclude_patterns = ["_build", "docs/manual/.ipynb_checkpoints"] -# HTML OUTPUT html_title = "ABlog" html_static_path = ["_static"] html_use_index = True @@ -49,12 +40,11 @@ html_show_sourcelink = True html_favicon = "_static/ablog.ico" -# ABLOG blog_title = "ABlog" blog_baseurl = "https://ablog.readthedocs.org/" blog_locations = { "Pittsburgh": ("Pittsburgh, PA", "https://en.wikipedia.org/wiki/Pittsburgh"), - "SF": ("San Francisco, CA", "https://en.wikipedia.org/wiki/San_Francisco"), + "San Fran": ("San Francisco, CA", "https://en.wikipedia.org/wiki/San_Francisco"), "Denizli": ("Denizli, Turkey", "https://en.wikipedia.org/wiki/Denizli"), } blog_languages = { @@ -71,18 +61,13 @@ } blog_feed_archives = True blog_feed_fulltext = True -blog_feed_length = None blog_feed_templates = { - # Use defaults, no templates "atom": { - # Format tags as hashtags and append to the content "content": "{{ title }}{% for tag in post.tags %}" " #{{ tag.name|trim()|replace(' ', '') }}" "{% endfor %}", }, - # Create content text suitable posting to micro-bogging "social": { - # Format tags as hashtags and append to the content "content": "{{ title }}{% for tag in post.tags %}" " #{{ tag.name|trim()|replace(' ', '') }}" "{% endfor %}", @@ -92,21 +77,19 @@ disqus_pages = True fontawesome_link_cdn = "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" -# THEME html_style = "alabaster.css" html_theme = "alabaster" html_sidebars = { "**": [ "about.html", - "postcard.html", - "recentposts.html", - "tagcloud.html", - "categories.html", - "archives.html", + "ablog/postcard.html", + "ablog/recentposts.html", + "ablog/tagcloud.html", + "ablog/categories.html", + "ablog/archives.html", "searchbox.html", ] } -html_theme_path = [alabaster.get_path()] html_theme_options = { "travis_button": False, "github_user": "sunpy", @@ -115,7 +98,6 @@ "logo": "ablog.png", } -# SPHINX intersphinx_mapping = { "python": ("https://docs.python.org/", None), "sphinx": ("https://www.sphinx-doc.org/en/master/", None), @@ -125,7 +107,6 @@ "issue": ("https://github.com/sunpy/ablog/issues/%s", "issue %s"), "pull": ("https://github.com/sunpy/ablog/pull/%s", "pull request %s"), } -exclude_patterns = ["docs/manual/.ipynb_checkpoints/*"] rst_epilog = """ .. _Sphinx: http://sphinx-doc.org/ .. _Python: https://python.org diff --git a/docs/manual/ablog-configuration-options.rst b/docs/manual/ablog-configuration-options.rst index 20b0e284..bf10e68c 100644 --- a/docs/manual/ablog-configuration-options.rst +++ b/docs/manual/ablog-configuration-options.rst @@ -271,9 +271,9 @@ Sidebars that you see on the left are listed below in the same order: html_sidebars = { '**': [..., - 'postcard.html', 'recentposts.html', - 'tagcloud.html', 'categories.html', - 'archives.html', ] + 'ablog/postcard.html', 'ablog/recentposts.html', + 'ablog/tagcloud.html', 'ablog/categories.html', + 'ablog/archives.html', ] } diff --git a/docs/release/ablog-v0.11-released.rst b/docs/release/ablog-v0.11-released.rst index 21b67b7e..1ec97e2e 100644 --- a/docs/release/ablog-v0.11-released.rst +++ b/docs/release/ablog-v0.11-released.rst @@ -15,7 +15,9 @@ There are several breaking changes: - 1. The template files are now in the `templates/ablog` folder. - 2. In theory ablog will now append the tempaltes to the start of the template list, this could break themes without support for it. -- 3. Minimum version of Python is 3.8, Sphinx is 5.0 and docutils is 0.19. +- 3. Minimum version of Python is >=3.8 and Sphinx is >=5.0. +- 4. Latex building is now not possible anymore. + This could change in future but for the first release of 0.11, it is nonfunctional. Pull Requests merged in: diff --git a/setup.cfg b/setup.cfg index 8ddbf448..edf6714a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -17,7 +17,7 @@ include_package_data = True setup_requires = setuptools_scm install_requires = - docutils>=0.19 + docutils feedgen>=0.9.0 invoke>=1.6.0 python-dateutil>=2.8.0 diff --git a/setup.py b/setup.py index 103e2be3..c63402d9 100644 --- a/setup.py +++ b/setup.py @@ -29,6 +29,7 @@ message_extractors={ "ablog": [ ("**.py", "python", None), + ("templates/**.html", "jinja2", None), ("templates/ablog/**.html", "jinja2", None), ], }, From 5fb799cf682910906cd371f34a328c8ca0c12257 Mon Sep 17 00:00:00 2001 From: Nabil Freij Date: Sat, 6 Aug 2022 18:45:09 -0700 Subject: [PATCH 4/9] Apply suggestions from code review Co-authored-by: Pradyun Gedam --- ablog/__init__.py | 36 +++++++++++++++++++----------------- ablog/blog.py | 2 +- ablog/start.py | 9 ++++----- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/ablog/__init__.py b/ablog/__init__.py index 7a58af8d..01c2c4c7 100755 --- a/ablog/__init__.py +++ b/ablog/__init__.py @@ -73,23 +73,25 @@ def html_page_context(app, pagename, templatename, context, doctree): def builder_inited(app): - if not app.config.inject_templates_after_theme: - if not isinstance(app.builder.templates, BuiltinTemplateLoader): - raise Exception( - "Ablog does not know how to inject templates into with custom " - "template bridges. You can use `ablog.get_html_templates_path()` to " - "get the path to add in your custom template bridge and set " - "`inject_templates_after_theme = False` in your " - "`conf.py` file." - ) - if get_html_templates_path() in app.config.templates_path: - raise Exception( - "Found the path from `ablog.get_html_templates_path()` in the " - "`templates_path` variable from `conf.py`. Doing so interferes " - "with Ablog's ability to stay compatible with Sphinx themes that " - "support it out of the box. Please remove `get_html_templates_path` " - "from `templates_path` in your `conf.py` to resolve this." - ) + if app.config.skip_injecting_base_ablog_templates: + return + + if not isinstance(app.builder.templates, BuiltinTemplateLoader): + raise Exception( + "Ablog does not know how to inject templates into with custom " + "template bridges. You can use `ablog.get_html_templates_path()` to " + "get the path to add in your custom template bridge and set " + "`skip_injecting_base_ablog_templates = False` in your " + "`conf.py` file." + ) + if get_html_templates_path() in app.config.templates_path: + raise Exception( + "Found the path from `ablog.get_html_templates_path()` in the " + "`templates_path` variable from `conf.py`. Doing so interferes " + "with Ablog's ability to stay compatible with Sphinx themes that " + "support it out of the box. Please remove `get_html_templates_path` " + "from `templates_path` in your `conf.py` to resolve this." + ) theme = app.builder.theme loaders = app.builder.templates.loaders templatepathlen = app.builder.templates.templatepathlen diff --git a/ablog/blog.py b/ablog/blog.py index 045b3264..d391ddb9 100644 --- a/ablog/blog.py +++ b/ablog/blog.py @@ -122,7 +122,7 @@ def verify_fn(key, value, config): ("post_date_format", "%d %B %Y", True, require_config_type(str)), ("post_redirect_refresh", 5, True), ("post_show_prev_next", True, True), - ("inject_templates_after_theme", False, True), + ("skip_injecting_base_ablog_templates", False, True), ] TOMORROW = datetime.today() + dtmod.timedelta(1) TOMORROW = TOMORROW.replace(hour=0, minute=0, second=0, microsecond=0) diff --git a/ablog/start.py b/ablog/start.py index 486a4a8b..3389df73 100644 --- a/ablog/start.py +++ b/ablog/start.py @@ -77,11 +77,10 @@ def w(t, ls=80): # 'Earth': ('The Blue Planet', 'https://en.wikipedia.org/wiki/Earth), # }} -# See https://github.com/sunpy/ablog/pull/144 for the full context -# This will prevent ablog from overriding any local templates that you might -# need to use for your project. -# Default is ``False``. -# inject_templates_after_theme = False +# This will prevent ablog from injecting its own templates into the Sphinx +# build. This is only useful when you have a custom template bridge (rare). +# See https://github.com/sunpy/ablog/pull/144 for the full context. +# skip_injecting_base_ablog_templates = False # -- Blog Post Related -------------------------------------------------------- From 934017c13273006741d880f8731b36fcb718ca61 Mon Sep 17 00:00:00 2001 From: Nabil Freij Date: Sat, 6 Aug 2022 18:46:36 -0700 Subject: [PATCH 5/9] split up back to config and builder parts --- ablog/__init__.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/ablog/__init__.py b/ablog/__init__.py index 01c2c4c7..a1478887 100755 --- a/ablog/__init__.py +++ b/ablog/__init__.py @@ -72,10 +72,24 @@ def html_page_context(app, pagename, templatename, context, doctree): context["feed_title"] = blog.blog_title +def config_inited(app): + # 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] + matched_patterns = [] + for pattern in app.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( + PurePath(ii).relative_to(app.srcdir).with_suffix("").as_posix() + for ii in glob(pattern, recursive=True) + ) + app.config.matched_blog_posts = matched_patterns + + def builder_inited(app): if app.config.skip_injecting_base_ablog_templates: return - if not isinstance(app.builder.templates, BuiltinTemplateLoader): raise Exception( "Ablog does not know how to inject templates into with custom " @@ -106,19 +120,6 @@ def builder_inited(app): # that don't support it out-of-the-box, like alabaster. loaders.insert(templatepathlen, SphinxFileSystemLoader(get_html_templates_path())) - # 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] - matched_patterns = [] - for pattern in app.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( - PurePath(ii).relative_to(app.srcdir).with_suffix("").as_posix() - for ii in glob(pattern, recursive=True) - ) - app.config.matched_blog_posts = matched_patterns - def setup(app): """ @@ -128,6 +129,7 @@ def setup(app): app.add_config_value(*args[:3]) app.add_directive("post", PostDirective) app.add_directive("postlist", PostListDirective) + app.connect("config-inited", config_inited) app.connect("builder-inited", builder_inited) app.connect("doctree-read", process_posts) app.connect("env-purge-doc", purge_posts) From 66f81bb0b569df39c6250b8d2a818a06b1217e36 Mon Sep 17 00:00:00 2001 From: Nabil Freij Date: Sat, 6 Aug 2022 18:48:11 -0700 Subject: [PATCH 6/9] add back latex tests --- .gitignore | 1 + Makefile | 5 ++++- ablog/__init__.py | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3aa51cde..30172161 100644 --- a/.gitignore +++ b/.gitignore @@ -224,6 +224,7 @@ tags docs/_build/ docs/.doctrees/ docs/_website/ +docs/_latex/ test/ *.orig .history/ diff --git a/Makefile b/Makefile index ab8907bb..29681cee 100644 --- a/Makefile +++ b/Makefile @@ -22,4 +22,7 @@ test3: test4: set -e; mkdir -p testablog; cd testablog; printf "\nABlog\nABlog Team\nhttps://ablog.readthedocs.org" | ablog start; ablog build -W; cd ..; rm -rf testablog -tests: test test1 test2 test3 test4 +test5: + set -e; cd docs; ablog build -W -b latex -T -d .doctrees -w _latex; git clean -xfd; cd .. + +tests: test test1 test2 test3 test4 test5 diff --git a/ablog/__init__.py b/ablog/__init__.py index a1478887..9b0f37c8 100755 --- a/ablog/__init__.py +++ b/ablog/__init__.py @@ -143,6 +143,7 @@ def setup(app): app.add_node( UpdateNode, html=(lambda s, n: s.visit_admonition(n), lambda s, n: s.depart_admonition(n)), + latex=(lambda s, n: s.visit_admonition(n), lambda s, n: s.depart_admonition(n)), ) pkgdir = os.path.abspath(os.path.dirname(__file__)) locale_dir = os.path.join(pkgdir, "locales") From 9abb8c4fb10d504f1f8187366b598d28d432c7a2 Mon Sep 17 00:00:00 2001 From: Nabil Freij Date: Sat, 6 Aug 2022 18:59:54 -0700 Subject: [PATCH 7/9] added back old templates but with warning --- ablog/__init__.py | 11 +- ablog/templates/archives.html | 17 +++ ablog/templates/authors.html | 13 ++ ablog/templates/catalog.html | 29 +++++ ablog/templates/categories.html | 17 +++ ablog/templates/collection.html | 63 ++++++++++ ablog/templates/languages.html | 15 +++ ablog/templates/locations.html | 17 +++ ablog/templates/postcard.html | 27 +++++ ablog/templates/postcard2.html | 166 ++++++++++++++++++++++++++ ablog/templates/postnavy.html | 34 ++++++ ablog/templates/recentposts.html | 18 +++ ablog/templates/redirect.html | 9 ++ ablog/templates/tagcloud.html | 15 +++ docs/release/ablog-v0.11-released.rst | 6 +- 15 files changed, 449 insertions(+), 8 deletions(-) create mode 100644 ablog/templates/archives.html create mode 100644 ablog/templates/authors.html create mode 100644 ablog/templates/catalog.html create mode 100644 ablog/templates/categories.html create mode 100644 ablog/templates/collection.html create mode 100644 ablog/templates/languages.html create mode 100644 ablog/templates/locations.html create mode 100644 ablog/templates/postcard.html create mode 100644 ablog/templates/postcard2.html create mode 100644 ablog/templates/postnavy.html create mode 100644 ablog/templates/recentposts.html create mode 100644 ablog/templates/redirect.html create mode 100644 ablog/templates/tagcloud.html diff --git a/ablog/__init__.py b/ablog/__init__.py index 9b0f37c8..a0f7082a 100755 --- a/ablog/__init__.py +++ b/ablog/__init__.py @@ -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 @@ -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( @@ -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( diff --git a/ablog/templates/archives.html b/ablog/templates/archives.html new file mode 100644 index 00000000..b26e94fe --- /dev/null +++ b/ablog/templates/archives.html @@ -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 %} +
    +

    + {{ gettext('Archives') }} +

    + +
    +{% endif %} diff --git a/ablog/templates/authors.html b/ablog/templates/authors.html new file mode 100644 index 00000000..4ac4ad43 --- /dev/null +++ b/ablog/templates/authors.html @@ -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 %} +
    +

    {{ gettext('Authors') }}

    + +
    +{% endif %} diff --git a/ablog/templates/catalog.html b/ablog/templates/catalog.html new file mode 100644 index 00000000..e1a2ed31 --- /dev/null +++ b/ablog/templates/catalog.html @@ -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 %} +
    +

    + {{ header }} + {{ collection }} +

    + {% for post in collection %} +
    +

    + {% if post.published %} + {{ post.date.strftime(ablog.post_date_format) }} + {% else %} + Draft + {% endif %} + - + {{ post.title }} +

    +
    + {% endfor %} +
    +{% endif %} +{% endfor %} +{% endblock %} diff --git a/ablog/templates/categories.html b/ablog/templates/categories.html new file mode 100644 index 00000000..b5d0e9a7 --- /dev/null +++ b/ablog/templates/categories.html @@ -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 %} +
    +

    + {{ gettext('Categories') }} +

    + +
    +{% endif %} diff --git a/ablog/templates/collection.html b/ablog/templates/collection.html new file mode 100644 index 00000000..d4957050 --- /dev/null +++ b/ablog/templates/collection.html @@ -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 %} +
    +

    + {% if archive_feed and fa %} + + + {% endif %} + {{ header }} + {% if collection.href %} + {{ collection }} + {% else %} + {{ collection }} + {% endif %} +

    + {% if ablog.blog_archive_titles %} + {% for post in collection %} +
    +

    + {% if post.published %} + {{ post.date.strftime(ablog.post_date_format) }} + {% else %} + Draft + {% endif %} + - + {{ post.title }} +

    +
    + {% endfor %} + {% else %} + {% for post in collection %} +
    +

    + {{ post.title }} +

    +
      +
    • + {% if post.published %} + {% if fa %} + + {% endif %} + {{ post.date.strftime(ablog.post_date_format) }} + {% else %} + {% if fa %} + + {% endif %} + {% if post.date %} + {{ post.date.strftime(ablog.post_date_format) }} + {% else %} + Draft + {% endif %} + {% endif %} +
    • + {% include "ablog/postcard2.html" %} +
    + {{ post.to_html(collection.docname) }} +

    {{ _("Read more ...") }}

    +
    +
    + {% endfor %} + {% endif %} +
    +{% endblock %} diff --git a/ablog/templates/languages.html b/ablog/templates/languages.html new file mode 100644 index 00000000..d159df1a --- /dev/null +++ b/ablog/templates/languages.html @@ -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 %} +
    +

    + {{ gettext('Languages') }} +

    + +
    +{% endif %} diff --git a/ablog/templates/locations.html b/ablog/templates/locations.html new file mode 100644 index 00000000..4ab646c9 --- /dev/null +++ b/ablog/templates/locations.html @@ -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 %} +
    +

    + {{ gettext('Locations') }} +

    + +
    +{% endif %} diff --git a/ablog/templates/postcard.html b/ablog/templates/postcard.html new file mode 100644 index 00000000..28186f19 --- /dev/null +++ b/ablog/templates/postcard.html @@ -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 %} +
    +{% set fa = ablog.fontawesome %} +{% set post = ablog[pagename] %} +

    + {% if post.published %} + {% if fa %} + + {% endif %} + {{ post.date.strftime(ablog.post_date_format) }} + {% else %} + {% if fa %} + + {% endif %} + {% if post.date %} + {{ post.date.strftime(ablog.post_date_format)}} + {% else %} + Draft + {% endif %} + {% endif %} +

    +
      + {% include "ablog/postcard2.html" %} +
    +
    +{% endif %} diff --git a/ablog/templates/postcard2.html b/ablog/templates/postcard2.html new file mode 100644 index 00000000..65cd04fc --- /dev/null +++ b/ablog/templates/postcard2.html @@ -0,0 +1,166 @@ +{{ warning("postcard2.html is an old template path, that is no longer used by ablog. Please use ablog/postcard2.html instead.") }} +{% if post.published and post.date != post.update %} +
    +
  • + + {% if fa %} + + {% else %} + {{gettext('Update') }}: + {% endif %} + + {{ post.update.strftime(ablog.post_date_format) }} +
  • +{% endif %} +{% if post.author %} +
  • + + {% if fa %} + + {% else %} + {{ gettext('Author')}}: + {% endif %} + + {% for coll in post.author %} + {% if coll|length %} + {{ coll }} + {% if loop.index < post.author|length %} + , + {% endif %} + {% else %} + {{ coll }} + {% if loop.index < post.author|length %} + , + {% endif %} + {% endif %} + {% endfor %} +
  • +{% endif %} +{% if post.location %} +
  • + + {% if fa %} + + {% else %} + {{gettext('Location') }}: + {% endif %} + + {% for coll in post.location %} + {% if coll|length %} + {{ coll }} + {% if loop.index < post.location|length %} + , + {% endif %} + {% else %} + {{ coll }} + {% if loop.index < post.location|length %} + , + {% endif %} + {% endif %} + {% endfor %} +
  • +{% endif %} +{% if post.language %} +
  • + + {% if fa %} + + {% else %} + {{gettext('Language') }}: + {% endif %} + + {% for coll in post.language %} + {% if coll|length %} + {{ coll }} + {% if loop.index < post.language|length %} + , + {% endif %} + {% else %} + {{ coll }} + {% if loop.index < post.language|length %} + , + {% endif %} + {% endif %} + {% endfor %} +
  • +{% endif %} +{% if post.category %} +
  • + + {% if fa %} + + {% else %} + {{ gettext('Category') }}: + {% endif %} + + {% for coll in post.category %} + {% if coll|length %} + {{ coll }} + {% if loop.index < post.category|length %} + , + {% endif %} + {% else %} + {{ coll }} + {% if loop.index < post.category|length %} + , + {% endif %} + {% endif %} + {% endfor %} +
  • +{% endif %} +{% if post.tags %} +
  • + + {% if post.tags|length > 1 %} + {% if fa %} + + {% else %} + {{ gettext('Tags') }}: + {% endif %} + {% else %} + {% if fa %} + + {% else %} + {{ gettext('Tag') }}: + {% endif %}{% endif %} + + {% for coll in post.tags %} + {% if coll|length %} + {{ coll }} + {% if loop.index < post.tags|length %} + {% endif %} + {% else %} + {{ coll }} + {% if loop.index < post.tags|length %} + {% endif %} + {% endif %} + {% endfor %} +
  • +{% endif %} +{% if ablog.disqus_shortname and (ablog[pagename].published or ablog.disqus_drafts) %} +
  • + + {% if fa %} + + {% endif %} + + {% if not fa %} + Comments + {% endif %} + +
  • +
    +{% endif %} diff --git a/ablog/templates/postnavy.html b/ablog/templates/postnavy.html new file mode 100644 index 00000000..4d324b38 --- /dev/null +++ b/ablog/templates/postnavy.html @@ -0,0 +1,34 @@ +{{ warning("postnavy.html is an old template path, that is no longer used by ablog. Please use ablog/postnavy.html instead.") }} +{# prev/next are not set for drafts #} +{% set post = ablog[pagename] %} +{% if post.published and ablog.post_show_prev_next %} +
    + + {% if post.prev %} + {% if not ablog.fontawesome %} + {{ gettext('Previous') }}: + {% endif %} + + {% if ablog.fontawesome %} + + {% endif %} + {{ post.prev.title }} + + {% endif %} + +   + + {% if post.next %} + {% if not ablog.fontawesome %} + {{ gettext('Next') }}: + {% endif %} + + {{ post.next.title }} + {% if ablog.fontawesome %} + + {% endif %} + + {% endif %} + +
    +{% endif %} diff --git a/ablog/templates/recentposts.html b/ablog/templates/recentposts.html new file mode 100644 index 00000000..5a7dad64 --- /dev/null +++ b/ablog/templates/recentposts.html @@ -0,0 +1,18 @@ +{{ warning("recentposts.html is an old template path, that is no longer used by ablog. Please use ablog/recentposts.html instead.") }} +{% if ablog %} +
    +

    + {{ gettext('Recent Posts') }} +

    + +
    +{% endif %} diff --git a/ablog/templates/redirect.html b/ablog/templates/redirect.html new file mode 100644 index 00000000..21109bb1 --- /dev/null +++ b/ablog/templates/redirect.html @@ -0,0 +1,9 @@ +{{ warning("redirect.html is an old template path, that is no longer used by ablog. Please use ablog/redirect.html instead.") }} +{%- extends "!layout.html" %} +{%- block extrahead %} +{{ super() }} + +{% endblock %} +{% block body %} +You are being redirected to {{ post.title }} in {{ ablog.post_redirect_refresh }} seconds; +{% endblock %} diff --git a/ablog/templates/tagcloud.html b/ablog/templates/tagcloud.html new file mode 100644 index 00000000..67592664 --- /dev/null +++ b/ablog/templates/tagcloud.html @@ -0,0 +1,15 @@ +{{ warning("tagcloud.html is an old template path, that is no longer used by ablog. Please use ablog/tagcloud.html instead.") }} +{% if ablog.tags %} +
    +

    {{ gettext('Tags') }}

    +
      + {% for coll in ablog.tags %} + {% if coll %} +
    • + {{ coll }} +
    • + {% endif %} + {% endfor %} +
    +
    +{% endif %} diff --git a/docs/release/ablog-v0.11-released.rst b/docs/release/ablog-v0.11-released.rst index 1ec97e2e..c341b55f 100644 --- a/docs/release/ablog-v0.11-released.rst +++ b/docs/release/ablog-v0.11-released.rst @@ -14,10 +14,10 @@ Added support for external links to be posts. There are several breaking changes: - 1. The template files are now in the `templates/ablog` folder. -- 2. In theory ablog will now append the tempaltes to the start of the template list, this could break themes without support for it. + Older templates are still in the old location but will raise a warning. +- 2. ``ablog`` has support for not injecting its own templates into the Sphinx build. + This is supported by add `skip_injecting_base_ablog_templates = True` to your configuration file. - 3. Minimum version of Python is >=3.8 and Sphinx is >=5.0. -- 4. Latex building is now not possible anymore. - This could change in future but for the first release of 0.11, it is nonfunctional. Pull Requests merged in: From f22aff37046d893d569c27a8e2be6d67ed5cb99f Mon Sep 17 00:00:00 2001 From: Nabil Freij Date: Sun, 7 Aug 2022 13:44:34 -0700 Subject: [PATCH 8/9] more general catch --- ablog/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ablog/__init__.py b/ablog/__init__.py index a0f7082a..9990d5f6 100755 --- a/ablog/__init__.py +++ b/ablog/__init__.py @@ -6,7 +6,7 @@ from glob import glob from pathlib import PurePath -from sphinx.builders.latex import LaTeXBuilder +from sphinx.builders.html import HTMLBuilder from sphinx.jinja2glue import BuiltinTemplateLoader, SphinxFileSystemLoader from .blog import CONFIG, Blog @@ -89,7 +89,7 @@ def config_inited(app, config): def builder_inited(app): - if isinstance(app.builder, LaTeXBuilder) or app.config.skip_injecting_base_ablog_templates: + if not isinstance(app.builder, HTMLBuilder) or app.config.skip_injecting_base_ablog_templates: return if not isinstance(app.builder.templates, BuiltinTemplateLoader): raise Exception( From 323890f64f8bb54c679ba60ff6c7c2ed79400020 Mon Sep 17 00:00:00 2001 From: Nabil Freij Date: Mon, 15 Aug 2022 22:38:26 -0700 Subject: [PATCH 9/9] update import --- ablog/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ablog/__init__.py b/ablog/__init__.py index 9990d5f6..d936f042 100755 --- a/ablog/__init__.py +++ b/ablog/__init__.py @@ -6,7 +6,7 @@ from glob import glob from pathlib import PurePath -from sphinx.builders.html import HTMLBuilder +from sphinx.builders.html import StandaloneHTMLBuilder from sphinx.jinja2glue import BuiltinTemplateLoader, SphinxFileSystemLoader from .blog import CONFIG, Blog @@ -89,7 +89,7 @@ def config_inited(app, config): def builder_inited(app): - if not isinstance(app.builder, HTMLBuilder) or app.config.skip_injecting_base_ablog_templates: + if not isinstance(app.builder, StandaloneHTMLBuilder) or app.config.skip_injecting_base_ablog_templates: return if not isinstance(app.builder.templates, BuiltinTemplateLoader): raise Exception(