diff options
-rw-r--r-- | web/lib/ui/keys.rb (renamed from web/lib/ui/keys_tags.rb) | 57 | ||||
-rw-r--r-- | web/lib/ui/tags.rb | 58 | ||||
-rwxr-xr-x | web/taginfo.rb | 3 |
3 files changed, 61 insertions, 57 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 + diff --git a/web/taginfo.rb b/web/taginfo.rb index 80ffe26..d972063 100755 --- a/web/taginfo.rb +++ b/web/taginfo.rb @@ -209,11 +209,12 @@ class Taginfo < Sinatra::Base load 'lib/ui/embed.rb' load 'lib/ui/help.rb' - load 'lib/ui/keys_tags.rb' + load 'lib/ui/keys.rb' load 'lib/ui/relation.rb' load 'lib/ui/reports.rb' load 'lib/ui/search.rb' load 'lib/ui/taginfo.rb' + load 'lib/ui/tags.rb' load 'lib/ui/test.rb' # run application |