]> git.openstreetmap.org Git - rails.git/commitdiff
Rework the generation of descriptions in the notes RSS feed
authorTom Hughes <tom@compton.nu>
Fri, 26 Apr 2013 18:34:32 +0000 (19:34 +0100)
committerTom Hughes <tom@compton.nu>
Fri, 26 Apr 2013 18:34:32 +0000 (19:34 +0100)
app/views/notes/_comment.html.erb [new file with mode: 0644]
app/views/notes/_description.html.erb
app/views/notes/_entry.html.erb [new file with mode: 0644]
app/views/notes/feed.rss.builder
config/locales/en.yml

diff --git a/app/views/notes/_comment.html.erb b/app/views/notes/_comment.html.erb
new file mode 100644 (file)
index 0000000..4fe7b59
--- /dev/null
@@ -0,0 +1,8 @@
+<div class="note-comment" style="margin-top: 5px">
+  <% if comment.author.nil? -%>
+  <div class="note-comment-description" style="font-size: smaller; color: #999999"><%= t "note.description.#{comment.event}_at", :when => friendly_date(comment.created_at) %></div>
+  <% else -%>
+  <div class="note-comment-description" style="font-size: smaller; color: #999999"><%= t "note.description.#{comment.event}_at_by", :when => friendly_date(comment.created_at), :user => note_author(comment.author, :only_path => false) %></div>
+  <% end -%>
+  <div class="note-comment-text"><%= comment.body %></div>
+</div>
index 761b69ea2db87fc7dd0528a1188a0705243328f0..4f03a1d59aadf32973468a5dc53d37109483199c 100644 (file)
@@ -1,12 +1,3 @@
 <div>
 <div>
-  <% description.comments.each do |comment| -%>
-  <div class="note-comment" style="margin-top: 5px">
-    <% if comment.author.nil? -%>
-    <div class="note-comment-description" style="font-size: smaller; color: #999999"><%= t "note.description.#{comment.event}_at", :when => friendly_date(comment.created_at) %></div>
-    <% else -%>
-    <div class="note-comment-description" style="font-size: smaller; color: #999999"><%= t "note.description.#{comment.event}_at_by", :when => friendly_date(comment.created_at), :user => note_author(comment.author, :only_path => false) %></div>
-    <% end -%>
-    <div class="note-comment-text"><%= comment.body %></div>
-  </div>
-  <% end -%>
+  <%= render :partial => "comment", :collection => description.comments %>
 </div>
 </div>
diff --git a/app/views/notes/_entry.html.erb b/app/views/notes/_entry.html.erb
new file mode 100644 (file)
index 0000000..6f0c8fb
--- /dev/null
@@ -0,0 +1,4 @@
+<h2><%= t "note.entry.comment" %></h2>
+<%= render :partial => "comment", :object => entry %>
+<h2><%= t "note.entry.full" %></h2>
+<%= render :partial => "description", :object => entry.note %>
index 4733c1bad77864377814f32139676c1ab27175e9..f17be09cbf4b34d2d8fc81a6d9620905427017cc 100644 (file)
@@ -25,18 +25,7 @@ xml.rss("version" => "2.0",
         xml.link url_for(:controller => "browse", :action => "note", :id => comment.note.id, :only_path => false)
         xml.guid url_for(:controller => "browse", :action => "note", :id => comment.note.id, :only_path => false)
 
         xml.link url_for(:controller => "browse", :action => "note", :id => comment.note.id, :only_path => false)
         xml.guid url_for(:controller => "browse", :action => "note", :id => comment.note.id, :only_path => false)
 
-        description_text = ""
-
-        if comment.event == "commented" and not comment.nil?
-          description_text += "<b>Comment:</b><br>"
-          description_text += comment.body.to_html
-          description_text += "<br>"
-        end
-
-        description_text += "<b>Full note:</b><br>"
-        description_text += comment.note.flatten_comment("<br>", comment.created_at)
-
-        xml.description description_text 
+        xml.description render(:partial => "entry", :object => comment, :formats => [ :html ])
 
         if comment.author
           xml.author comment.author.display_name
 
         if comment.author
           xml.author comment.author.display_name
index fda48ed570691b34621c19bc3777aecb7c283bac..6638589b0f33f809a6739b6cb22082ff37a37cd9 100644 (file)
@@ -2001,6 +2001,9 @@ en:
       closed: "closed note (near %{place})"
       new: "new note (near %{place})"
       comment: "new comment (near %{place})"
       closed: "closed note (near %{place})"
       new: "new note (near %{place})"
       comment: "new comment (near %{place})"
+    entry:
+      comment: Comment
+      full: Full note
     mine:
       title: "Notes submitted or commented on by %{user}"
       heading: "%{user}'s notes"
     mine:
       title: "Notes submitted or commented on by %{user}"
       heading: "%{user}'s notes"