Commit 78a64ca100a1afab84129afe625b0084c7fc9cd7
Exists in
master
and in
4 other branches
Merge pull request #1851 from riyad/link-to-commit-authors-everywhere
Link to commit authors everywhere
Showing
6 changed files
with
55 additions
and
24 deletions
Show diff stats
app/assets/stylesheets/sections/commits.scss
@@ -47,12 +47,15 @@ | @@ -47,12 +47,15 @@ | ||
47 | padding-left: 32px; | 47 | padding-left: 32px; |
48 | } | 48 | } |
49 | 49 | ||
50 | - .author, | ||
51 | - .committer { | 50 | + .author a, |
51 | + .committer a { | ||
52 | font-size:14px; | 52 | font-size:14px; |
53 | line-height:22px; | 53 | line-height:22px; |
54 | text-shadow:0 1px 1px #fff; | 54 | text-shadow:0 1px 1px #fff; |
55 | color:#777; | 55 | color:#777; |
56 | + &:hover { | ||
57 | + color: #999; | ||
58 | + } | ||
56 | } | 59 | } |
57 | 60 | ||
58 | .avatar { | 61 | .avatar { |
@@ -227,6 +230,9 @@ | @@ -227,6 +230,9 @@ | ||
227 | 230 | ||
228 | .commit-author-name { | 231 | .commit-author-name { |
229 | color: #777; | 232 | color: #777; |
233 | + &:hover { | ||
234 | + color: #999; | ||
235 | + } | ||
230 | } | 236 | } |
231 | } | 237 | } |
232 | 238 |
app/assets/stylesheets/sections/tree.scss
app/decorators/commit_decorator.rb
@@ -47,21 +47,15 @@ class CommitDecorator < ApplicationDecorator | @@ -47,21 +47,15 @@ class CommitDecorator < ApplicationDecorator | ||
47 | # Otherwise it will link to the author email as specified in the commit. | 47 | # Otherwise it will link to the author email as specified in the commit. |
48 | # | 48 | # |
49 | # options: | 49 | # options: |
50 | - # avatar: true will prepend avatar image | ||
51 | - def author_link(options) | ||
52 | - text = if options[:avatar] | ||
53 | - avatar = h.image_tag h.gravatar_icon(author_email), class: "avatar s16", width: 16 | ||
54 | - "#{avatar} #{author_name}" | ||
55 | - else | ||
56 | - author_name | ||
57 | - end | ||
58 | - team_member = @project.try(:team_member_by_name_or_email, author_name, author_email) | 50 | + # avatar: true will prepend the avatar image |
51 | + # size: size of the avatar image in px | ||
52 | + def author_link(options = {}) | ||
53 | + person_link(options.merge source: :author) | ||
54 | + end | ||
59 | 55 | ||
60 | - if team_member.nil? | ||
61 | - h.mail_to author_email, text.html_safe, class: "commit-author-link" | ||
62 | - else | ||
63 | - h.link_to text, h.project_team_member_path(@project, team_member), class: "commit-author-link" | ||
64 | - end | 56 | + # Just like #author_link but for the committer. |
57 | + def committer_link(options = {}) | ||
58 | + person_link(options.merge source: :committer) | ||
65 | end | 59 | end |
66 | 60 | ||
67 | protected | 61 | protected |
@@ -69,4 +63,30 @@ class CommitDecorator < ApplicationDecorator | @@ -69,4 +63,30 @@ class CommitDecorator < ApplicationDecorator | ||
69 | def no_commit_message | 63 | def no_commit_message |
70 | "--no commit message" | 64 | "--no commit message" |
71 | end | 65 | end |
66 | + | ||
67 | + # Private: Returns a link to a person. If the person has a matching user and | ||
68 | + # is a member of the current @project it will link to the team member page. | ||
69 | + # Otherwise it will link to the person email as specified in the commit. | ||
70 | + # | ||
71 | + # options: | ||
72 | + # source: one of :author or :committer | ||
73 | + # avatar: true will prepend the avatar image | ||
74 | + # size: size of the avatar image in px | ||
75 | + def person_link(options = {}) | ||
76 | + source_name = send "#{options[:source]}_name".to_sym | ||
77 | + source_email = send "#{options[:source]}_email".to_sym | ||
78 | + text = if options[:avatar] | ||
79 | + avatar = h.image_tag h.gravatar_icon(source_email, options[:size]), class: "avatar #{"s#{options[:size]}" if options[:size]}", width: options[:size] | ||
80 | + %Q{#{avatar} <span class="commit-#{options[:source]}-name">#{source_name}</span>} | ||
81 | + else | ||
82 | + source_name | ||
83 | + end | ||
84 | + team_member = @project.try(:team_member_by_name_or_email, source_name, source_email) | ||
85 | + | ||
86 | + if team_member.nil? | ||
87 | + h.mail_to source_email, text.html_safe, class: "commit-#{options[:source]}-link" | ||
88 | + else | ||
89 | + h.link_to text, h.project_team_member_path(@project, team_member), class: "commit-#{options[:source]}-link" | ||
90 | + end | ||
91 | + end | ||
72 | end | 92 | end |
app/views/blame/show.html.haml
@@ -24,9 +24,7 @@ | @@ -24,9 +24,7 @@ | ||
24 | - commit = Commit.new(commit) | 24 | - commit = Commit.new(commit) |
25 | - commit = CommitDecorator.decorate(commit) | 25 | - commit = CommitDecorator.decorate(commit) |
26 | %tr | 26 | %tr |
27 | - %td.author | ||
28 | - = image_tag gravatar_icon(commit.author_email, 16) | ||
29 | - = commit.author_name | 27 | + %td.author= commit.author_link avatar: true, size: 16 |
30 | %td.blame_commit | 28 | %td.blame_commit |
31 | | 29 | |
32 | %code= link_to commit.short_id, project_commit_path(@project, commit) | 30 | %code= link_to commit.short_id, project_commit_path(@project, commit) |
app/views/commits/_commit.html.haml
@@ -4,9 +4,8 @@ | @@ -4,9 +4,8 @@ | ||
4 | %strong= link_to "Browse Code »", project_tree_path(@project, commit), class: "right" | 4 | %strong= link_to "Browse Code »", project_tree_path(@project, commit), class: "right" |
5 | %p | 5 | %p |
6 | = link_to commit.short_id(8), project_commit_path(@project, commit), class: "commit_short_id" | 6 | = link_to commit.short_id(8), project_commit_path(@project, commit), class: "commit_short_id" |
7 | - %strong.commit-author-name= commit.author_name | 7 | + %strong= commit.author_link avatar: true, size: 24 |
8 | %span.dash – | 8 | %span.dash – |
9 | - = image_tag gravatar_icon(commit.author_email), class: "avatar", width: 16 | ||
10 | = link_to_gfm truncate(commit.title, length: 50), project_commit_path(@project, commit.id), class: "row_title" | 9 | = link_to_gfm truncate(commit.title, length: 50), project_commit_path(@project, commit.id), class: "row_title" |
11 | 10 | ||
12 | %span.committed_ago | 11 | %span.committed_ago |
app/views/commits/_commit_box.html.haml
@@ -18,16 +18,15 @@ | @@ -18,16 +18,15 @@ | ||
18 | .commit-info | 18 | .commit-info |
19 | .row | 19 | .row |
20 | .span5 | 20 | .span5 |
21 | - = image_tag gravatar_icon(@commit.author_email, 40), class: "avatar" | ||
22 | .author | 21 | .author |
23 | - %strong= @commit.author_name | 22 | + %strong= @commit.author_link avatar: true, size: 40 |
24 | authored | 23 | authored |
25 | %time{title: @commit.authored_date.stamp("Aug 21, 2011 9:23pm")} | 24 | %time{title: @commit.authored_date.stamp("Aug 21, 2011 9:23pm")} |
26 | #{time_ago_in_words(@commit.authored_date)} ago | 25 | #{time_ago_in_words(@commit.authored_date)} ago |
27 | - if @commit.different_committer? | 26 | - if @commit.different_committer? |
28 | .committer | 27 | .committer |
29 | → | 28 | → |
30 | - %strong= @commit.committer_name | 29 | + %strong= @commit.committer_link |
31 | committed | 30 | committed |
32 | %time{title: @commit.committed_date.stamp("Aug 21, 2011 9:23pm")} | 31 | %time{title: @commit.committed_date.stamp("Aug 21, 2011 9:23pm")} |
33 | #{time_ago_in_words(@commit.committed_date)} ago | 32 | #{time_ago_in_words(@commit.committed_date)} ago |