Web feeds are a convenient mechanism to let visitors be notified of changes to a site. Instead of repeatedly checking RecentChanges every day to see what is new, a visitor can use a news aggregator to quickly see what pages of interest have changed on a site. Web feeds are commonly recognized by terms such as RSS, Atom, and web syndication. They are also the foundation for podcasting.
In its simplest form, web feeds in PmWiki are built on WikiTrails. Using a feed action such as ?action=rss or ?action=atom on a trail generates a web feed (often called a "channel") where each page on the trail is an item in the feed. Since the RecentChanges and Site.AllRecentChanges pages are effectively trails, one can easily get an RSS feed for a group or site by simply adding ?action=rss to the url for a RecentChanges page. For example, to get the site feed for pmwiki.org, one would use
Authors can also create custom feeds by simply creating a wiki trail of the pages they want included in the feed. Feeds can also be generated from groups, categories, and backlinks, and the order and number of items in the feed can be changed using options in the feed url. Thus, one can obtain a feed for the Skins category (sorted with most recent items first) by using
PmWiki is able to generate feeds in many formats, including RSS 2.0 (?action=rss), Atom 1.0 (?action=atom), and RSS 1.0 (?action=rdf). In addition, although it is not normally considered a web feed, PmWiki can generate metadata information using the Dublin Core Metadata extensions (?action=dc).
How to read a PmWiki syndicated feed
You'll need a news aggregator, which is a piece of software designed to read news feeds. Many different news aggregators are available. Some run on your own computer, either on their own or as plugins for email clients, web browsers, or newsreaders. Others are web applications that you can use from any Internet-connected computer. Some are in between (technically web applications, but ones designed to run on your computer, not some remote server). Get one that you like.
Subscribe to the WikiTrail you desire by supplying the feed url to the aggregator. The feed url will be the name of a trail page with ?action=rss or ?action=atom added to the end of the url.
Feed options
Add any of the following options to the end of a PmWiki web feed url to change its output (basically any pagelist option is available for web feeds):
?count=n
Limit feed to n items (default 10)
?order=-time
Display most recently changed items first (default: the order of the trail, or by name; in RecentChanges pages the trail is already ordered by -time)
?trail=page
Obtain items from trail on page (default: the trail on the current page)
?group=group
Limit feed to pages in group
?name=name
Limit feed to pages with specific name
?link=page
Create feed from pages linked to page
?list=normal
Exclude things like RecentChanges, AllRecentChanges, etc.
authors (intermediate)
Configure PmWiki for feeds
This section describes how to syndicate portions of a wiki to appear in a web feed. It does not describe how to display a web feed within a wiki page -- for that, see Cookbook:RssFeedDisplay.
To enable web feed generation for a site, add one or more of the following to a local customization file:
if ($action == 'rss') include_once("$FarmD/scripts/feeds.php");
if ($action == 'atom') include_once("$FarmD/scripts/feeds.php");
if ($action == 'rdf') include_once("$FarmD/scripts/feeds.php");
if ($action == 'dc') include_once("$FarmD/scripts/feeds.php");
or you can combine multiple feeds into a single expression using "||" to separate each feed type. For example, if you want to enable RSS and Atom feeds you would use
Web feeds are highly configurable, new elements can be easily added to feeds via the $FeedFmt array. Elements in $FeedFmt look like
$FeedFmt['atom']['feed']['rights'] = 'All Rights Reserved';
where the first index corresponds to the action (?action=atom), the second index indicates a per-feed or per-item element, and
the third index is the name of the element being generated. The above setting would therefore generate a "<rights>All Rights Reserved</rights>" in the feed for ?action=atom.
If the value of an entry begins with a '<', then feeds.php doesn't automatically add the tag around it. Elements can also be callable functions which are called to generate the appropriate output. See RSS specification(approuver les sites) or other feed specifications for what feed content you can use.
You can also change an existing element rather than add a new one. You can use the following lines to ensure that changes made to the wiki will be picked up by some RSS readers that wouldn't otherwise "notice" a page has been changed:
# Change the link URL when an item is edited.
$FeedFmt['rss']['item']['link'] = '{$PageUrl}?when=$ItemISOTime';
$FeedFmt['atom']['item']['link'] =
"<link rel=\"alternate\" href=\"{\$PageUrl}?when=\$ItemISOTime\" />\n";
See Also
Cookbook:FeedLinks - Add HTML <head> links for auto-discovery of your feeds.
From mailing list Feb 13,2007, a response by Pm: Yes
How can I use the RSS <enclosure> tag for podcasting?
For podcasting of mp3 files, simply attach an mp3 file to the page
with the same name as the page (i.e., for a page named Podcast.Episode4,
one would attach to that page a file named "Episode4.mp3"). The
file is automatically picked up by ?action=rss and used as an
enclosure.
The set of potential enclosures is given by the $RSSEnclosureFmt
array, thus
you need to replicate these lines for each type (atom, rdf, dc) of feed you provide.
the RSS description-tag is not equivalent to the pmWiki $Description variable, despite the confusing similarity.
Some of my password-protected pages aren't appearing in the feed... how do I work around this?
From a similar question on the newsgroup, Pm's reply:
The last time I checked, RSS and other syndication protocols didn't
really have a well-established interface or mechanism for performing
access control (i.e., authentication). As far as I know this is
still the case.
PmWiki's WebFeeds capability is built on top of pagelists, so it
could simply be that the $EnablePageListProtect option is preventing
the updated pages from appearing in the feed. You might try
setting $EnablePageListProtect=0; and see if the password-protected
pages start appearing in the RSS feed.
The "downside" to setting $EnablePageListProtect to zero is that
anyone doing a search on your site will see the existence of the
pages in the locked section. They won't be able to read any of
them, but they'll know they are there!
The big downside to this is that the cleartext password will
end up traveling across the net with every RSS request, and
may end up being recorded in Apache's access logs.
How to add feed image?
Add the following to local/config.php (this example is for ?action=rss):
Are there ways to let people easily subscribe to a feed?
On some browsers (Mozilla Firefox), the visitor can see an orange RSS icon in the address bar, and subscribe to the feed by clicking on it. To enable the RSS icon, add this to config.php :
How do I create a custom FeedPage similar to RecentChanges or AllRecentChanges, but with only certain groups or pages recorded?
See Cookbook:CustomRecentChanges. In a nutshell, you'll declare a $RecentChangesFmt variable with your dedicated FeedPage, and then wrap it in a condition of your choice. For example:
Alternatively, you can create the option for edit monitoring by adding a qualifier for RSS links. This allows the user to choose between default new pages RSS feeds and new edits RSS feeds (pmwiki.org has this option enabled).
## For new pages updates: http://example.com/wiki/HomePage?action=rss
## For edits updates: http://example.com/wiki/HomePage?action=rss&edits=1
if(@$_REQUEST['edits'] && $action == 'rss')
$FeedFmt['rss']['item']['guid'] = '{$PageUrl}?guid=$ItemISOTime';