From b35996ca430c6d069fcfff751a8019d7bbd3737f Mon Sep 17 00:00:00 2001 From: Mario Lang Date: Mon, 10 Feb 2014 17:27:54 +0100 Subject: [PATCH] Allow for an optional maximum number of entries to display. --- github_activity/Readme.rst | 5 +++++ github_activity/github_activity.py | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/github_activity/Readme.rst b/github_activity/Readme.rst index fa3b95d..5e17eb0 100644 --- a/github_activity/Readme.rst +++ b/github_activity/Readme.rst @@ -9,6 +9,11 @@ For example, to track Pelican project activity, the setting would be:: GITHUB_ACTIVITY_FEED = 'https://github.com/getpelican.atom' +If you want to limit the amount of entries to a certain maximum set the +``GITHUB_ACTIVITY_MAX_ENTRIES`` parameter. + + GITHUB_ACTIVITY_MAX_ENTRIES = 10 + On the template side, you just have to iterate over the ``github_activity`` variable, as in this example:: diff --git a/github_activity/github_activity.py b/github_activity/github_activity.py index fb3b2b0..76e3405 100644 --- a/github_activity/github_activity.py +++ b/github_activity/github_activity.py @@ -25,6 +25,7 @@ class GitHubActivity(): import feedparser self.activities = feedparser.parse( generator.settings['GITHUB_ACTIVITY_FEED']) + self.max_entries = generator.settings['GITHUB_ACTIVITY_MAX_ENTRIES'] def fetch(self): """ @@ -37,7 +38,7 @@ class GitHubActivity(): [element for element in [activity['title'], activity['content'][0]['value']]]) - return entries + return entries[0:self.max_entries] def fetch_github_activity(gen, metadata):