From 803df4cc8afea91d3565732a1119345ac086bb37 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 19 Dec 2017 16:47:45 +0100 Subject: [PATCH] New m.metadata plugin. Provides per-category, per-author and per-tag metadata: * Author and category image and "badge" (short description) * Author, category and tag description on their filter page, filling social meta tags as well * Ability to specify author twitter handle for social meta tags --- doc/examples/authors/an-author.rst | 6 + doc/examples/categories/examples.rst | 6 + doc/examples/tags/jumbo.rst | 2 + doc/pelican/theme.rst | 11 + doc/plugins.rst | 9 + doc/plugins/metadata.rst | 260 ++++++++++++++++++ pelican-plugins/m/metadata.py | 81 ++++++ .../m/test/metadata/article-jumbo.html | 116 ++++++++ .../m/test/metadata/article-minimal.html | 80 ++++++ .../m/test/metadata/article-no-image.html | 80 ++++++ pelican-plugins/m/test/metadata/article.html | 88 ++++++ .../test/metadata/articles/article-jumbo.rst | 11 + .../metadata/articles/article-minimal.rst | 11 + .../metadata/articles/article-no-image.rst | 10 + .../m/test/metadata/articles/article.rst | 11 + .../m/test/metadata/author-an-author.html | 98 +++++++ .../metadata/author-author-with-no-image.html | 76 +++++ .../test/metadata/author-minimal-author.html | 76 +++++ .../m/test/metadata/authors/an-author.rst | 13 + .../metadata/authors/author-with-no-image.rst | 6 + .../test/metadata/authors/minimal-author.rst | 3 + .../m/test/metadata/categories/a-category.rst | 11 + .../categories/category-with-no-image.rst | 8 + .../metadata/categories/minimal-category.rst | 3 + .../m/test/metadata/category-a-category.html | 96 +++++++ .../category-category-with-no-image.html | 77 ++++++ .../metadata/category-minimal-category.html | 76 +++++ pelican-plugins/m/test/metadata/category.jpg | 1 + pelican-plugins/m/test/metadata/mosra.jpg | 1 + .../m/test/metadata/tag-a-tag.html | 78 ++++++ .../m/test/metadata/tag-minimal-tag.html | 76 +++++ .../m/test/metadata/tags/a-tag.rst | 8 + .../m/test/metadata/tags/minimal-tag.rst | 1 + .../article.html | 78 ++++++ .../articles/article.rst | 10 + .../author-an-author.html | 75 +++++ .../authors/an-author.rst | 9 + .../categories/a-category.rst | 9 + .../category-a-category.html | 75 +++++ .../tag-a-tag.html | 72 +++++ .../tags/a-tag.rst | 8 + pelican-plugins/m/test/test_metadata.py | 91 ++++++ pelican-theme/templates/article.html | 18 +- pelican-theme/templates/article_badges.html | 18 ++ pelican-theme/templates/author.html | 38 ++- .../templates/base_blog_section.html | 8 +- pelican-theme/templates/category.html | 32 ++- pelican-theme/templates/tag.html | 26 +- site/pelicanconf.py | 20 +- 49 files changed, 2055 insertions(+), 22 deletions(-) create mode 100644 doc/examples/authors/an-author.rst create mode 100644 doc/examples/categories/examples.rst create mode 100644 doc/examples/tags/jumbo.rst create mode 100644 doc/plugins/metadata.rst create mode 100644 pelican-plugins/m/metadata.py create mode 100644 pelican-plugins/m/test/metadata/article-jumbo.html create mode 100644 pelican-plugins/m/test/metadata/article-minimal.html create mode 100644 pelican-plugins/m/test/metadata/article-no-image.html create mode 100644 pelican-plugins/m/test/metadata/article.html create mode 100644 pelican-plugins/m/test/metadata/articles/article-jumbo.rst create mode 100644 pelican-plugins/m/test/metadata/articles/article-minimal.rst create mode 100644 pelican-plugins/m/test/metadata/articles/article-no-image.rst create mode 100644 pelican-plugins/m/test/metadata/articles/article.rst create mode 100644 pelican-plugins/m/test/metadata/author-an-author.html create mode 100644 pelican-plugins/m/test/metadata/author-author-with-no-image.html create mode 100644 pelican-plugins/m/test/metadata/author-minimal-author.html create mode 100644 pelican-plugins/m/test/metadata/authors/an-author.rst create mode 100644 pelican-plugins/m/test/metadata/authors/author-with-no-image.rst create mode 100644 pelican-plugins/m/test/metadata/authors/minimal-author.rst create mode 100644 pelican-plugins/m/test/metadata/categories/a-category.rst create mode 100644 pelican-plugins/m/test/metadata/categories/category-with-no-image.rst create mode 100644 pelican-plugins/m/test/metadata/categories/minimal-category.rst create mode 100644 pelican-plugins/m/test/metadata/category-a-category.html create mode 100644 pelican-plugins/m/test/metadata/category-category-with-no-image.html create mode 100644 pelican-plugins/m/test/metadata/category-minimal-category.html create mode 120000 pelican-plugins/m/test/metadata/category.jpg create mode 120000 pelican-plugins/m/test/metadata/mosra.jpg create mode 100644 pelican-plugins/m/test/metadata/tag-a-tag.html create mode 100644 pelican-plugins/m/test/metadata/tag-minimal-tag.html create mode 100644 pelican-plugins/m/test/metadata/tags/a-tag.rst create mode 100644 pelican-plugins/m/test/metadata/tags/minimal-tag.rst create mode 100644 pelican-plugins/m/test/metadata_typography_html_escape/article.html create mode 100644 pelican-plugins/m/test/metadata_typography_html_escape/articles/article.rst create mode 100644 pelican-plugins/m/test/metadata_typography_html_escape/author-an-author.html create mode 100644 pelican-plugins/m/test/metadata_typography_html_escape/authors/an-author.rst create mode 100644 pelican-plugins/m/test/metadata_typography_html_escape/categories/a-category.rst create mode 100644 pelican-plugins/m/test/metadata_typography_html_escape/category-a-category.html create mode 100644 pelican-plugins/m/test/metadata_typography_html_escape/tag-a-tag.html create mode 100644 pelican-plugins/m/test/metadata_typography_html_escape/tags/a-tag.rst create mode 100644 pelican-plugins/m/test/test_metadata.py create mode 100644 pelican-theme/templates/article_badges.html diff --git a/doc/examples/authors/an-author.rst b/doc/examples/authors/an-author.rst new file mode 100644 index 00000000..f4ca3ea5 --- /dev/null +++ b/doc/examples/authors/an-author.rst @@ -0,0 +1,6 @@ +:image: {filename}/static/mosra.jpg +:badge: Info badge for `An Author <{author}an-author>`_ provided by the + `Metadata <{filename}/plugins/metadata.rst>`_ plugin. + +Detailed author info provided by the `Metadata <{filename}/plugins/metadata.rst>`_ +plugin. diff --git a/doc/examples/categories/examples.rst b/doc/examples/categories/examples.rst new file mode 100644 index 00000000..001503c2 --- /dev/null +++ b/doc/examples/categories/examples.rst @@ -0,0 +1,6 @@ +:image: {filename}/static/site.jpg +:badge: Info badge for the `Examples <{category}examples>`_ category provided + by the `Metadata <{filename}/plugins/metadata.rst>`_ plugin. + +Detailed category info provided by the `Metadata <{filename}/plugins/metadata.rst>`_ +plugin. diff --git a/doc/examples/tags/jumbo.rst b/doc/examples/tags/jumbo.rst new file mode 100644 index 00000000..1ae79084 --- /dev/null +++ b/doc/examples/tags/jumbo.rst @@ -0,0 +1,2 @@ +Detailed tag info provided by the `Metadata <{filename}/plugins/metadata.rst>`_ +plugin. diff --git a/doc/pelican/theme.rst b/doc/pelican/theme.rst index 22f2641b..b6768e3e 100644 --- a/doc/pelican/theme.rst +++ b/doc/pelican/theme.rst @@ -563,6 +563,12 @@ option in the configuration: M_SHOW_AUTHOR_LIST = True +.. note-success:: + + The theme is able to recognize additional description and images for + authors, categories and tags from the + `Metadata plugin <{filename}/plugins/metadata.rst>`_, if you enable it. + `Jumbo articles`_ ----------------- @@ -622,6 +628,11 @@ specialized for articles like this: present and to ``summary`` otherwise - ``og:type`` is set to ``article`` +.. note-success:: + + Additional social meta tags (such as author or category info) are be + exposed by the `Metadata plugin <{filename}/plugins/metadata.rst>`_. + .. note-info:: You can see how article links will display by pasting diff --git a/doc/plugins.rst b/doc/plugins.rst index 0ed4f5f3..014aea8e 100644 --- a/doc/plugins.rst +++ b/doc/plugins.rst @@ -50,6 +50,7 @@ and restart Pelican. Download the plugins below or :gh:`m.gl `, :gh:`m.abbr `, :gh:`m.filesize ` +- :gh:`m.metadata ` Click on the headings below to get to know more. Note that particular plugins can have additional dependencies besides just Pelican, see documentation of @@ -90,3 +91,11 @@ entered directly in your :abbr:`reST ` sources. The :py:`m.gh`, :py:`m.dox`, :py:`m.gl`, :py:`m.abbr` and :py:`m.fiilesize` plugins make it easy for you to link to GitHub projects, issues or PRs, to Doxygen documentation and do more useful things. + +`Metadata » <{filename}/plugins/metadata.rst>`_ +=============================================== + +With the :py:`m.metadata` plugin it's possible to assign additional description +and images to authors, categories and tags. The information can then appear on +article listing page, as a badge under the article or be added to social meta +tags. diff --git a/doc/plugins/metadata.rst b/doc/plugins/metadata.rst new file mode 100644 index 00000000..559b517e --- /dev/null +++ b/doc/plugins/metadata.rst @@ -0,0 +1,260 @@ +.. + This file is part of m.css. + + Copyright © 2017 Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +.. + +Metadata +######## + +:breadcrumb: {filename}/plugins.rst Pelican plugins +:summary: Assigns additional description and images to categories, authors and + tags. +:footer: + .. note-dim:: + :class: m-text-center + + `« Links <{filename}/plugins/links.rst>`_ | `Pelican plugins <{filename}/plugins.rst>`_ + +.. role:: html(code) + :language: html +.. role:: py(code) + :language: py +.. role:: rst(code) + :language: rst + +Assigns additional description and images to categories, authors and tags. + +`How to use`_ +============= + +Download the `m/metadata.py <{filename}/plugins.rst>`_ file, put it including +the ``m/`` directory into one of your :py:`PLUGIN_PATHS` and add ``m.metadata`` +package to your :py:`PLUGINS` in ``pelicanconf.py``. In order to have the +contents properly rendered, it's advised to add the new fields to +:py:`FORMATTED_FIELDS`: + +.. code:: py + + PLUGINS += ['m.metadata'] + FORMATTED_FIELDS += ['description', 'badge'] + +This plugin parses additional info from pages in subdirectories of the contents +directory (i.e., where the :py:`PATH` setting points to). By default, the +directories are as follows and can be configured with these settings: + +.. code:: py + + M_METADATA_AUTHOR_PATH = 'authors' + M_METADATA_CATEGORY_PATH = 'categories' + M_METADATA_TAG_PATH = 'tags' + +The m.css Pelican theme recognizes presence of this plugin and renders the +additional metadata both in the page and in the `Open Graph `_ +and `Twitter Card `_ social :html:`` tags, in addition to tags rendered by +`articles themselves <{filename}/pelican/theme.rst#social-meta-tags-for-articles>`_. +See below for more information. + +`Author metadata`_ +================== + +Author pages are matched to authors based on the slug (so e.g. metadata for +author named *John Doe* will be in a file named ``authors/john-doe.rst``). The +following metadata are recognized: + +- Page content is exposed to the theme in :py:`author.page.content` on the + author page and used to fill author details block on top of the author page + in the m.css Pelican theme. If not set, no author details block is + rendered. +- Page title is exposed to the theme in :py:`author.page.title` on the author + page and in :py:`article.author.badge_title` in all articles having given + author. In the m.css Pelican theme it is used as caption in author details + block and in ``og:title`` / ``twitter:title`` social :html:`` tag on + author page. Can be used to provide a longer version of author name on this + page. If not set, the m.css Pelican theme uses the global author name (the + one set by articles) instead. +- The :rst:`:description:` field is exposed to the theme in + :py:`author.page.description` on the author page. The m.css Pelican theme + uses it in :html:``. If not set, no tag is + rendered. +- The :rst:`:summary:` field is exposed to the theme in :py:`author.page.summary` + on the author page. The m.css Pelican theme uses it in ``og:description`` + / ``twitter:description`` social :html:`` tag. If not set, no tag is + rendered. +- The :rst:`:badge:` field is exposed to the theme in :py:`article.author.badge` + in all articles having given author. The m.css Pelican theme uses it to + display an *About the author* badge at the end of article pages. Similarly + to page content, it's possible to use advanced :abbr:`reST ` + formatting capabilities here. If not set, no badge at the end of author's + articles is rendered. +- The :rst:`:image:` field is exposed to the theme in :py:`author.page.image` + on the author page and in :py:`article.author.image` in all articles having + given author. The m.css Pelican theme uses it to add an image to author + badge on articles, to author details on author page and in ``og:image`` / + ``twitter:image`` social :html:`` tags on author page, overriding the + global :py:`M_SOCIAL_IMAGE`. It's expected to be smaller and square + similarly to the :py:`M_SOCIAL_IMAGE` `described in the theme documentation <{filename}/pelican/theme.rst#global-site-image>`_. + If not set, the details and badges are rendered without images and no + social tag is present. Does not affect ``twitter:card``, it's set to + ``summary`` regardless of whether the image is present or not. +- The :rst:`:twitter:` / :rst:`:twitter_id:` fields are exposed to the theme + in :py:`article.author.twitter` / :py:`article.author.twitter_id` and + :py:`author.page.twitter` / :py:`author.page.twitter_id`. The m.css + Pelican theme uses it to render ``twitter:creator`` / ``twitter::creator:id`` + social :html:`` tags. If not set, no tags are rendered. + +Example of a completely filled author page, saved under ``authors/john-doe.rst`` +and matching an author named *John Doe*: + +.. code:: rst + + John "Not That Serial Killer" Doe + ################################# + + :twitter: @se7en + :twitter_id: 7777777 + :image: {filename}/authors/john-doe.jpg + :description: I'm not that serial killer. + :summary: I'm really not that serial killer. + :badge: No, really, don't confuse me with that guy. + + What? No, I didn't kill anybody. Yet. + +.. note-info:: + + See how author info is rendered in the m.css Pelican theme + `on the author page <{author}an-author>`_ and + `on the article page <{filename}/examples/article.rst>`_. + +`Category metadata`_ +==================== + +Category pages are matched to categories based on the slug (so e.g. metadata +for category named *Guest posts* will be in a file named +``categories/guest-posts.rst``). The following metadata are recognized: + +- Page content is exposed to the theme in :py:`category.page.content` on the + category page and used to fill category details block on top of the + category page in the m.css Pelican theme. If not set, no category details + block is rendered. +- Page title is exposed to the theme in :py:`category.page.title` on the + category page and in :py:`article.category.badge_title` in all articles + being in given category. In the m.css Pelican theme it is used as caption + in category details block, in ``og:title`` / ``twitter:title`` social + :html:`` tag on category page and as badge title on article pages. + Can be used to provide a longer version of category name for article badge + and detailed category info. If not set, the m.css Pelican theme uses the + global category name (the one set by articles) instead. +- The :rst:`:description:` field is exposed to the theme in + :py:`category.page.description` on the category page. The m.css Pelican + theme uses it in :html:``. If not set, no tag is + rendered. +- The :rst:`:summary:` field is exposed to the theme in :py:`category.page.summary` + on the category page. The m.css Pelican theme uses it in ``og:description`` + / ``twitter:description`` social :html:`` tag. If not set, no tag is + rendered. +- The :rst:`:badge:` field is exposed to the theme in :py:`article.category.badge` + in all articles being in given category. The m.css Pelican theme uses it to + display an informational badge at the end of article pages. Similarly to + page content, it's possible to use advanced :abbr:`reST ` + formatting capabilities here. If not set, no badge at the end of articles + in given category is rendered. +- The :rst:`:image:` field is exposed to the theme in :py:`category.page.image` + on the category page and in :py:`article.category.image` in all articles + being in given category. The m.css Pelican theme uses it to add an image to + category badges on articles, to category details on category page and + in ``og:image`` / ``twitter:image`` social :html:`` tags on category + page. If `article cover image <{filename}/pelican/theme.rst#jumbo-articles>`_ + is not specified, the image is used also for ``og:image`` / ``twitter:image`` + on given article, overriding the global :py:`M_SOCIAL_IMAGE`. It's expected + to be smaller and square similarly to the + :py:`M_SOCIAL_IMAGE` `described in the theme documentation <{filename}/pelican/theme.rst#global-site-image>`_. + If not set, the details and badges are rendered without images and no + social tag is present. Does not affect ``twitter:card``, it's set to + ``summary`` or ``summary_large_image`` depending only on presence of + article cover image. + +Example of a completely filled category page, saved under ``categories/guest-posts.rst`` +and matching a category named *Guest posts*: + +.. code:: rst + + Posts by our users + ################## + + :image: {filename}/categories/guest-posts.jpg + :description: User stories and product reviews + :summary: Stories of our users and honest reviews of our product. + :badge: This article is a guest post. Want to share your story as well? Head + over to the `intro article <{filename}/blog/introducing-guest-posts.rst>`_ + to get to know more. We'll happily publish it here. + + This section contains guest posts, reviews and success stories. Want to share + your story as well? Head over to the + `intro article <{filename}/blog/introducing-guest-posts.rst>`_ to get to know + more. We'll happily publish it here. + +.. note-info:: + + See how category info is rendered in the m.css Pelican theme + `on the category page <{category}a-category>`_ and + `on the article page <{filename}/examples/article.rst>`_. + +`Tag metadata`_ +=============== + +Tag pages are matched to authors based on the slug (so e.g. metadata for +tag named *Pantomime* will be in a file named ``tags/pantomime.rst``). The +following metadata are recognized: + +- Page content is exposed to the theme in :py:`tag.page.content` on the tag + page and used to fill tag details block on top of the tag page in the m.css + Pelican theme. If not set, no tag details block is rendered. +- Page title is exposed to the theme in :py:`tag.page.title` on the tag page, + is used as caption in tag details block on tag page and in ``og:title`` / + ``twitter:title`` social :html:`` tag. Can be used to provide a + longer version of tag name on this page. If not set, the m.css Pelican + theme uses the global tag name (the one set by articles) instead. +- The :rst:`:description:` field is exposed to the theme in + :py:`tag.page.description` on the tag page. The m.css Pelican theme uses + it in :html:``. If not set, no :html:`` tag + is rendered. +- The :rst:`:summary:` field is exposed to the theme in :py:`tag.page.summary` + on the tag page. The m.css Pelican theme uses it in ``og:description`` + / ``twitter:description`` social :html:`` tag. If not set, no + :html:`` tag is rendered. + +Example of a completely filled tag page, saved under ``tags/pantomime.rst`` +and matching a tag named *Pantomime*: + +.. code:: rst + + ¯\_(ツ)_/¯ + ########## + + :description: ¯\_(ツ)_/¯ + :summary: ¯\_(ツ)_/¯ + + ¯\_(ツ)_/¯ + +.. note-info:: + + See how tag info is rendered `in the m.css Pelican theme <{tag}Jumbo>`_. diff --git a/pelican-plugins/m/metadata.py b/pelican-plugins/m/metadata.py new file mode 100644 index 00000000..09bc50f9 --- /dev/null +++ b/pelican-plugins/m/metadata.py @@ -0,0 +1,81 @@ +# +# This file is part of m.css. +# +# Copyright © 2017 Vladimír Vondruš +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# + +import logging +import os + +from pelican import signals + +logger = logging.getLogger(__name__) + +_names = {'authors': "Author", + 'categories': "Category", + 'tags': "Tag"} + +def _read_pages(article_generator, key): + path = article_generator.settings.get(*key) + fullpath = os.path.join(article_generator.settings['PATH'], path) + if not os.path.isdir(fullpath): return {} + + pages = {} + for f in os.listdir(fullpath): + fullf = os.path.join(fullpath, f) + if not os.path.isfile(fullf): continue + + logger.debug("Read file {} -> {}".format(os.path.join(path, f), { + 'authors': "Author", + 'categories': "Category", + 'tags': "Tag"}[key[1]])) + + base_path, filename = os.path.split(fullf) + pages[os.path.splitext(filename)[0]] = article_generator.readers.read_file(base_path, filename, context=article_generator.context) + return pages + +def populate_metadata(article_generator): + authors = _read_pages(article_generator, ('M_METADATA_AUTHOR_PATH', 'authors')) + categories = _read_pages(article_generator, ('M_METADATA_CATEGORY_PATH', 'categories')) + tags = _read_pages(article_generator, ('M_METADATA_TAG_PATH', 'tags')) + + for author, _ in article_generator.authors: + author.page = authors.get(author.slug, {}) + for category, _ in article_generator.categories: + category.page = categories.get(category.slug, {}) + for tag in article_generator.tags: + tag.page = tags.get(tag.slug, {}) + + for article in article_generator.articles: + page = authors.get(article.author.slug, {}) + for i in ['badge', 'image', 'twitter', 'twitter_id']: + if hasattr(page, i): setattr(article.author, i, getattr(page, i)) + if hasattr(page, 'title'): + article.author.badge_title = page.title + + page = categories.get(article.category.slug, {}) + for i in ['badge', 'image']: + if hasattr(page, i): setattr(article.category, i, getattr(page, i)) + if hasattr(page, 'title'): + article.category.badge_title = page.title + +def register(): + signals.article_generator_finalized.connect(populate_metadata) diff --git a/pelican-plugins/m/test/metadata/article-jumbo.html b/pelican-plugins/m/test/metadata/article-jumbo.html new file mode 100644 index 00000000..ddd1c1f4 --- /dev/null +++ b/pelican-plugins/m/test/metadata/article-jumbo.html @@ -0,0 +1,116 @@ + + + + + A jumbo article | A Pelican Blog + + + + + + + + + + + + + + + + + + +
+
+
+
+
+
+
+
+
Dec 16, 2017
+ +
+
+ +
+
+
+
+
+
+
+

