summaryrefslogtreecommitdiff
path: root/plugins/related_posts/related_posts.py
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/related_posts/related_posts.py')
-rwxr-xr-x[-rw-r--r--]plugins/related_posts/related_posts.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/plugins/related_posts/related_posts.py b/plugins/related_posts/related_posts.py
index dff03c5..a0cfa15 100644..100755
--- a/plugins/related_posts/related_posts.py
+++ b/plugins/related_posts/related_posts.py
@@ -14,14 +14,15 @@ def add_related_posts(generator):
# get the max number of entries from settings
# or fall back to default (5)
numentries = generator.settings.get('RELATED_POSTS_MAX', 5)
+ ignore_tags = generator.settings.get('RELATED_POSTS_IGNORE_TAGS', [])
# Skip all posts in the same category as the article
skipcategory = generator.settings.get('RELATED_POSTS_SKIP_SAME_CATEGORY', False)
for article in generator.articles:
# set priority in case of forced related posts
if hasattr(article,'related_posts'):
- # split slugs
+ # split slugs
related_posts = article.related_posts.split(',')
- posts = []
+ posts = []
# get related articles
for slug in related_posts:
i = 0
@@ -40,7 +41,7 @@ def add_related_posts(generator):
continue
# score = number of common tags
- related = chain(*(generator.tags[tag] for tag in article.tags))
+ related = chain(*(generator.tags[tag] for tag in article.tags if tag.name not in ignore_tags))
if skipcategory:
related = (other for other in related
if other.category != article.category)
@@ -49,8 +50,8 @@ def add_related_posts(generator):
# remove itself
scores.pop(article, None)
- article.related_posts = [other for other, count
+ article.related_posts = [other for other, count
in scores.most_common(numentries)]
def register():
- signals.article_generator_finalized.connect(add_related_posts) \ No newline at end of file
+ signals.article_generator_finalized.connect(add_related_posts)