From bf5f9f7ea67dcb49b9791825408b68d438785b4b Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Fri, 5 Sep 2014 16:55:21 +0200 Subject: Add project icons. --- web/lib/api/v4/project.rb | 8 ++++++-- web/public/img/generic_project_icon.png | Bin 0 -> 285 bytes web/public/js/taginfo.js | 2 +- web/views/project.erb | 6 +++++- web/viewsjs/key.js.erb | 2 +- web/viewsjs/tag.js.erb | 2 +- 6 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 web/public/img/generic_project_icon.png diff --git a/web/lib/api/v4/project.rb b/web/lib/api/v4/project.rb index 94eeadc..b461b72 100644 --- a/web/lib/api/v4/project.rb +++ b/web/lib/api/v4/project.rb @@ -57,10 +57,14 @@ class Taginfo < Sinatra::Base :ui => '/projects' }) do project_id = params[:project] - content_type :png - @db.select('SELECT icon FROM projects.projects'). + 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/public/img/generic_project_icon.png b/web/public/img/generic_project_icon.png new file mode 100644 index 0000000..38ea79f Binary files /dev/null and b/web/public/img/generic_project_icon.png differ diff --git a/web/public/js/taginfo.js b/web/public/js/taginfo.js index 165b2b0..4fa0ed0 100644 --- a/web/public/js/taginfo.js +++ b/web/public/js/taginfo.js @@ -198,7 +198,7 @@ function link_to_rtype(rtype, attr) { } function link_to_project(id, name, attr) { - return /*img({ src: '/api/v4/project/icon?project=' + id, alt: '' }) + ' ' +*/ link( + return img({ src: '/api/4/project/icon?project=' + id, width: 16, height: 16, alt: '' }) + ' ' + link( url_for_project(id), html_escape(name), attr diff --git a/web/views/project.erb b/web/views/project.erb index 16637c1..faab181 100644 --- a/web/views/project.erb +++ b/web/views/project.erb @@ -9,7 +9,7 @@
- + <% if @project.doc_url %> @@ -33,11 +33,15 @@ function page_init2() { var project = #{ @project_id.to_json }, project_url = #{ @project.project_url.to_json }, json_url = #{ @project.json_url.to_json }, + icon_url = #{ @project.icon_url.to_json }, doc_url = #{ @project.doc_url.to_json }; if (project_url) { jQuery('#project_url').html(link_to_url(project_url)); } + if (icon_url) { + jQuery('#icon_url').html(img({ src: icon_url, width: 16, height: 16, alt: ''})); + } if (json_url) { jQuery('#json_url').html(link_to_url(json_url)); } diff --git a/web/viewsjs/key.js.erb b/web/viewsjs/key.js.erb index ad9937d..6035850 100644 --- a/web/viewsjs/key.js.erb +++ b/web/viewsjs/key.js.erb @@ -149,7 +149,7 @@ var create_flexigrid_for = { create_flexigrid('grid-projects', { url: '/api/4/tag/projects?key=' + encodeURIComponent(key), colModel: [ - { display: '<%= h(taginfo.project) %>', name: 'project_name', width: 200, sortable: true }, + { display: '<%= h(taginfo.project) %>', name: 'project_name', width: 280, sortable: true }, { display: '<%= h(osm.tag) %>', name: 'key', width: 220, sortable: true }, { display: '<%= h(misc.description) %>', name: 'description', width: 600, sortable: false, align: 'left' } ], diff --git a/web/viewsjs/tag.js.erb b/web/viewsjs/tag.js.erb index d47906e..bc24f5f 100644 --- a/web/viewsjs/tag.js.erb +++ b/web/viewsjs/tag.js.erb @@ -129,7 +129,7 @@ var create_flexigrid_for = { create_flexigrid('grid-projects', { url: '/api/4/tag/projects?key=' + encodeURIComponent(key) + '&value=' + encodeURIComponent(value), colModel: [ - { display: '<%= h(taginfo.project) %>', name: 'project_name', width: 200, sortable: true }, + { display: '<%= h(taginfo.project) %>', name: 'project_name', width: 280, sortable: true }, { display: '<%= h(osm.tag) %>', name: 'key', width: 220, sortable: true }, { display: '<%= h(misc.description) %>', name: 'description', width: 600, sortable: false, align: 'left' } ], -- cgit v1.2.3
<%= h(t.pages.project.overview.project_name) %>:<%= h(@project.name) %>
<%= h(t.pages.project.overview.project_name) %>: <%= h(@project.name) %>
<%= h(t.pages.project.overview.project_url) %>:
<%= h(t.pages.project.overview.description) %>:<%= h(@project.description) %>