Article summary.

+
+
+
+
+
+
+
+ +

An article that should have its own cover image in social meta tags, not the +category-specific one.

+ +
+ An Author +

About the author

+

Contents of the badge, displayed at article bottom. + Link to the author.

+
+
+ A category +

A category name, displayed on top of the category badge/details

+

Contents of the badge, displayed at article bottom. + Link to the category.

+
+
+
+
+ +
+ +
+ + diff --git a/pelican-plugins/m/test/metadata/article-minimal.html b/pelican-plugins/m/test/metadata/article-minimal.html new file mode 100644 index 00000000..d79b81c7 --- /dev/null +++ b/pelican-plugins/m/test/metadata/article-minimal.html @@ -0,0 +1,80 @@ + + + + + An article | A Pelican Blog + + + + + + + + + + + + + + +
+
+
+
+ + +
+
+
+ + diff --git a/pelican-plugins/m/test/metadata/article-no-image.html b/pelican-plugins/m/test/metadata/article-no-image.html new file mode 100644 index 00000000..c3554921 --- /dev/null +++ b/pelican-plugins/m/test/metadata/article-no-image.html @@ -0,0 +1,80 @@ + + + + + An article | A Pelican Blog + + + + + + + + + + + + + + +
+
+
+
+
+
+

+ + An article +

