From: Tom Hughes Date: Fri, 29 Apr 2011 16:06:10 +0000 (+0100) Subject: Merge remote-tracking branch 'apmon/openstreetbugs2' into openstreetbugs X-Git-Tag: live~5196^2~184^2 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/0a3087cd7dbf3c4ce98afe9e086aca50d19325cd?hp=af68e07272f2f42a581b435dc0563fe8a862a562 Merge remote-tracking branch 'apmon/openstreetbugs2' into openstreetbugs --- diff --git a/app/controllers/map_bugs_controller.rb b/app/controllers/map_bugs_controller.rb index bbde2148f..a967384b6 100644 --- a/app/controllers/map_bugs_controller.rb +++ b/app/controllers/map_bugs_controller.rb @@ -311,7 +311,18 @@ private end bug_comment.save; bug.last_changed = t - bug.save + bug.save + + sent_to = Set.new; + bug.map_bug_comment.each do | cmt | + if cmt.user + unless sent_to.include?(cmt.user) + Notifier.deliver_bug_comment_notification(bug_comment, cmt.user) unless cmt.user == @user; + sent_to.add(cmt.user); + end + end + end + end end diff --git a/app/models/notifier.rb b/app/models/notifier.rb index e6058d4b7..d3c975df9 100644 --- a/app/models/notifier.rb +++ b/app/models/notifier.rb @@ -95,6 +95,24 @@ class Notifier < ActionMailer::Base body :friend => friend end + def bug_comment_notification(bug_comment, recipient) + common_headers recipient + commenter_name = bug_comment.user.display_name if bug_comment.user + commenter_name = bug_comment.commenter_name unless bug_comment.user + owner = (recipient == bug_comment.map_bug.map_bug_comment[0].user); + subject I18n.t('notifier.map_bug_plain.subject_own', :commenter => commenter_name) if owner + subject I18n.t('notifier.map_bug_plain.subject_other', :commenter => commenter_name) unless owner + + body :bugurl => url_for(:host => SERVER_URL, + :controller => "browse", + :action => "bug", + :id => bug_comment.bug_id), + :place => bug_comment.map_bug.nearby_place, + :comment => bug_comment.comment, + :owner => owner, + :commenter => commenter_name + end + private def common_headers(recipient) diff --git a/app/views/notifier/bug_comment_notification.html.erb b/app/views/notifier/bug_comment_notification.html.erb new file mode 100644 index 000000000..ff8ad4265 --- /dev/null +++ b/app/views/notifier/bug_comment_notification.html.erb @@ -0,0 +1,15 @@ +<%= t 'notifier.map_bug_plain.greeting' %> + +<% if @owner %> +<%= t 'notifier.map_bug_plain.your_bug', :commenter => @commenter, :place => @place %> +<% else %> +<%= t 'notifier.map_bug_plain.commented_bug', :commenter => @commenter, :place => @place %> +<% end %> + +== +<%= @comment %> +== + +<%= t 'notifier.map_bug_plain.details', :URL => @bugurl %> + + diff --git a/app/views/site/index.html.erb b/app/views/site/index.html.erb index 7450eb2ba..27ecf1fa7 100644 --- a/app/views/site/index.html.erb +++ b/app/views/site/index.html.erb @@ -25,7 +25,7 @@
@@ -129,10 +129,9 @@ end OpenLayers.Lang.setCode("<%= I18n.locale.to_s %>"); - function createBugCallBack() { - map.osbControl.deactivate(); - document.getElementById("OpenLayers.Map_18_OpenLayers_Container").style.cursor = "default"; - } + <% if @user %> + var loginName = "<%= @user.display_name %>" + <% end %> function mapInit(){ map = createMap("map"); @@ -144,14 +143,14 @@ end map.osbLayer = new OpenLayers.Layer.OpenStreetBugs("OpenStreetBugs", { serverURL : "/api/0.6/", - iconOpen : new OpenLayers.Icon("http://openstreetbugs.schokokeks.org/client/open_bug_marker.png", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)), - iconClosed : new OpenLayers.Icon("http://openstreetbugs.schokokeks.org/client/closed_bug_marker.png", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)), + iconOpen : new OpenLayers.Icon("/images/open_bug_marker.png", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)), + iconClosed : new OpenLayers.Icon("/images/closed_bug_marker.png", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)), readonly : false, setCookie : false, cookieLifetime : 1000, cookiePath : "/my/map/", permalinkURL : "http://www.openstreetmap.org/", - theme : "http://osm.cdauth.de/map/openstreetbugs.css" + theme : "/stylesheets/openstreetbugs.css" }); map.addLayer(map.osbLayer); diff --git a/app/views/user/view.html.erb b/app/views/user/view.html.erb index 2fe92de5b..4d3d7c0c2 100644 --- a/app/views/user/view.html.erb +++ b/app/views/user/view.html.erb @@ -25,6 +25,8 @@ | <%= link_to t('user.view.my traces'), :controller => 'trace', :action=>'mine' %> | + <%= link_to t('user.view.my bugs'), :controller => 'map_bugs', :action=>'my_bugs' %> + | <%= link_to t('user.view.my settings'), :controller => 'user', :action => 'account', :display_name => @user.display_name %> | <%= link_to t('user.view.oauth settings'), :controller => 'oauth_clients', :action => 'index' %> @@ -43,6 +45,8 @@ | <%= link_to t('user.view.traces'), :controller => 'trace', :action => 'view', :display_name => @this_user.display_name %> | + <%= link_to t('user.view.bugs'), :controller => 'map_bugs', :action=>'my_bugs' %> + | <% if @user and @user.is_friends_with?(@this_user) %> <%= link_to t('user.view.remove as friend'), :controller => 'user', :action => 'remove_friend', :display_name => @this_user.display_name %> <% else %> diff --git a/config/locales/de.yml b/config/locales/de.yml index 702f80470..9017890e4 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -904,6 +904,22 @@ de: history_disabled_tooltip: Reinzoomen um Änderungen für diesen Bereich anzuzeigen history_tooltip: Änderungen für diesen Bereich anzeigen history_zoom_alert: Du musst näher heranzoomen, um die Chronik zu sehen + osb: + Fixed Error: Behobener Fehler + Unresolved Error: Offener Fehler + Description: Beschreibung + Comment: Kommentar + Has been fixed: Der Fehler wurde bereits behoben. Es kann jedoch bis zu einigen Tagen dauern, bis die Kartenansicht aktualisiert wird. + Comment/Close: Kommentieren/Schließen + Nickname: Benutzername + Add comment: Kommentar hinzufügen + Mark as fixed: Als behoben markieren + Cancel: Abbrechen + Create OpenStreetBug: OpenStreetBug melden + Create bug: Bug anlegen + Bug description: Fehlerbeschreibung + Create: Anlegeeen + Permalink: Permalink layouts: community_blogs: Blogs community_blogs_title: Blogs von Mitwirkenden bei OpenStreetMap diff --git a/config/locales/en.yml b/config/locales/en.yml index 10e2eef75..667a6faeb 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1176,6 +1176,14 @@ en: greeting: "Hi," hopefully_you: "Someone (possibly you) has asked for the password to be reset on this email address's openstreetmap.org account." click_the_link: "If this is you, please click the link below to reset your password." + map_bug_plain: + subject_own: "[OpenStreetMap bugs] {{commenter}} has commented on one of your bugs" + subject_other: "[OpenStreetMap bugs] {{commenter}} has commented on a bug you are interested in" + greeting: "Hi," + your_bug: "{{commenter}} has left a comment on one of your map bug reports near {{place}}." + commented_bug: "{{commenter}} has left a comment on a map bug report you have commented on. The bug is near {{place}}." + details: "More details about the bug report can be found at {{URL}}." + message: inbox: title: "Inbox" @@ -1607,6 +1615,7 @@ en: new diary entry: new diary entry my edits: my edits my traces: my traces + my bugs: my map bugs my settings: my settings oauth settings: oauth settings blocks on me: blocks on me @@ -1615,6 +1624,7 @@ en: diary: diary edits: edits traces: traces + bugs: map bugs remove as friend: remove as friend add as friend: add as friend mapper since: "Mapper since:" @@ -1892,3 +1902,22 @@ en: history_tooltip: View edits for this area history_disabled_tooltip: Zoom in to view edits for this area history_zoom_alert: You must zoom in to view edits for this area + osb: + Fixed Error: Fixed Error + Unresolved Error: Unresolved Error + Description: Description + Comment: Comment + Has been fixed: This error has been fixed already. However, it might take a couple of days before the map image is updated. + Comment/Close: Comment/Close + Nickname: Nickname + Add comment: Add comment + Mark as fixed: Mark as fixed + Cancel: Cancel + Create OpenStreetBug: Create OpenStreetBug + Create bug: Create bug + Bug description: Bug description + Create: Create + Permalink: Permalink + Login: Login + Details: Details + diff --git a/public/images/icon_error_add.png b/public/images/icon_error_add.png new file mode 100644 index 000000000..671cf424c Binary files /dev/null and b/public/images/icon_error_add.png differ diff --git a/public/javascripts/openstreetbugs.js b/public/javascripts/openstreetbugs.js index 72eeb60cf..378c2ce32 100644 --- a/public/javascripts/openstreetbugs.js +++ b/public/javascripts/openstreetbugs.js @@ -15,12 +15,14 @@ * Even though the OpenStreetBugs API originally does not intend this, you can create multiple instances of this Layer and add them to different maps (or to one single map for whatever crazy reason) without problems. */ +/** This version has been adapted from the original javascript library to fit the openstreetmap rails_port implementation */ + OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers, { /** * The URL of the OpenStreetBugs API. * @var String */ - serverURL : "http://openstreetbugs.schokokeks.org/api/0.1/", + serverURL : "/api/0.6/", /** * Associative array (index: bug ID) that is filled with the bugs loaded in this layer @@ -38,13 +40,13 @@ OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers, * The icon to be used for an open bug * @var OpenLayers.Icon */ - iconOpen : new OpenLayers.Icon("http://openstreetbugs.schokokeks.org/client/open_bug_marker.png", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)), + iconOpen : new OpenLayers.Icon("/images/open_bug_marker.png", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)), /** * The icon to be used for a closed bug * @var OpenLayers.Icon */ - iconClosed : new OpenLayers.Icon("http://openstreetbugs.schokokeks.org/client/closed_bug_marker.png", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)), + iconClosed : new OpenLayers.Icon("/images/closed_bug_marker.png", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)), /** * The projection of the coordinates sent by the OpenStreetBugs API. @@ -315,13 +317,13 @@ OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers, var newContent = document.createElement("div"); el1 = document.createElement("h3"); - el1.appendChild(document.createTextNode(closed ? OpenLayers.i18n("Fixed Error") : OpenLayers.i18n("Unresolved Error"))); + el1.appendChild(document.createTextNode(closed ? i18n("javascripts.osb.Fixed Error") : i18n("javascripts.osb.Unresolved Error"))); el1.appendChild(document.createTextNode(" [")); el2 = document.createElement("a"); - el2.href = "#"; + el2.href = "/browse/bug/" + id; el2.onclick = function(){ layer.map.setCenter(putAJAXMarker.bugs[id][0].clone().transform(layer.apiProjection, layer.map.getProjectionObject()), 15); }; - el2.appendChild(document.createTextNode(OpenLayers.i18n("Zoom"))); + el2.appendChild(document.createTextNode(i18n("javascripts.osb.Details"))); el1.appendChild(el2); el1.appendChild(document.createTextNode("]")); @@ -330,7 +332,7 @@ OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers, el1.appendChild(document.createTextNode(" [")); el2 = document.createElement("a"); el2.href = this.permalinkURL + (this.permalinkURL.indexOf("?") == -1 ? "?" : "&") + "lon="+putAJAXMarker.bugs[id][0].lon+"&lat="+putAJAXMarker.bugs[id][0].lat+"&zoom=15"; - el2.appendChild(document.createTextNode(OpenLayers.i18n("Permalink"))); + el2.appendChild(document.createTextNode(i18n("javascripts.osb.Permalink"))); el1.appendChild(el2); el1.appendChild(document.createTextNode("]")); } @@ -359,7 +361,7 @@ OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers, { el2 = document.createElement("dt"); el2.className = (i == 0 ? "osb-description" : "osb-comment"); - el2.appendChild(document.createTextNode(i == 0 ? OpenLayers.i18n("Description") : OpenLayers.i18n("Comment"))); + el2.appendChild(document.createTextNode(i == 0 ? i18n("javascripts.osb.Description") : i18n("javascripts.osb.Comment"))); el1.appendChild(el2); el2 = document.createElement("dd"); el2.className = (i == 0 ? "osb-description" : "osb-comment"); @@ -373,7 +375,7 @@ OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers, el1 = document.createElement("p"); el1.className = "osb-fixed"; el2 = document.createElement("em"); - el2.appendChild(document.createTextNode(OpenLayers.i18n("Has been fixed."))); + el2.appendChild(document.createTextNode(i18n("javascripts.osb.Has been fixed."))); el1.appendChild(el2); containerDescription.appendChild(el1); } @@ -383,7 +385,7 @@ OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers, el2 = document.createElement("input"); el2.setAttribute("type", "button"); el2.onclick = function(){ displayChange(); }; - el2.value = OpenLayers.i18n("Comment/Close"); + el2.value = i18n("javascripts.osb.Comment/Close"); el1.appendChild(el2); containerDescription.appendChild(el1); @@ -392,23 +394,36 @@ OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers, el1 = document.createElement("dl"); el2 = document.createElement("dt"); - el2.appendChild(document.createTextNode(OpenLayers.i18n("Nickname"))); + el2.appendChild(document.createTextNode(i18n("javascripts.osb.Nickname"))); el1.appendChild(el2); el2 = document.createElement("dd"); var inputUsername = document.createElement("input"); - inputUsername.value = this.username; + var inputUsername = document.createElement("input");; + if (typeof loginName === 'undefined') { + inputUsername.value = this.username; + } else { + inputUsername.value = loginName; + inputUsername.setAttribute('disabled','true'); + } inputUsername.className = "osbUsername"; inputUsername.onkeyup = function(){ layer.setUserName(inputUsername.value); }; el2.appendChild(inputUsername); - el1.appendChild(el2); + el3 = document.createElement("a"); + el3.setAttribute("href","login"); + el3.className = "hide_if_logged_in"; + el3.appendChild(document.createTextNode(i18n("javascripts.osb.Login"))); + el2.appendChild(el3) + el1.appendChild(el2); el2 = document.createElement("dt"); - el2.appendChild(document.createTextNode(OpenLayers.i18n("Comment"))); + el2.appendChild(document.createTextNode(i18n("javascripts.osb.Comment"))); el1.appendChild(el2); el2 = document.createElement("dd"); - var inputComment = document.createElement("input"); + var inputComment = document.createElement("textarea"); + inputComment.setAttribute("cols",40); el2.appendChild(inputComment); el1.appendChild(el2); + el_form.appendChild(el1); el1 = document.createElement("ul"); @@ -416,7 +431,7 @@ OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers, el2 = document.createElement("li"); el3 = document.createElement("input"); el3.setAttribute("type", "submit"); - el3.value = OpenLayers.i18n("Add comment"); + el3.value = i18n("javascripts.osb.Add comment"); el2.appendChild(el3); el1.appendChild(el2); @@ -424,7 +439,7 @@ OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers, el3 = document.createElement("input"); el3.setAttribute("type", "button"); el3.onclick = function(){ this.form.onsubmit(); layer.closeBug(id); layer.bugs[id].popup.hide(); return false; }; - el3.value = OpenLayers.i18n("Mark as fixed"); + el3.value = i18n("javascripts.osb.Mark as fixed"); el2.appendChild(el3); el1.appendChild(el2); el_form.appendChild(el1); @@ -434,7 +449,7 @@ OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers, el2 = document.createElement("input"); el2.setAttribute("type", "button"); el2.onclick = function(){ displayDescription(); }; - el2.value = OpenLayers.i18n("Cancel"); + el2.value = i18n("javascripts.osb.Cancel"); el1.appendChild(el2); containerChange.appendChild(el1); } @@ -455,7 +470,6 @@ OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers, + "&name="+encodeURIComponent(this.getUserName()) + "&format=js" ); - createBugCallBack(); }, /** @@ -575,7 +589,7 @@ OpenLayers.Control.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Control, { * The icon to be used for the temporary markers that the “create bug” popup belongs to. * @var OpenLayers.Icon */ - icon : new OpenLayers.Icon("http://openstreetbugs.schokokeks.org/client/icon_error_add.png", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)), + icon : new OpenLayers.Icon("/images/icon_error_add.png", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)), /** * An instance of the OpenStreetBugs layer that this control shall be connected to. Is set in the constructor. @@ -589,7 +603,7 @@ OpenLayers.Control.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Control, { initialize: function(osbLayer, options) { this.osbLayer = osbLayer; - this.title = OpenLayers.i18n("Create OpenStreetBug"); + this.title = i18n("javascripts.osb.Create OpenStreetBug"); OpenLayers.Control.prototype.initialize.apply(this, [ options ]); @@ -621,6 +635,7 @@ OpenLayers.Control.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Control, { */ click: function(e) { if(!this.map) return true; + deactivateControl(); var control = this; var lonlat = this.map.getLonLatFromViewPortPx(e.xy); @@ -634,7 +649,7 @@ OpenLayers.Control.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Control, { var newContent = document.createElement("div"); var el1,el2,el3; el1 = document.createElement("h3"); - el1.appendChild(document.createTextNode(OpenLayers.i18n("Create bug"))); + el1.appendChild(document.createTextNode(i18n("javascripts.osb.Create bug"))); newContent.appendChild(el1); var el_form = document.createElement("form"); @@ -642,21 +657,33 @@ OpenLayers.Control.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Control, { el1 = document.createElement("dl"); el2 = document.createElement("dt"); - el2.appendChild(document.createTextNode(OpenLayers.i18n("Nickname"))); + el2.appendChild(document.createTextNode(i18n("javascripts.osb.Nickname"))); el1.appendChild(el2); el2 = document.createElement("dd"); - var inputUsername = document.createElement("input"); - inputUsername.value = this.osbLayer.username; + var inputUsername = document.createElement("input");; + if (typeof loginName === 'undefined') { + inputUsername.value = this.osbLayer.username; + } else { + inputUsername.value = loginName; + inputUsername.setAttribute('disabled','true'); + } inputUsername.className = "osbUsername"; + inputUsername.onkeyup = function(){ control.osbLayer.setUserName(inputUsername.value); }; el2.appendChild(inputUsername); + el3 = document.createElement("a"); + el3.setAttribute("href","login"); + el3.className = "hide_if_logged_in"; + el3.appendChild(document.createTextNode(i18n("javascripts.osb.Login"))); + el2.appendChild(el3); el1.appendChild(el2); el2 = document.createElement("dt"); - el2.appendChild(document.createTextNode(OpenLayers.i18n("Bug description"))); + el2.appendChild(document.createTextNode(i18n("javascripts.osb.Bug description"))); el1.appendChild(el2); el2 = document.createElement("dd"); - var inputDescription = document.createElement("input"); + var inputDescription = document.createElement("textarea"); + inputDescription.setAttribute("cols",40); el2.appendChild(inputDescription); el1.appendChild(el2); el_form.appendChild(el1); @@ -664,7 +691,7 @@ OpenLayers.Control.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Control, { el1 = document.createElement("div"); el2 = document.createElement("input"); el2.setAttribute("type", "submit"); - el2.value = OpenLayers.i18n("Create"); + el2.value = i18n("javascripts.osb.Create"); el1.appendChild(el2); el_form.appendChild(el1); newContent.appendChild(el_form); @@ -745,24 +772,6 @@ OpenLayers.Popup.FramedCloud.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Po CLASS_NAME: "OpenLayers.Popup.FramedCloud.OpenStreetBugs" }); -/** - * Necessary improvement to the translate function: Fall back to default language if translated string is not - * available (see http://trac.openlayers.org/ticket/2308). -*/ - -OpenLayers.i18n = OpenLayers.Lang.translate = function(key, context) { - var message = OpenLayers.Lang[OpenLayers.Lang.getCode()][key]; - if(!message) - { - if(OpenLayers.Lang[OpenLayers.Lang.defaultCode][key]) - message = OpenLayers.Lang[OpenLayers.Lang.defaultCode][key]; - else - message = key; - } - if(context) - message = OpenLayers.String.format(message, context); - return message; -}; /** * This global function is executed by the OpenStreetBugs API getBugs script. @@ -802,9 +811,16 @@ function osbResponse(error) putAJAXMarker.layers = [ ]; putAJAXMarker.bugs = { }; +function deactivateControl() { + map.osbControl.deactivate(); + document.getElementById("OpenLayers.Map_18_OpenLayers_Container").style.cursor = "default"; + } + /* Translations */ +/* + OpenLayers.Lang.en = OpenLayers.Util.extend(OpenLayers.Lang.en, { "Fixed Error" : "Fixed Error", "Unresolved Error" : "Unresolved Error", @@ -918,3 +934,4 @@ OpenLayers.Lang.ro = OpenLayers.Util.extend(OpenLayers.Lang.ro, { "Permalink" : "Permalink", "Zoom" : "Zoom" }); +*/