From 6451e837bf2cf11f8956824329ddde0e14171a8e Mon Sep 17 00:00:00 2001 From: randx Date: Fri, 6 Jul 2012 02:16:41 +0300 Subject: Better event feed for dashboard --- app/decorators/event_decorator.rb | 25 +++++++++++++++++++++++++ app/views/dashboard/index.atom.builder | 13 +++---------- 2 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 app/decorators/event_decorator.rb diff --git a/app/decorators/event_decorator.rb b/app/decorators/event_decorator.rb new file mode 100644 index 00000000000..50aaa615d49 --- /dev/null +++ b/app/decorators/event_decorator.rb @@ -0,0 +1,25 @@ +class EventDecorator < ApplicationDecorator + decorates :event + + def feed_title + if self.issue? + "#{self.author_name} #{self.action_name} issue ##{self.target_id}:" + self.issue_title + elsif self.merge_request? + "#{self.author_name} #{self.action_name} MR ##{self.target_id}:" + self.merge_request_title + elsif self.push? + "#{self.author_name} #{self.push_action_name} #{self.ref_type} " + self.ref_name + else + "" + end + end + + def feed_url + if self.issue? + 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) + end + end +end diff --git a/app/views/dashboard/index.atom.builder b/app/views/dashboard/index.atom.builder index 706b808ee43..fa3bfade28b 100644 --- a/app/views/dashboard/index.atom.builder +++ b/app/views/dashboard/index.atom.builder @@ -8,17 +8,10 @@ xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://sear @events.each do |event| if event.allowed? + event = EventDecorator.decorate(event) xml.entry do - if event.issue? - event_link = project_issue_url(event.project, event.issue) - event_title = event.issue_title - elsif event.merge_request? - event_link = project_merge_request_url(event.project, event.merge_request) - event_title = event.merge_request_title - elsif event.push? - event_link = project_commits_url(event.project, :ref => event.ref_name) - event_title = event.ref_name - end + event_link = event.feed_url + event_title = event.feed_title xml.id "tag:#{request.host},#{event.created_at.strftime("%Y-%m-%d")}:#{event.id}" xml.link :href => event_link -- cgit v1.2.1