+

Article summary.

+
+
+ +

This article should have no images anywhere and everything still needs to look +properly.

+ +
+

About the author

+

Contents of the badge w/o image.

+
+
+

Category with no image

+

Contents of the badge w/o image, displayed at article bottom.

+
+ +
+ +
+
+
+ + diff --git a/pelican-plugins/m/test/metadata/article.html b/pelican-plugins/m/test/metadata/article.html new file mode 100644 index 00000000..d741a488 --- /dev/null +++ b/pelican-plugins/m/test/metadata/article.html @@ -0,0 +1,88 @@ + + + + + An article | A Pelican Blog + + + + + + + + + + + + + + + + + + +
+
+
+
+
+
+

+ + An article +

+

Article summary.

+
+
+ +

There should be a category image + author's twitter in the social meta tag and +two badges with images on the bottom.

+ +
+ An Author +

About the author

+

Contents of the badge, displayed at article bottom. + Link to the author.

+
+
+ A category +

A category name, displayed on top of the category badge/details

+

Contents of the badge, displayed at article bottom. + Link to the category.

+
+ +
+ +
+
+
+ + diff --git a/pelican-plugins/m/test/metadata/articles/article-jumbo.rst b/pelican-plugins/m/test/metadata/articles/article-jumbo.rst new file mode 100644 index 00000000..220bdeba --- /dev/null +++ b/pelican-plugins/m/test/metadata/articles/article-jumbo.rst @@ -0,0 +1,11 @@ +A jumbo article +############### + +:date: 2017-12-16 +:cover: image.jpg +:author: An Author +:category: A category +:summary: Article summary. + +An article that should have its own cover image in social meta tags, not the +category-specific one. diff --git a/pelican-plugins/m/test/metadata/articles/article-minimal.rst b/pelican-plugins/m/test/metadata/articles/article-minimal.rst new file mode 100644 index 00000000..8a212a29 --- /dev/null +++ b/pelican-plugins/m/test/metadata/articles/article-minimal.rst @@ -0,0 +1,11 @@ +An article +########## + +:date: 2017-12-17 +:author: Minimal author +:category: Minimal category +:tags: Minimal tag +:summary: Article summary. + +There should be no category or author-related anything in the meta tags. Just +badges with default titles. diff --git a/pelican-plugins/m/test/metadata/articles/article-no-image.rst b/pelican-plugins/m/test/metadata/articles/article-no-image.rst new file mode 100644 index 00000000..c0720285 --- /dev/null +++ b/pelican-plugins/m/test/metadata/articles/article-no-image.rst @@ -0,0 +1,10 @@ +An article +########## + +:date: 2017-12-17 +:author: Author with no image +:category: Category with no image +:summary: Article summary. + +This article should have no images anywhere and everything still needs to look +properly. diff --git a/pelican-plugins/m/test/metadata/articles/article.rst b/pelican-plugins/m/test/metadata/articles/article.rst new file mode 100644 index 00000000..f995b27b --- /dev/null +++ b/pelican-plugins/m/test/metadata/articles/article.rst @@ -0,0 +1,11 @@ +An article +########## + +:date: 2017-12-17 +:author: An Author +:category: A category +:tags: A tag +:summary: Article summary. + +There should be a category image + author's twitter in the social meta tag and +two badges with images on the bottom. diff --git a/pelican-plugins/m/test/metadata/author-an-author.html b/pelican-plugins/m/test/metadata/author-an-author.html new file mode 100644 index 00000000..46ddb13a --- /dev/null +++ b/pelican-plugins/m/test/metadata/author-an-author.html @@ -0,0 +1,98 @@ + + + + + Posts by An Author | A Pelican Blog + + + + + + + + + + + + + + + + + + +
+
+
+
+
+
+ Showing only posts by An Author. Show all posts. +
+
+ An Author +

