forked from edgewall/trac
-
Notifications
You must be signed in to change notification settings - Fork 1
/
jticket_change.html
248 lines (223 loc) · 8.84 KB
/
jticket_change.html
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
{# Copyright (C) 2010-2014 Edgewall Software
This software is licensed as described in the file COPYING, which
you should have received as part of this distribution. The terms
are also available at http://trac.edgewall.com/license.html.
This software consists of voluntary contributions made by many
individuals. For the exact contribution history, see the revision
history and logs, available at http://trac.edgewall.org/.
#}
## Renders a ticket comment.
{# Arguments:
- change: the change data
- hide_buttons=False: hide all buttons (Edit, Reply)
- cnum_edit=None: the comment number being edited
- edited_comment: the current value of the comment editor
- cnum_hist=None: the comment number for which to show a historical content
- can_append=False: True if the user is allowed to append to tickets
- has_edit_comment=False: True if the user is allowed to edit all comments
- preview=False: True if rendering a change preview
#}
# with
# set cnum = to_unicode(change.get('cnum'))
# set hide_buttons = hide_buttons|default(false)
# set cnum_edit = cnum_edit|default('')
# set cnum_hist = cnum_hist|default('')
# set can_append = can_append|default(false)
# set has_edit_comment = has_edit_comment|default(false)
# set preview = preview|default(false)
# set can_edit_comment = has_edit_comment or (
authname and authname != 'anonymous' and authname == change.author)
# set show_editor = can_edit_comment and to_unicode(cnum) == cnum_edit
# set show_history = cnum is equalto(cnum_hist)
# set max_version = change.comment_history|max(0)
# set comment_version = (as_int(cversion, max_version, 0, max_version) if
show_history else max_version)
# set show_buttons = (not hide_buttons and not show_editor and
comment_version == max_version)
# macro commentref(prefix, cnum, cls=none)
<a href="#comment:${cnum}" class="${cls}">${prefix}${cnum}</a>
# endmacro
<h3 class="change"${{'id': 'comment:%s' % cnum if 'cnum' in change}|htmlattr}>
<span class="threading">
# set change_replies = replies.get(cnum, []) if 'cnum' in change else []
# if 'cnum' in change:
<span class="cnum">${commentref('comment:', cnum)}</span>
# endif
# if 'replyto' in change:
<span class="trac-in-reply-to">
in reply to: ${commentref(' '|safe, change.replyto, 'in-reply-to')}
{% if change_replies: %}; {% endif %}
</span>
# endif
# if change_replies:
<span class="trac-follow-ups">
# trans numeral = change_replies|length
<span>follow-up:</span>
# pluralize
<span>follow-ups:</span>
# endtrans
# for reply in change_replies:
${commentref(' '|safe, reply, 'follow-up')}
# endfor
</span>
# endif
</span>
# if 'date' in change:
${tag_("Changed %(date)s by %(author)s",
date = pretty_dateinfo(change.date),
author = authorinfo(change.author))}
# else:
${tag_("Changed by %(author)s", author = authorinfo(change.author))}
# endif
# if preview or show_editor:
<span class="trac-loading"></span>
# endif
</h3>
<div class="trac-change-panel">
## Per-change controls
# if show_buttons:
<div class="trac-ticket-buttons">
# if 'cnum' in change and can_append:
<form id="reply-to-comment-${cnum}" method="get" action="#comment">
<div class="inlinebuttons">
<input type="hidden" name="replyto" value="${cnum}"/>
<input type="submit" value="${captioned_button('↳', _('Reply'))}"
title="${_('Reply to comment %(cnum)s', cnum=cnum)}" />
</div>
</form>
# endif
# if 'cnum' in change and can_edit_comment:
<form id="edit-comment-${cnum}" method="get" action="#comment:${cnum}">
<div class="inlinebuttons">
<input type="hidden" name="cnum_edit" value="${cnum}"/>
<input type="submit" value="${captioned_button('✎', _('Edit'))}"
title="${_('Edit comment %(cnum)s', cnum=cnum)}" />
</div>
</form>
# endif
</div>
# endif
## Property changes
# if change.fields:
<table class="changes">
## for field_name, field in sorted(change.fields.iteritems(), key=lambda item: item[1].label.lower()):
# for field_name, field in change.fields.iteritems()|sort(attribute='1.label'):
## FIXME attribute='1.label|lower'
<tr class="${classes(
'trac-field-' + field_name,
'trac-conflict' if preview and field_name in conflicts)}">
<th class="trac-field-${field_name}">${
_("%(label)s:", label=field.label)}</th>
<td>
# if field_name == 'attachment':
# set attachment_link
<a href="${href.attachment('ticket', ticket.id, field.new)}"><em>${
field.new}</em></a><a href="${href('raw-attachment', 'ticket',
ticket.id, field.new)}"
title="${_("Download")}"
class="trac-rawlink">​</a>
# endset
# trans attachment_link = attachment_link
${attachment_link} added
# endtrans
# elif 'rendered' in field:
${field.rendered}
# elif field.old and field.new:
<span class="trac-field-old">${field.old}</span> →
<span class="trac-field-new">${field.new}</span>
# elif not field.old and field.new:
→ <span class="trac-field-new">${field.new}</span>
# else:
<span class="trac-field-deleted">${field.old}</span>
# if preview and field.by == 'user':
# set old = (ticket.get_default(field_name) if
field.old is sameas(empty) else field.old)
(<button type="submit" name="revert_${field_name}" class="trac-revert"
title="Revert this change">${
_("revert")}<div id="revert-${field_name}">${
'0' if 'cc_update' in field else old}</div></button>)
# endif
# endif
</td>
</tr>
# endfor
</table>
# endif
</div>
## Comment editor
# if show_editor:
<form id="trac-comment-editor" method="post"
action="${href.ticket(ticket.id) + '#comment:' + cnum}">
${jmacros.form_token_input()}
<div>
<textarea name="edited_comment"
class="wikitext trac-fullwidth trac-resizable trac-autofocus"
rows="10" cols="78">
${edited_comment if edited_comment is not none else change.comment
}</textarea>
<input type="hidden" name="cnum_edit" value="${cnum}"/>
</div>
<div class="buttons">
<input type="submit" name="preview_comment" value="${_('Preview')}"
title="${_('Preview changes to comment %(cnum)s', cnum=cnum)}"/>
<input type="submit" name="edit_comment" value="${_('Submit changes')}"
title="${_('Submit changes to comment %(cnum)s', cnum=cnum)}"
class="trac-disable-on-submit" />
<input type="submit" name="cancel_comment" value="${_('Cancel')}"
title="Cancel comment edit"/>
</div>
</form>
# endif
## Comment display
# if cnum == cnum_edit:
<div class="comment searchable ticketdraft"${
{'style': 'display: none' if not text}|htmlattr}>
# set text = edited_comment if edited_comment is not none else change.comment
${wiki_to_html(context, text, escape_newlines=preserve_newlines)}
</div>
# elif show_history:
<div class="comment searchable">
${wiki_to_html(context, change.comment_history[comment_version].comment,
escape_newlines=preserve_newlines)}
</div>
# elif change.comment:
<div class="comment searchable">
${wiki_to_html(context, change.comment, escape_newlines=preserve_newlines)}
</div>
# endif
# if not show_editor and len(change.comment_history) is greaterthan(1):
<div${{'class': {
'trac-lastedit': true,
'trac-shade': comment_version != max_version}}|htmlattr}>
# with
# set date = pretty_dateinfo(change.comment_history[comment_version].date)
# set author = authorinfo(change.comment_history[comment_version].author)
# if comment_version != max_version:
# trans version = comment_version, date, author
Version ${version}, edited ${date} by ${author}
# endtrans
# else:
# trans date, author
Last edited ${date} by ${author}
# endtrans
# endif
# endwith
# if comment_version is greaterthan(0):
(<a href="${href.ticket(ticket.id, cnum_hist=cnum,
cversion=comment_version - 1)}#comment:${cnum}">${
_("previous")}</a>)
# endif
# if comment_version is lessthan(max_version):
(<a href="${href.ticket(ticket.id, cnum_hist=cnum,
cversion=comment_version + 1)}#comment:${cnum}">${
_("next")}</a>)
# endif
# if comment_version is greaterthan(0):
(<a href="${href.ticket(ticket.id, action='comment-diff', cnum=cnum,
version=comment_version)}">${
_("diff")}</a>)
# endif
</div>
# endif
# endwith
## jinjacheck: "CDATA" OK