Merge pull request #176 from kpanic/plugin-github-activity-new-feed

Plugin github activity new feed
This commit is contained in:
Alexis Metaireau 2011-10-27 07:15:24 -07:00
commit 3cf3657202
2 changed files with 36 additions and 14 deletions

View file

@ -100,15 +100,20 @@ in your template just write a for in jinja2 syntax against the
github_activity variable, like for example:: github_activity variable, like for example::
{% if GITHUB_ACTIVITY_FEED %} {% if GITHUB_ACTIVITY_FEED %}
<div class="social"> <div class="social">
<h2>Github Activity</h2> <h2>Github Activity</h2>
{% for activity in github_activity %} <ul>
{{ activity }}
{% endfor %} {% for entry in github_activity %}
</div><!-- /.social --> <li><b>{{ entry[0] }}</b><br /> {{ entry[1] }}</li>
{% endfor %}
</ul>
</div><!-- /.github_activity -->
{% endif %} {% endif %}
github_activity is a list containing raw html from github so you can include it
directly in your (for example base.html) template and style it in a way that github_activity is a list containing a list. The first element is the title and
your prefer using your css skills the second element is the raw html from github so you can include it directly
in your (for example base.html) template and style it in a way that your prefer
using your css skills

View file

@ -13,9 +13,20 @@
in your template just write a for in jinja2 syntax against the in your template just write a for in jinja2 syntax against the
github_activity variable. github_activity variable.
github_activity is a list containing raw html from github so you can i.e.
include it directly in your template
<div class="social">
<h2>Github Activity</h2>
<ul>
{% for entry in github_activity %}
<li><b>{{ entry[0] }}</b><br /> {{ entry[1] }}</li>
{% endfor %}
</ul>
</div><!-- /.github_activity -->
github_activity is a list containing a list. The first element is the title
and the second element is the raw html from github
""" """
from pelican import signals from pelican import signals
@ -31,14 +42,20 @@ class GitHubActivity():
self.activities = feedparser.parse( self.activities = feedparser.parse(
generator.settings['GITHUB_ACTIVITY_FEED']) generator.settings['GITHUB_ACTIVITY_FEED'])
except ImportError: except ImportError:
raise Exception("unable to find feedparser") raise Exception("Unable to find feedparser")
def fetch(self): def fetch(self):
""" """
returns a list of html snippets fetched from github actitivy feed returns a list of html snippets fetched from github actitivy feed
""" """
return [activity['content'][0]['value'].strip()
for activity in self.activities['entries']] entries = []
for activity in self.activities['entries']:
entries.append(
[element for element in [activity['title'],
activity['content'][0]['value']]])
return entries
def fetch_github_activity(gen, metadata): def fetch_github_activity(gen, metadata):