From 0b8e956f32cac5847029c29a607816b743e52465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Leutgo=CC=88b?= Date: Mon, 24 Sep 2012 11:01:44 +0200 Subject: [PATCH 1/3] Add a more verbose dashboard event feed - Add project name to event title - Push: Entry links to single commit or commits overview depending on number of pushed commits - Push: Display first 15 commits with commit message and author and link to single commit - Issues: Display issue description --- app/decorators/event_decorator.rb | 26 +++++++++++++++++++++---- app/views/dashboard/index.atom.builder | 3 ++- app/views/events/_event_issue.atom.haml | 2 ++ app/views/events/_event_push.atom.haml | 14 +++++++++++++ 4 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 app/views/events/_event_issue.atom.haml create mode 100644 app/views/events/_event_push.atom.haml diff --git a/app/decorators/event_decorator.rb b/app/decorators/event_decorator.rb index ce0aaa03..b2f9c439 100644 --- a/app/decorators/event_decorator.rb +++ b/app/decorators/event_decorator.rb @@ -3,11 +3,11 @@ class EventDecorator < ApplicationDecorator def feed_title if self.issue? - "#{self.author_name} #{self.action_name} issue ##{self.target_id}:" + self.issue_title + "#{self.author_name} #{self.action_name} issue ##{self.target_id}: #{self.issue_title} at #{self.project.name}" elsif self.merge_request? - "#{self.author_name} #{self.action_name} MR ##{self.target_id}:" + self.merge_request_title + "#{self.author_name} #{self.action_name} MR ##{self.target_id}: #{self.merge_request_title} at #{self.project.name}" elsif self.push? - "#{self.author_name} #{self.push_action_name} #{self.ref_type} " + self.ref_name + "#{self.author_name} #{self.push_action_name} #{self.ref_type} #{self.ref_name} at #{self.project.name}" elsif self.membership_changed? "#{self.author_name} #{self.action_name} #{self.project.name}" else @@ -20,8 +20,26 @@ class EventDecorator < ApplicationDecorator h.project_issue_url(self.project, self.issue) elsif self.merge_request? h.project_merge_request_url(self.project, self.merge_request) + elsif self.push? - h.project_commits_url(self.project, ref: self.ref_name) + if self.push_with_commits? + if self.commits_count > 1 + h.compare_project_commits_path(self.project, :from => self.parent_commit.id, :to => self.last_commit.id) + else + h.project_commit_path(self.project, :id => self.last_commit.id) + end + else + h.project_commits_url(self.project, ref: self.ref_name) + end + end + + end + + def feed_summary + if self.issue? + h.render "events/event_issue", issue: self.issue + elsif self.push? + h.render "events/event_push", event: self end end end diff --git a/app/views/dashboard/index.atom.builder b/app/views/dashboard/index.atom.builder index fa3bfade..ffa15258 100644 --- a/app/views/dashboard/index.atom.builder +++ b/app/views/dashboard/index.atom.builder @@ -12,6 +12,7 @@ xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://sear xml.entry do event_link = event.feed_url event_title = event.feed_title + event_summary = event.feed_summary xml.id "tag:#{request.host},#{event.created_at.strftime("%Y-%m-%d")}:#{event.id}" xml.link :href => event_link @@ -22,7 +23,7 @@ xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://sear xml.name event.author_name xml.email event.author_email end - xml.summary event_title + xml.summary(:type => "xhtml") { |x| x << event_summary unless event_summary.nil? } end end end diff --git a/app/views/events/_event_issue.atom.haml b/app/views/events/_event_issue.atom.haml new file mode 100644 index 00000000..64dc02e3 --- /dev/null +++ b/app/views/events/_event_issue.atom.haml @@ -0,0 +1,2 @@ +%div{:xmlns => "http://www.w3.org/1999/xhtml"} + %p= simple_format issue.description diff --git a/app/views/events/_event_push.atom.haml b/app/views/events/_event_push.atom.haml new file mode 100644 index 00000000..340275a5 --- /dev/null +++ b/app/views/events/_event_push.atom.haml @@ -0,0 +1,14 @@ +%div{:xmlns => "http://www.w3.org/1999/xhtml"} + - event.commits.first(15).each do |commit| + %p + %strong= commit.author_name + = link_to "(##{commit.short_id})", project_commit_path(event.project, :id => commit.id) + %i + at + = commit.committed_date.strftime("%Y-%m-%d %H:%M:%S") + %blockquote= simple_format commit.safe_message + - if event.commits_count > 15 + %p + %i + \... and + = pluralize(event.commits_count - 15, "more commit") From 987e351de7fb6c98094a1c099c717dacb3f1416e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Leutgo=CC=88b?= Date: Thu, 4 Oct 2012 10:06:17 +0200 Subject: [PATCH 2/3] Escape html entities in commit messages --- app/views/events/_event_push.atom.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/events/_event_push.atom.haml b/app/views/events/_event_push.atom.haml index 340275a5..d09e6e03 100644 --- a/app/views/events/_event_push.atom.haml +++ b/app/views/events/_event_push.atom.haml @@ -6,7 +6,7 @@ %i at = commit.committed_date.strftime("%Y-%m-%d %H:%M:%S") - %blockquote= simple_format commit.safe_message + %blockquote= simple_format(escape_once(commit.safe_message)) - if event.commits_count > 15 %p %i From bcdb168709ac03c7a7e00f440dcd47f2538894e3 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 8 Oct 2012 14:17:46 +0300 Subject: [PATCH 3/3] Fix dashboard atom feed routes --- app/decorators/event_decorator.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/decorators/event_decorator.rb b/app/decorators/event_decorator.rb index b2f9c439..1b0ad0da 100644 --- a/app/decorators/event_decorator.rb +++ b/app/decorators/event_decorator.rb @@ -24,15 +24,14 @@ class EventDecorator < ApplicationDecorator elsif self.push? if self.push_with_commits? if self.commits_count > 1 - h.compare_project_commits_path(self.project, :from => self.parent_commit.id, :to => self.last_commit.id) + h.project_compare_url(self.project, :from => self.parent_commit.id, :to => self.last_commit.id) else - h.project_commit_path(self.project, :id => self.last_commit.id) + h.project_commit_url(self.project, :id => self.last_commit.id) end else - h.project_commits_url(self.project, ref: self.ref_name) + h.project_commits_url(self.project, self.ref_name) end end - end def feed_summary