Contents
RSSReader
Description
This Macro will output the content of an RSS/ATOM Feed into a wikipage.
Download & Release Notes
Download |
Release Version |
Moin Version |
Release Notes |
Author |
2.2 |
1.9.61 |
new features |
Marcel Häfner / Matthijs Kooijman |
|
2.0 |
1.8 / 1.9 |
new version & new features |
||
1.0 |
1.5 |
|
Usage
Examples:
<<RSSReader("http://www.example.dot/feed.rss")>>
<<RSSReader("http://www.example.dot/feed.rss", maxEntries=30, allowHtml=False,includeStyle=True,dateFormat,linkEntries=False)>>
Description
<<RSSReader(feed, maxEntries, allowHtml, includeStyle, dateFormat, linkEntries>>
feed is the url of the RSS/ATOM feed to read, it's the only MUST field.
maxEntries define how many items the entire feed should display. Default is 30.
allowHtml is an optional argument if you trust the feed to put the HTML directly into the page. CAUTION: this could be an attack vector, although feedparser should strip most "bad" HTML. Default ist False.
includeStyle per default True, so a nice css is added before the macro, you can disabled it with False.
dateFormat is a date format to use for the last updated / published date and time of the entry. This format must be in strftime format (see http://docs.python.org/2/library/time.html#time.strftime). By default, whatever format is used in the feed is displayed as-is.
linkEntries indicates whether the title of a post should be a link to the actual post (as indicated by the "link" field for the entry in the feed). Defaults to True.
CSS
This following CSS will be automaticly inserted above the output of the rss feed, with includeStyle = False you can disable this style output and may use your own css.
/* macro RSSReader start*/ div.rssReader .rssHeader { margin-top: 1em; margin-bottom: 1em; border-bottom: 1px dotted gray; } div.rssReader .rssSubTitle, div.rssReader .rssDescription { font-size: bold; } div.rssReader div.rssEntries { margin-top: 1em; margin-bottom: 1em; border-bottom: 1px dotted gray; } div.rssReader div.rssEntry { margin-top: 1em; margin-bottom: 1em; } div.rssReader p.rssEntryTitle { font-size: 1.25em; font-weight: bold; margin: 0em; } div.rssReader p.rssEntryUpdated { color: gray; font-size: 0.75em; margin: 0em; } div.rssReader p.rssEntryBody { margin: 0em; padding-top: 1em; }
Additional CSS and Notes
For my site (http://rock.heavy.ch/Latest%20News) I had to also to remove some additional html elements, because if you allow some html in your feed, then some feeds will delivery you craps or unwanted stuff (big images, stupid buttons, icons, etcetera..). This spam I do not want to publish, so I removed them via css:
/* size the images */ div.rssReader p.rssEntryBody img, div.rssReader div.rssEntry img { float: left; margin: 10px 10px 10px 0px; max-width: 20em; } /* don't need the rss feed title, I want to set it in my wiki by myself */ div.rssReader div.rssHeader { display: none; } /* away with crap */ p.rssEntryBody img[alt="approved_small"], div.rssEntry>div>a { display: none; } div.rssReader p.rssEntryBody+p { margin-top: 0em; }
Note: I do use Google Reader together with my mobile phone (Android OS). So I can collect a few feeds, and choose (with a simple "share" button) witch news I would like to show on my wiki. I also planed in the beginning to make some automatical logic, like all article about topic xy should be published, etcetera. This first worked well, but the problem is if you using a a lot of similarly feed readers the "luck" are quite hight that more than one source will publish nearly the same information. And for sure you don't want publish the same news two or more times on your website. Thats why I had to let go my automatic variant and go back to a normal half-auto solution. Btw. if you don't like the google reader, you can install your own rss aggregator like Tiny Tiny RSS (PHP and MySQL], has a lot of interesting features.
Description for old Version 1.0
for older MoinMoin Version (1.5) [[RSSReader(URL-to-RSS-feed-to-display[, allow_html])]] Pass in optional allow_html argument if you trust the source to inject any HTML it wants. You need feedparser. See also macro/FeedParser
Example: [[RSSReader(http://www.kde.org/dot/kde-apps-content.rdf, allow_html)]]
Dependencies
Python Feedparser is needed, see here: http://www.feedparser.org/ or install it by yourself.
setuptools:
sudo easy_install feedparser
ubuntu:
sudo apt-get install python-feedparser
Copyright
IanWienand - <ianw AT ieee DOT org>
2010 by MarcelHäfner
License
- Public Domain (Release 1.0; see Sourcecode)
- GNU GPL, see COPYING for details (Release 2.0 and later)
ToDo
Some ideas what I need to do:
- Macro should check the xxs mime stuff, if htlm is ever allowed
- use wikiutil.escape to secure anything where's comming from the rss
Bugs
Discussion
Only tested with the latest 1.9.6 version, it may also works with older releases (1)