/
commit.erb
117 lines (111 loc) · 4.33 KB
/
commit.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<%= js_bundle(:commit_app_js) %>
<%= js_bundle(:commit_vendor_js) %>
<script id="context-expander-template" type="text/x-mustache-template">
<%= MustacheRenderer.context_expander_source %>
</script>
<% line_length = current_user ? current_user.line_length || 110 : 110 %>
<% default_to_side_by_side = current_user ? current_user.default_to_side_by_side : false %>
<div id="commit" sha="<%= commit.sha %>" repo="<%= commit.git_repo.name %>" margin-size="<%= line_length %>"
data-default-to-side-by-side="<%= default_to_side_by_side %>">
<div id="center">
<div id="commitMetadata" class="embossedPanel">
<div id="messageAndAuthor">
<div id="messageMetadata">
<p class="name">
<span class="sha"><%= commit.sha %></span>
<span class="repoName">| <%= commit.git_repo.name %></span>
</p>
<p class="message"><%= commit.filter_message %></p>
</div>
<div id="authorMetadata">
<div class="avatar"><img src="<%= commit.grit_commit.author.gravatar %>" /></div>
<div class="authorInfo">
<p class="author"><%= commit.grit_commit.author.name %></p>
<p class="email"><%= commit.grit_commit.author.email %></p>
<p class="date">
<span class="north" rel="tipsy" title="<%= commit.date.strftime("%Y-%m-%d %H:%M:%S") %>">
<%= commit.date.to_pretty %>
</span>
</p>
</div>
</div>
</div>
<div id="metadataButtons">
<div id="approvalGroup">
<% if current_user %>
<% if commit.approved? %>
<button id="disapproveButton" class="fancy" title="ಠ_ಠ">Disapprove Commit</button>
<% else %>
<button id="approveButton" class="fancy">Approve Commit</button>
<% end %>
<% end %>
<% if commit.approved? %>
<%= erb :_approved_banner, :layout => false, :locals => { :commit => commit } %>
<% end %>
</div>
<div id="minorButtons">
<% if current_user %>
<button id="requestReviewButton" class="standard">Request Review</button>
<% end %>
<button id="sideBySideButton" class="standard">View Side-By-Side</button>
<button id="hideCommentButton" class="standard">Hide comments</button>
</div>
</div>
</div>
<div id="reviewRequestContainer">
<div id="reviewRequest" animatingDirection="in">
<div id="requestInput">
<label>Request reviews from</label>
<input id="authorInput" type="text" />
<button class="standard">Send</button>
</div>
<div id="requestSubmitted">
<p>Review requests emailed to<span></span></p>
</div>
</div>
</div>
<div id="commitSummary">
<table id="filesChanged">
<tr><th></th><th>+</th><th>-</th></tr>
<% tagged_diff.each do |diff| %>
<tr>
<td class="path">
<a href="#<%= diff.file_name_before %>">
<%= StringFilter.truncate_front(diff.display_file_name, 100) %>
</a>
</td>
<td class="linesAdded"><%= diff.lines_added if diff.lines_added > 0%></td>
<td class="linesRemoved"><%= diff.lines_removed if diff.lines_removed > 0%></td>
</tr>
<% end %>
<% added, removed = [:lines_added, :lines_removed].map { |m| tagged_diff.map(&m).reduce(&:+) } %>
<tr class="total" >
<td class="path">Total</td>
<td class="linesAdded"><%= added %></td>
<td class="linesRemoved"><%= removed %></td>
</tr>
</table>
</div>
<% tagged_diff.each do |file| %>
<%= erb :_diff, :locals => { :commit => commit, :file => file } %>
<br/>
<% end %>
<div class="comments">
<% commit.comments.each do |comment| %>
<%= erb :_comment, :locals => { :comment => comment } %>
<% end %>
</div>
<% if current_user %>
<div id="commitComments">
<%= erb :_comment_form, :locals => {
:repo_name => commit.git_repo.name,
:sha => commit.sha,
:filename => nil,
:line_number => nil
} %>
</div>
<% else %>
<div id="signinPrompt" class="commit"><a href="/signin">Sign in</a> to post a comment.</div>
<% end %>
</div>
</div>