BigW Consortium Gitlab

dashboard_helper.rb 1.06 KB
Newer Older
gitlabhq committed
1
module DashboardHelper
gitlabhq committed
2
  def dashboard_feed_path(project, object)
gitlabhq committed
3
    case object.class.name.to_s
4
    when "Issue" then project_issue_path(project, project.issues.find(object.id))
gitlabhq committed
5
    when "Grit::Commit" then project_commit_path(project, project.repo.commits(object.id).first)
gitlabhq committed
6 7 8 9 10 11 12 13 14
    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
15
    else wall_project_path(project) 
gitlabhq committed
16
    end
gitlabhq committed
17 18 19 20 21
  rescue 
    "#"
  end

  def dashboard_feed_title(object)
22 23 24
    klass = object.class.to_s.split("::").last

    title = case klass
gitlabhq committed
25 26
            when "Note" then markdown(object.note)
            when "Issue" then object.title
27
            when "Commit" then object.safe_message
28
            else return "Project Wall"
gitlabhq committed
29
            end
30 31

    "[#{klass}] #{truncate(sanitize(title, :tags => []), :length => 60)} "
gitlabhq committed
32
  end
gitlabhq committed
33
end