summaryrefslogtreecommitdiff
path: root/web/lib/ui
diff options
context:
space:
mode:
authorJochen Topf <jochen@topf.org>2013-01-20 11:21:45 +0100
committerJochen Topf <jochen@topf.org>2013-01-20 11:21:45 +0100
commitb10a1ba32c53b764f2ba5fb597af015fc66af3bc (patch)
treeff2e8b6700d0a74e538d685d735c7effd4f1ae82 /web/lib/ui
parentad0df22a8f4b6e2546734f5990ea74bd73329d56 (diff)
downloadtaginfo-b10a1ba32c53b764f2ba5fb597af015fc66af3bc.tar
taginfo-b10a1ba32c53b764f2ba5fb597af015fc66af3bc.tar.gz
Split up keys_tags.rb
Diffstat (limited to 'web/lib/ui')
-rw-r--r--web/lib/ui/keys.rb (renamed from web/lib/ui/keys_tags.rb)57
-rw-r--r--web/lib/ui/tags.rb58
2 files changed, 59 insertions, 56 deletions
diff --git a/web/lib/ui/keys_tags.rb b/web/lib/ui/keys.rb
index 9e2962f..84e23f3 100644
--- a/web/lib/ui/keys_tags.rb
+++ b/web/lib/ui/keys.rb
@@ -1,4 +1,4 @@
-# web/lib/ui/keys_tags.rb
+# web/lib/ui/keys.rb
class Taginfo < Sinatra::Base
get %r{^/keys/(.*)} do |key|
@@ -67,60 +67,5 @@ class Taginfo < Sinatra::Base
erb :key
end
- #-------------------------------------
-
- get %r{^/tags/(.*)} do |tag|
- if tag.match(/=/)
- kv = tag.split('=', 2)
- else
- kv = [ tag, '' ]
- end
- if params[:key].nil?
- @key = kv[0]
- else
- @key = params[:key]
- end
- if params[:value].nil?
- @value = kv[1]
- else
- @value = params[:value]
- end
- @tag = @key + '=' + @value
-
- @key_uri = escape(@key)
-
- @title = [escape_html(@key) + '=' + escape_html(@value), t.osm.tags]
- section :tags
-
- @filter_type = get_filter()
- @sel = Hash.new('')
- @sel[@filter_type] = ' selected="selected"'
- @filter_xapi = { 'all' => '*', nil => '*', 'nodes' => 'node', 'ways' => 'way', 'relations' => 'relation' }[@filter_type];
-
- @josm_count = @db.count('josm_style_rules').condition('k = ?', @key).condition('v = ?', @value).get_first_value().to_i
- @wiki_count = @db.count('wiki.wikipages').condition('key=?', @key).condition('value=?', @value).get_first_value().to_i
- if @wiki_count == 0
- @wiki_count_key = @db.count('wiki.wikipages').condition('key=?', @key).condition('value IS NULL').get_first_value().to_i
- end
- @count_all = @db.select("SELECT count_#{@filter_type} FROM db.tags").condition('key = ? AND value = ?', @key, @value).get_first_value().to_i
-
- @desc = h(@db.select("SELECT description FROM wiki.wikipages WHERE lang=? AND key=? AND value=?", r18n.locale.code, @key, @value).get_first_value())
- @desc = h(@db.select("SELECT description FROM wiki.wikipages WHERE lang='en' AND key=? AND value=?", @key, @value).get_first_value()) if @desc == ''
- if @desc == ''
- @desc = "<span class='empty'>#{ t.pages.tag.no_description_in_wiki }</span>"
- else
- @desc = "<span title='#{ t.pages.tag.description_from_wiki }' tipsy='w'>#{ @desc }</span>"
- end
-
- @db.select("SELECT width, height, image_url, thumb_url_prefix, thumb_url_suffix FROM wiki.wikipages LEFT OUTER JOIN wiki.wiki_images USING(image) WHERE lang=? AND key=? AND value=? UNION SELECT width, height, image_url, thumb_url_prefix, thumb_url_suffix FROM wiki.wikipages LEFT OUTER JOIN wiki.wiki_images USING(image) WHERE lang='en' AND key=? AND value=? LIMIT 1", r18n.locale.code, @key, @value, @key, @value).
- execute() do |row|
- @image_url = build_image_url(row)
- end
-
- javascript_for(:flexigrid)
- javascript "#{ r18n.locale.code }/tag"
- erb :tag
- end
-
end
diff --git a/web/lib/ui/tags.rb b/web/lib/ui/tags.rb
new file mode 100644
index 0000000..525e157
--- /dev/null
+++ b/web/lib/ui/tags.rb
@@ -0,0 +1,58 @@
+# web/lib/ui/tags.rb
+class Taginfo < Sinatra::Base
+
+ get %r{^/tags/(.*)} do |tag|
+ if tag.match(/=/)
+ kv = tag.split('=', 2)
+ else
+ kv = [ tag, '' ]
+ end
+ if params[:key].nil?
+ @key = kv[0]
+ else
+ @key = params[:key]
+ end
+ if params[:value].nil?
+ @value = kv[1]
+ else
+ @value = params[:value]
+ end
+ @tag = @key + '=' + @value
+
+ @key_uri = escape(@key)
+
+ @title = [escape_html(@key) + '=' + escape_html(@value), t.osm.tags]
+ section :tags
+
+ @filter_type = get_filter()
+ @sel = Hash.new('')
+ @sel[@filter_type] = ' selected="selected"'
+ @filter_xapi = { 'all' => '*', nil => '*', 'nodes' => 'node', 'ways' => 'way', 'relations' => 'relation' }[@filter_type];
+
+ @josm_count = @db.count('josm_style_rules').condition('k = ?', @key).condition('v = ?', @value).get_first_value().to_i
+ @wiki_count = @db.count('wiki.wikipages').condition('key=?', @key).condition('value=?', @value).get_first_value().to_i
+ if @wiki_count == 0
+ @wiki_count_key = @db.count('wiki.wikipages').condition('key=?', @key).condition('value IS NULL').get_first_value().to_i
+ end
+ @count_all = @db.select("SELECT count_#{@filter_type} FROM db.tags").condition('key = ? AND value = ?', @key, @value).get_first_value().to_i
+
+ @desc = h(@db.select("SELECT description FROM wiki.wikipages WHERE lang=? AND key=? AND value=?", r18n.locale.code, @key, @value).get_first_value())
+ @desc = h(@db.select("SELECT description FROM wiki.wikipages WHERE lang='en' AND key=? AND value=?", @key, @value).get_first_value()) if @desc == ''
+ if @desc == ''
+ @desc = "<span class='empty'>#{ t.pages.tag.no_description_in_wiki }</span>"
+ else
+ @desc = "<span title='#{ t.pages.tag.description_from_wiki }' tipsy='w'>#{ @desc }</span>"
+ end
+
+ @db.select("SELECT width, height, image_url, thumb_url_prefix, thumb_url_suffix FROM wiki.wikipages LEFT OUTER JOIN wiki.wiki_images USING(image) WHERE lang=? AND key=? AND value=? UNION SELECT width, height, image_url, thumb_url_prefix, thumb_url_suffix FROM wiki.wikipages LEFT OUTER JOIN wiki.wiki_images USING(image) WHERE lang='en' AND key=? AND value=? LIMIT 1", r18n.locale.code, @key, @value, @key, @value).
+ execute() do |row|
+ @image_url = build_image_url(row)
+ end
+
+ javascript_for(:flexigrid)
+ javascript "#{ r18n.locale.code }/tag"
+ erb :tag
+ end
+
+end
+