Commit 34cea1cb632c907ae399df64c60e93a5c716eeca

Authored by Riyad Preukschas
1 parent ff40b7de

Update views to use CommitDecorator

app/controllers/commits_controller.rb
... ... @@ -17,6 +17,7 @@ class CommitsController < ApplicationController
17 17 @limit, @offset = (params[:limit] || 40), (params[:offset] || 0)
18 18  
19 19 @commits = @project.commits(@ref, params[:path], @limit, @offset)
  20 + @commits = CommitDecorator.decorate(@commits)
20 21  
21 22 respond_to do |format|
22 23 format.html # index.html.erb
... ...
app/controllers/merge_requests_controller.rb
... ... @@ -143,5 +143,6 @@ class MergeRequestsController < ApplicationController
143 143 # Get commits from repository
144 144 # or from cache if already merged
145 145 @commits = @merge_request.commits
  146 + @commits = CommitDecorator.decorate(@commits)
146 147 end
147 148 end
... ...
app/controllers/refs_controller.rb
... ... @@ -51,7 +51,8 @@ class RefsController < ApplicationController
51 51 @logs = contents.map do |content|
52 52 file = params[:path] ? File.join(params[:path], content.name) : content.name
53 53 last_commit = @project.commits(@commit.id, file, 1).last
54   - {
  54 + last_commit = CommitDecorator.decorate(last_commit)
  55 + {
55 56 :file_name => content.name,
56 57 :commit => last_commit
57 58 }
... ...
app/views/commits/_commit.html.haml
... ... @@ -4,11 +4,11 @@
4 4 %strong= link_to "Browse Code »", tree_project_ref_path(@project, commit.id), :class => "right"
5 5 = link_to project_commit_path(@project, :id => commit.id) do
6 6 %p
7   - %code.left= commit.id.to_s[0..10]
  7 + %code.left= commit.short_id
8 8 %strong.cgray= commit.author_name
9 9 –
10 10 = image_tag gravatar_icon(commit.author_email), :class => "avatar", :width => 16
11   - %span.row_title= truncate(commit.safe_message, :length => 50)
  11 + %span.row_title= truncate(commit.title, :length => 50)
12 12  
13 13 %span.committed_ago
14 14 = time_ago_in_words(commit.committed_date)
... ...
app/views/commits/index.atom.builder
... ... @@ -10,14 +10,14 @@ xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://sear
10 10 xml.entry do
11 11 xml.id project_commit_url(@project, :id => commit.id)
12 12 xml.link :href => project_commit_url(@project, :id => commit.id)
13   - xml.title truncate(commit.safe_message, :length => 80)
  13 + xml.title truncate(commit.title, :length => 80)
14 14 xml.updated commit.committed_date.strftime("%Y-%m-%dT%H:%M:%SZ")
15 15 xml.media :thumbnail, :width => "40", :height => "40", :url => gravatar_icon(commit.author_email)
16 16 xml.author do |author|
17 17 xml.name commit.author_name
18 18 xml.email commit.author_email
19 19 end
20   - xml.summary commit.safe_message
  20 + xml.summary commit.description
21 21 end
22 22 end
23 23 end
... ...
app/views/events/_commit.html.haml
  1 +- commit = CommitDecorator.decorate(commit)
1 2 %li.wll.commit
2 3 = link_to project_commit_path(project, :id => commit.id) do
3 4 %p
4   - %code.left= commit.id.to_s[0..10]
  5 + %code.left= commit.short_id
5 6 %strong.cgray= commit.author_name
6 7 –
7 8 = image_tag gravatar_icon(commit.author_email), :class => "avatar", :width => 16
8   - %span.row_title= truncate(commit.safe_message, :length => 50) rescue "--broken encoding"
  9 + %span.row_title= truncate(commit.title, :length => 50) rescue "--broken encoding"
9 10  
... ...
app/views/refs/_tree_commit.html.haml
1 1 - if tm
2 2 %strong= link_to "[#{tm.user_name}]", project_team_member_path(@project, tm)
3   -= link_to truncate(content_commit.safe_message, :length => tm ? 30 : 50), project_commit_path(@project, content_commit.id), :class => "tree-commit-link"
  3 += link_to truncate(content_commit.title, :length => tm ? 30 : 50), project_commit_path(@project, content_commit.id), :class => "tree-commit-link"
... ...
app/views/refs/blame.html.haml
... ... @@ -25,6 +25,7 @@
25 25 %table
26 26 - @blame.each do |commit, lines|
27 27 - commit = Commit.new(commit)
  28 + - commit = CommitDecorator.decorate(commit)
28 29 %tr
29 30 %td.author
30 31 = image_tag gravatar_icon(commit.author_email, 16)
... ... @@ -32,8 +33,8 @@
32 33 %td.blame_commit
33 34  
34 35 = link_to project_commit_path(@project, :id => commit.id) do
35   - %code= commit.id.to_s[0..10]
36   - %span.row_title= truncate(commit.safe_message, :length => 30) rescue "--broken encoding"
  36 + %code= commit.short_id
  37 + %span.row_title= truncate(commit.title, :length => 30) rescue "--broken encoding"
37 38 %td.lines
38 39 = preserve do
39 40 %pre
... ...
app/views/repositories/_branch.html.haml
  1 +- commit = Commit.new(branch.commit)
  2 +- commit = CommitDecorator.decorate(commit)
1 3 %tr
2 4 %td
3 5 = link_to project_commits_path(@project, :ref => branch.name) do
... ... @@ -5,14 +7,14 @@
5 7 - if branch.name == @project.root_ref
6 8 %span.label default
7 9 %td
8   - = link_to project_commit_path(@project, :id => branch.commit.id) do
9   - %code= branch.commit.id.to_s[0..10]
  10 + = link_to project_commit_path(@project, :id => commit.id) do
  11 + %code= commit.short_id
10 12  
11   - = image_tag gravatar_icon(Commit.new(branch.commit).author_email), :class => "", :width => 16
12   - = truncate(Commit.new(branch.commit).safe_message, :length => 40)
  13 + = image_tag gravatar_icon(commit.author_email), :class => "", :width => 16
  14 + = truncate(commit.title, :length => 40)
13 15 %td
14 16 %span.update-author.right
15   - = time_ago_in_words(branch.commit.committed_date)
  17 + = time_ago_in_words(commit.committed_date)
16 18 ago
17 19 %td
18 20 - if can? current_user, :download_code, @project
... ...
app/views/repositories/_feed.html.haml
1 1 - commit = update
  2 +- commit = CommitDecorator.new(commit)
2 3 %tr
3 4 %td
4 5 = link_to project_commits_path(@project, :ref => commit.head.name) do
... ... @@ -10,9 +11,9 @@
10 11 %td
11 12 %div
12 13 = link_to project_commits_path(@project, commit.id) do
13   - %code= commit.id.to_s[0..10]
  14 + %code= commit.short_id
14 15 = image_tag gravatar_icon(commit.author_email), :class => "", :width => 16
15   - = truncate(commit.safe_message, :length => 40)
  16 + = truncate(commit.title, :length => 40)
16 17 %td
17 18 %span.right.cgray
18 19 = time_ago_in_words(commit.committed_date)
... ...
app/views/repositories/tags.html.haml
... ... @@ -9,14 +9,15 @@
9 9 %th
10 10 - @tags.each do |tag|
11 11 - commit = Commit.new(tag.commit)
  12 + - commit = CommitDecorator.decorate(commit)
12 13 %tr
13 14 %td
14 15 %strong= link_to tag.name, project_commits_path(@project, :ref => tag.name), :class => ""
15 16 %td
16 17 = link_to project_commit_path(@project, commit.id) do
17   - %code= commit.id.to_s[0..10]
  18 + %code= commit.short_id
18 19 = image_tag gravatar_icon(commit.author_email), :class => "", :width => 16
19   - = truncate(commit.safe_message, :length => 40)
  20 + = truncate(commit.title, :length => 40)
20 21 %td
21 22 %span.update-author.right
22 23 = time_ago_in_words(commit.committed_date)
... ...