Author name, displayed on top of the author page

+

Contents of author details, displayed on top of the author page. + Link.

+
+ + +
+ +
+
+
+ + diff --git a/pelican-plugins/m/test/metadata/author-author-with-no-image.html b/pelican-plugins/m/test/metadata/author-author-with-no-image.html new file mode 100644 index 00000000..03bf429b --- /dev/null +++ b/pelican-plugins/m/test/metadata/author-author-with-no-image.html @@ -0,0 +1,76 @@ + + + + + Posts by Author with no image | A Pelican Blog + + + + + + + + + + + + + +
+
+
+
+
+
+ Showing only posts by Author with no image. Show all posts. +
+
+

Author with no image

+

Contents of author details w/o image, displayed on top of the author page.

+
+ +
+ +
+
+
+ + diff --git a/pelican-plugins/m/test/metadata/author-minimal-author.html b/pelican-plugins/m/test/metadata/author-minimal-author.html new file mode 100644 index 00000000..37ff2d9f --- /dev/null +++ b/pelican-plugins/m/test/metadata/author-minimal-author.html @@ -0,0 +1,76 @@ + + + + + Posts by Minimal author | A Pelican Blog + + + + + + + + + + + + + +
+
+
+
+
+
+ Showing only posts by Minimal author. Show all posts. +
+
+

