forked from douban/code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommit.html
More file actions
138 lines (118 loc) · 5.39 KB
/
commit.html
File metadata and controls
138 lines (118 loc) · 5.39 KB
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<%inherit file="/source.html" />
<%namespace name="inline_comment_form" file="/widgets/diff/inline_comment_form.html" />
<%namespace name="thread_form" file="/pull/ticket_thread.html" />
<%namespace name="pull_util" file="/pull/utils.html" />
## 跟pr的diff统一
<%namespace name="diff_render" file="/widgets/diff/diff.html" />
<%namespace name="commit_render" file="/widgets/commit.html" />
<%namespace name="utils" file="/pull/utils.html"/>
<%def name="bottom_script()">
<script src="${static('/js/app/src/src.js')}"></script>
<script src="${static('/js/app/src/commit.js')}"></script>
</%def>
<%def name="head_style()">
<link rel="stylesheet" type="text/css" href="/static/css/lib/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="${static('/css/app/commit.css')}" />
</%def>
${parent.body()}
<%!
from vilya.libs.text import render_markdown, parse_emoji, replace_onimaru_to_link
from vilya.libs.text import parse_emoji
from vilya.models.user import User
%>
<%def name="title()">${self.commit_title(truncate=True)}</%def>
<%def name="suffix()">${ref[:8]} · ${project.name}</%def>
<%def name="commit_title(truncate=False)">
<% message = commit.rendered_message %>
% if truncate:
${len(message) > 50 and message[:50] + '..' or message}
% else:
${message | n}
% endif
</%def>
<%def name="main()">
${self.sourcenav_bar(active="commits")}
<div class="span12">
% if not diff:
<span id="emptyrepo-hint">You appear to be browsing a merge commit (or this commit has too many diffs to be displayed).</span>
% else:
<%
ntotal = diff.length
nadds = diff.additions
ndels = diff.deletions
%>
<!-- commit summary -->
${commit_render.commit(commit, ref, project, path=path)}
<!-- diff stat -->
<a name="diff-stat"></a>
<div id='toc' class="js-details-container">
${diff_render.diff_topic(diff)}
</div>
<!-- diff files -->
% if nadds+ndels > 10000 or ntotal > 100:
<div class="timeout">
<h3>
<strong>Sorry,</strong> this commit is taking too long to generate.
</h3>
<p>Try the <a href="/${project.name}/commit/${ref}.diff">raw diff</a> instead.</p>
</div>
% else:
<div id="files" class="diff-view commentable">
## TODO: commit 目前 side by side diff 时不显示 linecomment
## 因为样式会乱,暂时把 show inline comments toggle 去掉了
<% is_commentable = True if current_user else False %>
${diff_render.diff_files(diff.patches, project, is_commentable=is_commentable)}
</div>
% endif
% endif
${self.disp_comments(project, ref, comments, current_user)}
</div>
${self.bottom_template()}
</%def>
## 是comment,不是 linecomment
## TODO: comment 相关的移到 widgets/comment
<%def name="disp_comments(project, ref, comments, current_user)">
<div class="commit full-comment " id="all-comments">
% for comment in comments:
${self.disp_one_comment(project, comment, current_user)}
% endfor
</div>
% if current_user:
${self.add_comment(project, ref, commit, current_user)}
% endif
</%def>
<%def name="disp_one_comment(project, comment, current_user)">
<div class="commit-meta clearfix comment-row">
${utils.side_avatar(comment.author)}
<div class="comment-header" style="height: 23px;">
<% content = comment.content %>
<% uid = comment.uid %>
<span class="author-name"><a href="/people/${comment.author}" rel="author">${comment.author}</a></span>
<span>commented</span>
<span clsss="comment-header-right" style="float: right; height: 15px;">
<time class="js-relative-date" data-time="${comment.created.strftime('%Y-%m-%dT%H:%M:%S+0800')}" title="${comment.created}">${comment.created}</time>
% if current_user and comment.author == current_user.name:
<% comment_url = '/%s/comments/%s' % (project.name, comment.comment_id) %>
<a class="mini-icon-delete-note mini-icon delete-btn" href='${comment_url}'></a>
% endif
</span>
</div>
<div style='margin-left:27px; margin-right:27px; margin-top:5px; word-wrap:break-word'>
<span class="emojstext">${render_markdown(replace_onimaru_to_link(content, project))|n}</span>
</div>
</div>
</%def>
<%def name="add_comment(project, ref, commit, current_user)">
<form action='/${project.name}/comments/new' id="new_comment" method="post" class="previewable-comment-form write-selected">
<input name="ref" value="${ref}" type="hidden" />
<input name="commit_author" value="${commit.author.name}" type="hidden" />
${pull_util.side_avatar(current_user)}
${thread_form.cm_form_content()}
<div class="form-actions">
<button type="submit" class="classy primary" tabindex="2" data-disable-with="">Comment</button>
</div>
</form>
</%def>
<%def name="bottom_template()">
${inline_comment_form.inline_comment_form_template('/%s/line_comments/create' % project.name)}
</%def>