Commit c530543c1a2db47866f3b695f46b57b043c01d97
1 parent
a1d59d80
Exists in
master
and in
4 other branches
Nicer commit headers.
Showing
4 changed files
with
99 additions
and
21 deletions
Show diff stats
app/assets/stylesheets/main.scss
| ... | ... | @@ -94,7 +94,12 @@ $hover: #FDF5D9; |
| 94 | 94 | @import "common.scss"; |
| 95 | 95 | |
| 96 | 96 | /** |
| 97 | - * This scss file redefine chozen selectbox styles for | |
| 97 | + * Styles related to displaying commits | |
| 98 | + */ | |
| 99 | +@import "sections/commits.scss"; | |
| 100 | + | |
| 101 | +/** | |
| 102 | + * This scss file redefine chozen selectbox styles for | |
| 98 | 103 | * project Branch/Tag select element |
| 99 | 104 | */ |
| 100 | 105 | @import "ref_select.scss"; | ... | ... |
| ... | ... | @@ -0,0 +1,33 @@ |
| 1 | +.commit-head { | |
| 2 | + @extend .well; | |
| 3 | + | |
| 4 | + padding: 14px; | |
| 5 | + padding-bottom: 8px; | |
| 6 | + | |
| 7 | + .browse-button { | |
| 8 | + @extend .btn; | |
| 9 | + @extend .btn-small; | |
| 10 | + float: right; | |
| 11 | + } | |
| 12 | + | |
| 13 | + .commit-title { | |
| 14 | + line-height: 26px; | |
| 15 | + } | |
| 16 | + | |
| 17 | + .commit-description { | |
| 18 | + background-color: white; | |
| 19 | + } | |
| 20 | + | |
| 21 | + .sha-block { | |
| 22 | + float: right; | |
| 23 | + margin-left: 10px | |
| 24 | + } | |
| 25 | + | |
| 26 | + .committer { | |
| 27 | + padding-left: 32px; | |
| 28 | + } | |
| 29 | + | |
| 30 | + .avatar { | |
| 31 | + margin-right: 4px; | |
| 32 | + } | |
| 33 | +} | |
| 0 | 34 | \ No newline at end of file | ... | ... |
app/models/commit.rb
| ... | ... | @@ -106,6 +106,41 @@ class Commit |
| 106 | 106 | utf8 author.name |
| 107 | 107 | end |
| 108 | 108 | |
| 109 | + # Returns the commits title. | |
| 110 | + # | |
| 111 | + # Usually, the commit title is the first line of the commit message. | |
| 112 | + # In case this first line is longer than 80 characters, it is cut off | |
| 113 | + # after 70 characters and ellipses (`&hellp;`) are appended. | |
| 114 | + # | |
| 115 | + # @todo This might be better placed in a view helper. | |
| 116 | + def title | |
| 117 | + title_end = safe_message.index(/\n/) | |
| 118 | + if (!title_end && safe_message.length > 80) || (title_end && title_end > 80) | |
| 119 | + safe_message[0..69] << "…".html_safe | |
| 120 | + else | |
| 121 | + safe_message.split(/\n/, 2).first | |
| 122 | + end | |
| 123 | + end | |
| 124 | + | |
| 125 | + # Returns the commits description | |
| 126 | + # | |
| 127 | + # cut off, ellipses (`&hellp;`) are prepended to the commit message. | |
| 128 | + # | |
| 129 | + # @todo This might be better placed in a view helper. | |
| 130 | + def description | |
| 131 | + title_end = safe_message.index(/\n/) | |
| 132 | + if (!title_end && safe_message.length > 80) || (title_end && title_end > 80) | |
| 133 | + "…".html_safe << safe_message[70..-1] | |
| 134 | + else | |
| 135 | + safe_message.split(/\n/, 2)[1].try(:chomp) | |
| 136 | + end | |
| 137 | + end | |
| 138 | + | |
| 139 | + # Was this commit committed by a different person than the original author? | |
| 140 | + def different_committer? | |
| 141 | + author_name != committer_name || author_email != committer_email | |
| 142 | + end | |
| 143 | + | |
| 109 | 144 | def committer_name |
| 110 | 145 | utf8 committer.name |
| 111 | 146 | end | ... | ... |
app/views/commits/show.html.haml
| 1 | -.main_box | |
| 2 | - .top_box_content | |
| 3 | - .right | |
| 4 | - - unless @notes_count.zero? | |
| 5 | - %span.btn.small.disabled.padded= pluralize @notes_count, 'note' | |
| 6 | - | |
| 7 | - = link_to tree_project_ref_path(@project, @commit.id), :class => "btn small" do | |
| 8 | - Browse Code » | |
| 9 | - = image_tag gravatar_icon(@commit.author_email), :class => "avatar" | |
| 10 | - %code= @commit.id.to_s | |
| 11 | - %h5 | |
| 1 | +.commit-head{class: @commit.parents.count > 1 ? "merge-commit" : ""} | |
| 2 | + = link_to "Browse Code »", tree_project_ref_path(@project, @commit.id), :class => "browse-button" | |
| 3 | + %h3.commit-title | |
| 4 | + = commit_msg_with_link_to_issues(@project, @commit.title) | |
| 5 | + - if @commit.description.present? | |
| 6 | + %pre.commit-description | |
| 7 | + = commit_msg_with_link_to_issues(@project, @commit.description) | |
| 8 | + %span.sha-block | |
| 9 | + commit | |
| 10 | + %code= @commit.id | |
| 11 | + %span.sha-block | |
| 12 | + = pluralize(@commit.parents.count, "parent") | |
| 13 | + - @commit.parents.each do |parent| | |
| 14 | + %code= link_to parent.id, project_commit_path(@project, parent) | |
| 15 | + .commit-info | |
| 16 | + .author | |
| 17 | + = image_tag gravatar_icon(@commit.author_email, 24), :class => "avatar", :height => 24, :width => 24 | |
| 12 | 18 | = @commit.author_name |
| 13 | - %small= @commit.created_at.stamp("Aug 21, 2011 9:23pm") | |
| 14 | - - if @commit.author_name != @commit.committer_name or @commit.author_email != @commit.committer_email or @commit.authored_date != @commit.committed_date | |
| 15 | - – | |
| 16 | - %cite committed by | |
| 19 | + authored | |
| 20 | + %time{title: @commit.authored_date.stamp("Aug 21, 2011 9:23pm")} | |
| 21 | + #{time_ago_in_words(@commit.authored_date)} ago | |
| 22 | + - if @commit.different_committer? | |
| 23 | + .committer | |
| 17 | 24 | = @commit.committer_name |
| 18 | - %small= @commit.committed_date.stamp("Aug 21, 2011 9:23pm") | |
| 25 | + committed | |
| 26 | + %time{title: @commit.committed_date.stamp("Aug 21, 2011 9:23pm")} | |
| 27 | + #{time_ago_in_words(@commit.committed_date)} ago | |
| 19 | 28 | |
| 20 | - .middle_box_content | |
| 21 | - %pre.commit_message | |
| 22 | - = commit_msg_with_link_to_issues(@project, @commit.safe_message) | |
| 23 | -%br | |
| 24 | 29 | = render "commits/diffs", :diffs => @commit.diffs |
| 25 | 30 | = render "notes/notes", :tid => @commit.id, :tt => "commit" |
| 26 | 31 | = render "notes/per_line_form" | ... | ... |