tagging: Allow using titles in for related stories.
[matthijs/upstream/blosxom-plugins.git] / general / atomfeed
index 0b322ab4e12d2c90124ff3498473961b3f6f21fb..c8d36c1da4e3bca8020187131ca09f5196902836 100644 (file)
@@ -4,8 +4,8 @@
 #            UTC and <modified> fixes for 0.3: Frank Hecker
 #            Enclosures support: Dave Slusher and Keith Irwin
 #            Upgrade to Atom 1.0 spec: Sam Pearson
-#            Replace $feed_url with $path_info_full: Gavin Carr
-# Version: 2007-12-17
+#            Removed static $feed_url, added georss support: Gavin Carr
+# Version: 2007-12-31
 # Docs: Included below: type "perldoc atomfeed", or scroll down
 # Blosxom Home/Docs/Licensing: http://blosxom.sourceforge.net/
 
@@ -97,11 +97,11 @@ $zerozero = '00';
 $id_domain or ($id_domain) = $blosxom::url =~ m#http://(?:www\.)?([^\/]+)#;
 
 $utc_date = '';
-$feed_utc_date = '';
 use vars qw/$feed_utc_date/;
 $category;
 $links;
 $summary;
+$georss;
 
 # ----- plugin subroutines -----
 
@@ -159,6 +159,8 @@ sub head {
   ($blog_title_type, $blog_title) = _parse_markup($blosxom::blog_title);
   ($blog_description_type, $blog_description) = _parse_markup($blosxom::blog_description);
 
+  $feed_utc_date = '';
+
   1;
 }
 
@@ -169,10 +171,17 @@ sub story {
   use File::stat;
 
   # set up <category>:
+  $category = '';
   if ( $path ) {
     $category = "<category term=\"$path\"/>";
   }
 
+  # GeoRSS support
+  $georss = '';
+  if ($blosxom::plugins{geo} && $geo::latitude && $geo::longitude) {
+    $georss = qq(<georss:point>$geo::latitude $geo::longitude</georss:point>);
+  }
+
   # <published>: derive from %blosxom::files
   my @published_utc = gmtime($blosxom::files{"$blosxom::datadir$path/$filename.$blosxom::file_extension"});
   $published_utc_date = sprintf("%4d-%02d-%02dT%02d:%02d:00Z",
@@ -192,7 +201,7 @@ sub story {
                              $updated_utc[1]);
 
   # Date/time of most recently-modified story becomes date/time of the feed.
-  $feed_utc_date = $updated_utc_date if $updated_utc_date > $feed_utc_date;
+  $feed_utc_date = $updated_utc_date if $updated_utc_date gt $feed_utc_date;
 
   # use %blosxom::files for the year component of feed-level <atom:id>
   # in case the creation time is cached somewhere.
@@ -259,7 +268,7 @@ sub story {
   # Parse the post body:
   ($body_type, $body) = _parse_markup($$body_ref);
 
-  1;
+  return 1;
 }
 
 sub foot {
@@ -365,7 +374,16 @@ sub _load_templates {
   my $path_info_full = $blosxom::path_info_full || "$blosxom::path_info/index.atom";
   $blosxom::template{'atom'}{'head'} =<<HEAD;
 <?xml version="1.0" encoding="utf-8"?>\$atomfeed::css_url
-<feed xmlns="http://www.w3.org/2005/Atom" xml:base="http://\$atomfeed::id_domain">
+<feed xmlns="http://www.w3.org/2005/Atom" xml:base="http://\$atomfeed::id_domain"
+HEAD
+
+  if ($blosxom::plugins{geo}) {
+    $blosxom::template{'atom'}{'head'} .= 
+      qq(      xmlns:georss="http://www.georss.org/georss");
+  }
+
+  $blosxom::template{'atom'}{'head'} .= <<HEAD;
+>
   <title type="\$atomfeed::blog_title_type">\$atomfeed::blog_title</title>
   <subtitle type="\$atomfeed::blog_description_type">\$atomfeed::blog_description</subtitle>
   <link rel="self" type="application/atom+xml" href="$blosxom::url$path_info_full" />
@@ -385,7 +403,7 @@ HEAD
     <title type="$atomfeed::title_type">$atomfeed::title</title>
     <published>$atomfeed::published_utc_date</published>
     <updated>$atomfeed::updated_utc_date</updated>
-    $atomfeed::category
+    $atomfeed::category$atomfeed::georss
     <author>
       <name>$atomfeed::author</name>
       $atomfeed::author_uri$atomfeed::author_email