From b4a22eee7178207971ec89b834f3790f10eb216e Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Mon, 28 Jun 2010 17:47:05 +0100 Subject: [PATCH 01/29] Reject leading and trailing whitespace in display names --- app/models/user.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/user.rb b/app/models/user.rb index 31b0f27a0..1a50f7053 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -28,6 +28,8 @@ class User < ActiveRecord::Base validates_email_format_of :email validates_email_format_of :new_email, :allow_blank => true validates_format_of :display_name, :with => /^[^\/;.,?]*$/ + validates_format_of :display_name, :with => /^\S/, :message => "has leading whitespace" + validates_format_of :display_name, :with => /\S$/, :message => "has trailing whitespace" validates_numericality_of :home_lat, :allow_nil => true validates_numericality_of :home_lon, :allow_nil => true validates_numericality_of :home_zoom, :only_integer => true, :allow_nil => true From 2038cd52c65158a9b31299c62e4beb72c61a18b7 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 29 Jun 2010 09:43:30 +0100 Subject: [PATCH 02/29] Include an [OpenStreetMap] prefix on the subject of message notifications Put back the [OpenStreetMap] prefix to the subject line of email notifications of messages, but strip it again from any incoming email replies. --- app/models/notifier.rb | 2 +- config/locales/en.yml | 1 + script/deliver-message | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/notifier.rb b/app/models/notifier.rb index de0ad21d6..f63d08b67 100644 --- a/app/models/notifier.rb +++ b/app/models/notifier.rb @@ -48,7 +48,7 @@ class Notifier < ActionMailer::Base def message_notification(message) common_headers message.recipient from_header message.sender.display_name, "m", message.id, message.digest - subject message.title + subject I18n.t('notifier.message_notification.subject_header', :user => message.title, :locale => locale) body :to_user => message.recipient.display_name, :from_user => message.sender.display_name, :body => message.body, diff --git a/config/locales/en.yml b/config/locales/en.yml index f79a3d9e5..e3d8803ed 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1062,6 +1062,7 @@ en: header: "{{from_user}} has commented on your recent OpenStreetMap diary entry with the subject {{subject}}:" footer: "You can also read the comment at {{readurl}} and you can comment at {{commenturl}} or reply at {{replyurl}}" message_notification: + subject_header: "[OpenStreetMap] {{subject}}" hi: "Hi {{to_user}}," header: "{{from_user}} has sent you a message through OpenStreetMap with the subject {{subject}}:" footer1: "You can also read the message at {{readurl}}" diff --git a/script/deliver-message b/script/deliver-message index 3df09f85f..58afa3451 100755 --- a/script/deliver-message +++ b/script/deliver-message @@ -15,6 +15,7 @@ else digest = message.digest from = message.recipient to = message.sender + subject = message.subject.sub(/\[OpenStreetMap\] */, "") end exit 0 unless recipient[3] == digest[0,6] @@ -23,7 +24,7 @@ mail = TMail::Mail.parse(STDIN.readlines.join) message = Message.new(:sender => from, :recipient => to, :sent_on => Time.now.getutc, - :title => mail.subject, + :title => subject, :body => mail.body) message.save! From 6740cab85b28e808e12ec47785547eebce5f40fa Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 29 Jun 2010 15:19:54 +0100 Subject: [PATCH 03/29] Use the correct name for the interpolation variable --- app/models/notifier.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/notifier.rb b/app/models/notifier.rb index f63d08b67..364463336 100644 --- a/app/models/notifier.rb +++ b/app/models/notifier.rb @@ -48,7 +48,7 @@ class Notifier < ActionMailer::Base def message_notification(message) common_headers message.recipient from_header message.sender.display_name, "m", message.id, message.digest - subject I18n.t('notifier.message_notification.subject_header', :user => message.title, :locale => locale) + subject I18n.t('notifier.message_notification.subject_header', :subject => message.title, :locale => locale) body :to_user => message.recipient.display_name, :from_user => message.sender.display_name, :body => message.body, From a7a4dadbd5e9b0644e44800324dc81d1ec56201e Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 30 Jun 2010 12:51:22 +0100 Subject: [PATCH 04/29] Add a notice about the downtime --- app/views/layouts/site.html.erb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/views/layouts/site.html.erb b/app/views/layouts/site.html.erb index cecf5acc2..976117e08 100644 --- a/app/views/layouts/site.html.erb +++ b/app/views/layouts/site.html.erb @@ -109,6 +109,13 @@ <% end %> +
+ OpenStreetMap will be undergoing database maintenance from 1st to 3rd + July. See + the wiki + for details. +
+ <% if false %> <% end %> -
- OpenStreetMap will be undergoing database maintenance from 1st to 3rd - July. See - the wiki - for details. -
- <% if false %> -
- <%= link_to image_tag("sotm.png", :alt => t('layouts.sotm2010'), :title => t('layouts.sotm2010'), :border => "0"), "http://www.stateofthemap.org/register/" %> -
- <%= yield :optionals %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index e3d8803ed..ce80b6931 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -933,7 +933,6 @@ en: shop: Shop shop_tooltip: Shop with branded OpenStreetMap merchandise shop_url: http://wiki.openstreetmap.org/wiki/Merchandise - sotm2010: 'Come to the 2010 OpenStreetMap Conference, The State of the Map, July 9-11 in Girona!' license: alt: CC by-sa 2.0 title: OpenStreetMap data is licensed under the Creative Commons Attribution-Share Alike 2.0 Generic License diff --git a/public/images/sotm.png b/public/images/sotm.png deleted file mode 100644 index af2d049bc72b94bed1ebb227db9e1144eaf38236..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11841 zcmV-HF22!;P)|!}kv3qCutFQI$#B!eAodxb}c>Yg==jm%Zh4btcL=+KGLJhr#1W37fbMJ4AuUAcYL8*`*# zKbUJj-PRNpdma8g`U5k$v^Dlfs6e}DoCN;&e_OA;R;{V&zh}1DGY{MQ>DzlTM;i9y z#a5oyVpY&QI-=}Yw&%VCT|$skW%Fjw#TVn)PmkS)?ARmrEGztX!cVZbs?kF0S)iDK zbX>n}a91_0wG}d;pD2JA+=qt(($a_bZHGq+{CRA!2kZgiUPJO{(sA}lgnu{%wB2_f zjz0-tqTeOszY%^1t&A5vJyz59vc0?!xZii*efz3Ff7Ax48!C0B;(vDVMztl?7i5} zVngJndPbi#OVJ#~gk_r3whNSmb4F_hhGtEMVpt<{ky&eD@Y?jupe9X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B%66TWf(jcr|3+E#4OyPVEZG8Q2hE(2aEn|3&=*Myvst9v>L3NX;Hso{*7T5EJfY z#`vN>?Gz&s*+$0ulMLf1vd-D<$tx6H3pCc-(=xjG0Qv?|D$DM^vDynC6fSDpY-Lb9bsisxw)N>z3JvgAm&1e+S#TbjBl z0)5Nkc7MOXZ?V<_V296_B1}f!CgC2!$7J?II1A!ml%r2#B%;r74ITdgOf0F;S4~hUX{}AaC3PA?M(gMlDZ?3ff(&3_#C{b`NUan~_ zp(f!cVy}Vi%%KrdXfFI9${S5^j*@T&jdK77)lA>7TOv)+Gx~?n4qtf^so=t;QMach zzY!)UtUvS1?7d0oT!0rJmf55N!%zee1HQ&OIn=cy1Z=>7uT52yqhX)EN#J;pSLEL9 zJ*MRwb|H5~XIVky1X17oI11P*rG*qJpoH4xWOn!9M3Hwm1$);AdN@JgMO*kZQSK;~ zKT5K5qMLWHwDr~-H0T34MR5ASz;b&+yebES$N^6aOhOJ>6rl)^K?E$vvmB>O=A+zy zIMb@FRbQ{!nI^b-CgH{Uil(-Pe1W7Qh9t2(4FZ7+b0J=1j+TFNRo1BEa)irC!E?_eS0gm z)@XRkw2jnXZdxTKHQTXGxq(U1$T?v7op!v<8IOFH-{=mA= vJLdH^r)C93d+(peE48;t{$6(Se*z2uq5A)KV9J*$00000NkvXXu0mjfHG*{I From 140455c0f812470800b12b239d66dc019002ea52 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Mon, 19 Jul 2010 12:23:19 +0100 Subject: [PATCH 12/29] Correct some exception names --- lib/diff_reader.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/diff_reader.rb b/lib/diff_reader.rb index 0b1593158..9b3e01b86 100644 --- a/lib/diff_reader.rb +++ b/lib/diff_reader.rb @@ -104,7 +104,7 @@ class DiffReader # take the first element and check that it is an osmChange element @reader.read - raise APIBadUserInput.new("Document element should be 'osmChange'.") if @reader.name != 'osmChange' + raise OSM::APIBadUserInput.new("Document element should be 'osmChange'.") if @reader.name != 'osmChange' result = OSM::API.new.get_xml_doc result.root.name = "diffResult" @@ -185,7 +185,7 @@ class DiffReader # delete doesn't have to contain a full payload, according to # the wiki docs, so we just extract the things we need. new_id = xml['id'].to_i - raise API::APIBadXMLError.new(model, xml, "ID attribute is required") if new_id.nil? + raise OSM::APIBadXMLError.new(model, xml, "ID attribute is required") if new_id.nil? # if the ID is a placeholder then map it to the real ID model_sym = model.to_s.downcase.to_sym From 8abe7ec6ed86c05cf15303db0d32453c8ccdfbc9 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Mon, 19 Jul 2010 12:36:30 +0100 Subject: [PATCH 13/29] Fix typo that stopped monkey patch working --- config/initializers/abstract_adapter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/abstract_adapter.rb b/config/initializers/abstract_adapter.rb index d96742ee5..f9b711f6c 100644 --- a/config/initializers/abstract_adapter.rb +++ b/config/initializers/abstract_adapter.rb @@ -1,4 +1,4 @@ -if defined?(ActiveRecord::ConnectionAdaptors::AbstractAdaptor) +if defined?(ActiveRecord::ConnectionAdaptors::AbstractAdapter) module ActiveRecord module ConnectionAdapters class AbstractAdapter From 5e2b8d087c868107e6013f1745a09b0c1dffa4e9 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Mon, 19 Jul 2010 18:01:42 +0100 Subject: [PATCH 14/29] Make memory limits configurable and make them work with passenger --- config/application.yml | 5 +++- config/initializers/limits.rb | 4 --- config/initializers/memory_limits.rb | 44 ++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 5 deletions(-) delete mode 100644 config/initializers/limits.rb create mode 100644 config/initializers/memory_limits.rb diff --git a/config/application.yml b/config/application.yml index 1b38f8f74..95037f83e 100644 --- a/config/application.yml +++ b/config/application.yml @@ -28,7 +28,10 @@ standard_settings: &standard_settings spam_threshold: 50 # Default legale (jurisdiction location) for contributor terms default_legale: GB - + # Memory limits (in Mb) + #soft_memory_limit: 512 + #hard_memory_limit: 2048 + development: <<: *standard_settings diff --git a/config/initializers/limits.rb b/config/initializers/limits.rb deleted file mode 100644 index 9862036f7..000000000 --- a/config/initializers/limits.rb +++ /dev/null @@ -1,4 +0,0 @@ -# Set a hard limit of 1Gb on the virtual size of the process -if Process.const_defined?(:RLIMIT_AS) - Process.setrlimit Process::RLIMIT_AS, 1024*1024*1024, Process::RLIM_INFINITY -end diff --git a/config/initializers/memory_limits.rb b/config/initializers/memory_limits.rb new file mode 100644 index 000000000..bab94b09a --- /dev/null +++ b/config/initializers/memory_limits.rb @@ -0,0 +1,44 @@ +# Setup any specified hard limit on the virtual size of the process +if APP_CONFIG.include?('hard_memory_limit') and Process.const_defined?(:RLIMIT_AS) + Process.setrlimit Process::RLIMIT_AS, APP_CONFIG['hard_memory_limit']*1024*1024, Process::RLIM_INFINITY +end + +# If we're running under passenger and a soft memory limit is +# configured then setup some rack middleware to police the limit +if APP_CONFIG.include?('soft_memory_limit') and defined?(PhusionPassenger) + # Define some rack middleware to police the soft memory limit + module OSM + class MemoryLimit + def initialize(app) + @app = app + end + + def call(env) + # Process this requst + status, headers, body = @app.call(env) + + # Restart if we've hit our memory limit + if resident_size > APP_CONFIG['soft_memory_limit'] + Process.kill("USR1", 0) + end + + # Return the result of this request + [status, headers, body] + end + private + def resident_size + # Read statm to get process sizes. Format is + # Size RSS Shared Text Lib Data + fields = File.open("/proc/self/statm") do |file| + fields = file.gets.split(" ") + end + + # Return resident size in megabytes + return fields[1].to_i / 256 + end + end + end + + # Install the memory limit checker + Rails.configuration.middleware.use OSM::MemoryLimit +end From 723cb57e6dfac1d5d3255843b384bf5905f8098f Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Mon, 19 Jul 2010 18:15:40 +0100 Subject: [PATCH 15/29] Don't put MemoryLimit class in the OSM module as it breaks autoloading --- config/initializers/memory_limits.rb | 54 ++++++++++++++-------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/config/initializers/memory_limits.rb b/config/initializers/memory_limits.rb index bab94b09a..6f553aff6 100644 --- a/config/initializers/memory_limits.rb +++ b/config/initializers/memory_limits.rb @@ -7,38 +7,36 @@ end # configured then setup some rack middleware to police the limit if APP_CONFIG.include?('soft_memory_limit') and defined?(PhusionPassenger) # Define some rack middleware to police the soft memory limit - module OSM - class MemoryLimit - def initialize(app) - @app = app + class MemoryLimit + def initialize(app) + @app = app + end + + def call(env) + # Process this requst + status, headers, body = @app.call(env) + + # Restart if we've hit our memory limit + if resident_size > APP_CONFIG['soft_memory_limit'] + Process.kill("USR1", 0) end - - def call(env) - # Process this requst - status, headers, body = @app.call(env) - - # Restart if we've hit our memory limit - if resident_size > APP_CONFIG['soft_memory_limit'] - Process.kill("USR1", 0) - end - - # Return the result of this request - [status, headers, body] - end - private - def resident_size - # Read statm to get process sizes. Format is - # Size RSS Shared Text Lib Data - fields = File.open("/proc/self/statm") do |file| - fields = file.gets.split(" ") - end - - # Return resident size in megabytes - return fields[1].to_i / 256 + + # Return the result of this request + [status, headers, body] + end + private + def resident_size + # Read statm to get process sizes. Format is + # Size RSS Shared Text Lib Data + fields = File.open("/proc/self/statm") do |file| + fields = file.gets.split(" ") end + + # Return resident size in megabytes + return fields[1].to_i / 256 end end # Install the memory limit checker - Rails.configuration.middleware.use OSM::MemoryLimit + Rails.configuration.middleware.use MemoryLimit end From 84b39122f1f9d6bb057273d9e5fd8ecf3cc550dd Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 20 Jul 2010 08:55:08 +0100 Subject: [PATCH 16/29] Make the suspended user view work again The suspended user view was broken in 2a2818d so it threw an error instead of rendering a friendyish message. --- app/views/user/suspended.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/user/suspended.html.erb b/app/views/user/suspended.html.erb index fd6a4f441..0ea1cb50d 100644 --- a/app/views/user/suspended.html.erb +++ b/app/views/user/suspended.html.erb @@ -2,4 +2,4 @@

