source "https://rubygems.org"
# Require rails
-gem "rails", "5.2.2"
+gem "rails", "5.2.2.1"
# Require things which have moved to gems in ruby 1.9
gem "bigdecimal", "~> 1.1.0", :platforms => :ruby_19
remote: https://rubygems.org/
specs:
SystemTimer (1.2.3)
- aasm (5.0.1)
+ aasm (5.0.2)
concurrent-ruby (~> 1.0)
- actioncable (5.2.2)
- actionpack (= 5.2.2)
+ actioncable (5.2.2.1)
+ actionpack (= 5.2.2.1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
- actionmailer (5.2.2)
- actionpack (= 5.2.2)
- actionview (= 5.2.2)
- activejob (= 5.2.2)
+ actionmailer (5.2.2.1)
+ actionpack (= 5.2.2.1)
+ actionview (= 5.2.2.1)
+ activejob (= 5.2.2.1)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
- actionpack (5.2.2)
- actionview (= 5.2.2)
- activesupport (= 5.2.2)
+ actionpack (5.2.2.1)
+ actionview (= 5.2.2.1)
+ activesupport (= 5.2.2.1)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionpack-page_caching (1.1.1)
actionpack (>= 4.0.0, < 6)
- actionview (5.2.2)
- activesupport (= 5.2.2)
+ actionview (5.2.2.1)
+ activesupport (= 5.2.2.1)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
active_record_union (1.3.0)
activerecord (>= 4.0)
- activejob (5.2.2)
- activesupport (= 5.2.2)
+ activejob (5.2.2.1)
+ activesupport (= 5.2.2.1)
globalid (>= 0.3.6)
- activemodel (5.2.2)
- activesupport (= 5.2.2)
- activerecord (5.2.2)
- activemodel (= 5.2.2)
- activesupport (= 5.2.2)
+ activemodel (5.2.2.1)
+ activesupport (= 5.2.2.1)
+ activerecord (5.2.2.1)
+ activemodel (= 5.2.2.1)
+ activesupport (= 5.2.2.1)
arel (>= 9.0)
- activestorage (5.2.2)
- actionpack (= 5.2.2)
- activerecord (= 5.2.2)
+ activestorage (5.2.2.1)
+ actionpack (= 5.2.2.1)
+ activerecord (= 5.2.2.1)
marcel (~> 0.3.1)
- activesupport (5.2.2)
+ activesupport (5.2.2.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
bigdecimal (1.1.0)
binding_of_caller (0.8.0)
debug_inspector (>= 0.0.1)
- bootsnap (1.4.0)
+ bootsnap (1.4.1)
msgpack (~> 1.0)
browser (2.5.3)
builder (3.2.3)
coffee-script-source (1.12.2)
composite_primary_keys (11.1.0)
activerecord (~> 5.2.1)
- concurrent-ruby (1.1.4)
+ concurrent-ruby (1.1.5)
config (1.7.1)
activesupport (>= 3.0)
deep_merge (~> 1.2.1)
erubi (1.8.0)
execjs (2.7.0)
exifr (1.3.6)
- factory_bot (5.0.0)
+ factory_bot (5.0.2)
activesupport (>= 4.2.0)
factory_bot_rails (5.0.1)
factory_bot (~> 5.0.0)
railties (>= 4.2.0)
- fakefs (0.19.1)
+ fakefs (0.20.0)
faraday (0.15.4)
multipart-post (>= 1.2, < 3)
- ffi (1.9.25)
+ ffi (1.10.0)
fspath (3.1.0)
gd2-ffij (0.3.0)
ffi (>= 1.0.0)
execjs (>= 1.4.0)
multi_json (~> 1.0)
therubyracer (~> 0.12.1)
- json (2.1.0)
+ json (2.2.0)
jsonify (0.3.1)
multi_json (~> 1.0)
jsonify-rails (0.3.2)
mini_mime (1.0.1)
mini_portile2 (2.4.0)
minitest (5.11.3)
- msgpack (1.2.6)
+ msgpack (1.2.9)
multi_json (1.13.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
omniauth-github (1.3.0)
omniauth (~> 1.5)
omniauth-oauth2 (>= 1.4.0, < 2.0)
- omniauth-google-oauth2 (0.6.0)
+ omniauth-google-oauth2 (0.6.1)
jwt (>= 2.0)
omniauth (>= 1.1.1)
omniauth-oauth2 (>= 1.5)
mime-types
mimemagic (~> 0.3.0)
terrapin (~> 0.6.0)
- parallel (1.13.0)
+ parallel (1.14.0)
parser (2.6.0.0)
ast (~> 2.4.0)
pg (0.21.0)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rack-uri_sanitizer (0.0.2)
- rails (5.2.2)
- actioncable (= 5.2.2)
- actionmailer (= 5.2.2)
- actionpack (= 5.2.2)
- actionview (= 5.2.2)
- activejob (= 5.2.2)
- activemodel (= 5.2.2)
- activerecord (= 5.2.2)
- activestorage (= 5.2.2)
- activesupport (= 5.2.2)
+ rails (5.2.2.1)
+ actioncable (= 5.2.2.1)
+ actionmailer (= 5.2.2.1)
+ actionpack (= 5.2.2.1)
+ actionview (= 5.2.2.1)
+ activejob (= 5.2.2.1)
+ activemodel (= 5.2.2.1)
+ activerecord (= 5.2.2.1)
+ activestorage (= 5.2.2.1)
+ activesupport (= 5.2.2.1)
bundler (>= 1.3.0)
- railties (= 5.2.2)
+ railties (= 5.2.2.1)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.4)
actionpack (>= 5.0.1.x)
rails-i18n (4.0.2)
i18n (~> 0.6)
rails (>= 4.0)
- railties (5.2.2)
- actionpack (= 5.2.2)
- activesupport (= 5.2.2)
+ railties (5.2.2.1)
+ actionpack (= 5.2.2.1)
+ activesupport (= 5.2.2.1)
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
request_store (1.4.1)
rack (>= 1.4)
rinku (2.0.4)
- rotp (4.0.2)
+ rotp (4.1.0)
addressable (~> 2.5)
- rubocop (0.64.0)
+ rubocop (0.65.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.5, != 2.5.1.1)
powerpack (~> 0.1)
+ psych (>= 3.1.0)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.4.0)
ruby-openid (2.7.0)
ruby-progressbar (1.10.0)
ruby_dep (1.5.0)
- safe_yaml (1.0.4)
+ safe_yaml (1.0.5)
sanitize (5.0.0)
crass (~> 1.0.2)
nokogiri (>= 1.8.0)
nokogumbo (~> 2.0)
- sassc (2.0.0)
- ffi (~> 1.9.6)
+ sassc (2.0.1)
+ ffi (~> 1.9)
rake
sassc-rails (2.1.0)
railties (>= 4.0.0)
sprockets (> 3.0)
sprockets-rails
tilt
- secure_headers (6.0.0)
+ secure_headers (6.1.0)
simplecov (0.16.1)
docile (~> 1.1)
json (>= 1.8, < 3)
r2 (~> 0.2.7)
rack-cors
rack-uri_sanitizer
- rails (= 5.2.2)
+ rails (= 5.2.2.1)
rails-controller-testing
rails-i18n (~> 4.0.0)
record_tag_helper
changeset.subscribers << current_user unless changeset.subscribers.exists?(current_user.id)
# Return a copy of the updated changeset
- render :xml => changeset.to_xml.to_s
+ @changeset = changeset
+ render "api/changesets/changeset"
end
##
comment.update(:visible => false)
# Return a copy of the updated changeset
- render :xml => comment.changeset.to_xml.to_s
+ @changeset = comment.changeset
+ render "api/changesets/changeset"
end
##
comment.update(:visible => true)
# Return a copy of the updated changeset
- render :xml => comment.changeset.to_xml.to_s
+ @changeset = comment.changeset
+ render "api/changesets/changeset"
end
end
end
# Return XML giving the basic info about the changeset. Does not
# return anything about the nodes, ways and relations in the changeset.
def show
- changeset = Changeset.find(params[:id])
-
- render :xml => changeset.to_xml(params[:include_discussion].presence).to_s
+ @changeset = Changeset.find(params[:id])
+ @include_discussion = params[:include_discussion].presence
+ render "changeset"
end
##
# save the larger bounding box and return the changeset, which
# will include the bigger bounding box.
cs.save!
- render :xml => cs.to_xml.to_s
+ @changeset = cs
+ render "changeset"
end
##
# sort and limit the changesets
changesets = changesets.order("created_at DESC").limit(100)
- # preload users, tags and comments
- changesets = changesets.preload(:user, :changeset_tags, :comments)
-
- # create the results document
- results = OSM::API.new.get_xml_doc
-
- # add all matching changesets to the XML results document
- changesets.order("created_at DESC").limit(100).each do |cs|
- results.root << cs.to_xml_node
- end
-
- render :xml => results.to_s
+ # preload users, tags and comments, and render result
+ @changesets = changesets.preload(:user, :changeset_tags, :comments)
+ render "changesets"
end
##
# request *must* be a PUT.
assert_method :put
- changeset = Changeset.find(params[:id])
+ @changeset = Changeset.find(params[:id])
new_changeset = Changeset.from_xml(request.raw_post)
- check_changeset_consistency(changeset, current_user)
- changeset.update_from(new_changeset, current_user)
- render :xml => changeset.to_xml.to_s
+ check_changeset_consistency(@changeset, current_user)
+ @changeset.update_from(new_changeset, current_user)
+ render "changeset"
end
##
changeset.subscribers << current_user
# Return a copy of the updated changeset
- render :xml => changeset.to_xml.to_s
+ @changeset = changeset
+ render "changeset"
end
##
changeset.subscribers.delete(current_user)
# Return a copy of the updated changeset
- render :xml => changeset.to_xml.to_s
+ @changeset = changeset
+ render "changeset"
end
private
end
end
- def to_xml(include_discussion = false)
- doc = OSM::API.new.get_xml_doc
- doc.root << to_xml_node(nil, include_discussion)
- doc
- end
-
- def to_xml_node(user_display_name_cache = nil, include_discussion = false)
- el1 = XML::Node.new "changeset"
- el1["id"] = id.to_s
-
- user_display_name_cache = {} if user_display_name_cache.nil?
-
- if user_display_name_cache&.key?(user_id)
- # use the cache if available
- elsif user.data_public?
- user_display_name_cache[user_id] = user.display_name
- else
- user_display_name_cache[user_id] = nil
- end
-
- el1["user"] = user_display_name_cache[user_id] unless user_display_name_cache[user_id].nil?
- el1["uid"] = user_id.to_s if user.data_public?
-
- tags.each do |k, v|
- el2 = XML::Node.new("tag")
- el2["k"] = k.to_s
- el2["v"] = v.to_s
- el1 << el2
- end
-
- el1["created_at"] = created_at.xmlschema
- el1["closed_at"] = closed_at.xmlschema unless is_open?
- el1["open"] = is_open?.to_s
-
- bbox.to_unscaled.add_bounds_to(el1, "_") if bbox.complete?
-
- el1["comments_count"] = comments.length.to_s
- el1["changes_count"] = num_changes.to_s
-
- if include_discussion
- el2 = XML::Node.new("discussion")
- comments.includes(:author).each do |comment|
- el3 = XML::Node.new("comment")
- el3["date"] = comment.created_at.xmlschema
- el3["uid"] = comment.author.id.to_s if comment.author.data_public?
- el3["user"] = comment.author.display_name.to_s if comment.author.data_public?
- el4 = XML::Node.new("text")
- el4.content = comment.body.to_s
- el3 << el4
- el2 << el3
- end
- el1 << el2
- end
-
- # NOTE: changesets don't include the XML of the changes within them,
- # they are just structures for tagging. to get the osmChange of a
- # changeset, see the download method of the controller.
-
- el1
- end
-
##
# update this instance from another instance given and the user who is
# doing the updating. note that this method is not for updating the
--- /dev/null
+# basic attributes
+
+attrs = {
+ "id" => changeset.id,
+ "created_at" => changeset.created_at.xmlschema,
+ "open" => changeset.is_open?,
+ "comments_count" => changeset.comments.length,
+ "changes_count" => changeset.num_changes
+}
+attrs["closed_at"] = changeset.closed_at unless changeset.is_open?
+changeset.bbox.to_unscaled.add_bounds_to(attrs, "_") if changeset.bbox.complete?
+
+# user attributes
+
+if changeset.user.data_public?
+ attrs["uid"] = changeset.user_id
+ attrs["user"] = changeset.user.display_name
+end
+
+xml.changeset(attrs) do |changeset_xml_node|
+ changeset.tags.each do |k, v|
+ changeset_xml_node.tag(:k => k, :v => v)
+ end
+
+ # include discussion if requested
+
+ if @include_discussion
+ changeset_xml_node.discussion do |discussion_xml_node|
+ changeset.comments.includes(:author).each do |comment|
+ cattrs = {
+ "date" => comment.created_at.xmlschema
+ }
+ if comment.author.data_public?
+ cattrs["uid"] = comment.author.id
+ cattrs["user"] = comment.author.display_name
+ end
+ discussion_xml_node.comment(cattrs) do |comment_xml_node|
+ comment_xml_node.text(comment.body)
+ end
+ end
+ end
+ end
+end
--- /dev/null
+xml.instruct! :xml, :version => "1.0"
+
+# basic attributes
+
+xml.osm(OSM::API.new.xml_root_attributes) do |osm|
+ osm << render(:partial => "api/changesets/changeset.builder", :locals => { :changeset => @changeset })
+end
--- /dev/null
+xml.instruct! :xml, :version => "1.0"
+
+# basic attributes
+
+xml.osm(OSM::API.new.xml_root_attributes) do |osm|
+ @changesets.each do |changeset|
+ osm << render(:partial => "api/changesets/changeset.builder", :locals => { :changeset => changeset })
+ end
+end
<li><%= t ".legal_babble.contributors_nl_html", :locale => @locale %></li>
<li><%= t ".legal_babble.contributors_nz_html", :locale => @locale %></li>
<li><%= t ".legal_babble.contributors_si_html", :locale => @locale %></li>
+ <li><%= t ".legal_babble.contributors_es_html", :locale => @locale %></li>
<li><%= t ".legal_babble.contributors_za_html", :locale => @locale %></li>
<li><%= t ".legal_babble.contributors_gb_html", :locale => @locale %></li>
</ul>
<a href="http://www.gu.gov.si/en/">Surveying and Mapping Authority</a> and
<a href="http://www.mkgp.gov.si/en/">Ministry of Agriculture, Forestry and Food</a>
(public information of Slovenia).
+ contributors_es_html: |
+ <strong>Spain</strong>: Contains data sourced from the
+ Spanish National Geographic Institute (<a href="http://www.ign.es/">IGN</a>) and
+ National Cartographic System (<a href="http://www.scne.es/">SCNE</a>)
+ licensed for reuse under <a href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a>.
contributors_za_html: |
<strong>South Africa</strong>: Contains data sourced from
<a href="http://www.ngi.gov.za/">Chief Directorate:
Nacional Geoespacial</a>, State copyright reserved.
contributors_gb_html: |-
<strong>Reino Unido</strong>: Contiene datos de Ordnance Survey © Crown copyright and database right
- 2010-12.
+ 2010-19.
contributors_footer_1_html: Para obtener más detalles sobre estas y otras
fuentes que se han utilizado para ayudar a mejorar OpenStreetMap, véase
la <a href="https://wiki.openstreetmap.org/wiki/Contributors">página de
changeset = create(:changeset, :user => user)
## First try with a non-public user
- new_changeset = private_changeset.to_xml
+ new_changeset = create_changeset_xml(:user => private_user)
new_tag = XML::Node.new "tag"
new_tag["k"] = "tagtesting"
new_tag["v"] = "valuetesting"
assert_require_public_data "user with their data non-public, shouldn't be able to edit their changeset"
## Now try with the public user
- create(:changeset_tag, :changeset => changeset)
- new_changeset = changeset.to_xml
+ new_changeset = create_changeset_xml(:id => 1)
new_tag = XML::Node.new "tag"
new_tag["k"] = "tagtesting"
new_tag["v"] = "valuetesting"
assert_response :success
assert_select "osm>changeset[id='#{changeset.id}']", 1
- assert_select "osm>changeset>tag", 2
+ assert_select "osm>changeset>tag", 1
assert_select "osm>changeset>tag[k='tagtesting'][v='valuetesting']", 1
end
basic_authorization create(:user).email, "test"
changeset = create(:changeset)
- new_changeset = changeset.to_xml
+ new_changeset = create_changeset_xml(:user => changeset.user, :id => changeset.id)
new_tag = XML::Node.new "tag"
new_tag["k"] = "testing"
new_tag["v"] = "testing"
xml.find("//osm/way").first[name] = value.to_s
xml
end
+
+ ##
+ # build XML for changesets
+ def create_changeset_xml(user: nil, id: nil)
+ root = XML::Document.new
+ root.root = XML::Node.new "osm"
+ cs = XML::Node.new "changeset"
+ if user
+ cs["user"] = user.display_name
+ cs["uid"] = user.id.to_s
+ end
+ cs["id"] = id.to_s if id
+ root.root << cs
+ root
+ end
end
end