aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2015-03-21 11:32:09 +0100
committerSébastien Dailly <sebastien@chimrod.com>2015-03-25 21:30:13 +0100
commit3fcddf78f965a2c5ee0a9602708899fb0e72a7c0 (patch)
treee6e1ea32bde1e0e98be7e5595172a12938ea74b7 /plugins
parent9823d9e70be435e5a86f9d51489d85b6c6ba7a69 (diff)
Article on sailfish developpement
Diffstat (limited to 'plugins')
-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)