//
// FeedTable
// by neilw, 2009
//
// Version history:
// 1.01 Sept. 11, 2009 neilw Fixed bug with creator (thanks brentg!)
// 1.00 July 31, 2009 neilw First published version
//
// Usage
// FeedTable(uri, entries?, content?)
//
// uri: uri of RSS2.0 feed
// entries: max number of entries to display (default: 10). 0 => 100
// content: "summary" = show content summary only
// "full" = show full article content collapsed
// default = show article titles only
var uri = $0 ?? $uri;
var entries = $1 ?? $entries ?? 10;
var content = $2 ?? $content;
if (entries == 0) let entries = 100;
var x = nil;
if (uri == nil) { "ERROR: Must specify feed URI";<br />; }
else let x = web.xml(uri);
if (content != nil && content != "summary" && content != "full") {
"ERROR: if specified, 'content' must be equal to 'full' or 'summary'";<br />;
let content = nil;
}
if (x) <div class="plain"><table cellspacing="0" cellpadding="3" border="2" class="table">
<thead><tr>
<th style="padding: 5px; font-size: medium; font-weight: bold;"> web.link(xml.text(x,".//channel/link"), xml.text(x,".//channel/title")) </th>
</tr></thead>
<tbody><tr><td>
foreach (var e in xml.select(x,'//item')) {
if (__index < entries) <div>
if (content=="summary" && __index > 0)
<hr style="border: medium none; color:rgb(221,221,221); background-color:rgb(221,221,221); height: 1px;" />;
if (content == "full") collapseItem(@id..__index, _,_, "slide");
var title = web.link(xml.text(e,".//link"),xml.text(e,".//title"));
if (content) <strong> title </strong>;
else title;
<span style="color:rgb(128,128,128); font-size:smaller;"> " (posted "..string.substr(xml.text(e,".//pubDate"),0,16).." by "..
xml.text(e,".//dc:creator", { dc:"http://purl.org/dc/elements/1.1/" }) .. ")" </span>;
if (content == "summary")
<p style="font-size: small;"> web.html(xml.text(e,".//description")) </p>;
else if (content == "full")
<div id=(@id..__index) style="display:none; font-size:small;">
web.html(xml.text(e, ".//content:encoded", {content:"http://purl.org/rss/1.0/modules/content/"}));
<hr style="border: medium none; color:rgb(221,221,221); background-color:rgb(221,221,221); height: 1px;" />;
</div>;
</div>;
}
</td></tr></tbody>
</table></div>;
| Images 0 | ||
|---|---|---|
| No images to display in the gallery. |
Copyright © 2011 MindTouch, Inc. Powered by