* (bug 2392) Fix Atom items content type, upgrade to Atom 1.0
authorBrion Vibber <brion@users.mediawiki.org>
Sat, 5 Nov 2005 10:38:46 +0000 (10:38 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sat, 5 Nov 2005 10:38:46 +0000 (10:38 +0000)
* Allow $wgFeedCacheTimeout of 0 to disable feed caching
Hooray for gratuitou s changes from atom 0.3 to 1.0!

RELEASE-NOTES
includes/DefaultSettings.php
includes/Feed.php
includes/SpecialRecentchanges.php
skins/common/feed.css

index 524d002..d569a51 100644 (file)
@@ -206,7 +206,8 @@ fully support the editing toolbar, but was found to be too confusing.
   subdir so you can render new math images and have them work
 * (bug 3797) Don't expand variables and sigs in comments
 * (bug 3666) Don't spew PHP warnings in prefs on unrecognized site language
-
+* (bug 2392) Fix Atom items content type, upgrade to Atom 1.0
+* Allow $wgFeedCacheTimeout of 0 to disable feed caching
 
 === Caveats ===
 
index 3e9eda6..a95925b 100644 (file)
@@ -1389,7 +1389,11 @@ $wgFeedLimit = 50;
 
 /** _Minimum_ timeout for cached Recentchanges feed, in seconds.
  * A cached version will continue to be served out even if changes
- * are made, until this many seconds runs out since the last render. */
+ * are made, until this many seconds runs out since the last render.
+ *
+ * If set to 0, feed caching is disabled. Use this for debugging only;
+ * feed generation can be pretty slow with diffs.
+ */
 $wgFeedCacheTimeout = 60;
 
 /** When generating Recentchanges RSS/Atom feed, diffs will not be generated for
index d47f33c..0f5febd 100644 (file)
@@ -240,16 +240,40 @@ class AtomFeed extends ChannelFeed {
                global $wgVersion, $wgOut;
                
                $this->outXmlHeader();
-               ?><feed version="0.3" xml:lang="<?php print $this->getLanguage() ?>">   
+               ?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="<?php print $this->getLanguage() ?>">     
+               <id><?php print $this->getFeedId() ?></id>
                <title><?php print $this->getTitle() ?></title>
+               <link rel="self" type="application/atom+xml" href="<?php print $this->getSelfUrl() ?>"/>
                <link rel="alternate" type="text/html" href="<?php print $this->getUrl() ?>"/>
-               <modified><?php print $this->formatTime( wfTimestampNow() ) ?>Z</modified>
-               <tagline><?php print $this->getDescription() ?></tagline>
+               <updated><?php print $this->formatTime( wfTimestampNow() ) ?>Z</updated>
+               <subtitle><?php print $this->getDescription() ?></subtitle>
                <generator>MediaWiki <?php print $wgVersion ?></generator>
                
 <?php
        }
        
+       /**
+        * Atom 1.0 requires a unique, opaque IRI as a unique indentifier
+        * for every feed we create.
+        * @return string
+        * @access private
+        */
+       function getFeedId() {
+               global $wgServer, $wgScript;
+               return htmlspecialchars( "$wgServer$wgScript?atom-feed-id/" .
+                       wfTimestamp( TS_MW ) . "/" . wfRandom() );
+       }
+       
+       /**
+        * Atom 1.0 requests a self-reference to the feed.
+        * @return string
+        * @access private
+        */
+       function getSelfUrl() {
+               global $wgRequest;
+               return htmlspecialchars( $wgRequest->getFullRequestURL() );
+       }
+       
        /**
         * @todo document
         */
@@ -257,16 +281,15 @@ class AtomFeed extends ChannelFeed {
                global $wgMimeType;
        ?>
        <entry>
+               <id><?php print $item->getUrl() ?></id>
                <title><?php print $item->getTitle() ?></title>
                <link rel="alternate" type="<?php print $wgMimeType ?>" href="<?php print $item->getUrl() ?>"/>
                <?php if( $item->getDate() ) { ?>
-               <modified><?php print $this->formatTime( $item->getDate() ) ?>Z</modified>
-               <issued><?php print $this->formatTime( $item->getDate() ) ?></issued>
-               <created><?php print $this->formatTime( $item->getDate() ) ?>Z</created><?php } ?>
+               <updated><?php print $this->formatTime( $item->getDate() ) ?>Z</updated>
+               <?php } ?>
        
-               <summary type="text/plain"><?php print $item->getDescription() ?></summary>
-               <?php if( $item->getAuthor() ) { ?><author><name><?php print $item->getAuthor() ?></name><!-- <url></url><email></email> --></author><?php }?>
-               <comment>foobar</comment>
+               <summary type="html"><?php print $item->getDescription() ?></summary>
+               <?php if( $item->getAuthor() ) { ?><author><name><?php print $item->getAuthor() ?></name></author><?php }?>
        </entry>
 
 <?php /* FIXME need to add comments
index 50991be..8123694 100644 (file)
@@ -260,7 +260,7 @@ function rcOutputFeed( $rows, $feedFormat, $limit, $hideminor, $lastmod ) {
         * gets it quick too.
         */
        $cachedFeed = false;
-       if( $feedLastmod = $messageMemc->get( $timekey ) ) {
+       if( ( $wgFeedCacheTimeout > 0 ) && ( $feedLastmod = $messageMemc->get( $timekey ) ) ) {
                /**
                 * If the cached feed was rendered very recently, we may
                 * go ahead and use it even if there have been edits made
index 1e131fc..9439663 100644 (file)
@@ -12,7 +12,7 @@ Compatibility:
 */
 
 /* RSS: */ rss, channel, title, link, description, language, generator, lastBuildDate, item, pubDate, author, comments, creator,
-/* Atom: */ feed, modified, tagline, entry, issued, created, summary, comment {
+/* Atom: */ feed, id, modified, tagline, entry, issued, created, updated, summary, comment {
        display: block;
 }
 
@@ -67,6 +67,7 @@ pubDate:before { content: "Date: " }
 link:before { content: "Link: " }
 author:before, creator:before { content: "Author: " }
 description:before { content: "Description: " }
+id:before { content: "Id: " }
 
 generator:before { content: "Generator: " }
 language:before { content: "Language: " }
@@ -77,13 +78,14 @@ tagline:before { content: "Tagline: " }
 issued:before { content: "Issued: " }
 created:before { content: "Created: " }
 modified:before { content: "Modified: " }
+updated:before { content: "Updated: " }
 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, creator:before {
+summary:before, comment:before, creator:before, id:before, updated:before {
        color: #224;
        font-weight: bold;
 }