Minimal author

+

Author details.

+
+ +
+ +
+
+
+ + diff --git a/pelican-plugins/m/test/metadata/authors/an-author.rst b/pelican-plugins/m/test/metadata/authors/an-author.rst new file mode 100644 index 00000000..2d21cc31 --- /dev/null +++ b/pelican-plugins/m/test/metadata/authors/an-author.rst @@ -0,0 +1,13 @@ +Author name, displayed on top of the author page +################################################ + +:twitter: @czmosra +:twitter_id: 1537427036 +:image: {filename}/mosra.jpg +:description: Author description, used for a tag. +:summary: Author summary, used for the social tags. +:badge: Contents of the badge, displayed at article bottom. + `Link to the author. <{author}an-author>`_ + +Contents of author details, displayed on top of the author page. +`Link. `_ diff --git a/pelican-plugins/m/test/metadata/authors/author-with-no-image.rst b/pelican-plugins/m/test/metadata/authors/author-with-no-image.rst new file mode 100644 index 00000000..d0c85c46 --- /dev/null +++ b/pelican-plugins/m/test/metadata/authors/author-with-no-image.rst @@ -0,0 +1,6 @@ +Author with no image +#################### + +:badge: Contents of the badge w/o image. + +Contents of author details w/o image, displayed on top of the author page. diff --git a/pelican-plugins/m/test/metadata/authors/minimal-author.rst b/pelican-plugins/m/test/metadata/authors/minimal-author.rst new file mode 100644 index 00000000..52a9622c --- /dev/null +++ b/pelican-plugins/m/test/metadata/authors/minimal-author.rst @@ -0,0 +1,3 @@ +:badge: Author badge. + +Author details. diff --git a/pelican-plugins/m/test/metadata/categories/a-category.rst b/pelican-plugins/m/test/metadata/categories/a-category.rst new file mode 100644 index 00000000..e178d4af --- /dev/null +++ b/pelican-plugins/m/test/metadata/categories/a-category.rst @@ -0,0 +1,11 @@ +A category name, displayed on top of the category badge/details +############################################################### + +:image: {filename}/category.jpg +:description: Category description, used for a tag. +:summary: Category summary, used for the social tags. +:badge: Contents of the badge, displayed at article bottom. + `Link to the category. <{category}a-category>`_ + +Contents of category details, displayed on top of the category page. +`Link. `_ diff --git a/pelican-plugins/m/test/metadata/categories/category-with-no-image.rst b/pelican-plugins/m/test/metadata/categories/category-with-no-image.rst new file mode 100644 index 00000000..f18074c1 --- /dev/null +++ b/pelican-plugins/m/test/metadata/categories/category-with-no-image.rst @@ -0,0 +1,8 @@ +Category with no image +###################### + +:description: Category description, used for a tag. +:summary: Category summary, used for the social tags. +:badge: Contents of the badge w/o image, displayed at article bottom. + +Contents of category details w/o image, displayed on top of the category page. diff --git a/pelican-plugins/m/test/metadata/categories/minimal-category.rst b/pelican-plugins/m/test/metadata/categories/minimal-category.rst new file mode 100644 index 00000000..d7683ce5 --- /dev/null +++ b/pelican-plugins/m/test/metadata/categories/minimal-category.rst @@ -0,0 +1,3 @@ +:badge: Category badge. + +Category details. diff --git a/pelican-plugins/m/test/metadata/category-a-category.html b/pelican-plugins/m/test/metadata/category-a-category.html new file mode 100644 index 00000000..585ca496 --- /dev/null +++ b/pelican-plugins/m/test/metadata/category-a-category.html @@ -0,0 +1,96 @@ + + + + + A category | A Pelican Blog + + + + + + + + + + + + + + + + +
+
+
+
+
+
+ Showing only posts in A category. Show all posts. +
+
+ A category +

