Added user ID, description, languages and image link to the user details API call.
authorMatt Amos <zerebubuth@gmail.com>
Mon, 31 Aug 2009 23:11:15 +0000 (23:11 +0000)
committerMatt Amos <zerebubuth@gmail.com>
Mon, 31 Aug 2009 23:11:15 +0000 (23:11 +0000)
app/controllers/user_controller.rb
app/views/user/api_details.builder [new file with mode: 0644]

index bea700331c2eb67f362f4a51d7089546f3b99a10..eeef4b6de0b0072ca21a0811de08d5e11f087fdf 100644 (file)
@@ -246,7 +246,8 @@ class UserController < ApplicationController
   end
 
   def api_details
-    render :text => @user.to_xml.to_s, :content_type => "text/xml"
+    # moved implementation to a view.
+    render :layout => false
   end
 
   def api_gpx_files
diff --git a/app/views/user/api_details.builder b/app/views/user/api_details.builder
new file mode 100644 (file)
index 0000000..656218a
--- /dev/null
@@ -0,0 +1,25 @@
+xml.instruct! :xml, :version => "1.0"
+xml.osm("version" => API_VERSION, "generator" => GENERATOR) do
+  xml.tag! "user", :id => @user.id,
+                   :display_name => @user.display_name,
+                   :account_created => @user.creation_time.xmlschema do
+    if @user.description
+      xml.tag! "description", @user.description
+    end
+    if @user.home_lat and @user.home_lon
+      xml.tag! "home", :lat => @user.home_lat,
+                       :lon => @user.home_lon,
+                       :zoom => @user.home_zoom
+    end    
+    if @user.image
+      # i'd love to use "url_for_file_column, :absolute=>true", but that doesn't seem
+      # to work with the file_column plugin version we're using.
+      xml.tag! "img", :href => ("http://" + SERVER_URL + url_for_file_column(@user, "image"))
+    end
+    if @user.languages
+      xml.tag! "languages" do
+        @user.languages.split(",") { |lang| xml.tag! "lang", lang }
+      end
+    end
+  end
+end