diff options
author | Jochen Topf <jochen@topf.org> | 2014-09-07 17:15:50 +0200 |
---|---|---|
committer | Jochen Topf <jochen@topf.org> | 2014-09-07 17:15:50 +0200 |
commit | eb33a1a95fb1357e048c159432fbfd0b196befb6 (patch) | |
tree | e1c299a957eabb48f4765330af4600621d654095 /web/lib | |
parent | 71edd0277b7effa2b1dc18486a5be78cddf49425 (diff) | |
download | taginfo-eb33a1a95fb1357e048c159432fbfd0b196befb6.tar taginfo-eb33a1a95fb1357e048c159432fbfd0b196befb6.tar.gz |
Remove need for project icon redirect.
Diffstat (limited to 'web/lib')
-rw-r--r-- | web/lib/api/v4/project.rb | 18 | ||||
-rw-r--r-- | web/lib/api/v4/projects.rb | 8 | ||||
-rw-r--r-- | web/lib/api/v4/tag.rb | 48 |
3 files changed, 31 insertions, 43 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 |