A category name, displayed on top of the category badge/details

+

Contents of category details, displayed on top of the category page. + Link.

+
+ + +
+ +
+
+
+ + diff --git a/pelican-plugins/m/test/metadata/category-category-with-no-image.html b/pelican-plugins/m/test/metadata/category-category-with-no-image.html new file mode 100644 index 00000000..41157431 --- /dev/null +++ b/pelican-plugins/m/test/metadata/category-category-with-no-image.html @@ -0,0 +1,77 @@ + + + + + Category with no image | A Pelican Blog + + + + + + + + + + + + + + +
+
+
+
+
+
+ Showing only posts in Category with no image. Show all posts. +
+
+

Category with no image

+

Contents of category details w/o image, displayed on top of the category page.

+
+ +
+ +
+
+
+ + diff --git a/pelican-plugins/m/test/metadata/category-minimal-category.html b/pelican-plugins/m/test/metadata/category-minimal-category.html new file mode 100644 index 00000000..87e68804 --- /dev/null +++ b/pelican-plugins/m/test/metadata/category-minimal-category.html @@ -0,0 +1,76 @@ + + + + + Minimal category | A Pelican Blog + + + + + + + + + + + + + +
+
+
+
+
+
+ Showing only posts in Minimal category. Show all posts. +
+
+

Minimal category

+

Category details.

+
+ +
+ +
+
+
+ + diff --git a/pelican-plugins/m/test/metadata/category.jpg b/pelican-plugins/m/test/metadata/category.jpg new file mode 120000 index 00000000..158969f0 --- /dev/null +++ b/pelican-plugins/m/test/metadata/category.jpg @@ -0,0 +1 @@ +../../../../doc/static/site.jpg \ No newline at end of file diff --git a/pelican-plugins/m/test/metadata/mosra.jpg b/pelican-plugins/m/test/metadata/mosra.jpg new file mode 120000 index 00000000..23fd0963 --- /dev/null +++ b/pelican-plugins/m/test/metadata/mosra.jpg @@ -0,0 +1 @@ +../../../../doc/static/mosra.jpg \ No newline at end of file diff --git a/pelican-plugins/m/test/metadata/tag-a-tag.html b/pelican-plugins/m/test/metadata/tag-a-tag.html new file mode 100644 index 00000000..33192f02 --- /dev/null +++ b/pelican-plugins/m/test/metadata/tag-a-tag.html @@ -0,0 +1,78 @@ + + + + + Posts tagged A tag | A Pelican Blog + + + + + + + + + + + + + + +
+
+
+
+
+
+ Showing only posts tagged A tag. Show all posts. +
+
+

Tag name, displayed on top of the tag page

+

Contents of tag details, displayed on top of the tag page. + Link.

+
+ +
+ +
+
+
+ + diff --git a/pelican-plugins/m/test/metadata/tag-minimal-tag.html b/pelican-plugins/m/test/metadata/tag-minimal-tag.html new file mode 100644 index 00000000..bdc288f1 --- /dev/null +++ b/pelican-plugins/m/test/metadata/tag-minimal-tag.html @@ -0,0 +1,76 @@ + + + + + Posts tagged Minimal tag | A Pelican Blog + + + + + + + + + + + + + +
+
+
+
+
+
+ Showing only posts tagged Minimal tag. Show all posts. +
+
+

