From 29804835657280d77082b72fbd23f44fffdc3512 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 28 Apr 2004 07:02:53 +0000 Subject: [PATCH] Add a quickie style sheet to make the feeds semi-legible if someone loads them into a browser instead of a syndicated news reader. Some way to get at the info on a in atom might be nice. --- includes/Feed.php | 29 ++++++++-------- stylesheets/feed.css | 78 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 13 deletions(-) create mode 100644 stylesheets/feed.css diff --git a/includes/Feed.php b/includes/Feed.php index 95f8e8c4ab..0f654af20b 100644 --- a/includes/Feed.php +++ b/includes/Feed.php @@ -84,6 +84,19 @@ class ChannelFeed extends FeedItem { function outFooter() { # print ""; } + + function outXmlHeader( $mimetype="application/xml" ) { + global $wgServer, $wgStylePath, $wgOut; + + # We take over from $wgOut, excepting its cache header info + $wgOut->disable(); + header( "Content-type: $mimetype; charset=UTF-8" ); + $wgOut->sendCacheControl(); + + print '<' . '?xml version="1.0" encoding="utf-8"?' . ">\n"; + print '<' . '?xml-stylesheet type="text/css" href="' . + htmlspecialchars( "$wgServer$wgStylePath/feed.css" ) . '"?' . ">\n"; + } } class RSSFeed extends ChannelFeed { @@ -93,14 +106,9 @@ class RSSFeed extends ChannelFeed { } function outHeader() { - global $wgVersion, $wgOut; + global $wgVersion; - # We take over from $wgOut, excepting its cache header info - $wgOut->disable(); - header( "Content-type: application/xml; charset=UTF-8" ); - $wgOut->sendCacheControl(); - - print '<' . '?xml version="1.0" encoding="utf-8"?' . ">\n"; + $this->outXmlHeader(); ?> <?php print $this->getTitle() ?> @@ -141,12 +149,7 @@ class AtomFeed extends ChannelFeed { function outHeader() { global $wgVersion, $wgOut; - # We take over from $wgOut, excepting its cache header info - $wgOut->disable(); - header( "Content-type: application/xml; charset=UTF-8" ); - $wgOut->sendCacheControl(); - - print '<' . '?xml version="1.0" encoding="utf-8"?' . ">\n"; + $this->outXmlHeader(); ?> <?php print $this->getTitle() ?> diff --git a/stylesheets/feed.css b/stylesheets/feed.css new file mode 100644 index 0000000000..73cce5415a --- /dev/null +++ b/stylesheets/feed.css @@ -0,0 +1,78 @@ +/* Make RSS and Atom feeds at least semi-legible to folk who accidentally load them in a browser */ + +/* RSS: */ rss, channel, title, link, description, language, generator, lastBuildDate, item, pubDate, author, comments, +/* Atom: */ feed, modified, tagline, entry, issued, created, summary, comment { + display: block; +} + +rss, feed { + background: white; + color: black; + margin: 1em; + font-family: "Verdana", "Tahoma", "Arial", "Helvetica", sans-serif; + line-height: 1.5em; +} + +rss:before { + content: "This RSS feed is meant to be read by a syndicated news reader, and isn't ideal for a web browser."; +} + +feed:before { + content: "This Atom feed is meant to be read by a syndicated news reader, and isn't ideal for a web browser."; +} +rss:before, feed:before { + color: red; + text-align: center; + line-height: 2em; +} + +channel>title, +item>title, +feed>title, +entry>title { + font-weight: bold; + border-bottom: solid 1px #aaa; + margin-left: -0.5em; +} +channel>title, feed>title { + font-size: larger; +} +item>title, entry>title { + font-size: large; +} +item, entry { + margin-top: 1em; + margin-left: 2em; +} + +item>description, entry>summary { + white-space: pre; + overflow: auto; + background: #f8f8ff; +} + +pubDate:before { content: "Date: " } +link:before { content: "Link: " } +author:before { content: "Author: " } +description:before { content: "Description: " } + +generator:before { content: "Generator: " } +language:before { content: "Language: " } +lastBuildDate:before { content: "Updated: " } +comments:before { content: "Comments page: " } + +tagline:before { content: "Tagline: " } +issued:before { content: "Issued: " } +created:before { content: "Created: " } +modified:before { content: "Modified: " } +summary:before { content: "Summary: " } +comment:before { content: "Comment: " } + +pubDate:before, link:before, author:before, description:before, +language:before, generator:before, lastBuildDate:before, comments:before, +tagline:before, issued:before, created:before, modified:before, +summary:before, comment:before { + color: #224; + font-weight: bold; +} + -- 2.20.1