]> git.openstreetmap.org Git - rails.git/blob - app/views/user/api_read.builder
Enable/disable some context-menu options conditional on zoom
[rails.git] / app / views / user / api_read.builder
1 xml.instruct! :xml, :version => "1.0"
2 xml.osm("version" => API_VERSION, "generator" => GENERATOR) do
3   xml.tag! "user", :id => @this_user.id,
4                    :display_name => @this_user.display_name,
5                    :account_created => @this_user.creation_time.xmlschema do
6     if @this_user.description
7       xml.tag! "description", @this_user.description
8     end
9     if @user && @user == @this_user
10       xml.tag! "contributor-terms", :agreed => !!@this_user.terms_agreed,
11                                     :pd => !!@this_user.consider_pd
12     else
13       xml.tag! "contributor-terms", :agreed => !!@this_user.terms_agreed
14     end
15     if @this_user.image.file? or @this_user.image_use_gravatar
16       xml.tag! "img", :href => user_image_url(@this_user, :size => 256)
17     end
18     xml.tag! "roles" do
19       @this_user.roles.each do |role|
20         xml.tag! role.role
21       end
22     end
23     xml.tag! "changesets", :count => @this_user.changesets.size
24     xml.tag! "traces", :count => @this_user.traces.size
25     xml.tag! "blocks" do
26       xml.tag! "received", :count => @this_user.blocks.size,
27                            :active => @this_user.blocks.active.size
28       if @this_user.moderator?
29         xml.tag! "issued", :count => @this_user.blocks_created.size,
30                            :active => @this_user.blocks_created.active.size
31       end
32     end
33     if @user && @user == @this_user
34       if @this_user.home_lat and @this_user.home_lon
35         xml.tag! "home", :lat => @this_user.home_lat,
36                          :lon => @this_user.home_lon,
37                          :zoom => @this_user.home_zoom
38       end
39       if @this_user.languages
40         xml.tag! "languages" do
41           @this_user.languages.split(",") { |lang| xml.tag! "lang", lang }
42         end
43       end
44       xml.tag! "messages" do
45         xml.tag! "received", :count => @this_user.messages.size,
46                              :unread => @this_user.new_messages.size
47         xml.tag! "sent", :count => @this_user.sent_messages.size
48       end
49     end
50   end
51 end