Add a quickie style sheet to make the feeds semi-legible if someone loads
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 28 Apr 2004 07:02:53 +0000 (07:02 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 28 Apr 2004 07:02:53 +0000 (07:02 +0000)
them into a browser instead of a syndicated news reader.

Some way to get at the info on a <link> in atom might be nice.

includes/Feed.php
stylesheets/feed.css [new file with mode: 0644]

index 95f8e8c..0f654af 100644 (file)
@@ -84,6 +84,19 @@ class ChannelFeed extends FeedItem {
        function outFooter() {
                # print "</feed>";
        }
+       
+       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();
                ?><rss version="2.0">
        <channel>
                <title><?php print $this->getTitle() ?></title>
@@ -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();
                ?><feed version="0.3" xml:lang="<?php print $this->getLanguage() ?>">   
                <title><?php print $this->getTitle() ?></title>
                <link rel="alternate" type="text/html" href="<?php print $this->getUrl() ?>"/>
diff --git a/stylesheets/feed.css b/stylesheets/feed.css
new file mode 100644 (file)
index 0000000..73cce54
--- /dev/null
@@ -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;
+}
+