gitlabhq/app/helpers/dashboard_helper.rb

31 lines
1 KiB
Ruby
Raw Normal View History

2011-10-08 23:36:38 +02:00
module DashboardHelper
2011-11-02 21:14:03 +01:00
def dashboard_feed_path(project, object)
2011-10-31 21:57:16 +01:00
case object.class.name.to_s
when "Issue" then project_issues_path(project, project.issues.find(object.id))
when "Grit::Commit" then project_commit_path(project, project.repo.commits(object.id).first)
2011-11-02 21:14:03 +01:00
when "Note"
then
note = object
case note.noteable_type
when "Issue" then project_issue_path(project, note.noteable_id)
when "Snippet" then project_snippet_path(project, note.noteable_id)
when "Commit" then project_commit_path(project, :id => note.noteable_id)
else wall_project_path(project)
end
else "#"
2011-10-31 21:57:16 +01:00
end
2011-11-02 21:14:03 +01:00
rescue
"#"
end
def dashboard_feed_title(object)
title = case object.class.name.to_s
when "Note" then markdown(object.note)
when "Issue" then object.title
when "Grit::Commit" then object.safe_message
else ""
end
"[#{object.class.name}] #{truncate(sanitize(title, :tags => []), :length => 60)} "
2011-10-31 21:57:16 +01:00
end
2011-10-08 23:36:38 +02:00
end