Minimal tag

+

Tag details.

+
+ +
+ +
+
+
+ + diff --git a/pelican-plugins/m/test/metadata/tags/a-tag.rst b/pelican-plugins/m/test/metadata/tags/a-tag.rst new file mode 100644 index 00000000..2642ea36 --- /dev/null +++ b/pelican-plugins/m/test/metadata/tags/a-tag.rst @@ -0,0 +1,8 @@ +Tag name, displayed on top of the tag page +########################################## + +:description: Tag description, used for a tag. +:summary: Tag summary, used for the social tags. + +Contents of tag details, displayed on top of the tag page. +`Link. `_ diff --git a/pelican-plugins/m/test/metadata/tags/minimal-tag.rst b/pelican-plugins/m/test/metadata/tags/minimal-tag.rst new file mode 100644 index 00000000..228c2c6e --- /dev/null +++ b/pelican-plugins/m/test/metadata/tags/minimal-tag.rst @@ -0,0 +1 @@ +Tag details. diff --git a/pelican-plugins/m/test/metadata_typography_html_escape/article.html b/pelican-plugins/m/test/metadata_typography_html_escape/article.html new file mode 100644 index 00000000..fe081ec6 --- /dev/null +++ b/pelican-plugins/m/test/metadata_typography_html_escape/article.html @@ -0,0 +1,78 @@ + + + + + An article | A Pelican Blog + + + + + + + + + + + + + + + + +
+
+
+
+
+
+

+ + An article +

+

Ar­ti­cle sum­ma­ry.

+
+
+ +

Ar­ti­cle con­tents.

+ +
+ An <&> Author +

About the author

+

Au­thor <&> badge, hy­phen­at­ed and “quotes”.

+
+
+ A <&> category +

A <&> “category”

+

Cat­e­go­ry <&> badge, hy­phen­at­ed and “quotes”.

+
+ +
+ +
+
+
+ + diff --git a/pelican-plugins/m/test/metadata_typography_html_escape/articles/article.rst b/pelican-plugins/m/test/metadata_typography_html_escape/articles/article.rst new file mode 100644 index 00000000..1b1f878a --- /dev/null +++ b/pelican-plugins/m/test/metadata_typography_html_escape/articles/article.rst @@ -0,0 +1,10 @@ +An article +########## + +:date: 2017-12-17 +:author: An <&> Author +:category: A <&> category +:tags: A <&> tag +:summary: Article summary. + +Article contents. diff --git a/pelican-plugins/m/test/metadata_typography_html_escape/author-an-author.html b/pelican-plugins/m/test/metadata_typography_html_escape/author-an-author.html new file mode 100644 index 00000000..19d755e6 --- /dev/null +++ b/pelican-plugins/m/test/metadata_typography_html_escape/author-an-author.html @@ -0,0 +1,75 @@ + + + + + Posts by An <&> Author | A Pelican Blog + + + + + + + + + + + + + + + + +
+
+
+
+
+
+ Showing only posts by An <&> Author. Show all posts. +
+
+ An <&> Author +

An <&> “Author”

+

Au­thor <&> de­tails, hy­phen­at­ed and “quotes”.

+
+ +
+ +
+
+
+ + diff --git a/pelican-plugins/m/test/metadata_typography_html_escape/authors/an-author.rst b/pelican-plugins/m/test/metadata_typography_html_escape/authors/an-author.rst new file mode 100644 index 00000000..c8925ed6 --- /dev/null +++ b/pelican-plugins/m/test/metadata_typography_html_escape/authors/an-author.rst @@ -0,0 +1,9 @@ +An <&> "Author" +############### + +:image: author.jpg?and&in&url="" +:description: Author <&> description, not hyphenated but "quotes" +:summary: Author <&> summary, not hyphenated but "quotes" +:badge: Author <&> badge, hyphenated and "quotes". + +Author <&> details, hyphenated and "quotes". diff --git a/pelican-plugins/m/test/metadata_typography_html_escape/categories/a-category.rst b/pelican-plugins/m/test/metadata_typography_html_escape/categories/a-category.rst new file mode 100644 index 00000000..3fdef2de --- /dev/null +++ b/pelican-plugins/m/test/metadata_typography_html_escape/categories/a-category.rst @@ -0,0 +1,9 @@ +A <&> "category" +################ + +:image: category.jpg?and&in&url="" +:description: Category <&> description, not hyphenated but "quotes" +:summary: Category <&> summary, not hyphenated but "quotes" +:badge: Category <&> badge, hyphenated and "quotes". + +Category <&> details, hyphenated and "quotes". diff --git a/pelican-plugins/m/test/metadata_typography_html_escape/category-a-category.html b/pelican-plugins/m/test/metadata_typography_html_escape/category-a-category.html new file mode 100644 index 00000000..3e2f0cde --- /dev/null +++ b/pelican-plugins/m/test/metadata_typography_html_escape/category-a-category.html @@ -0,0 +1,75 @@ + + + + + A <&> category | A Pelican Blog + + + + + + + + + + + + + + + + +
+
+
+
+
+
+ Showing only posts in A <&> category. Show all posts. +
+
+ A <&> category +

A <&> “category”

+

Cat­e­go­ry <&> de­tails, hy­phen­at­ed and “quotes”.

+
+ +
+ +
+
+
+ + diff --git a/pelican-plugins/m/test/metadata_typography_html_escape/tag-a-tag.html b/pelican-plugins/m/test/metadata_typography_html_escape/tag-a-tag.html new file mode 100644 index 00000000..b884226c --- /dev/null +++ b/pelican-plugins/m/test/metadata_typography_html_escape/tag-a-tag.html @@ -0,0 +1,72 @@ + + + + + Posts tagged A <&> tag | A Pelican Blog + + + + + + + + + + + + + + +
+
+
+
+
+
+ Showing only posts tagged A <&> tag. Show all posts. +
+
+

