mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
implemented github activity plugin
This commit is contained in:
parent
28c0644eb6
commit
c6c0ee76c2
3 changed files with 40 additions and 0 deletions
27
pelican/plugins/github_activity.py
Normal file
27
pelican/plugins/github_activity.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
from pelican import signals
|
||||
from pelican.utils import singleton
|
||||
|
||||
@singleton
|
||||
class GitHubActivity():
|
||||
def __init__(self, generator):
|
||||
try:
|
||||
import feedparser
|
||||
self.ga = feedparser.parse(
|
||||
generator.settings['GITHUB_ACTIVITY_FEED'])
|
||||
except ImportError:
|
||||
raise Exception("unable to find feedparser")
|
||||
|
||||
def fetch(self):
|
||||
return [activity['content'][0]['value'].strip()
|
||||
for activity in self.ga['entries']]
|
||||
|
||||
def add_github_activity(generator, metadata):
|
||||
if 'GITHUB_ACTIVITY_FEED' in generator.settings.keys():
|
||||
|
||||
ga = GitHubActivity(generator)
|
||||
|
||||
ga_html_snippets = ga.fetch()
|
||||
generator.context['github_activity'] = ga_html_snippets
|
||||
|
||||
def register():
|
||||
signals.article_generate_context.connect(add_github_activity)
|
||||
Loading…
Add table
Add a link
Reference in a new issue