Package: pelican-show-source
Show Source: A Plugin for PelicanThis Pelican plugin allows you to place a link to your posts’ source content files in the same way thatSphinxdoes. It works for both pages and articles.InstallationThis plugin can be installed via:python -m pip install pelican-show-sourceFor more detailed plugin installation instructions, please refer to thePelican Plugin Documentation.ConfigurationTo enable the plugin, ensure that you haveSHOW_SOURCE_ON_SIDEBAR = TrueorSHOW_SOURCE_IN_SECTION = Truein your settings file.SHOW_SOURCE_ALL_POSTS = Truewill show the source for all posts, instead of only posts with the source explicitly made available (see below.) By default, this isFalse.The optionSHOW_SOURCE_PRESERVE_EXTENSION(Falseby default) controls the extension of the output source file. IfTrue, the file will have the same extension as the real source document (.rst,.md, etc). Otherwise, it will be a plain-text.txtfile.Making Source Available for PostsIn order to mark posts so that their source may be seen, use the following metadata fields (unless overridden) for reStructuredText documents::show_source:TrueAlternatively, for Markdown syntax:Show_source: TrueThe plugin will render your source document URL to a correspondingarticle.show_source_url(orpage.show_source_url) attribute, which is then accessible in the site templates.Show Source in the TemplatesTo get the “show source” links to display in the article or page you will have to modify your theme, either as a sidebar display or at the foot of an article.Article or Page Sidebar DisplayHow to get the source link to appear in the sidebar using thepelican-bootstrap3theme:{% if SHOW_SOURCE_ON_SIDEBAR %}
    {% if (article and article.show_source_url) or (page and page.show_source_url) %}<liclass="list-group-item"><h4><iclass="fa fa-tags fa-file-text"></i><spanclass="icon-label">This Page</span></h4><ulclass="list-group"><liclass="list-group-item">{% if article %}<ahref="{{ SITEURL }}/{{ article.show_source_url }}">Show source</a>{% elif page %}<ahref="{{ SITEURL }}/{{ page.show_source_url }}">Show source</a>{% endif %}</li></ul></li>{% endif %}
{% endif %}Article Footer DisplayFollowing is some code (yes,pelican-bootstrap3again) to enable a source link at the bottom of an article:{% if SHOW_SOURCE_IN_SECTION %}
    {% if article and article.show_source_url %}<sectionclass="well"id="show-source"><h4>This Page</h4><ul><ahref="{{ SITEURL }}/{{ article.show_source_url }}">Show source</a></ul></section>{% endif %}
{% endif %}Overriding Default Plugin BehaviourThe default behaviour of the plugin is that revealing source is enabled on a case-by-case basis. This can be changed by the use ofSHOW_SOURCE_ALL_POSTS = Truein the settings file. This does mean that the plugin will publish all source documents no matter whethershow_sourceis set in the metadata or not.Unless overridden, each document is saved as the article or page slug attribute with a.txtextension.So for example, if your configuration hadARTICLE_SAVE_ASconfigured like so:ARTICLE_SAVE_AS="posts/{date:%Y}/{date:%m}/{slug}/index.html"… your static HTML post and source text document will be like the following:posts/2016/10/welcome-to-my article/index.html
posts/2016/10/welcome-to-my article/welcome-to-my article.txtYou can add theSHOW_SOURCE_FILENAMEvariable in your settings file to override the source file name, so you could set the following:SHOW_SOURCE_FILENAME="my_source_file.txt"So with theARTICLE_SAVE_ASconfigured as above, the files would be saved
thus:posts/2016/10/welcome-to-my article/index.html
posts/2016/10/welcome-to-my article/my_source_file.txtThis is the same behaviour for pages as well.ContributingContributions are welcome and much appreciated. Every little bit helps. You can contribute by improving the documentation, adding missing features, and fixing bugs. You can also help out by reviewing and commenting onexisting issues.To start contributing to this plugin, review theContributing to Pelicandocumentation, beginning with theContributing Codesection.LicenseThis project is licensed under the AGPL-3.0 license.