aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--web/lib/api/v4/project.rb18
-rw-r--r--web/lib/api/v4/projects.rb8
-rw-r--r--web/lib/api/v4/tag.rb48
-rw-r--r--web/public/js/taginfo.js7
-rw-r--r--web/viewsjs/key.js.erb2
-rw-r--r--web/viewsjs/projects.js.erb2
-rw-r--r--web/viewsjs/tag.js.erb2
7 files changed, 39 insertions, 48 deletions
diff --git a/web/lib/api/v4/project.rb b/web/lib/api/v4/project.rb
index b1fa2e8..50e1753 100644
--- a/web/lib/api/v4/project.rb
+++ b/web/lib/api/v4/project.rb
@@ -57,22 +57,4 @@ class Taginfo < Sinatra::Base
}, json_opts(params[:format]))
end
- api(4, 'project/icon', {
- :description => 'Access logo icon for project.',
- :parameters => { :project => 'Project ID' },
- :result => 'Redirect to project image.',
- :example => { :project => 'osmcoastline' },
- :ui => '/projects'
- }) do
- project_id = params[:project]
- url = @db.select('SELECT icon_url FROM projects.projects').
- condition('id = ?', project_id).
- get_first_value()
- if url.nil? || url == ''
- redirect '/img/generic_project_icon.png'
- else
- redirect url
- end
- end
-
end
diff --git a/web/lib/api/v4/projects.rb b/web/lib/api/v4/projects.rb
index 2cbb7fb..1ab9ede 100644
--- a/web/lib/api/v4/projects.rb
+++ b/web/lib/api/v4/projects.rb
@@ -9,7 +9,9 @@ class Taginfo < Sinatra::Base
:result => paging_results([
[:id, :STRING, 'Project id'],
[:name, :STRING, 'Project name'],
- [:url, :STRING, 'Project URL'],
+ [:project_url, :STRING, 'Project URL'],
+ [:icon_url, :STRING, 'Icon URL'],
+ [:doc_url, :STRING, 'Documentation URL'],
[:description, :STRING, 'Project description']
]),
:example => { :page => 1, :rp => 10, :sortname => 'name', :sortorder => 'asc' },
@@ -44,7 +46,9 @@ class Taginfo < Sinatra::Base
:data => res.map{ |row| {
:id => row['id'],
:name => row['name'],
- :url => row['project_url'],
+ :project_url => row['project_url'],
+ :icon_url => row['icon_url'],
+ :doc_url => row['doc_url'],
:description => row['description'],
}}
}, json_opts(params[:format]))
diff --git a/web/lib/api/v4/tag.rb b/web/lib/api/v4/tag.rb
index 35e4870..b15cf8d 100644
--- a/web/lib/api/v4/tag.rb
+++ b/web/lib/api/v4/tag.rb
@@ -258,17 +258,18 @@ class Taginfo < Sinatra::Base
:paging => :optional,
:sort => %w( project_name key value ),
:result => paging_results([
- [:project_id, :STRING, 'Project ID'],
- [:project_name, :STRING, 'Project name'],
- [:key, :STRING, 'Key'],
- [:value, :STRING, 'Value'],
- [:on_node, :BOOL, 'For nodes?'],
- [:on_way, :BOOL, 'For ways?'],
- [:on_relation, :BOOL, 'For relations?'],
- [:on_area, :BOOL, 'For areas?'],
- [:description, :STRING, 'Description'],
- [:doc_url, :STRING, 'Documentation URL'],
- [:icon_url, :STRING, 'Icon URL']
+ [:project_id, :STRING, 'Project ID'],
+ [:project_name, :STRING, 'Project name'],
+ [:project_icon_url, :STRING, 'Project icon URL'],
+ [:key, :STRING, 'Key'],
+ [:value, :STRING, 'Value'],
+ [:on_node, :BOOL, 'For nodes?'],
+ [:on_way, :BOOL, 'For ways?'],
+ [:on_relation, :BOOL, 'For relations?'],
+ [:on_area, :BOOL, 'For areas?'],
+ [:description, :STRING, 'Description'],
+ [:doc_url, :STRING, 'Documentation URL'],
+ [:icon_url, :STRING, 'Icon URL']
]),
:example => { :key => 'highway', :value => 'residential', :page => 1, :rp => 10, :sortname => 'project_name', :sortorder => 'asc' },
:ui => '/keys/highway=residential#projects'
@@ -282,7 +283,7 @@ class Taginfo < Sinatra::Base
condition_if("value LIKE ? ESCAPE '@' OR name LIKE ? ESCAPE '@'", q, q).
get_first_value().to_i
- res = @db.select('SELECT t.project_id, p.name, t.key, t.value, t.description, t.doc_url, t.icon_url, t.on_node, t.on_way, t.on_relation, t.on_area FROM projects.projects p, projects.project_tags t ON p.id=t.project_id').
+ res = @db.select('SELECT t.project_id, p.name, p.icon_url AS project_icon_url, t.key, t.value, t.description, t.doc_url, t.icon_url, t.on_node, t.on_way, t.on_relation, t.on_area FROM projects.projects p, projects.project_tags t ON p.id=t.project_id').
condition('key = ?', key).
condition_if('value = ? OR VALUE IS NULL', value).
condition_if("value LIKE ? ESCAPE '@' OR name LIKE ? ESCAPE '@'", q, q).
@@ -304,17 +305,18 @@ class Taginfo < Sinatra::Base
:total => total.to_i,
:url => request.url,
:data => res.map{ |row| {
- :project_id => row['project_id'],
- :project_name => row['name'],
- :key => row['key'],
- :value => row['value'],
- :on_node => row['on_node'].to_i == 1,
- :on_way => row['on_way'].to_i == 1,
- :on_relation => row['on_relation'].to_i == 1,
- :on_area => row['on_area'].to_i == 1,
- :description => row['description'],
- :doc_url => row['doc_url'],
- :icon_url => row['icon_url']
+ :project_id => row['project_id'],
+ :project_name => row['name'],
+ :project_icon_url => row['project_icon_url'],
+ :key => row['key'],
+ :value => row['value'],
+ :on_node => row['on_node'].to_i == 1,
+ :on_way => row['on_way'].to_i == 1,
+ :on_relation => row['on_relation'].to_i == 1,
+ :on_area => row['on_area'].to_i == 1,
+ :description => row['description'],
+ :doc_url => row['doc_url'],
+ :icon_url => row['icon_url']
} }
}, json_opts(params[:format]))
end
diff --git a/web/public/js/taginfo.js b/web/public/js/taginfo.js
index e944aaa..f859c86 100644
--- a/web/public/js/taginfo.js
+++ b/web/public/js/taginfo.js
@@ -197,8 +197,11 @@ function link_to_rtype(rtype, attr) {
);
}
-function link_to_project(id, name, attr) {
- return img({ src: '/api/4/project/icon?project=' + id, width: 16, height: 16, alt: '' }) + ' ' + link(
+function link_to_project(id, name, icon_url, attr) {
+ if (icon_url === null) {
+ icon_url = '/img/generic_project_icon.png';
+ }
+ return img({ src: icon_url, width: 16, height: 16, alt: '' }) + ' ' + link(
url_for_project(id),
html_escape(name),
attr
diff --git a/web/viewsjs/key.js.erb b/web/viewsjs/key.js.erb
index 9bf8583..46b4920 100644
--- a/web/viewsjs/key.js.erb
+++ b/web/viewsjs/key.js.erb
@@ -162,7 +162,7 @@ var create_flexigrid_for = {
preProcess: function(data) {
data.rows = jQuery.map(data.data, function(row, i) {
return { 'cell': [
- link_to_project(row.project_id, row.project_name),
+ link_to_project(row.project_id, row.project_name, row.project_icon_url),
row.value ? link_to_tag(row.key, row.value) : (link_to_key(row.key) + '=*'),
fmt_type_icon('node', row.on_node) +
fmt_type_icon('way', row.on_way) +
diff --git a/web/viewsjs/projects.js.erb b/web/viewsjs/projects.js.erb
index 55878c9..ac4eabf 100644
--- a/web/viewsjs/projects.js.erb
+++ b/web/viewsjs/projects.js.erb
@@ -13,7 +13,7 @@ function page_init() {
preProcess: function(data) {
data.rows = jQuery.map(data.data, function(row, i) {
return { 'cell': [
- link_to_project(row.id, row.name),
+ link_to_project(row.id, row.name, row.icon_url),
html_escape(row.description)
] };
});
diff --git a/web/viewsjs/tag.js.erb b/web/viewsjs/tag.js.erb
index 34b5935..52821ea 100644
--- a/web/viewsjs/tag.js.erb
+++ b/web/viewsjs/tag.js.erb
@@ -142,7 +142,7 @@ var create_flexigrid_for = {
preProcess: function(data) {
data.rows = jQuery.map(data.data, function(row, i) {
return { 'cell': [
- link_to_project(row.project_id, row.project_name),
+ link_to_project(row.project_id, row.project_name, row.project_icon_url),
row.value ? link_to_tag(row.key, row.value) : (link_to_key(row.key) + '=*'),
fmt_type_icon('node', row.on_node) +
fmt_type_icon('way', row.on_way) +