Summary is a plugin for Pelican, a static site generator written in Python.
Summary allows easy, variable length summaries directly embedded into the body of your articles.
Installation
The easiest way to install Summary is through the use of pip. This will also install the required dependencies automatically (currently none beyond Pelican).
pip install minchin.pelican.plugins.summary
Then, in your pelicanconf.py
file, add Summary to your list of plugins:
PLUGINS = [
# ...
'minchin.pelican.plugins.summary',
# ...
]
You may also need to configure the summary start and end markers (see Configuration below).
Configuration and Usage
This plugin introduces two new settings: SUMMARY_BEGIN_MARKER
and
SUMMARY_END_MARKER
: strings which can be placed directly into an article to
mark the beginning and end of a summary. When found, the standard
SUMMARY_MAX_LENGTH
setting will be ignored. The markers themselves will also
be removed from your articles before they are published. The default values are
<!-- PELICAN_BEGIN_SUMMARY -->
and <!-- PELICAN_END_SUMMARY -->
.
If no beginning or end marker is found, and if SUMMARY_USE_FIRST_PARAGRAPH
is
enabled in the settings, the summary will be the first paragraph of the post.
The plugin also sets a has_summary
attribute on every article. It is True for
articles with an explicitly-defined summary, and False otherwise. (It is also
False for an article truncated by SUMMARY_MAX_LENGTH
.) Your templates can use
this e.g. to add a link to the full text at the end of the summary.
Known Issues
An issue, as such, is that there is no formal test suite. Testing is
currently limited to my in-use observations. I also run a basic check upon
uploaded the package to PyPI that it can be downloaded and loaded into
Python.
The package is tested in Python 3.5; compatibility with other version of
Python is unknown.
Tests are actually included and can be run from the root directory:
python minchin/pelican/plugins/summary/test_summary.py
Changes
This version is basically just repackaging the plugin and making it available on pip.
Code
The code for this project is available on GitHub. Contributions are welcome!
Credits
Original plugin from the Pelican-Plugins repo.
License
The plugin code is assumed to be under the AGPLv3 license (this is the license of the Pelican-Plugins repo).
Comments
I don’t think that it is very useful to package such a simple plugin for pypi. In my case, I just have to download the Python files with wget, place them in a folder called summary inside the plugin’s folder and change the pelicanconf.py file. Anyway, it’s great that you’ve done that for people who prefer using pip.
You can use the
test_summary.py
script from the original summary plugin, so I don’t see why you cannot use that for the tests.PD. It’s a shame that the comment system doesn’t work without JavaScript.
Jorge, I agree, it does sometimes seem a little overkill to me to package such a simple package as this and post in on PyPI; perhaps that’s the reason it hasn’t been done before now. However there are two big reasons I’ve packaged these plugins up:
wget
isn’t available, by default, on Windows, but if you’ve managed to get Python installed,pip
is; andpip
allows for better, easier repeatability in installing. This is important because I’m working to automate the build process for my blog.It turns out the original test suite was copied over with the rest of the code, and the tests there still pass. I’ve updated the article accordingly. Thanks for pointing me in that direction!
As for the comment system, I should figure out what better to display if JavaScript is disabled….