diff options
-rw-r--r-- | web/lib/ui/embed.rb | 8 | ||||
-rw-r--r-- | web/views/embed/key.erb | 25 | ||||
-rw-r--r-- | web/views/embed/layout.erb | 50 | ||||
-rw-r--r-- | web/views/embed/tag.erb | 25 |
4 files changed, 84 insertions, 24 deletions
diff --git a/web/lib/ui/embed.rb b/web/lib/ui/embed.rb index 6561da6..5bf73ef 100644 --- a/web/lib/ui/embed.rb +++ b/web/lib/ui/embed.rb @@ -3,15 +3,15 @@ class Taginfo < Sinatra::Base get '/embed/key' do @key = params[:key] - @count = @db.select("SELECT count_all FROM db.keys").condition('key = ?', @key).get_first_value().to_i - erb :'embed/key', :layout => false + @res = @db.select("SELECT * FROM db.keys").condition('key = ?', @key).execute()[0] + erb :'embed/key', :layout => :'embed/layout' end get '/embed/tag' do @key = params[:key] @value = params[:value] - @count = @db.select("SELECT count_all FROM db.tags").condition('key = ?', @key).condition('value = ?', @value).get_first_value().to_i - erb :'embed/tag', :layout => false + @res = @db.select("SELECT * FROM db.tags").condition('key = ?', @key).condition('value = ?', @value).execute()[0] + erb :'embed/tag', :layout => :'embed/layout' end end diff --git a/web/views/embed/key.erb b/web/views/embed/key.erb index 27d6a64..6cc5353 100644 --- a/web/views/embed/key.erb +++ b/web/views/embed/key.erb @@ -1,10 +1,15 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> -<html> - <head> - <meta http-equiv="content-type" content="text/html; charset=utf-8" /> - </head> - <body> - <p>TEST TEST TEST</p> - <p>There are <b><%= @count %></b> objects in the database with the key <b><%= escape_html(@key) %></b>.</p> - </body> -</html> +<a target="_blank" title="More stats at Taginfo" href="http://taginfo.openstreetmap.de/keys?key=<%= escape(@key) %>"><img src="/img/taginfo.32.png" alt="Taginfo"/> Taginfo</a> +<div class="content"><table> + <tr> + <td><img src="/img/types/node.16.png" alt="Nodes" title="Nodes with key <%= escape_html(@key) %> in database"></td> + <td><%= @res['count_nodes'].to_i.to_s_with_ts %></td> + </tr> + <tr> + <td><img src="/img/types/way.16.png" alt="Ways" title="Ways with key <%= escape_html(@key) %> in database"></td> + <td><%= @res['count_ways'].to_i.to_s_with_ts %></td> + </tr> + <tr> + <td><img src="/img/types/relation.16.png" alt="Relations" title="Relations with key <%= escape_html(@key) %> in database"></td> + <td><%= @res['count_relations'].to_i.to_s_with_ts %></td> + </tr> +</table></div> diff --git a/web/views/embed/layout.erb b/web/views/embed/layout.erb new file mode 100644 index 0000000..b1e37bc --- /dev/null +++ b/web/views/embed/layout.erb @@ -0,0 +1,50 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html> + <head> + <meta http-equiv="content-type" content="text/html; charset=utf-8" /> + <style> +body { + font-family: Verdana,Arial,sans-serif; + padding: 0; + margin: 0; +} + +div.main { + width: 180px; + background-color: #f0f0f0; + border: 1px solid #e8e8e8; + padding: 4px; + -moz-border-radius: 4px; + -khtml-border-radius: 4px; + -webkit-border-radius: 4px; + -chrome-border-radius: 4px; + -o-border-radius: 4px; +} + +img { + border: none; +} + +a { + text-decoration: none; + font-weight: bold; + color: #006000; +} + +div.content { + margin-top: 6px; + text-align: right; +} + +div.content img { + padding-right: 4px; +} + +</style> + </head> + <body> + <div class="main"> +<%= yield %> + </div> + </body> +</html> diff --git a/web/views/embed/tag.erb b/web/views/embed/tag.erb index 32ab764..031eed5 100644 --- a/web/views/embed/tag.erb +++ b/web/views/embed/tag.erb @@ -1,10 +1,15 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> -<html> - <head> - <meta http-equiv="content-type" content="text/html; charset=utf-8" /> - </head> - <body> - <p>TEST TEST TEST</p> - <p>There are <b><%= @count %></b> objects in the database with the tag <b><%= escape_html(@key) %></b>=<b><%= escape_html(@value) %></b>.</p> - </body> -</html> +<a target="_blank" title="More stats at Taginfo" href="http://taginfo.openstreetmap.de/tags?key=<%= escape(@key) %>&value=<%= escape(@value) %>"><img src="/img/taginfo.32.png" alt="Taginfo"/> Taginfo</a> +<div class="content"><table> + <tr> + <td><img src="/img/types/node.16.png" alt="Nodes" title="Nodes with tag <%= escape_html(@key) %>=<%= escape_html(@value) %> in database"></td> + <td><%= @res['count_nodes'].to_i.to_s_with_ts %></td> + </tr> + <tr> + <td><img src="/img/types/way.16.png" alt="Ways" title="Ways with tag <%= escape_html(@key) %>=<%= escape_html(@value) %> in database"></td> + <td><%= @res['count_ways'].to_i.to_s_with_ts %></td> + </tr> + <tr> + <td><img src="/img/types/relation.16.png" alt="Relations" title="Relations with tag <%= escape_html(@key) %>=<%= escape_html(@value) %> in database"></td> + <td><%= @res['count_relations'].to_i.to_s_with_ts %></td> + </tr> +</table></div> |