aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--taginfo-config-example.json5
-rw-r--r--web/lib/utils.rb40
-rw-r--r--web/views/key.erb2
-rw-r--r--web/views/tag.erb2
4 files changed, 33 insertions, 16 deletions
diff --git a/taginfo-config-example.json b/taginfo-config-example.json
index 74789c2..2ea5db2 100644
--- a/taginfo-config-example.json
+++ b/taginfo-config-example.json
@@ -36,7 +36,10 @@
"url_prefix": "http://overpass-api.de/api/xapi_meta?"
},
"turbo": {
- "url_prefix": "http://overpass-turbo.eu/?"
+ "max_auto": 100,
+ "url_prefix": "http://overpass-turbo.eu/?",
+ "wizard_url_prefix": "http://overpass-turbo.eu/master?",
+ "wizard_area": "global"
},
"level0": {
"max_results": 50,
diff --git a/web/lib/utils.rb b/web/lib/utils.rb
index 33aac9b..7d64538 100644
--- a/web/lib/utils.rb
+++ b/web/lib/utils.rb
@@ -85,22 +85,36 @@ def josm_link(element, key, value=nil)
'<span class="button">' + external_link('josm_button', 'JOSM', 'http://localhost:8111/import?url=' + Rack::Utils::escape(xapi_url(element, key, value)), true) + '</span>'
end
-def turbo_link(filter, key, value=nil)
- template = 'key';
- parameters = { :key => key }
+def quote_double(text)
+ text.gsub(/["\\]/, "\\\\\\0")
+end
- unless value.nil?
- parameters[:value] = value;
- template += '-value'
- end
+def turbo_link(count, filter, key, value=nil)
+ if count <= TaginfoConfig.get('turbo.max_auto', 100)
+ key = quote_double(key)
+ if value.nil?
+ value = '*'
+ else
+ value = '"' + quote_double(value) + '"'
+ end
+ url = TaginfoConfig.get('turbo.wizard_url_prefix', 'http://overpass-turbo.eu/master?') + 'w=' + Rack::Utils::escape('"' + key + '"=' + value + ' ' + TaginfoConfig.get('turbo.wizard_area', 'global')) + '&R'
+ else
+ template = 'key';
+ parameters = { :key => key }
+
+ unless value.nil?
+ parameters[:value] = value;
+ template += '-value'
+ end
+
+ if filter != 'all'
+ template += '-type'
+ parameters[:type] = filter.chop
+ end
+ parameters[:template] = template
- if filter != 'all'
- template += '-type'
- parameters[:type] = filter.chop
+ url = TaginfoConfig.get('turbo.url_prefix', 'http://overpass-turbo.eu/?') + Rack::Utils::build_query(parameters)
end
- parameters[:template] = template
-
- url = TaginfoConfig.get('turbo.url_prefix', 'http://overpass-turbo.eu/?') + Rack::Utils::build_query(parameters)
return '<span class="button">' + external_link('turbo_button', '<img src="/img/turbo.png"/> overpass turbo', url, true) + '</span>'
end
diff --git a/web/views/key.erb b/web/views/key.erb
index a4a415a..d168aa4 100644
--- a/web/views/key.erb
+++ b/web/views/key.erb
@@ -20,7 +20,7 @@
<% else %>
<span class="button disabled" title="<%= h(t.pages.key.button_disabled) %>">Level0 Editor</span>
<% end %>
- <%= turbo_link(@filter_type, @key) %>
+ <%= turbo_link(@count_all_values, @filter_type, @key) %>
</div>
<h1></h1>
<p><%= @desc %></p>
diff --git a/web/views/tag.erb b/web/views/tag.erb
index b3b7782..b1758fa 100644
--- a/web/views/tag.erb
+++ b/web/views/tag.erb
@@ -20,7 +20,7 @@
<% else %>
<span class="button disabled" title="<%= h(t.pages.tag.button_disabled) %>">Level0 Editor</span>
<% end %>
- <%= turbo_link(@filter_type, @key, @value) %>
+ <%= turbo_link(@count_all, @filter_type, @key, @value) %>
</div>
<h1></h1>
<p><%= @desc %></p>