diff options
Diffstat (limited to 'web/lib/ui/test.rb')
-rw-r--r-- | web/lib/ui/test.rb | 54 |
1 files changed, 4 insertions, 50 deletions
diff --git a/web/lib/ui/test.rb b/web/lib/ui/test.rb index 9117da1..ba66f3b 100644 --- a/web/lib/ui/test.rb +++ b/web/lib/ui/test.rb @@ -7,6 +7,8 @@ class Taginfo < Sinatra::Base end get! '/test/tags' do + @section = 'test' + @section_title = 'Test' @title = ['Tags', 'Test'] limit = 300; (@min, @max) = @db.select('SELECT min(count) AS min, max(count) AS max FROM popular_keys').get_columns(:min, :max) @@ -18,59 +20,11 @@ class Taginfo < Sinatra::Base end get '/test/wiki_import' do + @section = 'test' + @section_title = 'Test' @title = ['Wiki Import', 'Test'] @invalid_page_titles = @db.select('SELECT * FROM invalid_page_titles').execute() erb :'test/wiki_import' end - get %r{^/test/keys/(.*)} do |key| - if params[:key].nil? - @key = key - else - @key = params[:key] - end - - @key_html = escape_html(@key) - @key_uri = escape(@key) - @key_json = @key.to_json - @key_pp = pp_key(@key) - - @title = [@key_html, 'Keys'] - - @filter_type = get_filter() - @sel = Hash.new('') - @sel[@filter_type] = ' selected="selected"' - - @count_all_values = @db.select("SELECT count_#{@filter_type} FROM db.keys").condition('key = ?', @key).get_first_value().to_i - - @desc = h(@db.select("SELECT description FROM wiki.wikipages WHERE lang='en' AND key=? AND value IS NULL", @key).get_first_value()) - @desc = '<i>no description in wiki</i>' if @desc == '' - - @prevalent_values = @db.select("SELECT value, count_#{@filter_type} AS count FROM tags"). - condition('key=?', @key). - condition('count > ?', @count_all_values * 0.02). - order_by(:count, 'DESC'). - execute().map{ |row| [{ 'value' => row['value'], 'count' => row['count'].to_i }] } - - # add "(other)" label for the rest of the values - sum = @prevalent_values.inject(0){ |sum, x| sum += x[0]['count'] } - if sum < @count_all_values - @prevalent_values << [{ 'value' => '(other)', 'count' => @count_all_values - sum }] - end - - @wiki_count = @db.count('wiki.wikipages').condition('value IS NULL').condition('key=?', @key).get_first_value().to_i - - (@merkaartor_type, @merkaartor_link, @merkaartor_selector) = @db.select('SELECT tag_type, link, selector FROM merkaartor.keys').condition('key=?', @key).get_columns(:tag_type, :link, :selector) - @merkaartor_images = [:node, :way, :area, :relation].map{ |type| - name = type.to_s.capitalize - '<img src="/img/types/' + (@merkaartor_selector =~ /Type is #{name}/ ? type.to_s : 'none') + '.16.png" alt="' + name + '" title="' + name + '"/>' - }.join(' ') - - @merkaartor_values = @db.select('SELECT value FROM merkaartor.tags').condition('key=?', @key).order_by(:value).execute().map{ |row| row['value'] } - - @merkaartor_desc = @db.select('SELECT lang, description FROM key_descriptions').condition('key=?', @key).order_by(:lang).execute() - - erb :'test/key' - end - end |