From 5dda4196d50774e8a44e9e137d45141d4151764b Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 26 Apr 2013 19:34:32 +0100 Subject: [PATCH] Rework the generation of descriptions in the notes RSS feed --- app/views/notes/_comment.html.erb | 8 ++++++++ app/views/notes/_description.html.erb | 11 +---------- app/views/notes/_entry.html.erb | 4 ++++ app/views/notes/feed.rss.builder | 13 +------------ config/locales/en.yml | 3 +++ 5 files changed, 17 insertions(+), 22 deletions(-) create mode 100644 app/views/notes/_comment.html.erb create mode 100644 app/views/notes/_entry.html.erb diff --git a/app/views/notes/_comment.html.erb b/app/views/notes/_comment.html.erb new file mode 100644 index 000000000..4fe7b59d5 --- /dev/null +++ b/app/views/notes/_comment.html.erb @@ -0,0 +1,8 @@ +
+ <% if comment.author.nil? -%> +
<%= t "note.description.#{comment.event}_at", :when => friendly_date(comment.created_at) %>
+ <% else -%> +
<%= t "note.description.#{comment.event}_at_by", :when => friendly_date(comment.created_at), :user => note_author(comment.author, :only_path => false) %>
+ <% end -%> +
<%= comment.body %>
+
diff --git a/app/views/notes/_description.html.erb b/app/views/notes/_description.html.erb index 761b69ea2..4f03a1d59 100644 --- a/app/views/notes/_description.html.erb +++ b/app/views/notes/_description.html.erb @@ -1,12 +1,3 @@
- <% description.comments.each do |comment| -%> -
- <% if comment.author.nil? -%> -
<%= t "note.description.#{comment.event}_at", :when => friendly_date(comment.created_at) %>
- <% else -%> -
<%= t "note.description.#{comment.event}_at_by", :when => friendly_date(comment.created_at), :user => note_author(comment.author, :only_path => false) %>
- <% end -%> -
<%= comment.body %>
-
- <% end -%> + <%= render :partial => "comment", :collection => description.comments %>
diff --git a/app/views/notes/_entry.html.erb b/app/views/notes/_entry.html.erb new file mode 100644 index 000000000..6f0c8fb71 --- /dev/null +++ b/app/views/notes/_entry.html.erb @@ -0,0 +1,4 @@ +

<%= t "note.entry.comment" %>

+<%= render :partial => "comment", :object => entry %> +

<%= t "note.entry.full" %>

+<%= render :partial => "description", :object => entry.note %> diff --git a/app/views/notes/feed.rss.builder b/app/views/notes/feed.rss.builder index 4733c1bad..f17be09cb 100644 --- a/app/views/notes/feed.rss.builder +++ b/app/views/notes/feed.rss.builder @@ -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) - description_text = "" - - if comment.event == "commented" and not comment.nil? - description_text += "Comment:
" - description_text += comment.body.to_html - description_text += "
" - end - - description_text += "Full note:
" - description_text += comment.note.flatten_comment("
", 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 diff --git a/config/locales/en.yml b/config/locales/en.yml index fda48ed57..6638589b0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2001,6 +2001,9 @@ en: 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" -- 2.43.2