]> git.openstreetmap.org Git - rails.git/blobdiff - lib/osm.rb
Adding a guid element to feed items, replicates URL.
[rails.git] / lib / osm.rb
index 6c3cf07c48f654cfac4b347e52871d2bdaa8a98b..6d2ef9efdcfb06394df481aa29f5780442ebcde1 100644 (file)
@@ -241,7 +241,7 @@ module OSM
   end
 
   class GeoRSS
-    def initialize(description='OpenStreetMap GPS Traces')
+    def initialize(feed_title='OpenStreetMap GPS Traces', feed_description='OpenStreetMap GPS Traces', feed_url='http://www.openstreetmap.org/traces/')
       @doc = XML::Document.new
       @doc.encoding = 'UTF-8' 
       
@@ -252,14 +252,14 @@ module OSM
       @channel = XML::Node.new 'channel'
       rss << @channel
       title = XML::Node.new 'title'
-      title <<  'OpenStreetMap GPS Traces'
+      title <<  feed_title
       @channel << title
       description_el = XML::Node.new 'description'
       @channel << description_el
 
-      description_el << description
+      description_el << feed_description
       link = XML::Node.new 'link'
-      link << 'http://www.openstreetmap.org/traces/'
+      link << feed_url
       @channel << link
       image = XML::Node.new 'image'
       @channel << image
@@ -276,7 +276,7 @@ module OSM
       height << '100'
       image << height
       link = XML::Node.new 'link'
-      link << 'http://www.openstreetmap.org/traces/'
+      link << feed_url
       image << link
     end
 
@@ -290,21 +290,29 @@ module OSM
       link << url
       item << link
 
+      guid = XML::Node.new 'guid'
+      guid << url
+      item << guid
+
       description = XML::Node.new 'description'
       description << description_text
       item << description
 
       pubDate = XML::Node.new 'pubDate'
-      pubDate << timestamp.xmlschema
+      pubDate << timestamp.to_s(:rfc822)
       item << pubDate
 
-      lat_el = XML::Node.new 'geo:lat'
-      lat_el << latitude.to_s
-      item << lat_el
+      if latitude
+        lat_el = XML::Node.new 'geo:lat'
+        lat_el << latitude.to_s
+        item << lat_el
+      end
 
-      lon_el = XML::Node.new 'geo:lon'
-      lon_el << longitude.to_s
-      item << lon_el
+      if longitude
+        lon_el = XML::Node.new 'geo:long'
+        lon_el << longitude.to_s
+        item << lon_el
+      end
 
       @channel << item
     end