Skip to content

Latest commit

 

History

History
54 lines (37 loc) · 1.85 KB

readme.rst

File metadata and controls

54 lines (37 loc) · 1.85 KB

Post Statistics

NOTE: This plugin has been moved to its own repository. Please file any issues/PRs there. Once all plugins have been migrated to the new Pelican Plugins organization, this monolithic repository will be archived.

A Pelican plugin to calculate 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.

Requirements

post_stats requires BeautifulSoup.

$ pip install beautifulsoup4