Commits

John Paulett  committed dd2de73

Added simple RSS MoinMoin macro

  • Participants
  • Parent commits 1003dc9

Comments (0)

Files changed (1)

File 7oars-moin/RSS.py

+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2009 John Paulett (john -at- 7oars.com)
+# All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution.
+
+"""MoinMoin macro for making a simple list from an RSS feed
+
+Installation:
+  Copy RSS.py into $INSTANCE/data/plugin/macro 
+
+Usage:
+  <<<RSS(feedurl)>>
+
+"""
+
+from MoinMoin import wikiutil
+
+def macro_RSS(macro, url):
+    import feedparser    
+    f = feedparser.parse(url)
+    links = ['<a href="%s">%s</a>' % (item.link, item.title) for item in f.entries]
+    result = make_list(links)
+    return macro.formatter.rawHTML(result)
+
+def make_list(links):
+    if len(links) > 0:
+        return '<ul><li>%s</li></ul>' % '</li><li>'.join(links)
+    return 'No links found.'