aboutsummaryrefslogtreecommitdiff
path: root/plugins/related_posts/related_posts.py
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/related_posts/related_posts.py')
-rw-r--r--[-rwxr-xr-x]plugins/related_posts/related_posts.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/plugins/related_posts/related_posts.py b/plugins/related_posts/related_posts.py
index a0cfa15..fbb2426 100755..100644
--- a/plugins/related_posts/related_posts.py
+++ b/plugins/related_posts/related_posts.py
@@ -14,15 +14,14 @@ 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:
+ for article in chain(generator.articles, generator.drafts):
# 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
@@ -41,7 +40,7 @@ def add_related_posts(generator):
continue
# score = number of common tags
- related = chain(*(generator.tags[tag] for tag in article.tags if tag.name not in ignore_tags))
+ related = chain(*(generator.tags[tag] for tag in article.tags))
if skipcategory:
related = (other for other in related
if other.category != article.category)
@@ -50,7 +49,7 @@ 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():