<%= t "user.suspended.heading" %>

-<%= t "user.suspended.body", link_to t("user.suspended.webmaster"), "mailto:webmaster@openstreetmap.org" %> +<%= t "user.suspended.body", :webmaster => link_to(t("user.suspended.webmaster"), "mailto:webmaster@openstreetmap.org") %> From 53b0ace4c0577385af71394f03e2f4e2fb810f77 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 20 Jul 2010 18:21:54 +0100 Subject: [PATCH 17/29] Remove maplint layer fron the map Remove the maplint layer from the map and change the way layers are encoded in URLs to make links more robust when the available layers are changed. --- public/javascripts/map.js | 73 +++++++++++++++++------------- public/openlayers/OpenStreetMap.js | 28 ------------ 2 files changed, 42 insertions(+), 59 deletions(-) diff --git a/public/javascripts/map.js b/public/javascripts/map.js index fd45d9304..6fcfdf120 100644 --- a/public/javascripts/map.js +++ b/public/javascripts/map.js @@ -34,21 +34,24 @@ function createMap(divName, options) { var mapnik = new OpenLayers.Layer.OSM.Mapnik(i18n("javascripts.map.base.mapnik"), { keyid: "mapnik", displayOutsideMaxExtent: true, - wrapDateLine: true + wrapDateLine: true, + layerCode: "M" }); map.addLayer(mapnik); var osmarender = new OpenLayers.Layer.OSM.Osmarender(i18n("javascripts.map.base.osmarender"), { keyid: "osmarender", displayOutsideMaxExtent: true, - wrapDateLine: true + wrapDateLine: true, + layerCode: "O" }); map.addLayer(osmarender); var cyclemap = new OpenLayers.Layer.OSM.CycleMap(i18n("javascripts.map.base.cycle_map"), { keyid: "cyclemap", displayOutsideMaxExtent: true, - wrapDateLine: true + wrapDateLine: true, + layerCode: "C" }); map.addLayer(cyclemap); @@ -60,16 +63,11 @@ function createMap(divName, options) { ], { displayOutsideMaxExtent: true, wrapDateLine: true, - numZoomLevels: 19 + numZoomLevels: 19, + layerCode: "N" }); map.addLayer(noname); - var maplint = new OpenLayers.Layer.OSM.Maplint(i18n("javascripts.map.overlays.maplint"), { - displayOutsideMaxExtent: true, - wrapDateLine: true - }); - map.addLayer(maplint); - var numZoomLevels = Math.max(mapnik.numZoomLevels, osmarender.numZoomLevels); markers = new OpenLayers.Layer.Markers("Markers", { @@ -226,39 +224,52 @@ function getEventPosition(event) { function getMapLayers() { var layerConfig = ""; - for (var layers = map.getLayersBy("isBaseLayer", true), i = 0; i < layers.length; i++) { - layerConfig += layers[i] == map.baseLayer ? "B" : "0"; - } - - for (var layers = map.getLayersBy("isBaseLayer", false), i = 0; i < layers.length; i++) { - layerConfig += layers[i].getVisibility() ? "T" : "F"; + for (var i = 0; i < map.layers.length; i++) { + if (map.layers[i].layerCode && map.layers[i].getVisibility()) { + layerConfig += map.layers[i].layerCode; + } } return layerConfig; } function setMapLayers(layerConfig) { - var l = 0; + if (layerConfig.charAt(0) == "B" || layerConfig.charAt(0) == "0") { + var l = 0; - for (var layers = map.getLayersBy("isBaseLayer", true), i = 0; i < layers.length; i++) { - var c = layerConfig.charAt(l++); + for (var layers = map.getLayersBy("isBaseLayer", true), i = 0; i < layers.length; i++) { + var c = layerConfig.charAt(l++); - if (c == "B") { - map.setBaseLayer(layers[i]); + if (c == "B") { + map.setBaseLayer(layers[i]); + } } - } - while (layerConfig.charAt(l) == "B" || layerConfig.charAt(l) == "0") { - l++; - } + while (layerConfig.charAt(l) == "B" || layerConfig.charAt(l) == "0") { + l++; + } - for (var layers = map.getLayersBy("isBaseLayer", false), i = 0; i < layers.length; i++) { - var c = layerConfig.charAt(l++); + for (var layers = map.getLayersBy("isBaseLayer", false), i = 0; i < layers.length; i++) { + var c = layerConfig.charAt(l++); - if (c == "T") { - layers[i].setVisibility(true); - } else if(c == "F") { - layers[i].setVisibility(false); + if (c == "T") { + layers[i].setVisibility(true); + } else if(c == "F") { + layers[i].setVisibility(false); + } + } + } else { + for (var i = 0; i < map.layers.length; i++) { + if (map.layers[i].layerCode && + layerConfig.indexOf(map.layers[i].layerCode) >= 0) { + if (map.layers[i].isBaseLayer) { + map.setBaseLayer(map.layers[i]); + } else { + map.layers[i].setVisibility(true); + } + } else { + map.layers[i].setVisibility(false); + } } } } diff --git a/public/openlayers/OpenStreetMap.js b/public/openlayers/OpenStreetMap.js index ce8a6e81f..69f141806 100644 --- a/public/openlayers/OpenStreetMap.js +++ b/public/openlayers/OpenStreetMap.js @@ -111,31 +111,3 @@ OpenLayers.Layer.OSM.CycleMap = OpenLayers.Class(OpenLayers.Layer.OSM, { CLASS_NAME: "OpenLayers.Layer.OSM.CycleMap" }); - -/** - * Class: OpenLayers.Layer.OSM.Maplint - * - * Inherits from: - * - - */ -OpenLayers.Layer.OSM.Maplint = OpenLayers.Class(OpenLayers.Layer.OSM, { - /** - * Constructor: OpenLayers.Layer.OSM.Maplint - * - * Parameters: - * name - {String} - * options - {Object} Hashtable of extra options to tag onto the layer - */ - initialize: function(name, options) { - var url = [ - "http://d.tah.openstreetmap.org/Tiles/maplint/${z}/${x}/${y}.png", - "http://e.tah.openstreetmap.org/Tiles/maplint/${z}/${x}/${y}.png", - "http://f.tah.openstreetmap.org/Tiles/maplint/${z}/${x}/${y}.png" - ]; - options = OpenLayers.Util.extend({ numZoomLevels: 18, isBaseLayer: false, visibility: false }, options); - var newArguments = [name, url, options]; - OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments); - }, - - CLASS_NAME: "OpenLayers.Layer.OSM.Maplint" -}); From ad116b243127bc37ea51d765c577de050b5ad33a Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 21 Jul 2010 09:07:38 +0100 Subject: [PATCH 18/29] Don't change the visibility of layers with no code When parsing a layer state ignore any layers with no code attached rather than turning them off - this ensures that the marker layer remains enabled and any markers can be displayed. --- public/javascripts/map.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/public/javascripts/map.js b/public/javascripts/map.js index 6fcfdf120..272913d20 100644 --- a/public/javascripts/map.js +++ b/public/javascripts/map.js @@ -260,15 +260,16 @@ function setMapLayers(layerConfig) { } } else { for (var i = 0; i < map.layers.length; i++) { - if (map.layers[i].layerCode && - layerConfig.indexOf(map.layers[i].layerCode) >= 0) { - if (map.layers[i].isBaseLayer) { - map.setBaseLayer(map.layers[i]); + if (map.layers[i].layerCode) { + if (layerConfig.indexOf(map.layers[i].layerCode) >= 0) { + if (map.layers[i].isBaseLayer) { + map.setBaseLayer(map.layers[i]); + } else { + map.layers[i].setVisibility(true); + } } else { - map.layers[i].setVisibility(true); + map.layers[i].setVisibility(false); } - } else { - map.layers[i].setVisibility(false); } } } From d87ea6863ad8d525d9320e6d1d13350f8263cf52 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 21 Jul 2010 14:49:09 +0100 Subject: [PATCH 19/29] Fix short links to drop the layers param for the default layer --- public/javascripts/site.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/public/javascripts/site.js b/public/javascripts/site.js index 0a5aae4ad..0e2c5aeb7 100644 --- a/public/javascripts/site.js +++ b/public/javascripts/site.js @@ -107,10 +107,8 @@ function updatelinks(lon,lat,zoom,layers,minlon,minlat,maxlon,maxlat,objtype,obj args[objtype] = objid; } - // This is a hack to omit the default mapnik layer (B000FTF) from - // the shortlink. B000FTFT is then the "Object" layer which we get - // on /?{node,way,relation}=id - if (layers && (layers != "B000FTF") && (layers != "B000FTFT")) { + // This is a hack to omit the default mapnik layer from the shortlink. + if (layers && layers != "M") { args["layers"] = layers; } else { From 51195c450d16e35a62bff2bbf6c9dd0923bd0db4 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 21 Jul 2010 21:00:26 +0100 Subject: [PATCH 20/29] Add support for CSS based control of user specific components Define some helper routines which can be used to make page elements only display when the logged in user matches certain conditions and add style rules to the layout to trigger those elements based on the logged in user. --- app/helpers/application_helper.rb | 39 +++++++++++++++++++++++++++++++ app/views/layouts/site.html.erb | 1 + 2 files changed, 40 insertions(+) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5fa021bcf..3d2c70a13 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -40,6 +40,45 @@ module ApplicationHelper return js end + def style_rules + css = "" + + css << ".hidden { display: none }"; + css << ".hide_unless_logged_in { display: none }" unless @user; + css << ".hide_if_logged_in { display: none }" if @user; + css << ".hide_if_user_#{@user.id} { display: none }" if @user; + css << ".show_if_user_#{@user.id} { display: inline }" if @user; + css << ".hide_unless_administrator { display: none }" unless @user and @user.administrator?; + + return content_tag(:style, css) + end + + def if_logged_in(tag = :div, &block) + concat(content_tag(tag, capture(&block), :class => "hide_unless_logged_in")) + end + + def if_not_logged_in(tag = :div, &block) + concat(content_tag(tag, capture(&block), :class => "hide_if_logged_in")) + end + + def if_user(user, tag = :div, &block) + if user + concat(content_tag(tag, capture(&block), :class => "hidden show_if_user_#{user.id}")) + end + end + + def unless_user(user, tag = :div, &block) + if user + concat(content_tag(tag, capture(&block), :class => "hide_if_user_#{user.id}")) + else + concat(content_tag(tag, capture(&block))) + end + end + + def if_administrator(tag = :div, &block) + concat(content_tag(tag, capture(&block), :class => "hide_unless_administrator")) + end + def describe_location(lat, lon, zoom = nil, language = nil) zoom = zoom || 14 language = language || request.user_preferred_languages.join(',') diff --git a/app/views/layouts/site.html.erb b/app/views/layouts/site.html.erb index c17255709..6a820ef26 100644 --- a/app/views/layouts/site.html.erb +++ b/app/views/layouts/site.html.erb @@ -13,6 +13,7 @@ <%= stylesheet_link_tag 'print', :media => "print" %> <%= tag("link", { :rel => "search", :type => "application/opensearchdescription+xml", :title => "OpenStreetMap Search", :href => "/opensearch/osm.xml" }) %> <%= tag("meta", { :name => "description", :content => "OpenStreetMap is the free wiki world map." }) %> + <%= style_rules %> <%= yield :head %> <%= t 'layouts.project_name.title' %><%= ' | '+ h(@title) if @title %> From 6f73468f188630be503cdb19b00be7d1ea888785 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 21 Jul 2010 21:11:52 +0100 Subject: [PATCH 21/29] Convert diary views to use CSS based user specific components --- app/views/diary_entry/_diary_comment.html.erb | 4 +-- app/views/diary_entry/_diary_entry.html.erb | 31 +++++++++++-------- app/views/diary_entry/list.html.erb | 4 +-- app/views/diary_entry/view.html.erb | 24 +++++++------- .../functional/diary_entry_controller_test.rb | 4 ++- 5 files changed, 37 insertions(+), 30 deletions(-) diff --git a/app/views/diary_entry/_diary_comment.html.erb b/app/views/diary_entry/_diary_comment.html.erb index 77238b4d3..a0e75ecce 100644 --- a/app/views/diary_entry/_diary_comment.html.erb +++ b/app/views/diary_entry/_diary_comment.html.erb @@ -1,7 +1,7 @@ <%= user_thumbnail diary_comment.user, :style => "float: right" %>

<%= t('diary_entry.diary_comment.comment_from', :link_user => (link_to h(diary_comment.user.display_name), :controller => 'user', :action => 'view', :display_name => diary_comment.user.display_name), :comment_created_at => l(diary_comment.created_at, :format => :friendly)) %>

<%= htmlize(diary_comment.body) %> -<% if @user && @user.administrator? %> -<%= link_to t('diary_entry.diary_comment.hide_link'), {:action => 'hidecomment', :display_name => @user.display_name, :id => diary_comment.diary_entry.id, :comment => diary_comment.id}, {:confirm => t('diary_entry.diary_comment.confirm')} %> +<% if_administrator(:span) do %> + <%= link_to t('diary_entry.diary_comment.hide_link'), {:action => 'hidecomment', :display_name => diary_comment.diary_entry.user.display_name, :id => diary_comment.diary_entry.id, :comment => diary_comment.id}, {:confirm => t('diary_entry.diary_comment.confirm')} %> <% end %>
diff --git a/app/views/diary_entry/_diary_entry.html.erb b/app/views/diary_entry/_diary_entry.html.erb index 8991e1d54..d6e21869f 100644 --- a/app/views/diary_entry/_diary_entry.html.erb +++ b/app/views/diary_entry/_diary_entry.html.erb @@ -1,25 +1,30 @@ <%= link_to h(diary_entry.title), :action => 'view', :display_name => diary_entry.user.display_name, :id => diary_entry.id %>
+
-<%= htmlize(diary_entry.body) %> + <%= htmlize(diary_entry.body) %>
+ <% if diary_entry.latitude and diary_entry.longitude %> -<%= render :partial => "location", :object => diary_entry %> -
+ <%= render :partial => "location", :object => diary_entry %> +
<% end %> + <%= t 'diary_entry.diary_entry.posted_by', :link_user => (link_to h(diary_entry.user.display_name), :controller => 'user', :action => 'view', :display_name => diary_entry.user.display_name), :created => l(diary_entry.created_at, :format => :friendly), :language_link => (link_to h(diary_entry.language.name), :controller => 'diary_entry', :action => 'list', :language => diary_entry.language_code) %> + <% if params[:action] == 'list' %> -
-<%= link_to t('diary_entry.diary_entry.comment_link'), :action => 'view', :display_name => diary_entry.user.display_name, :id => diary_entry.id, :anchor => 'newcomment' %> -| -<%= link_to t('diary_entry.diary_entry.reply_link'), :controller => 'message', :action => 'new', :display_name => diary_entry.user.display_name, :title => "Re: #{diary_entry.title}" %> -| -<%= link_to t('diary_entry.diary_entry.comment_count', :count => diary_entry.visible_comments.count), :action => 'view', :display_name => diary_entry.user.display_name, :id => diary_entry.id, :anchor => 'comments' %> +
+ <%= link_to t('diary_entry.diary_entry.comment_link'), :action => 'view', :display_name => diary_entry.user.display_name, :id => diary_entry.id, :anchor => 'newcomment' %> + | + <%= link_to t('diary_entry.diary_entry.reply_link'), :controller => 'message', :action => 'new', :display_name => diary_entry.user.display_name, :title => "Re: #{diary_entry.title}" %> + | + <%= link_to t('diary_entry.diary_entry.comment_count', :count => diary_entry.visible_comments.count), :action => 'view', :display_name => diary_entry.user.display_name, :id => diary_entry.id, :anchor => 'comments' %> <% end %> -<% if @user == diary_entry.user %> -| <%= link_to t('diary_entry.diary_entry.edit_link'), :action => 'edit', :display_name => @user.display_name, :id => diary_entry.id %> +<% if_user(diary_entry.user, :span) do %> + | <%= link_to t('diary_entry.diary_entry.edit_link'), :action => 'edit', :display_name => diary_entry.user.display_name, :id => diary_entry.id %> <% end %> -<% if @user && @user.administrator? %> -| <%= link_to t('diary_entry.diary_entry.hide_link'), {:action => 'hide', :display_name => @user.display_name, :id => diary_entry.id}, {:confirm => t('diary_entry.diary_entry.confirm')} %> +<% if_administrator(:span) do %> + | <%= link_to t('diary_entry.diary_entry.hide_link'), {:action => 'hide', :display_name => diary_entry.user.display_name, :id => diary_entry.id}, {:confirm => t('diary_entry.diary_entry.confirm')} %> <% end %> +

diff --git a/app/views/diary_entry/list.html.erb b/app/views/diary_entry/list.html.erb index 9fbb9ca32..1be32fd21 100644 --- a/app/views/diary_entry/list.html.erb +++ b/app/views/diary_entry/list.html.erb @@ -5,11 +5,11 @@

<%= h(@title) %>

<% if @this_user %> - <% if @user == @this_user %> + <% if_user(@this_user) do %> <%= link_to image_tag("new.png", :border=>0) + t('diary_entry.list.new'), {:controller => 'diary_entry', :action => 'new'}, {:title => t('diary_entry.list.new_title')} %> <% end %> <% else %> - <% if @user %> + <% if_logged_in do %> <%= link_to image_tag("new.png", :border=>0) + t('diary_entry.list.new'), {:controller => 'diary_entry', :action => 'new'}, {:title => t('diary_entry.list.new_title')} %> <% end %> <% end %> diff --git a/app/views/diary_entry/view.html.erb b/app/views/diary_entry/view.html.erb index 312b7b81a..c3e49a227 100644 --- a/app/views/diary_entry/view.html.erb +++ b/app/views/diary_entry/view.html.erb @@ -8,19 +8,19 @@ <%= render :partial => 'diary_comment', :collection => @entry.visible_comments %> -<% if @user %> +<% if_logged_in(:div) do %> +

<%= t 'diary_entry.view.leave_a_comment' %>

-

<%= t 'diary_entry.view.leave_a_comment' %>

-<%= error_messages_for 'diary_comment' %> -<% form_for :diary_comment, @diary_comment, :url => { :action => 'comment' } do |f| %> -<%= f.text_area :body, :cols => 80, :rows => 5 %> -
-
-<%= submit_tag t('diary_entry.view.save_button') %> + <%= error_messages_for 'diary_comment' %> + + <% form_for :diary_comment, @diary_comment, :url => { :action => 'comment' } do |f| %> + <%= f.text_area :body, :cols => 80, :rows => 5 %> +
+
+ <%= submit_tag t('diary_entry.view.save_button') %> + <% end %> <% end %> -<% else %> - -

<%= t("diary_entry.view.login_to_leave_a_comment", :login_link => link_to(t("diary_entry.view.login"), :controller => 'user', :action => 'login', :referer => request.request_uri)) %>

- +<% if_not_logged_in(:div) do %> +

<%= t("diary_entry.view.login_to_leave_a_comment", :login_link => link_to(t("diary_entry.view.login"), :controller => 'user', :action => 'login', :referer => request.request_uri)) %>

<% end %> diff --git a/test/functional/diary_entry_controller_test.rb b/test/functional/diary_entry_controller_test.rb index bd65088e4..38c7bddcd 100644 --- a/test/functional/diary_entry_controller_test.rb +++ b/test/functional/diary_entry_controller_test.rb @@ -137,7 +137,9 @@ class DiaryEntryControllerTest < ActionController::TestCase assert_select "p", :text => /#{new_body}/, :count => 1 assert_select "abbr[class=geo][title=#{number_with_precision(new_latitude, :precision => 4)}; #{number_with_precision(new_longitude, :precision => 4)}]", :count => 1 # As we're not logged in, check that you cannot edit - assert_select "a[href='/user/#{users(:normal_user).display_name}/diary/#{diary_entries(:normal_user_entry_1).id}/edit']", :text => "Edit this entry", :count => 0 + assert_select "span[class=hidden show_if_user_#{users(:normal_user).id}]", :count => 1 do + assert_select "a[href='/user/#{users(:normal_user).display_name}/diary/#{diary_entries(:normal_user_entry_1).id}/edit']", :text => "Edit this entry", :count => 1 + end end end end From 5a2ffa227c99a271366735fa43a02ef93b99a673 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 21 Jul 2010 21:48:32 +0100 Subject: [PATCH 22/29] Convert trace views to use CSS based user specific components --- app/controllers/trace_controller.rb | 6 +++--- app/views/trace/_trace_form.html.erb | 4 ++-- app/views/trace/_trace_header.html.erb | 14 ++++++++------ app/views/trace/list.html.erb | 2 +- app/views/trace/view.html.erb | 18 ++++++++---------- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/app/controllers/trace_controller.rb b/app/controllers/trace_controller.rb index c51f54c5e..d82308baa 100644 --- a/app/controllers/trace_controller.rb +++ b/app/controllers/trace_controller.rb @@ -23,10 +23,10 @@ class TraceController < ApplicationController # Counts and selects pages of GPX traces for various criteria (by user, tags, public etc.). # target_user - if set, specifies the user to fetch traces for. if not set will fetch all traces - def list(target_user = nil, action = "list") + def list # from display name, pick up user id if one user's traces only display_name = params[:display_name] - if target_user.nil? and !display_name.blank? + if !display_name.blank? target_user = User.find(:first, :conditions => { :status => ["active", "confirmed"], :display_name => display_name }) if target_user.nil? @title = t'trace.no_such_user.title' @@ -103,7 +103,7 @@ class TraceController < ApplicationController end # final helper vars for view - @action = action + @target_user = target_user @display_name = target_user.display_name if target_user @all_tags = tagset.values @trace = Trace.new(:visibility => default_visibility) if @user diff --git a/app/views/trace/_trace_form.html.erb b/app/views/trace/_trace_form.html.erb index 3d93b65e8..c6e755b1e 100644 --- a/app/views/trace/_trace_form.html.erb +++ b/app/views/trace/_trace_form.html.erb @@ -1,5 +1,5 @@ -<% if @user.traces.count(:conditions => ["inserted=?", false]) > 4 %> -

<%= t'trace.trace_header.traces_waiting', :count => @user.traces.count(:conditions => ["inserted=?", false]) %>

+<% if @target_user.traces.count(:conditions => ["inserted=?", false]) > 4 %> +

<%= t'trace.trace_header.traces_waiting', :count => @target_user.traces.count(:conditions => ["inserted=?", false]) %>

<% end %> <% form_for :trace, @trace, :url => { :action => "create" }, :html => { :multipart => true } do |f| %> diff --git a/app/views/trace/_trace_header.html.erb b/app/views/trace/_trace_header.html.erb index 85de77396..37b944fd4 100644 --- a/app/views/trace/_trace_header.html.erb +++ b/app/views/trace/_trace_header.html.erb @@ -6,13 +6,15 @@

<%= rss_link_to :action => 'georss', :display_name => @display_name, :tag => @tag %> - <% if @user.nil? or @display_name.nil? or @user.display_name != @display_name %> + <% unless_user(@target_user, :span) do %> | <%= link_to t('trace.trace_header.see_just_your_traces'), :action => 'mine' %> <% end %> - <% if @tag or @display_name %> - | <%= link_to t('trace.trace_header.see_all_traces'), :controller => 'trace', :action => 'list' %> - <% end %> - <% if @tag and @user and @user.display_name == @display_name %> - | <%= link_to t('trace.trace_header.see_your_traces'), :controller => 'trace', :action => 'mine' %> + <% if @tag %> + <% if @display_name %> + | <%= link_to t('trace.trace_header.see_all_traces'), :controller => 'trace', :action => 'list' %> + <% end %> + <% if_user(@target_user, :span) do %> + | <%= link_to t('trace.trace_header.see_your_traces'), :controller => 'trace', :action => 'mine' %> + <% end %> <% end %>

diff --git a/app/views/trace/list.html.erb b/app/views/trace/list.html.erb index fe7e5a13a..a954dd766 100644 --- a/app/views/trace/list.html.erb +++ b/app/views/trace/list.html.erb @@ -1,5 +1,5 @@ <%= render :partial => 'trace_header' %> -<% if @user and @user.display_name == @display_name %> +<% if_user(@target_user) do %> <%= render :partial => 'trace_form' %> <% end %> <%= render :partial => 'trace_list' %> diff --git a/app/views/trace/view.html.erb b/app/views/trace/view.html.erb index 73638cb3d..bfef5d901 100644 --- a/app/views/trace/view.html.erb +++ b/app/views/trace/view.html.erb @@ -52,13 +52,11 @@

- - - <% if @trace.user == @user %> - - <% end %> - <% if @trace.user == @user %> - - <% end %> - -
<%= button_to t('trace.view.edit_track'), :controller => 'trace', :action => 'edit', :id => @trace.id %><%= button_to t('trace.view.delete_track'), :controller => 'trace', :action => 'delete', :id => @trace.id %>
+<% if_user(@trace.user) do %> + + + + + +
<%= button_to t('trace.view.edit_track'), :controller => 'trace', :action => 'edit', :id => @trace.id %><%= button_to t('trace.view.delete_track'), :controller => 'trace', :action => 'delete', :id => @trace.id %>
+<% end %> From b551fef0b77af868ba1c6af933df551f54b5ec12 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 22 Jul 2010 00:20:31 +0100 Subject: [PATCH 23/29] Present "too many pending traces" message as a warning box --- app/controllers/trace_controller.rb | 4 ++++ app/views/trace/_trace_form.html.erb | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/trace_controller.rb b/app/controllers/trace_controller.rb index d82308baa..0ec033ae7 100644 --- a/app/controllers/trace_controller.rb +++ b/app/controllers/trace_controller.rb @@ -143,6 +143,10 @@ class TraceController < ApplicationController logger.info("id is #{@trace.id}") flash[:notice] = t 'trace.create.trace_uploaded' + if @user.traces.count(:conditions => { :inserted => false }) > 4 + flash[:warning] = t 'trace.trace_header.traces_waiting', :count => @user.traces.count(:conditions => { :inserted => false }) + end + redirect_to :action => 'mine' end else diff --git a/app/views/trace/_trace_form.html.erb b/app/views/trace/_trace_form.html.erb index c6e755b1e..194b8b2bc 100644 --- a/app/views/trace/_trace_form.html.erb +++ b/app/views/trace/_trace_form.html.erb @@ -1,7 +1,3 @@ -<% if @target_user.traces.count(:conditions => ["inserted=?", false]) > 4 %> -

<%= t'trace.trace_header.traces_waiting', :count => @target_user.traces.count(:conditions => ["inserted=?", false]) %>

-<% end %> - <% form_for :trace, @trace, :url => { :action => "create" }, :html => { :multipart => true } do |f| %> From cd3fc33171daf8ae2d2a0cc3ff4261c021da3f85 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 22 Jul 2010 00:27:35 +0100 Subject: [PATCH 24/29] Remove the user type from cache keys --- app/controllers/application_controller.rb | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c7c6c4add..9af28de6f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -250,17 +250,7 @@ class ApplicationController < ActionController::Base cache_path = options[:cache_path] || Hash.new options[:cache_path] = Proc.new do |controller| - user = controller.instance_variable_get("@user") - - case - when user.nil? then user = :none - when user.display_name == controller.params[:display_name] then user = :self - when user.administrator? then user = :administrator - when user.moderator? then user = :moderator - else user = :other - end - - cache_path.merge(controller.params).merge(:locale => I18n.locale, :user => user) + cache_path.merge(controller.params).merge(:locale => I18n.locale) end actions.push(options) From 0e19a9290d77430dc68479ea469f19fb83ab0fcc Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 22 Jul 2010 00:33:07 +0100 Subject: [PATCH 25/29] Remove use of wildcard cache expiry Instead of doing wildcard cache expiry, just iterate over the available locales, expiring the requested entry in each locale. --- app/controllers/application_controller.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9af28de6f..c50c5f664 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -261,8 +261,9 @@ class ApplicationController < ActionController::Base ## # extend expire_action to expire all variants def expire_action(options = {}) - path = ActionCachePath.path_for(self, options, false).gsub('?', '.').gsub(':', '.') - expire_fragment(Regexp.new(Regexp.escape(path) + "\\..*")) + I18n.available_locales.each do |locale| + super options.merge(:locale => locale) + end end ## From af70363d029202b53c5813e06117dfdc1208cccd Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 22 Jul 2010 19:53:11 +0100 Subject: [PATCH 26/29] Don't cache actions with a page number --- app/controllers/application_controller.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c50c5f664..1605e1133 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -249,6 +249,16 @@ class ApplicationController < ActionController::Base options = actions.extract_options! cache_path = options[:cache_path] || Hash.new + options[:unless] = case options[:unless] + when NilClass then Array.new + when Array then options[:unless] + else unlessp = [ options[:unless] ] + end + + options[:unless].push(Proc.new do |controller| + controller.params.include?(:page) + end) + options[:cache_path] = Proc.new do |controller| cache_path.merge(controller.params).merge(:locale => I18n.locale) end From f30dcd1a629449c19bc75fb3e6baa2a58f57d3c5 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 22 Jul 2010 19:54:46 +0100 Subject: [PATCH 27/29] We can cache the trace list for logged in users now --- app/controllers/trace_controller.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/trace_controller.rb b/app/controllers/trace_controller.rb index 0ec033ae7..abd59aeb2 100644 --- a/app/controllers/trace_controller.rb +++ b/app/controllers/trace_controller.rb @@ -15,8 +15,7 @@ class TraceController < ApplicationController before_filter :offline_redirect, :only => [:create, :edit, :delete, :data, :api_data, :api_create] around_filter :api_call_handle_error, :only => [:api_details, :api_data, :api_create] - caches_action :list, :unless => :logged_in?, :layout => false - caches_action :view, :layout => false + caches_action :list, :view, :layout => false caches_action :georss, :layout => true cache_sweeper :trace_sweeper, :only => [:create, :edit, :delete, :api_create], :unless => OSM_STATUS == :database_offline cache_sweeper :tracetag_sweeper, :only => [:create, :edit, :delete, :api_create], :unless => OSM_STATUS == :database_offline From 9f83acfb44d13fda8600ba8e730be722e08e7fb8 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 22 Jul 2010 21:00:39 +0100 Subject: [PATCH 28/29] Move the trace upload form from the list to a create trace page --- app/views/trace/_trace_form.html.erb | 9 ------ app/views/trace/_trace_header.html.erb | 20 -------------- app/views/trace/_trace_list.html.erb | 13 --------- app/views/trace/create.html.erb | 10 ++++++- app/views/trace/list.html.erb | 38 +++++++++++++++++++++++--- config/locales/en.yml | 3 +- 6 files changed, 45 insertions(+), 48 deletions(-) delete mode 100644 app/views/trace/_trace_form.html.erb delete mode 100644 app/views/trace/_trace_header.html.erb delete mode 100644 app/views/trace/_trace_list.html.erb diff --git a/app/views/trace/_trace_form.html.erb b/app/views/trace/_trace_form.html.erb deleted file mode 100644 index 194b8b2bc..000000000 --- a/app/views/trace/_trace_form.html.erb +++ /dev/null @@ -1,9 +0,0 @@ -<% form_for :trace, @trace, :url => { :action => "create" }, :html => { :multipart => true } do |f| %> -
<%= t'trace.trace_form.upload_gpx' %><%= f.file_field :gpx_file, :size => 50, :maxlength => 255 %>
- - - - - -
<%= t'trace.trace_form.upload_gpx' %><%= f.file_field :gpx_file, :size => 50, :maxlength => 255 %>
<%= t'trace.trace_form.description' %><%= f.text_field :description, :size => 50, :maxlength => 255 %>
<%= t'trace.trace_form.tags' %><%= f.text_field :tagstring, :size => 50, :maxlength => 255 %> (<%= t'trace.trace_form.tags_help' %>)
<%= t'trace.trace_form.visibility' %><%= f.select :visibility, [[t('trace.visibility.private'),"private"],[t('trace.visibility.public'),"public"],[t('trace.visibility.trackable'),"trackable"],[t('trace.visibility.identifiable'),"identifiable"]] %> (<%= t'trace.trace_form.visibility_help' %>)
<%= submit_tag t('trace.trace_form.upload_button') %> | <%= t'trace.trace_form.help' %>
-<% end %> diff --git a/app/views/trace/_trace_header.html.erb b/app/views/trace/_trace_header.html.erb deleted file mode 100644 index 37b944fd4..000000000 --- a/app/views/trace/_trace_header.html.erb +++ /dev/null @@ -1,20 +0,0 @@ -

<%= h(@title) %>

- -<% content_for :head do %> -<%= auto_discovery_link_tag :atom, :action => 'georss', :display_name => @display_name, :tag => @tag %> -<% end %> - -

- <%= rss_link_to :action => 'georss', :display_name => @display_name, :tag => @tag %> - <% unless_user(@target_user, :span) do %> - | <%= link_to t('trace.trace_header.see_just_your_traces'), :action => 'mine' %> - <% end %> - <% if @tag %> - <% if @display_name %> - | <%= link_to t('trace.trace_header.see_all_traces'), :controller => 'trace', :action => 'list' %> - <% end %> - <% if_user(@target_user, :span) do %> - | <%= link_to t('trace.trace_header.see_your_traces'), :controller => 'trace', :action => 'mine' %> - <% end %> - <% end %> -

diff --git a/app/views/trace/_trace_list.html.erb b/app/views/trace/_trace_list.html.erb deleted file mode 100644 index 968fd85be..000000000 --- a/app/views/trace/_trace_list.html.erb +++ /dev/null @@ -1,13 +0,0 @@ -<%= render :partial => 'trace_paging_nav' %> - - - - - - - <%= render :partial => 'trace', :collection => @traces unless @traces.nil? %> -
- -<%= render :partial => 'trace_paging_nav' %> - -<%= render :partial => 'trace_optionals' %> diff --git a/app/views/trace/create.html.erb b/app/views/trace/create.html.erb index 140b74918..ba8b8e700 100644 --- a/app/views/trace/create.html.erb +++ b/app/views/trace/create.html.erb @@ -2,4 +2,12 @@ <%= error_messages_for 'trace' %> -<%= render :partial => 'trace_form' %> +<% form_for :trace, @trace, :url => { :action => "create" }, :html => { :multipart => true } do |f| %> + + + + + + +
<%= t'trace.trace_form.upload_gpx' %><%= f.file_field :gpx_file, :size => 50, :maxlength => 255 %>
<%= t'trace.trace_form.description' %><%= f.text_field :description, :size => 50, :maxlength => 255 %>
<%= t'trace.trace_form.tags' %><%= f.text_field :tagstring, :size => 50, :maxlength => 255 %> (<%= t'trace.trace_form.tags_help' %>)
<%= t'trace.trace_form.visibility' %><%= f.select :visibility, [[t('trace.visibility.private'),"private"],[t('trace.visibility.public'),"public"],[t('trace.visibility.trackable'),"trackable"],[t('trace.visibility.identifiable'),"identifiable"]] %> (<%= t'trace.trace_form.visibility_help' %>)
<%= submit_tag t('trace.trace_form.upload_button') %> | <%= t'trace.trace_form.help' %>
+<% end %> diff --git a/app/views/trace/list.html.erb b/app/views/trace/list.html.erb index a954dd766..78d203756 100644 --- a/app/views/trace/list.html.erb +++ b/app/views/trace/list.html.erb @@ -1,5 +1,35 @@ -<%= render :partial => 'trace_header' %> -<% if_user(@target_user) do %> - <%= render :partial => 'trace_form' %> +

<%= h(@title) %>

+ +<% content_for :head do %> +<%= auto_discovery_link_tag :atom, :action => 'georss', :display_name => @display_name, :tag => @tag %> <% end %> -<%= render :partial => 'trace_list' %> + +

+ <%= rss_link_to :action => 'georss', :display_name => @display_name, :tag => @tag %> + <% unless_user(@target_user, :span) do %> + | <%= link_to t('trace.trace_header.your_traces'), :action => 'mine' %> + <% end %> + | <%= link_to t('trace.trace_header.upload_trace'), :action => 'create' %> + <% if @tag %> + <% if @display_name %> + | <%= link_to t('trace.trace_header.see_all_traces'), :controller => 'trace', :action => 'list' %> + <% end %> + <% if_user(@target_user, :span) do %> + | <%= link_to t('trace.trace_header.see_your_traces'), :controller => 'trace', :action => 'mine' %> + <% end %> + <% end %> +

+ +<%= render :partial => 'trace_paging_nav' %> + + + + + + + <%= render :partial => 'trace', :collection => @traces unless @traces.nil? %> +
+ +<%= render :partial => 'trace_paging_nav' %> + +<%= render :partial => 'trace_optionals' %> diff --git a/config/locales/en.yml b/config/locales/en.yml index ce80b6931..61616c562 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1351,7 +1351,8 @@ en: help: "Help" help_url: "http://wiki.openstreetmap.org/wiki/Upload" trace_header: - see_just_your_traces: "See just your traces, or upload a trace" + your_traces: "See just your traces" + upload_trace: "Upload a trace" see_all_traces: "See all traces" see_your_traces: "See all your traces" traces_waiting: "You have {{count}} traces waiting for upload. Please consider waiting for these to finish before uploading any more, so as not to block the queue for other users." From 72984673067a37a1ea687709a33b18263f850633 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 23 Jul 2010 00:53:36 +0100 Subject: [PATCH 29/29] Fix scoping of reverse geocode result --- app/helpers/application_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 3d2c70a13..2ccfcca2b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -85,8 +85,8 @@ module ApplicationHelper url = "http://nominatim.openstreetmap.org/reverse?lat=#{lat}&lon=#{lon}&zoom=#{zoom}&accept-language=#{language}" begin - Timeout::timeout(4) do - response = REXML::Document.new(Net::HTTP.get(URI.parse(url))) + response = Timeout::timeout(4) do + REXML::Document.new(Net::HTTP.get(URI.parse(url))) end rescue Exception response = nil