A <&> “tag”

+

Tag <&> de­tails, hy­phen­at­ed and “quotes”.

+
+ +
+ +
+
+
+ + diff --git a/pelican-plugins/m/test/metadata_typography_html_escape/tags/a-tag.rst b/pelican-plugins/m/test/metadata_typography_html_escape/tags/a-tag.rst new file mode 100644 index 00000000..f58a6eac --- /dev/null +++ b/pelican-plugins/m/test/metadata_typography_html_escape/tags/a-tag.rst @@ -0,0 +1,8 @@ +A <&> "tag" +########### + +:description: Tag <&> description, not hyphenated but "quotes" +:summary: Tag <&> summary, not hyphenated but "quotes" +:badge: Tag <&> badge, hyphenated and "quotes". + +Tag <&> details, hyphenated and "quotes". diff --git a/pelican-plugins/m/test/test_metadata.py b/pelican-plugins/m/test/test_metadata.py new file mode 100644 index 00000000..44c8289d --- /dev/null +++ b/pelican-plugins/m/test/test_metadata.py @@ -0,0 +1,91 @@ +# +# This file is part of m.css. +# +# Copyright © 2017 Vladimír Vondruš +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# + +from m.test import PluginTestCase + +class Metadata(PluginTestCase): + def __init__(self, *args, **kwargs): + super().__init__(__file__, '', *args, **kwargs) + + def test(self): + self.run_pelican({ + 'PLUGINS': ['m.htmlsanity', 'm.metadata'], + 'STATIC_PATHS': ['mosra.jpg', 'category.jpg'], + 'FORMATTED_FIELDS': ['summary', 'description', 'badge'], + 'DATE_FORMATS': {'en': ('en_US.UTF-8', '%b %d, %Y')}, + 'PAGE_PATHS': ['pages'], # doesn't exist + 'ARTICLE_PATHS': ['articles'], + 'AUTHOR_SAVE_AS': 'author-{slug}.html', + 'AUTHOR_URL': 'author-{slug}.html', + 'CATEGORY_SAVE_AS': 'category-{slug}.html', + 'CATEGORY_URL': 'category-{slug}.html', + 'TAG_SAVE_AS': 'tag-{slug}.html', + 'TAG_URL': 'tag-{slug}.html', + 'M_DISABLE_SOCIAL_META_TAGS': False, + 'M_SHOW_AUTHOR_LIST': True + }) + + self.assertEqual(*self.actual_expected_contents('article.html')) + self.assertEqual(*self.actual_expected_contents('article-no-image.html')) + self.assertEqual(*self.actual_expected_contents('article-jumbo.html')) + self.assertEqual(*self.actual_expected_contents('article-minimal.html')) + + self.assertEqual(*self.actual_expected_contents('author-an-author.html')) + self.assertEqual(*self.actual_expected_contents('author-author-with-no-image.html')) + self.assertEqual(*self.actual_expected_contents('author-minimal-author.html')) + + self.assertEqual(*self.actual_expected_contents('category-a-category.html')) + self.assertEqual(*self.actual_expected_contents('category-category-with-no-image.html')) + self.assertEqual(*self.actual_expected_contents('category-minimal-category.html')) + + self.assertEqual(*self.actual_expected_contents('tag-a-tag.html')) + self.assertEqual(*self.actual_expected_contents('tag-minimal-tag.html')) + +class TypographyHtmlEscape(PluginTestCase): + def __init__(self, *args, **kwargs): + super().__init__(__file__, 'typography_html_escape', *args, **kwargs) + + def test(self): + self.run_pelican({ + 'PLUGINS': ['m.htmlsanity', 'm.metadata'], + 'FORMATTED_FIELDS': ['summary', 'description', 'badge'], + 'DATE_FORMATS': {'en': ('en_US.UTF-8', '%b %d, %Y')}, + 'PAGE_PATHS': ['pages'], # doesn't exist + 'ARTICLE_PATHS': ['articles'], + 'AUTHOR_SAVE_AS': 'author-{slug}.html', + 'AUTHOR_URL': 'author-{slug}.html', + 'CATEGORY_SAVE_AS': 'category-{slug}.html', + 'CATEGORY_URL': 'category-{slug}.html', + 'TAG_SAVE_AS': 'tag-{slug}.html', + 'TAG_URL': 'tag-{slug}.html', + 'M_DISABLE_SOCIAL_META_TAGS': False, + 'M_SHOW_AUTHOR_LIST': True, + 'M_HTMLSANITY_HYPHENATION': True, + 'M_HTMLSANITY_SMART_QUOTES': True + }) + + self.assertEqual(*self.actual_expected_contents('article.html')) + self.assertEqual(*self.actual_expected_contents('author-an-author.html')) + self.assertEqual(*self.actual_expected_contents('category-a-category.html')) + self.assertEqual(*self.actual_expected_contents('tag-a-tag.html')) diff --git a/pelican-theme/templates/article.html b/pelican-theme/templates/article.html index 801aa3f0..92ee30fe 100644 --- a/pelican-theme/templates/article.html +++ b/pelican-theme/templates/article.html @@ -14,7 +14,12 @@ {% block social %} {{- super() -}} - {# this has to be here otherwise the spacing is all wrong #} + {% if article.author and article.author.twitter %} + + {% endif %} + {% if article.author and article.author.twitter_id %} + + {% endif %} @@ -26,6 +31,9 @@ + {% elif article.category.image %} + + {% elif M_SOCIAL_IMAGE %} @@ -36,6 +44,8 @@ {% endblock %} +{% macro badges() %}{% include "article_badges.html" %}{% endmacro %} + {% block content %} {% if article.cover %}
@@ -80,6 +90,9 @@ {{ article.content|trim }} + {% if article.category.badge or (article.author and article.author.badge) %} + {{ badges()|indent(10) }} + {% endif %} @@ -102,6 +115,9 @@ {{ article.content|trim }} + {% endif %} + {% if article.category.badge or (article.author and article.author.badge) %} + {{ badges()|indent(6) }} {% endif %}