]> git.openstreetmap.org Git - rails.git/blobdiff - lib/osm.rb
Various updates to the user management, including the creation of a
[rails.git] / lib / osm.rb
index 3d53b453a8b41f2e164dbdc42b36a8755045cb2c..ea2a581645d797e7fd677cf31629863f569b2967 100644 (file)
@@ -311,7 +311,7 @@ module OSM
       image << link
     end
 
-    def add(latitude=0, longitude=0, title_text='dummy title', url='http://www.example.com/', description_text='dummy description', timestamp=DateTime.now)
+    def add(latitude=0, longitude=0, title_text='dummy title', author_text='anonymous', url='http://www.example.com/', description_text='dummy description', timestamp=DateTime.now)
       item = XML::Node.new 'item'
 
       title = XML::Node.new 'title'
@@ -329,6 +329,10 @@ module OSM
       description << description_text
       item << description
 
+      author = XML::Node.new 'author'
+      author << author_text
+      item << author
+
       pubDate = XML::Node.new 'pubDate'
       pubDate << timestamp.to_s(:rfc822)
       item << pubDate
@@ -384,7 +388,19 @@ module OSM
     end
 
     return nil
-  rescue
+  rescue Exception
     return nil
   end
+
+  # Construct a random token of a given length
+  def self.make_token(length = 30)
+    chars = 'abcdefghijklmnopqrtuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
+    token = ''
+
+    length.times do
+      token += chars[(rand * chars.length).to_i].chr
+    end
+
+    return token
+  end
 end