Show More
@@ -1,391 +1,392 b'' | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | """ |
|
3 | 3 | rhodecode.controllers.changeset |
|
4 | 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
5 | 5 | |
|
6 | 6 | changeset controller for pylons showoing changes beetween |
|
7 | 7 | revisions |
|
8 | 8 | |
|
9 | 9 | :created_on: Apr 25, 2010 |
|
10 | 10 | :author: marcink |
|
11 | 11 | :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> |
|
12 | 12 | :license: GPLv3, see COPYING for more details. |
|
13 | 13 | """ |
|
14 | 14 | # This program is free software: you can redistribute it and/or modify |
|
15 | 15 | # it under the terms of the GNU General Public License as published by |
|
16 | 16 | # the Free Software Foundation, either version 3 of the License, or |
|
17 | 17 | # (at your option) any later version. |
|
18 | 18 | # |
|
19 | 19 | # This program is distributed in the hope that it will be useful, |
|
20 | 20 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
21 | 21 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
22 | 22 | # GNU General Public License for more details. |
|
23 | 23 | # |
|
24 | 24 | # You should have received a copy of the GNU General Public License |
|
25 | 25 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
26 | 26 | import logging |
|
27 | 27 | import traceback |
|
28 | 28 | from collections import defaultdict |
|
29 | 29 | from webob.exc import HTTPForbidden |
|
30 | 30 | |
|
31 | 31 | from pylons import tmpl_context as c, url, request, response |
|
32 | 32 | from pylons.i18n.translation import _ |
|
33 | 33 | from pylons.controllers.util import redirect |
|
34 | 34 | from pylons.decorators import jsonify |
|
35 | 35 | |
|
36 | 36 | from rhodecode.lib.vcs.exceptions import RepositoryError, ChangesetError, \ |
|
37 | 37 | ChangesetDoesNotExistError |
|
38 | 38 | from rhodecode.lib.vcs.nodes import FileNode |
|
39 | 39 | |
|
40 | 40 | import rhodecode.lib.helpers as h |
|
41 | 41 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator |
|
42 | 42 | from rhodecode.lib.base import BaseRepoController, render |
|
43 | 43 | from rhodecode.lib.utils import EmptyChangeset |
|
44 | 44 | from rhodecode.lib.compat import OrderedDict |
|
45 | 45 | from rhodecode.lib import diffs |
|
46 | 46 | from rhodecode.model.db import ChangesetComment |
|
47 | 47 | from rhodecode.model.comment import ChangesetCommentsModel |
|
48 | 48 | from rhodecode.model.meta import Session |
|
49 | 49 | from rhodecode.lib.diffs import wrapped_diff |
|
50 | 50 | |
|
51 | 51 | log = logging.getLogger(__name__) |
|
52 | 52 | |
|
53 | 53 | |
|
54 | 54 | def _update_with_GET(params, GET): |
|
55 | 55 | for k in ['diff1', 'diff2', 'diff']: |
|
56 | 56 | params[k] += GET.getall(k) |
|
57 | 57 | |
|
58 | 58 | |
|
59 | 59 | def anchor_url(revision, path, GET): |
|
60 | 60 | fid = h.FID(revision, path) |
|
61 | 61 | return h.url.current(anchor=fid, **dict(GET)) |
|
62 | 62 | |
|
63 | 63 | |
|
64 | 64 | def get_ignore_ws(fid, GET): |
|
65 | 65 | ig_ws_global = GET.get('ignorews') |
|
66 | 66 | ig_ws = filter(lambda k: k.startswith('WS'), GET.getall(fid)) |
|
67 | 67 | if ig_ws: |
|
68 | 68 | try: |
|
69 | 69 | return int(ig_ws[0].split(':')[-1]) |
|
70 | 70 | except: |
|
71 | 71 | pass |
|
72 | 72 | return ig_ws_global |
|
73 | 73 | |
|
74 | 74 | |
|
75 | 75 | def _ignorews_url(GET, fileid=None): |
|
76 | 76 | fileid = str(fileid) if fileid else None |
|
77 | 77 | params = defaultdict(list) |
|
78 | 78 | _update_with_GET(params, GET) |
|
79 | 79 | lbl = _('show white space') |
|
80 | 80 | ig_ws = get_ignore_ws(fileid, GET) |
|
81 | 81 | ln_ctx = get_line_ctx(fileid, GET) |
|
82 | 82 | # global option |
|
83 | 83 | if fileid is None: |
|
84 | 84 | if ig_ws is None: |
|
85 | 85 | params['ignorews'] += [1] |
|
86 | 86 | lbl = _('ignore white space') |
|
87 | 87 | ctx_key = 'context' |
|
88 | 88 | ctx_val = ln_ctx |
|
89 | 89 | # per file options |
|
90 | 90 | else: |
|
91 | 91 | if ig_ws is None: |
|
92 | 92 | params[fileid] += ['WS:1'] |
|
93 | 93 | lbl = _('ignore white space') |
|
94 | 94 | |
|
95 | 95 | ctx_key = fileid |
|
96 | 96 | ctx_val = 'C:%s' % ln_ctx |
|
97 | 97 | # if we have passed in ln_ctx pass it along to our params |
|
98 | 98 | if ln_ctx: |
|
99 | 99 | params[ctx_key] += [ctx_val] |
|
100 | 100 | |
|
101 | 101 | params['anchor'] = fileid |
|
102 | 102 | img = h.image(h.url('/images/icons/text_strikethrough.png'), lbl, class_='icon') |
|
103 | 103 | return h.link_to(img, h.url.current(**params), title=lbl, class_='tooltip') |
|
104 | 104 | |
|
105 | 105 | |
|
106 | 106 | def get_line_ctx(fid, GET): |
|
107 | 107 | ln_ctx_global = GET.get('context') |
|
108 | 108 | ln_ctx = filter(lambda k: k.startswith('C'), GET.getall(fid)) |
|
109 | 109 | |
|
110 | 110 | if ln_ctx: |
|
111 | 111 | retval = ln_ctx[0].split(':')[-1] |
|
112 | 112 | else: |
|
113 | 113 | retval = ln_ctx_global |
|
114 | 114 | |
|
115 | 115 | try: |
|
116 | 116 | return int(retval) |
|
117 | 117 | except: |
|
118 | 118 | return |
|
119 | 119 | |
|
120 | 120 | |
|
121 | 121 | def _context_url(GET, fileid=None): |
|
122 | 122 | """ |
|
123 | 123 | Generates url for context lines |
|
124 | 124 | |
|
125 | 125 | :param fileid: |
|
126 | 126 | """ |
|
127 | 127 | |
|
128 | 128 | fileid = str(fileid) if fileid else None |
|
129 | 129 | ig_ws = get_ignore_ws(fileid, GET) |
|
130 | 130 | ln_ctx = (get_line_ctx(fileid, GET) or 3) * 2 |
|
131 | 131 | |
|
132 | 132 | params = defaultdict(list) |
|
133 | 133 | _update_with_GET(params, GET) |
|
134 | 134 | |
|
135 | 135 | # global option |
|
136 | 136 | if fileid is None: |
|
137 | 137 | if ln_ctx > 0: |
|
138 | 138 | params['context'] += [ln_ctx] |
|
139 | 139 | |
|
140 | 140 | if ig_ws: |
|
141 | 141 | ig_ws_key = 'ignorews' |
|
142 | 142 | ig_ws_val = 1 |
|
143 | 143 | |
|
144 | 144 | # per file option |
|
145 | 145 | else: |
|
146 | 146 | params[fileid] += ['C:%s' % ln_ctx] |
|
147 | 147 | ig_ws_key = fileid |
|
148 | 148 | ig_ws_val = 'WS:%s' % 1 |
|
149 | 149 | |
|
150 | 150 | if ig_ws: |
|
151 | 151 | params[ig_ws_key] += [ig_ws_val] |
|
152 | 152 | |
|
153 | 153 | lbl = _('%s line context') % ln_ctx |
|
154 | 154 | |
|
155 | 155 | params['anchor'] = fileid |
|
156 | 156 | img = h.image(h.url('/images/icons/table_add.png'), lbl, class_='icon') |
|
157 | 157 | return h.link_to(img, h.url.current(**params), title=lbl, class_='tooltip') |
|
158 | 158 | |
|
159 | 159 | |
|
160 | 160 | class ChangesetController(BaseRepoController): |
|
161 | 161 | |
|
162 | 162 | @LoginRequired() |
|
163 | 163 | @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
|
164 | 164 | 'repository.admin') |
|
165 | 165 | def __before__(self): |
|
166 | 166 | super(ChangesetController, self).__before__() |
|
167 | 167 | c.affected_files_cut_off = 60 |
|
168 | 168 | |
|
169 | 169 | def index(self, revision): |
|
170 | 170 | |
|
171 | 171 | c.anchor_url = anchor_url |
|
172 | 172 | c.ignorews_url = _ignorews_url |
|
173 | 173 | c.context_url = _context_url |
|
174 | 174 | limit_off = request.GET.get('fulldiff') |
|
175 | 175 | #get ranges of revisions if preset |
|
176 | 176 | rev_range = revision.split('...')[:2] |
|
177 | 177 | enable_comments = True |
|
178 | 178 | try: |
|
179 | 179 | if len(rev_range) == 2: |
|
180 | 180 | enable_comments = False |
|
181 | 181 | rev_start = rev_range[0] |
|
182 | 182 | rev_end = rev_range[1] |
|
183 | 183 | rev_ranges = c.rhodecode_repo.get_changesets(start=rev_start, |
|
184 | 184 | end=rev_end) |
|
185 | 185 | else: |
|
186 | 186 | rev_ranges = [c.rhodecode_repo.get_changeset(revision)] |
|
187 | 187 | |
|
188 | 188 | c.cs_ranges = list(rev_ranges) |
|
189 | 189 | if not c.cs_ranges: |
|
190 | 190 | raise RepositoryError('Changeset range returned empty result') |
|
191 | 191 | |
|
192 | 192 | except (RepositoryError, ChangesetDoesNotExistError, Exception), e: |
|
193 | 193 | log.error(traceback.format_exc()) |
|
194 | 194 | h.flash(str(e), category='warning') |
|
195 | 195 | return redirect(url('home')) |
|
196 | 196 | |
|
197 | 197 | c.changes = OrderedDict() |
|
198 | 198 | |
|
199 | 199 | c.lines_added = 0 # count of lines added |
|
200 | 200 | c.lines_deleted = 0 # count of lines removes |
|
201 | 201 | |
|
202 | 202 | cumulative_diff = 0 |
|
203 | 203 | c.cut_off = False # defines if cut off limit is reached |
|
204 | 204 | |
|
205 | 205 | c.comments = [] |
|
206 | 206 | c.inline_comments = [] |
|
207 | 207 | c.inline_cnt = 0 |
|
208 | 208 | # Iterate over ranges (default changeset view is always one changeset) |
|
209 | 209 | for changeset in c.cs_ranges: |
|
210 | 210 | c.comments.extend(ChangesetCommentsModel()\ |
|
211 | 211 | .get_comments(c.rhodecode_db_repo.repo_id, |
|
212 | 212 | changeset.raw_id)) |
|
213 | 213 | inlines = ChangesetCommentsModel()\ |
|
214 | 214 | .get_inline_comments(c.rhodecode_db_repo.repo_id, |
|
215 | 215 | changeset.raw_id) |
|
216 | 216 | c.inline_comments.extend(inlines) |
|
217 | 217 | c.changes[changeset.raw_id] = [] |
|
218 | 218 | try: |
|
219 | 219 | changeset_parent = changeset.parents[0] |
|
220 | 220 | except IndexError: |
|
221 | 221 | changeset_parent = None |
|
222 | 222 | |
|
223 | 223 | #================================================================== |
|
224 | 224 | # ADDED FILES |
|
225 | 225 | #================================================================== |
|
226 | 226 | for node in changeset.added: |
|
227 | 227 | fid = h.FID(revision, node.path) |
|
228 | 228 | line_context_lcl = get_line_ctx(fid, request.GET) |
|
229 | 229 | ign_whitespace_lcl = get_ignore_ws(fid, request.GET) |
|
230 | 230 | lim = self.cut_off_limit |
|
231 | 231 | if cumulative_diff > self.cut_off_limit: |
|
232 | 232 | lim = -1 if limit_off is None else None |
|
233 | 233 | size, cs1, cs2, diff, st = wrapped_diff( |
|
234 | 234 | filenode_old=None, |
|
235 | 235 | filenode_new=node, |
|
236 | 236 | cut_off_limit=lim, |
|
237 | 237 | ignore_whitespace=ign_whitespace_lcl, |
|
238 | 238 | line_context=line_context_lcl, |
|
239 | 239 | enable_comments=enable_comments |
|
240 | 240 | ) |
|
241 | 241 | cumulative_diff += size |
|
242 | 242 | c.lines_added += st[0] |
|
243 | 243 | c.lines_deleted += st[1] |
|
244 | 244 | c.changes[changeset.raw_id].append( |
|
245 | 245 | ('added', node, diff, cs1, cs2, st) |
|
246 | 246 | ) |
|
247 | 247 | |
|
248 | 248 | #================================================================== |
|
249 | 249 | # CHANGED FILES |
|
250 | 250 | #================================================================== |
|
251 | 251 | for node in changeset.changed: |
|
252 | 252 | try: |
|
253 | 253 | filenode_old = changeset_parent.get_node(node.path) |
|
254 | 254 | except ChangesetError: |
|
255 | 255 | log.warning('Unable to fetch parent node for diff') |
|
256 | 256 | filenode_old = FileNode(node.path, '', EmptyChangeset()) |
|
257 | 257 | |
|
258 | 258 | fid = h.FID(revision, node.path) |
|
259 | 259 | line_context_lcl = get_line_ctx(fid, request.GET) |
|
260 | 260 | ign_whitespace_lcl = get_ignore_ws(fid, request.GET) |
|
261 | 261 | lim = self.cut_off_limit |
|
262 | 262 | if cumulative_diff > self.cut_off_limit: |
|
263 | 263 | lim = -1 if limit_off is None else None |
|
264 | 264 | size, cs1, cs2, diff, st = wrapped_diff( |
|
265 | 265 | filenode_old=filenode_old, |
|
266 | 266 | filenode_new=node, |
|
267 | 267 | cut_off_limit=lim, |
|
268 | 268 | ignore_whitespace=ign_whitespace_lcl, |
|
269 | 269 | line_context=line_context_lcl, |
|
270 | 270 | enable_comments=enable_comments |
|
271 | 271 | ) |
|
272 | 272 | cumulative_diff += size |
|
273 | 273 | c.lines_added += st[0] |
|
274 | 274 | c.lines_deleted += st[1] |
|
275 | 275 | c.changes[changeset.raw_id].append( |
|
276 | 276 | ('changed', node, diff, cs1, cs2, st) |
|
277 | 277 | ) |
|
278 | 278 | #================================================================== |
|
279 | 279 | # REMOVED FILES |
|
280 | 280 | #================================================================== |
|
281 | 281 | for node in changeset.removed: |
|
282 | 282 | c.changes[changeset.raw_id].append( |
|
283 | 283 | ('removed', node, None, None, None, (0, 0)) |
|
284 | 284 | ) |
|
285 | 285 | |
|
286 | 286 | # count inline comments |
|
287 | 287 | for path, lines in c.inline_comments: |
|
288 | 288 | for comments in lines.values(): |
|
289 | 289 | c.inline_cnt += len(comments) |
|
290 | 290 | |
|
291 | 291 | if len(c.cs_ranges) == 1: |
|
292 | 292 | c.changeset = c.cs_ranges[0] |
|
293 | 293 | c.changes = c.changes[c.changeset.raw_id] |
|
294 | 294 | |
|
295 | 295 | return render('changeset/changeset.html') |
|
296 | 296 | else: |
|
297 | 297 | return render('changeset/changeset_range.html') |
|
298 | 298 | |
|
299 | 299 | def raw_changeset(self, revision): |
|
300 | 300 | |
|
301 | 301 | method = request.GET.get('diff', 'show') |
|
302 | 302 | ignore_whitespace = request.GET.get('ignorews') == '1' |
|
303 | 303 | line_context = request.GET.get('context', 3) |
|
304 | 304 | try: |
|
305 | 305 | c.scm_type = c.rhodecode_repo.alias |
|
306 | 306 | c.changeset = c.rhodecode_repo.get_changeset(revision) |
|
307 | 307 | except RepositoryError: |
|
308 | 308 | log.error(traceback.format_exc()) |
|
309 | 309 | return redirect(url('home')) |
|
310 | 310 | else: |
|
311 | 311 | try: |
|
312 | 312 | c.changeset_parent = c.changeset.parents[0] |
|
313 | 313 | except IndexError: |
|
314 | 314 | c.changeset_parent = None |
|
315 | 315 | c.changes = [] |
|
316 | 316 | |
|
317 | 317 | for node in c.changeset.added: |
|
318 | 318 | filenode_old = FileNode(node.path, '') |
|
319 | 319 | if filenode_old.is_binary or node.is_binary: |
|
320 | 320 | diff = _('binary file') + '\n' |
|
321 | 321 | else: |
|
322 | 322 | f_gitdiff = diffs.get_gitdiff(filenode_old, node, |
|
323 | 323 | ignore_whitespace=ignore_whitespace, |
|
324 | 324 | context=line_context) |
|
325 | 325 | diff = diffs.DiffProcessor(f_gitdiff, |
|
326 | 326 | format='gitdiff').raw_diff() |
|
327 | 327 | |
|
328 | 328 | cs1 = None |
|
329 | 329 | cs2 = node.changeset.raw_id |
|
330 | 330 | c.changes.append(('added', node, diff, cs1, cs2)) |
|
331 | 331 | |
|
332 | 332 | for node in c.changeset.changed: |
|
333 | 333 | filenode_old = c.changeset_parent.get_node(node.path) |
|
334 | 334 | if filenode_old.is_binary or node.is_binary: |
|
335 | 335 | diff = _('binary file') |
|
336 | 336 | else: |
|
337 | 337 | f_gitdiff = diffs.get_gitdiff(filenode_old, node, |
|
338 | 338 | ignore_whitespace=ignore_whitespace, |
|
339 | 339 | context=line_context) |
|
340 | 340 | diff = diffs.DiffProcessor(f_gitdiff, |
|
341 | 341 | format='gitdiff').raw_diff() |
|
342 | 342 | |
|
343 | 343 | cs1 = filenode_old.changeset.raw_id |
|
344 | 344 | cs2 = node.changeset.raw_id |
|
345 | 345 | c.changes.append(('changed', node, diff, cs1, cs2)) |
|
346 | 346 | |
|
347 | 347 | response.content_type = 'text/plain' |
|
348 | 348 | |
|
349 | 349 | if method == 'download': |
|
350 | 350 | response.content_disposition = 'attachment; filename=%s.patch' \ |
|
351 | 351 | % revision |
|
352 | 352 | |
|
353 | 353 | c.parent_tmpl = ''.join(['# Parent %s\n' % x.raw_id |
|
354 | 354 | for x in c.changeset.parents]) |
|
355 | 355 | |
|
356 | 356 | c.diffs = '' |
|
357 | 357 | for x in c.changes: |
|
358 | 358 | c.diffs += x[2] |
|
359 | 359 | |
|
360 | 360 | return render('changeset/raw_changeset.html') |
|
361 | 361 | |
|
362 | 362 | @jsonify |
|
363 | 363 | def comment(self, repo_name, revision): |
|
364 | 364 | comm = ChangesetCommentsModel().create( |
|
365 | 365 | text=request.POST.get('text'), |
|
366 | 366 | repo_id=c.rhodecode_db_repo.repo_id, |
|
367 | 367 | user_id=c.rhodecode_user.user_id, |
|
368 | 368 | revision=revision, |
|
369 | 369 | f_path=request.POST.get('f_path'), |
|
370 | 370 | line_no=request.POST.get('line') |
|
371 | 371 | ) |
|
372 | 372 | Session.commit() |
|
373 | 373 | data = { |
|
374 | 374 | 'target_id': h.safeid(h.safe_unicode(request.POST.get('f_path'))), |
|
375 | 375 | } |
|
376 | 376 | if comm: |
|
377 | 377 | c.co = comm |
|
378 | 378 | data.update(comm.get_dict()) |
|
379 |
data.update({'rendered_text': |
|
|
379 | data.update({'rendered_text': | |
|
380 | render('changeset/changeset_comment_block.html')}) | |
|
380 | 381 | return data |
|
381 | 382 | |
|
382 | 383 | @jsonify |
|
383 | 384 | def delete_comment(self, repo_name, comment_id): |
|
384 | 385 | co = ChangesetComment.get(comment_id) |
|
385 | 386 | owner = lambda: co.author.user_id == c.rhodecode_user.user_id |
|
386 | 387 | if h.HasPermissionAny('hg.admin', 'repository.admin')() or owner: |
|
387 | 388 | ChangesetCommentsModel().delete(comment=co) |
|
388 | 389 | Session.commit() |
|
389 | 390 | return True |
|
390 | 391 | else: |
|
391 | 392 | raise HTTPForbidden() |
@@ -1,150 +1,150 b'' | |||
|
1 | 1 | ## -*- coding: utf-8 -*- |
|
2 | 2 | <!DOCTYPE html> |
|
3 | 3 | <html xmlns="http://www.w3.org/1999/xhtml"> |
|
4 | 4 | <head> |
|
5 | 5 | <title>${self.title()}</title> |
|
6 | 6 | <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> |
|
7 | 7 | <meta name="robots" content="index, nofollow"/> |
|
8 | 8 | <link rel="icon" href="${h.url('/images/icons/database_gear.png')}" type="image/png" /> |
|
9 | 9 | |
|
10 | 10 | ## CSS ### |
|
11 | 11 | <%def name="css()"> |
|
12 | 12 | <link rel="stylesheet" type="text/css" href="${h.url('/css/style.css')}" media="screen"/> |
|
13 | 13 | <link rel="stylesheet" type="text/css" href="${h.url('/css/pygments.css')}"/> |
|
14 | 14 | ## EXTRA FOR CSS |
|
15 | 15 | ${self.css_extra()} |
|
16 | 16 | </%def> |
|
17 | 17 | <%def name="css_extra()"> |
|
18 | 18 | </%def> |
|
19 | 19 | |
|
20 | 20 | ${self.css()} |
|
21 | 21 | |
|
22 | 22 | %if c.ga_code: |
|
23 | 23 | <!-- Analytics --> |
|
24 | 24 | <script type="text/javascript"> |
|
25 | 25 | var _gaq = _gaq || []; |
|
26 | 26 | _gaq.push(['_setAccount', '${c.ga_code}']); |
|
27 | 27 | _gaq.push(['_trackPageview']); |
|
28 | 28 | |
|
29 | 29 | (function() { |
|
30 | 30 | var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; |
|
31 | 31 | ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; |
|
32 | 32 | var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); |
|
33 | 33 | })(); |
|
34 | 34 | </script> |
|
35 | 35 | %endif |
|
36 | 36 | |
|
37 | 37 | ## JAVASCRIPT ## |
|
38 | 38 | <%def name="js()"> |
|
39 | 39 | <script type="text/javascript" src="${h.url('/js/yui.2.9.js')}"></script> |
|
40 | 40 | <!--[if lt IE 9]> |
|
41 | 41 | <script language="javascript" type="text/javascript" src="${h.url('/js/excanvas.min.js')}"></script> |
|
42 | 42 | <![endif]--> |
|
43 | 43 | <script type="text/javascript" src="${h.url('/js/yui.flot.js')}"></script> |
|
44 | 44 | <script type="text/javascript" src="${h.url('/js/rhodecode.js')}"></script> |
|
45 | 45 | ## EXTRA FOR JS |
|
46 | 46 | ${self.js_extra()} |
|
47 | 47 | |
|
48 | 48 | <script type="text/javascript"> |
|
49 | 49 | var follow_base_url = "${h.url('toggle_following')}"; |
|
50 | ||
|
50 | ||
|
51 | 51 | //JS translations map |
|
52 | 52 | var TRANSLATION_MAP = { |
|
53 | 53 | 'add another comment':'${_("add another comment")}', |
|
54 | 54 | 'Stop following this repository':"${_('Stop following this repository')}", |
|
55 | 55 | 'Start following this repository':"${_('Start following this repository')}", |
|
56 | 56 | }; |
|
57 | 57 | |
|
58 | 58 | var onSuccessFollow = function(target){ |
|
59 | 59 | var f = YUD.get(target.id); |
|
60 | 60 | var f_cnt = YUD.get('current_followers_count'); |
|
61 | 61 | |
|
62 | 62 | if(f.getAttribute('class')=='follow'){ |
|
63 | 63 | f.setAttribute('class','following'); |
|
64 | 64 | f.setAttribute('title',TRANSLATION_MAP['Stop following this repository']); |
|
65 | 65 | |
|
66 | 66 | if(f_cnt){ |
|
67 | 67 | var cnt = Number(f_cnt.innerHTML)+1; |
|
68 | 68 | f_cnt.innerHTML = cnt; |
|
69 | 69 | } |
|
70 | 70 | } |
|
71 | 71 | else{ |
|
72 | 72 | f.setAttribute('class','follow'); |
|
73 | 73 | f.setAttribute('title',TRANSLATION_MAP['Start following this repository']); |
|
74 | 74 | if(f_cnt){ |
|
75 | 75 | var cnt = Number(f_cnt.innerHTML)+1; |
|
76 | 76 | f_cnt.innerHTML = cnt; |
|
77 | 77 | } |
|
78 | 78 | } |
|
79 | 79 | } |
|
80 | 80 | |
|
81 | 81 | var toggleFollowingUser = function(target,fallows_user_id,token,user_id){ |
|
82 | 82 | args = 'follows_user_id='+fallows_user_id; |
|
83 | 83 | args+= '&auth_token='+token; |
|
84 | 84 | if(user_id != undefined){ |
|
85 | 85 | args+="&user_id="+user_id; |
|
86 | 86 | } |
|
87 | 87 | YUC.asyncRequest('POST',follow_base_url,{ |
|
88 | 88 | success:function(o){ |
|
89 | 89 | onSuccessFollow(target); |
|
90 | 90 | } |
|
91 | 91 | },args); |
|
92 | 92 | return false; |
|
93 | 93 | } |
|
94 | 94 | |
|
95 | 95 | var toggleFollowingRepo = function(target,fallows_repo_id,token,user_id){ |
|
96 | 96 | |
|
97 | 97 | args = 'follows_repo_id='+fallows_repo_id; |
|
98 | 98 | args+= '&auth_token='+token; |
|
99 | 99 | if(user_id != undefined){ |
|
100 | 100 | args+="&user_id="+user_id; |
|
101 | 101 | } |
|
102 | 102 | YUC.asyncRequest('POST',follow_base_url,{ |
|
103 | 103 | success:function(o){ |
|
104 | 104 | onSuccessFollow(target); |
|
105 | 105 | } |
|
106 | 106 | },args); |
|
107 | 107 | return false; |
|
108 | 108 | } |
|
109 | 109 | YUE.onDOMReady(function(){ |
|
110 | 110 | tooltip_activate(); |
|
111 | 111 | show_more_event(); |
|
112 | 112 | |
|
113 | 113 | YUE.on('quick_login_link','click',function(e){ |
|
114 | 114 | // make sure we don't redirect |
|
115 | 115 | YUE.preventDefault(e); |
|
116 | 116 | |
|
117 | 117 | if(YUD.hasClass('quick_login_link','enabled')){ |
|
118 | 118 | YUD.setStyle('quick_login','display','none'); |
|
119 | 119 | YUD.removeClass('quick_login_link','enabled'); |
|
120 | 120 | } |
|
121 | 121 | else{ |
|
122 | 122 | YUD.setStyle('quick_login','display',''); |
|
123 | 123 | YUD.addClass('quick_login_link','enabled'); |
|
124 | 124 | var usr = YUD.get('username'); |
|
125 | 125 | if(usr){ |
|
126 | 126 | usr.focus(); |
|
127 | 127 | } |
|
128 | 128 | } |
|
129 | 129 | }); |
|
130 | 130 | }) |
|
131 | 131 | </script> |
|
132 | 132 | </%def> |
|
133 | 133 | <%def name="js_extra()"></%def> |
|
134 | 134 | ${self.js()} |
|
135 | 135 | </head> |
|
136 | 136 | <body id="body"> |
|
137 | 137 | ## IE hacks |
|
138 | 138 | <!--[if IE 7]> |
|
139 | 139 | <script>YUD.addClass(document.body,'ie7')</script> |
|
140 | 140 | <![endif]--> |
|
141 | 141 | <!--[if IE 8]> |
|
142 | 142 | <script>YUD.addClass(document.body,'ie8')</script> |
|
143 | 143 | <![endif]--> |
|
144 | 144 | <!--[if IE 9]> |
|
145 | 145 | <script>YUD.addClass(document.body,'ie9')</script> |
|
146 | 146 | <![endif]--> |
|
147 | 147 | |
|
148 | 148 | ${next.body()} |
|
149 | 149 | </body> |
|
150 | 150 | </html> |
@@ -1,2 +1,2 b'' | |||
|
1 | 1 | <%namespace name="comment" file="/changeset/changeset_file_comment.html"/> |
|
2 | ${comment.comment_block(c.co)} No newline at end of file | |
|
2 | ${comment.comment_block(c.co)} |
@@ -1,110 +1,110 b'' | |||
|
1 | 1 | ## -*- coding: utf-8 -*- |
|
2 | 2 | ## usage: |
|
3 | 3 | ## <%namespace name="comment" file="/changeset/changeset_file_comment.html"/> |
|
4 | 4 | ## ${comment.comment_block(co)} |
|
5 | 5 | ## |
|
6 | 6 | <%def name="comment_block(co)"> |
|
7 | 7 | <div class="comment" id="comment-${co.comment_id}" line="${co.line_no}"> |
|
8 | 8 | <div class="comment-wrapp"> |
|
9 | 9 | <div class="meta"> |
|
10 | 10 | <span class="user"> |
|
11 | 11 | <img src="${h.gravatar_url(co.author.email, 20)}" /> |
|
12 | 12 | ${co.author.username} |
|
13 | 13 | </span> |
|
14 | 14 | <span class="date"> |
|
15 | 15 | ${h.age(co.modified_at)} |
|
16 | 16 | </span> |
|
17 | 17 | %if h.HasPermissionAny('hg.admin', 'repository.admin')() or co.author.user_id == c.rhodecode_user.user_id: |
|
18 | 18 | <span class="buttons"> |
|
19 | 19 | <span onClick="deleteComment(${co.comment_id})" class="delete-comment ui-btn">${_('Delete')}</span> |
|
20 | 20 | </span> |
|
21 | 21 | %endif |
|
22 | 22 | </div> |
|
23 | 23 | <div class="text"> |
|
24 | 24 | ${h.rst_w_mentions(co.text)|n} |
|
25 | 25 | </div> |
|
26 | 26 | </div> |
|
27 | 27 | </div> |
|
28 | 28 | </%def> |
|
29 | 29 | |
|
30 | 30 | |
|
31 | 31 | <%def name="comment_inline_form(changeset)"> |
|
32 | 32 | <div id='comment-inline-form-template' style="display:none"> |
|
33 | 33 | <div class="comment-inline-form"> |
|
34 | 34 | %if c.rhodecode_user.username != 'default': |
|
35 | 35 | <div class="overlay"><div class="overlay-text">${_('Submitting...')}</div></div> |
|
36 | 36 | ${h.form(h.url('changeset_comment', repo_name=c.repo_name, revision=changeset.raw_id),class_='inline-form')} |
|
37 | 37 | <div class="clearfix"> |
|
38 | 38 | <div class="comment-help">${_('Commenting on line')} {1}. ${_('Comments parsed using')} |
|
39 | 39 | <a href="${h.url('rst_help')}">RST</a> ${_('syntax')} ${_('with')} |
|
40 | 40 | <span style="color:#003367" class="tooltip" title="${_('Use @username inside this text to send notification to this RhodeCode user')}">@mention</span> ${_('support')} |
|
41 | 41 | </div> |
|
42 | 42 | <textarea id="text_{1}" name="text"></textarea> |
|
43 | 43 | </div> |
|
44 | 44 | <div class="comment-button"> |
|
45 | 45 | <input type="hidden" name="f_path" value="{0}"> |
|
46 | 46 | <input type="hidden" name="line" value="{1}"> |
|
47 | 47 | ${h.submit('save', _('Comment'), class_='ui-btn save-inline-form')} |
|
48 | 48 | ${h.reset('hide-inline-form', _('Hide'), class_='ui-btn hide-inline-form')} |
|
49 | 49 | </div> |
|
50 | 50 | ${h.end_form()} |
|
51 | 51 | %else: |
|
52 | 52 | ${h.form('')} |
|
53 | 53 | <div class="clearfix"> |
|
54 | 54 | <div class="comment-help"> |
|
55 | 55 | ${'You need to be logged in to comment.'} <a href="${h.url('login_home',came_from=h.url.current())}">${_('Login now')}</a> |
|
56 | 56 | </div> |
|
57 | 57 | </div> |
|
58 | 58 | <div class="comment-button"> |
|
59 | 59 | ${h.reset('hide-inline-form', _('Hide'), class_='ui-btn hide-inline-form')} |
|
60 | 60 | </div> |
|
61 | 61 | ${h.end_form()} |
|
62 | 62 | %endif |
|
63 | 63 | </div> |
|
64 | 64 | </div> |
|
65 | 65 | </%def> |
|
66 | 66 | |
|
67 | 67 | |
|
68 | 68 | <%def name="inlines(changeset)"> |
|
69 | 69 | <div class="comments-number">${len(c.comments)} comment(s) (${c.inline_cnt} ${_('inline')})</div> |
|
70 | 70 | %for path, lines in c.inline_comments: |
|
71 | 71 | % for line,comments in lines.iteritems(): |
|
72 | 72 | <div style="display:none" class="inline-comment-placeholder" path="${path}" target_id="${h.safeid(h.safe_unicode(path))}"> |
|
73 | 73 | %for co in comments: |
|
74 | 74 | ${comment_block(co)} |
|
75 | 75 | %endfor |
|
76 | 76 | </div> |
|
77 | 77 | %endfor |
|
78 | 78 | %endfor |
|
79 | ||
|
79 | ||
|
80 | 80 | </%def> |
|
81 | 81 | |
|
82 | 82 | <%def name="comments(changeset)"> |
|
83 | 83 | |
|
84 | 84 | <div class="comments"> |
|
85 | 85 | <div id="inline-comments-container"> |
|
86 | 86 | ${inlines(changeset)} |
|
87 | 87 | </div> |
|
88 | ||
|
88 | ||
|
89 | 89 | %for co in c.comments: |
|
90 | 90 | ${comment_block(co)} |
|
91 | 91 | %endfor |
|
92 | 92 | %if c.rhodecode_user.username != 'default': |
|
93 | 93 | <div class="comment-form"> |
|
94 | 94 | ${h.form(h.url('changeset_comment', repo_name=c.repo_name, revision=changeset.raw_id))} |
|
95 | 95 | <strong>${_('Leave a comment')}</strong> |
|
96 | 96 | <div class="clearfix"> |
|
97 | 97 | <div class="comment-help"> |
|
98 | 98 | ${_('Comments parsed using')} <a href="${h.url('rst_help')}">RST</a> ${_('syntax')} |
|
99 | 99 | ${_('with')} <span style="color:#003367" class="tooltip" title="${_('Use @username inside this text to send notification to this RhodeCode user')}">@mention</span> ${_('support')} |
|
100 | 100 | </div> |
|
101 | 101 | ${h.textarea('text')} |
|
102 | 102 | </div> |
|
103 | 103 | <div class="comment-button"> |
|
104 | 104 | ${h.submit('save', _('Comment'), class_='ui-button')} |
|
105 | 105 | </div> |
|
106 | 106 | ${h.end_form()} |
|
107 | 107 | </div> |
|
108 | 108 | %endif |
|
109 | 109 | </div> |
|
110 | 110 | </%def> |
@@ -1,18 +1,18 b'' | |||
|
1 | 1 | %if c.file: |
|
2 | 2 | <h3 class="files_location"> |
|
3 | 3 | ${_('Location')}: ${h.files_breadcrumbs(c.repo_name,c.changeset.raw_id,c.file.path)} |
|
4 |
%if c.annotate: |
|
|
5 |
- ${_('annotation')} |
|
|
6 |
%endif |
|
|
4 | %if c.annotate: | |
|
5 | - ${_('annotation')} | |
|
6 | %endif | |
|
7 | 7 | </h3> |
|
8 | 8 | %if c.file.is_dir(): |
|
9 | 9 | <%include file='files_browser.html'/> |
|
10 | 10 | %else: |
|
11 | 11 | <%include file='files_source.html'/> |
|
12 | 12 | %endif |
|
13 | 13 | %else: |
|
14 | 14 | <h2> |
|
15 | 15 | <a href="#" onClick="javascript:parent.history.back();" target="main">${_('Go back')}</a> |
|
16 | 16 | ${_('No files at given path')}: "${c.f_path or "/"}" |
|
17 | 17 | </h2> |
|
18 | 18 | %endif |
General Comments 0
You need to be logged in to leave comments.
Login now