This Pelcan plugin calculates various statistics about a post and stores them in an article.stats dictionary.
Project description
Post Stats is a plugin for Pelican, a static site generator written in Python.
Post Stats calculates various statistics about a post and store them in an article.stats dictionary:
wc: how many words
read_mins: how many minutes would it take to read this article, based on 250 wpm (source)
word_counts: frquency count of all the words in the article; can be used for tag/word clouds
fi: Flesch-Kincaid Index/Reading Ease (more info)
fk: Flesch-Kincaid Grade Level
Installation
The easiest way to install Post Stats is through the use of pip. This will also install the required dependencies automatically.
pip install minchin.pelican.plugins.post_stats
On Pelican versions 4.5 and later, the plugin will automatically activate itself!
You may also need to configure your template to make use of the statistics generated.
Requirements
Post Stats depends on (and is really only useful with) Pelican. The plugin also requries Beautiful Soup 4 to process your content. If the plugin is installed from pip, these will automatically be installed. These can also be manually installed with pip:
pip install pelican
pip install beautifulsoup4
Configuration and Usage
This plugin calculates various statistics about a post and store them in an article.stats dictionary.
Example:
{
'wc': 2760,
'fi': '65.94',
'fk': '7.65',
'word_counts': Counter({u'to': 98, u'a': 90, u'the': 83, u'of': 50, ...}),
'read_mins': 12
}
This allows you to output these values in your templates, like this, for example:
<p title="~{{ article.stats['wc'] }} words">~{{ article.stats['read_mins'] }} min read</p>
<ul>
<li>Flesch-kincaid Index/ Reading Ease: {{ article.stats['fi'] }}</li>
<li>Flesch-kincaid Grade Level: {{ article.stats['fk'] }}</li>
</ul>
The word_counts variable is a python Counter dictionary and looks something like this, with each unique word and it’s frequency:
Counter({u'to': 98, u'a': 90, u'the': 83, u'of': 50, u'karma': 50, .....
and can be used to create a tag/word cloud for a post.
There are no user-configurable settings.
Credits
Original plugin by Duncan Lock (@dflock) and posted to 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).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file minchin.pelican.plugins.post_stats-1.2.0.tar.gz
.
File metadata
- Download URL: minchin.pelican.plugins.post_stats-1.2.0.tar.gz
- Upload date:
- Size: 19.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 341796a82efe4f651c31fc31a0d4018abaac3074775ed598b04a83037986d5f8 |
|
MD5 | 80fc47470d267eebed1dac5aedeb63a6 |
|
BLAKE2b-256 | 7c1bdb7cc319f78df11187a40a28979f02630c96c133b10773cac6ed93e6a984 |
File details
Details for the file minchin.pelican.plugins.post_stats-1.2.0-py3-none-any.whl
.
File metadata
- Download URL: minchin.pelican.plugins.post_stats-1.2.0-py3-none-any.whl
- Upload date:
- Size: 18.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41b131219864754466b6b652728f3bd5b8d9c3e72726fe18c0019e50dc8f5bce |
|
MD5 | 1ccaa173bf5a778d6de7b7829007cd9f |
|
BLAKE2b-256 | 34d12e1dcd7eb37ba2a116b2abace34ded975cf45ad286e8a22b8851350b7e10 |