aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsources/potlatch/import_potlatch.rb8
-rw-r--r--sources/potlatch/pre.sql20
-rw-r--r--web/lib/sql.rb2
-rw-r--r--web/lib/utils.rb4
-rw-r--r--web/public/css/taginfo.css48
-rw-r--r--web/public/js/taginfo.js2
-rwxr-xr-xweb/taginfo.rb41
-rw-r--r--web/views/sources/potlatch/categories.erb36
-rw-r--r--web/views/sources/potlatch/category.erb17
-rw-r--r--web/views/sources/potlatch/feature.erb24
-rw-r--r--web/views/sources/potlatch/features.erb0
-rw-r--r--web/views/sources/potlatch/index.erb7
12 files changed, 196 insertions, 13 deletions
diff --git a/sources/potlatch/import_potlatch.rb b/sources/potlatch/import_potlatch.rb
index b939cc6..61832e3 100755
--- a/sources/potlatch/import_potlatch.rb
+++ b/sources/potlatch/import_potlatch.rb
@@ -57,6 +57,10 @@ doc.elements.each('/mapFeatures/feature') do |feature_element|
on[$1.to_sym] = 1
when /^(category|help)$/
fields[element.name] = element.text.strip
+ when 'icon'
+ fields['icon_image'] = element.attributes['image']
+ fields['icon_background'] = element.attributes['background']
+ fields['icon_foreground'] = element.attributes['foreground']
end
end
@@ -64,8 +68,8 @@ doc.elements.each('/mapFeatures/feature') do |feature_element|
on = { :point => 1, :line => 1, :area => 1, :relation => 1 }
end
- db.execute('INSERT INTO features (name, category_id, help, on_point, on_line, on_area, on_relation) VALUES (?, ?, ?, ?, ?, ?, ?)',
- feature_name, fields['category'], fields['help'], on[:point], on[:line], on[:area], on[:relation])
+ db.execute('INSERT INTO features (name, category_id, help, on_point, on_line, on_area, on_relation, icon_image, icon_background, icon_foreground) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
+ feature_name, fields['category'], fields['help'], on[:point], on[:line], on[:area], on[:relation], fields['icon_image'], fields['icon_background'], fields['icon_foreground'])
end
db.execute('COMMIT');
diff --git a/sources/potlatch/pre.sql b/sources/potlatch/pre.sql
index 7f3a40b..9f79445 100644
--- a/sources/potlatch/pre.sql
+++ b/sources/potlatch/pre.sql
@@ -36,7 +36,6 @@ CREATE TABLE categories (
name TEXT
);
-
--
-- features
--
@@ -44,14 +43,17 @@ CREATE TABLE categories (
DROP TABLE IF EXISTS features;
CREATE TABLE features (
- name TEXT,
- category_id TEXT REFERENCES categories (id),
- category_name TEXT,
- help TEXT,
- on_point INTEGER,
- on_line INTEGER,
- on_area INTEGER,
- on_relation INTEGER
+ name TEXT,
+ category_id TEXT REFERENCES categories (id),
+ category_name TEXT,
+ help TEXT,
+ on_point INTEGER,
+ on_line INTEGER,
+ on_area INTEGER,
+ on_relation INTEGER,
+ icon_image TEXT,
+ icon_foreground TEXT,
+ icon_background TEXT
);
--
diff --git a/web/lib/sql.rb b/web/lib/sql.rb
index c2487c0..1b9db32 100644
--- a/web/lib/sql.rb
+++ b/web/lib/sql.rb
@@ -11,7 +11,7 @@ module SQL
@db = SQLite3::Database.new(filename)
@db.results_as_hash = true
- [:db, :wiki, :josm, :merkaartor].each do |dbname|
+ [:db, :wiki, :josm, :potlatch, :merkaartor].each do |dbname|
@db.execute("ATTACH DATABASE '#{dir}/taginfo-#{dbname}.db' AS #{dbname}")
end
diff --git a/web/lib/utils.rb b/web/lib/utils.rb
index 415553b..7ffc55f 100644
--- a/web/lib/utils.rb
+++ b/web/lib/utils.rb
@@ -171,3 +171,7 @@ def link_to_tag(key, value)
return link_to_key(key) + '=' + link_to_value(key, value)
end
+def external_link(title, link)
+ %Q{&rarr; <a class="extlink" href="#{link}" target="_blank">#{title}</a>}
+end
+
diff --git a/web/public/css/taginfo.css b/web/public/css/taginfo.css
index b28f132..1ef4fe8 100644
--- a/web/public/css/taginfo.css
+++ b/web/public/css/taginfo.css
@@ -342,3 +342,51 @@ div#canvas-keypairs {
background-color: #ffffff;
}
+/* ========== */
+
+table.drilldown {
+ border-collapse: separate;
+ border-spacing: 10px;
+}
+
+table.drilldown td, table.drilldown th {
+ vertical-align: top;
+}
+
+table.drilldown th h2 {
+ padding: 0;
+ margin: 0;
+}
+
+table.drilldown td.content {
+ width: 16em;
+ border: 1px solid #d0d0d0;
+ background-color: #f0f0f0;
+ -moz-border-radius: 8px;
+ -khtml-border-radius: 8px;
+ -webkit-border-radius: 8px;
+ -chrome-border-radius: 8px;
+ -o-border-radius: 8px;
+ padding: 10px 0;
+}
+
+table.drilldown td.content div {
+ width: 100%;
+ padding: 1px 0;
+}
+
+table.drilldown td.content div.current {
+ background-color: #e0e0e0;
+}
+
+table.drilldown td.arrow {
+ vertical-align: middle;
+ font-size: 200%;
+}
+
+table.drilldown td#feature {
+ min-width: 16em;
+ padding: 10px;
+}
+
+/* ========== */
diff --git a/web/public/js/taginfo.js b/web/public/js/taginfo.js
index b563315..fcaa13f 100644
--- a/web/public/js/taginfo.js
+++ b/web/public/js/taginfo.js
@@ -1,7 +1,7 @@
// taginfo.js
function print_wiki_link(title) {
- return '&rarr; <a class="wikilink" href="http://wiki.openstreetmap.org/wiki/' + title + '">' + title + '</a>';
+ return '&rarr; <a class="wikilink" href="http://wiki.openstreetmap.org/wiki/' + title + '" target="_blank">' + title + '</a>';
}
function print_wiki_edit_link(title) {
diff --git a/web/taginfo.rb b/web/taginfo.rb
index ef08bf0..42a162c 100755
--- a/web/taginfo.rb
+++ b/web/taginfo.rb
@@ -317,6 +317,47 @@ class Taginfo < Sinatra::Base
#--------------------------------------------------------------------------
+ get '/sources/potlatch/?' do
+ @title = 'Potlatch'
+ @breadcrumbs << ['Sources', '/sources']
+ @breadcrumbs << ['Potlatch']
+
+ erb :'sources/potlatch/index'
+ end
+
+ get '/sources/potlatch/categories' do
+ @title = 'Potlatch Features'
+ @breadcrumbs << ['Sources', '/sources']
+ @breadcrumbs << ['Potlatch', '/sources/potlatch']
+ @breadcrumbs << ['Features']
+
+ @categories = @db.execute('SELECT * FROM potlatch.categories ORDER BY name')
+
+ erb :'sources/potlatch/categories'
+ end
+
+ get '/sources/potlatch/categories/:category' do
+ @category = params[:category]
+ @features = @db.execute('SELECT * FROM potlatch.features WHERE category_id=? ORDER BY name', @category)
+
+ erb :'sources/potlatch/category', :layout => false
+ end
+
+ get '/sources/potlatch/features/:feature' do
+ @feature_name = params[:feature]
+ @feature = @db.execute('SELECT * FROM potlatch.features WHERE name=?', @feature_name)[0]
+ @tags = @db.execute('SELECT * FROM potlatch.tags WHERE feature_name=? ORDER BY key, value', @feature_name)
+
+ erb :'sources/potlatch/feature', :layout => false
+ end
+
+ get %r{/sources/potlatch/icon/(.*)} do
+ content_type :png
+ IO.read('../../var/sources/potlatch/resources/' + params[:captures].first)
+ end
+
+ #--------------------------------------------------------------------------
+
get '/sources/merkaartor/?' do
@title = 'Merkaartor'
@breadcrumbs << ['Sources', '/sources']
diff --git a/web/views/sources/potlatch/categories.erb b/web/views/sources/potlatch/categories.erb
new file mode 100644
index 0000000..3aa75d1
--- /dev/null
+++ b/web/views/sources/potlatch/categories.erb
@@ -0,0 +1,36 @@
+<h1><img src="/img/sources/potlatch.32.png" alt="" title="Potlatch"/> Potlatch</h1>
+
+<table class="drilldown"><tr>
+ <th><h2>&#x278a; Categories</h2></th>
+ <th></th>
+ <th><h2>&#x278b; Features</h2></th>
+ <th></th>
+ <th><h2>&#x278c; Feature</h2></th>
+</tr><tr>
+ <td class="content" id="categories">
+ <% @categories.each do |row| %>
+ <div>&nbsp;&nbsp;<a href="/sources/potlatch/categories#<%= escape row['id'] %>"><%= row['name'] %></a></div>
+ <% end %>
+ </div>
+ <td class="arrow">&#x2771;</td>
+ <td class="content" id="features"></td>
+ <td class="arrow">&#x2771;</td>
+ <td class="content" id="feature"></td>
+</tr></table>
+
+<script type="text/javascript">
+
+jQuery('#categories a').bind('click', function() {
+ jQuery('#categories div').removeClass('current');
+ jQuery(this).parent().addClass('current');
+ jQuery('#feature').html('');
+ jQuery.ajax({
+ url: this.href.replace(/#/, '/'),
+ success: function(html) {
+ jQuery('#features').html(html);
+ }
+ });
+ return false;
+});
+
+</script>
diff --git a/web/views/sources/potlatch/category.erb b/web/views/sources/potlatch/category.erb
new file mode 100644
index 0000000..2355ec6
--- /dev/null
+++ b/web/views/sources/potlatch/category.erb
@@ -0,0 +1,17 @@
+<% @features.each do |row| %>
+ <div>&nbsp;&nbsp;<a href="/sources/potlatch/features/<%= escape row['name'] %>"><%= row['name'] %></a></div>
+<% end %>
+<script type="text/javascript">
+jQuery('#features a').bind('click', function() {
+ jQuery('#features div').removeClass('current');
+ jQuery(this).parent().addClass('current');
+ jQuery.ajax({
+ url: this.href,
+ success: function(html) {
+ jQuery('#feature').html(html);
+ }
+ });
+ return false;
+});
+
+</script>
diff --git a/web/views/sources/potlatch/feature.erb b/web/views/sources/potlatch/feature.erb
new file mode 100644
index 0000000..6e53f0b
--- /dev/null
+++ b/web/views/sources/potlatch/feature.erb
@@ -0,0 +1,24 @@
+<p style="text-align: center;"><b><%= @feature_name %></b></p>
+
+<p style="background: #ffffff; padding: 4px; -moz-border-radius: 3px; text-align: center; min-height: 36px; vertical-align: middle;">
+<% if @feature['icon_image'] %>
+ <img src="/sources/potlatch/icon/<%= @feature['icon_image'] %>" alt="Icon" title="Icon"/>
+<% end %>
+</p>
+
+<p style="text-align: center;">
+<% [:point, :line, :area, :relation].each do |otype| %>
+ <% imgmatch = { :point => 'node', :line => 'way', :area => 'area', :relation => 'relation' };
+ image = @feature['on_' + otype.to_s] == '1' ? imgmatch[otype] : 'none' %>
+ <img src="/img/types/<%= image %>.16.png" alt="" title="<%= otype.to_s.capitalize %>"/>
+<% end %>
+</p>
+
+<p style="text-align: center;"><%= external_link('Help text', @feature['help']) %></p>
+
+<p style="text-align: center;">Tags:<br/>
+ <% @tags.each do |tag| %>
+ <%= link_to_tag(tag['key'], tag['value']) %><br/>
+ <% end %>
+</p>
+
diff --git a/web/views/sources/potlatch/features.erb b/web/views/sources/potlatch/features.erb
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/web/views/sources/potlatch/features.erb
diff --git a/web/views/sources/potlatch/index.erb b/web/views/sources/potlatch/index.erb
new file mode 100644
index 0000000..5a1a289
--- /dev/null
+++ b/web/views/sources/potlatch/index.erb
@@ -0,0 +1,7 @@
+<h1><img src="/img/sources/potlatch.32.png" alt="" title="Potlatch"/> Potlatch</h1>
+
+<ul>
+ <li><a href="/sources/potlatch/categories">Categories</a></li>
+ <li><a href="/sources/potlatch/features">Features</a></li>
+</ul>
+