Mercurial > kallithea
annotate rhodecode/lib/helpers.py @ 4116:ffd45b185016 rhodecode-2.2.5-gpl
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
This imports changes between changesets 21af6c4eab3d and 6177597791c2 in
RhodeCode's original repository, including only changes to Python files and HTML.
RhodeCode clearly licensed its changes to these files under GPLv3
in their /LICENSE file, which states the following:
The Python code and integrated HTML are licensed under the GPLv3 license.
(See:
https://code.rhodecode.com/rhodecode/files/v2.2.5/LICENSE
or
http://web.archive.org/web/20140512193334/https://code.rhodecode.com/rhodecode/files/f3b123159901f15426d18e3dc395e8369f70ebe0/LICENSE
for an online copy of that LICENSE file)
Conservancy reviewed these changes and confirmed that they can be licensed as
a whole to the Kallithea project under GPLv3-only.
While some of the contents committed herein are clearly licensed
GPLv3-or-later, on the whole we must assume the are GPLv3-only, since the
statement above from RhodeCode indicates that they intend GPLv3-only as their
license, per GPLv3ยง14 and other relevant sections of GPLv3.
author | Bradley M. Kuhn <bkuhn@sfconservancy.org> |
---|---|
date | Wed, 02 Jul 2014 19:03:13 -0400 |
parents | a1bc4af25ec5 |
children | cc1ee59e7155 |
rev | line source |
---|---|
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
1 # -*- coding: utf-8 -*- |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
2 # This program is free software: you can redistribute it and/or modify |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
3 # it under the terms of the GNU General Public License as published by |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
4 # the Free Software Foundation, either version 3 of the License, or |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
5 # (at your option) any later version. |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
6 # |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
7 # This program is distributed in the hope that it will be useful, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
10 # GNU General Public License for more details. |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
11 # |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
12 # You should have received a copy of the GNU General Public License |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
13 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
14 """ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
15 Helper functions |
0 | 16 |
17 Consists of functions to typically be used within templates, but also | |
18 available to Controllers. This module is available to both as 'h'. | |
19 """ | |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
718
diff
changeset
|
20 import random |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
718
diff
changeset
|
21 import hashlib |
966
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
22 import StringIO |
1101
c1080b42a7cb
fixed problem with int. chars in gravatars
Marcin Kuzminski <marcin@python-works.com>
parents:
1100
diff
changeset
|
23 import urllib |
1422
e69da281e235
fixed issues with repo pager
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
24 import math |
1837
a6a30c919513
#73 mapping of commited issues from commit message into issue tracker url.
Marcin Kuzminski <marcin@python-works.com>
parents:
1832
diff
changeset
|
25 import logging |
2674
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2609
diff
changeset
|
26 import re |
2836
819eb7f8a555
Implemented patch from andrewsh ref #565 Add support for {netloc} and {scheme}
Marcin Kuzminski <marcin@python-works.com>
parents:
2751
diff
changeset
|
27 import urlparse |
3070
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
28 import textwrap |
1101
c1080b42a7cb
fixed problem with int. chars in gravatars
Marcin Kuzminski <marcin@python-works.com>
parents:
1100
diff
changeset
|
29 |
1154
36fe593dfe4b
simplified str2bool, and moved safe_unicode out of helpers since it was not html specific function
Marcin Kuzminski <marcin@python-works.com>
parents:
1115
diff
changeset
|
30 from datetime import datetime |
1716
7d1fc253549e
notification to commit author + gardening
Marcin Kuzminski <marcin@python-works.com>
parents:
1676
diff
changeset
|
31 from pygments.formatters.html import HtmlFormatter |
250
be4621c6de58
Pygments code coloring rewrite, annotation was moved to vcs whitch had much better lib for that. Fixed code recognition based on mimetypes of filenodes, for better coloring.
Marcin Kuzminski <marcin@python-works.com>
parents:
165
diff
changeset
|
32 from pygments import highlight as code_highlight |
3905
f7bf0cebe391
Switch gravatar to always use ssl.
Marcin Kuzminski <marcin@python-works.com>
parents:
3890
diff
changeset
|
33 from pylons import url |
97
be0096a02772
added helper for filesize
Marcin Kuzminski <marcin@python-works.com>
parents:
94
diff
changeset
|
34 from pylons.i18n.translation import _, ungettext |
1832
b9708d66277c
fixed problem with anchor links that contains non ascii chars
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
35 from hashlib import md5 |
1022
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1009
diff
changeset
|
36 |
250
be4621c6de58
Pygments code coloring rewrite, annotation was moved to vcs whitch had much better lib for that. Fixed code recognition based on mimetypes of filenodes, for better coloring.
Marcin Kuzminski <marcin@python-works.com>
parents:
165
diff
changeset
|
37 from webhelpers.html import literal, HTML, escape |
281
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
278
diff
changeset
|
38 from webhelpers.html.tools import * |
98
01d0f363f36d
added pygments webhelper
Marcin Kuzminski <marcin@python-works.com>
parents:
97
diff
changeset
|
39 from webhelpers.html.builder import make_tag |
250
be4621c6de58
Pygments code coloring rewrite, annotation was moved to vcs whitch had much better lib for that. Fixed code recognition based on mimetypes of filenodes, for better coloring.
Marcin Kuzminski <marcin@python-works.com>
parents:
165
diff
changeset
|
40 from webhelpers.html.tags import auto_discovery_link, checkbox, css_classes, \ |
1766 | 41 end_form, file, form, hidden, image, javascript_link, link_to, \ |
42 link_to_if, link_to_unless, ol, required_legend, select, stylesheet_link, \ | |
43 submit, text, password, textarea, title, ul, xml_declaration, radio | |
44 from webhelpers.html.tools import auto_link, button_to, highlight, \ | |
45 js_obfuscate, mail_to, strip_links, strip_tags, tag_re | |
250
be4621c6de58
Pygments code coloring rewrite, annotation was moved to vcs whitch had much better lib for that. Fixed code recognition based on mimetypes of filenodes, for better coloring.
Marcin Kuzminski <marcin@python-works.com>
parents:
165
diff
changeset
|
46 from webhelpers.number import format_byte_size, format_bit_size |
0 | 47 from webhelpers.pylonslib import Flash as _Flash |
48 from webhelpers.pylonslib.secure_form import secure_form | |
250
be4621c6de58
Pygments code coloring rewrite, annotation was moved to vcs whitch had much better lib for that. Fixed code recognition based on mimetypes of filenodes, for better coloring.
Marcin Kuzminski <marcin@python-works.com>
parents:
165
diff
changeset
|
49 from webhelpers.text import chop_at, collapse, convert_accented_entities, \ |
be4621c6de58
Pygments code coloring rewrite, annotation was moved to vcs whitch had much better lib for that. Fixed code recognition based on mimetypes of filenodes, for better coloring.
Marcin Kuzminski <marcin@python-works.com>
parents:
165
diff
changeset
|
50 convert_misc_entities, lchop, plural, rchop, remove_formatting, \ |
281
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
278
diff
changeset
|
51 replace_whitespace, urlify, truncate, wrap_paragraphs |
635
fd63782c4426
Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents:
631
diff
changeset
|
52 from webhelpers.date import time_ago_in_words |
3776
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
53 from webhelpers.paginate import Page as _Page |
698
4cd0709b6d4b
fixes #65, Added reset buttons to edit forms
Marcin Kuzminski <marcin@python-works.com>
parents:
668
diff
changeset
|
54 from webhelpers.html.tags import _set_input_attrs, _set_id_attr, \ |
1676
e86191684f4b
fixed some anchor id problems for changeset ranges
Marcin Kuzminski <marcin@python-works.com>
parents:
1670
diff
changeset
|
55 convert_boolean_attrs, NotGiven, _make_safe_id_component |
698
4cd0709b6d4b
fixes #65, Added reset buttons to edit forms
Marcin Kuzminski <marcin@python-works.com>
parents:
668
diff
changeset
|
56 |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
1747
diff
changeset
|
57 from rhodecode.lib.annotate import annotate_highlight |
3375
7000fc4aa569
Add option to define custom lexers for custom extensions for code highlight in rcextension module
Marcin Kuzminski <marcin@python-works.com>
parents:
3367
diff
changeset
|
58 from rhodecode.lib.utils import repo_name_slug, get_custom_lexer |
2109 | 59 from rhodecode.lib.utils2 import str2bool, safe_unicode, safe_str, \ |
3557
58dcef7eef03
Implemented show_id function that is a configurable way to display sha hashes in the changelog.
Marcin Kuzminski <marcin@python-works.com>
parents:
3540
diff
changeset
|
60 get_changeset_safe, datetime_to_time, time_to_datetime, AttributeDict,\ |
58dcef7eef03
Implemented show_id function that is a configurable way to display sha hashes in the changelog.
Marcin Kuzminski <marcin@python-works.com>
parents:
3540
diff
changeset
|
61 safe_int |
1670
d2de0c2f02cd
#77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
1656
diff
changeset
|
62 from rhodecode.lib.markup_renderer import MarkupRenderer |
2323
6c0f76330d91
fix for issue #450. Rhodecode no longer will crash when bad revision is present in journal data.
Marcin Kuzminski <marcin@python-works.com>
parents:
2203
diff
changeset
|
63 from rhodecode.lib.vcs.exceptions import ChangesetDoesNotExistError |
3012
58f3bba0ddc1
extend helper for better breadcrumbs for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents:
2998
diff
changeset
|
64 from rhodecode.lib.vcs.backends.base import BaseChangeset, EmptyChangeset |
2445
9b623dcddb02
Format datetime in notifications according to unified function
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
65 from rhodecode.config.conf import DATE_FORMAT, DATETIME_FORMAT |
2217
76947224bf27
Implemented initial code-review status of changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2203
diff
changeset
|
66 from rhodecode.model.changeset_status import ChangesetStatusModel |
2532
19de74e33fb0
Better descriptions of given permission overview in edit user view
Marcin Kuzminski <marcin@python-works.com>
parents:
2491
diff
changeset
|
67 from rhodecode.model.db import URL_SEP, Permission |
1670
d2de0c2f02cd
#77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
1656
diff
changeset
|
68 |
1837
a6a30c919513
#73 mapping of commited issues from commit message into issue tracker url.
Marcin Kuzminski <marcin@python-works.com>
parents:
1832
diff
changeset
|
69 log = logging.getLogger(__name__) |
a6a30c919513
#73 mapping of commited issues from commit message into issue tracker url.
Marcin Kuzminski <marcin@python-works.com>
parents:
1832
diff
changeset
|
70 |
1789
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1781
diff
changeset
|
71 |
4043
a1bc4af25ec5
Implemented issue #387 side-by-side diffs view
Marcin Kuzminski <marcin@python-works.com>
parents:
3960
diff
changeset
|
72 def html_escape(text, html_escape_table=None): |
2466
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
2447
diff
changeset
|
73 """Produce entities within text.""" |
4043
a1bc4af25ec5
Implemented issue #387 side-by-side diffs view
Marcin Kuzminski <marcin@python-works.com>
parents:
3960
diff
changeset
|
74 if not html_escape_table: |
a1bc4af25ec5
Implemented issue #387 side-by-side diffs view
Marcin Kuzminski <marcin@python-works.com>
parents:
3960
diff
changeset
|
75 html_escape_table = { |
a1bc4af25ec5
Implemented issue #387 side-by-side diffs view
Marcin Kuzminski <marcin@python-works.com>
parents:
3960
diff
changeset
|
76 "&": "&", |
a1bc4af25ec5
Implemented issue #387 side-by-side diffs view
Marcin Kuzminski <marcin@python-works.com>
parents:
3960
diff
changeset
|
77 '"': """, |
a1bc4af25ec5
Implemented issue #387 side-by-side diffs view
Marcin Kuzminski <marcin@python-works.com>
parents:
3960
diff
changeset
|
78 "'": "'", |
a1bc4af25ec5
Implemented issue #387 side-by-side diffs view
Marcin Kuzminski <marcin@python-works.com>
parents:
3960
diff
changeset
|
79 ">": ">", |
a1bc4af25ec5
Implemented issue #387 side-by-side diffs view
Marcin Kuzminski <marcin@python-works.com>
parents:
3960
diff
changeset
|
80 "<": "<", |
a1bc4af25ec5
Implemented issue #387 side-by-side diffs view
Marcin Kuzminski <marcin@python-works.com>
parents:
3960
diff
changeset
|
81 } |
2958
c0a6a2e6bb2e
Use lightweight revisions in journal by default
Marcin Kuzminski <marcin@python-works.com>
parents:
2956
diff
changeset
|
82 return "".join(html_escape_table.get(c, c) for c in text) |
2466
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
2447
diff
changeset
|
83 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
2447
diff
changeset
|
84 |
2162
04d3fae0e4c0
imported patch 2260
Marcin Kuzminski <marcin@python-works.com>
parents:
2148
diff
changeset
|
85 def shorter(text, size=20): |
04d3fae0e4c0
imported patch 2260
Marcin Kuzminski <marcin@python-works.com>
parents:
2148
diff
changeset
|
86 postfix = '...' |
04d3fae0e4c0
imported patch 2260
Marcin Kuzminski <marcin@python-works.com>
parents:
2148
diff
changeset
|
87 if len(text) > size: |
04d3fae0e4c0
imported patch 2260
Marcin Kuzminski <marcin@python-works.com>
parents:
2148
diff
changeset
|
88 return text[:size - len(postfix)] + postfix |
04d3fae0e4c0
imported patch 2260
Marcin Kuzminski <marcin@python-works.com>
parents:
2148
diff
changeset
|
89 return text |
04d3fae0e4c0
imported patch 2260
Marcin Kuzminski <marcin@python-works.com>
parents:
2148
diff
changeset
|
90 |
04d3fae0e4c0
imported patch 2260
Marcin Kuzminski <marcin@python-works.com>
parents:
2148
diff
changeset
|
91 |
698
4cd0709b6d4b
fixes #65, Added reset buttons to edit forms
Marcin Kuzminski <marcin@python-works.com>
parents:
668
diff
changeset
|
92 def _reset(name, value=None, id=NotGiven, type="reset", **attrs): |
1154
36fe593dfe4b
simplified str2bool, and moved safe_unicode out of helpers since it was not html specific function
Marcin Kuzminski <marcin@python-works.com>
parents:
1115
diff
changeset
|
93 """ |
36fe593dfe4b
simplified str2bool, and moved safe_unicode out of helpers since it was not html specific function
Marcin Kuzminski <marcin@python-works.com>
parents:
1115
diff
changeset
|
94 Reset button |
899
d65843e07d3c
Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents:
864
diff
changeset
|
95 """ |
698
4cd0709b6d4b
fixes #65, Added reset buttons to edit forms
Marcin Kuzminski <marcin@python-works.com>
parents:
668
diff
changeset
|
96 _set_input_attrs(attrs, type, name, value) |
4cd0709b6d4b
fixes #65, Added reset buttons to edit forms
Marcin Kuzminski <marcin@python-works.com>
parents:
668
diff
changeset
|
97 _set_id_attr(attrs, id, name) |
4cd0709b6d4b
fixes #65, Added reset buttons to edit forms
Marcin Kuzminski <marcin@python-works.com>
parents:
668
diff
changeset
|
98 convert_boolean_attrs(attrs, ["disabled"]) |
4cd0709b6d4b
fixes #65, Added reset buttons to edit forms
Marcin Kuzminski <marcin@python-works.com>
parents:
668
diff
changeset
|
99 return HTML.input(**attrs) |
4cd0709b6d4b
fixes #65, Added reset buttons to edit forms
Marcin Kuzminski <marcin@python-works.com>
parents:
668
diff
changeset
|
100 |
4cd0709b6d4b
fixes #65, Added reset buttons to edit forms
Marcin Kuzminski <marcin@python-works.com>
parents:
668
diff
changeset
|
101 reset = _reset |
1676
e86191684f4b
fixed some anchor id problems for changeset ranges
Marcin Kuzminski <marcin@python-works.com>
parents:
1670
diff
changeset
|
102 safeid = _make_safe_id_component |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
718
diff
changeset
|
103 |
1789
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1781
diff
changeset
|
104 |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1781
diff
changeset
|
105 def FID(raw_id, path): |
1776
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1769
diff
changeset
|
106 """ |
1832
b9708d66277c
fixed problem with anchor links that contains non ascii chars
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
107 Creates a uniqe ID for filenode based on it's hash of path and revision |
b9708d66277c
fixed problem with anchor links that contains non ascii chars
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
108 it's safe to use in urls |
1789
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1781
diff
changeset
|
109 |
1776
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1769
diff
changeset
|
110 :param raw_id: |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1769
diff
changeset
|
111 :param path: |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1769
diff
changeset
|
112 """ |
1832
b9708d66277c
fixed problem with anchor links that contains non ascii chars
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
113 |
2148
ad127a5cef73
fixed comments issue on non-ascii file names
Marcin Kuzminski <marcin@python-works.com>
parents:
2125
diff
changeset
|
114 return 'C-%s-%s' % (short_id(raw_id), md5(safe_str(path)).hexdigest()[:12]) |
1776
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1769
diff
changeset
|
115 |
22333ddd1a40
implements #307, configurable diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1769
diff
changeset
|
116 |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
718
diff
changeset
|
117 def get_token(): |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
718
diff
changeset
|
118 """Return the current authentication token, creating one if one doesn't |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
718
diff
changeset
|
119 already exist. |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
718
diff
changeset
|
120 """ |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
718
diff
changeset
|
121 token_key = "_authentication_token" |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
718
diff
changeset
|
122 from pylons import session |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
718
diff
changeset
|
123 if not token_key in session: |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
718
diff
changeset
|
124 try: |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
718
diff
changeset
|
125 token = hashlib.sha1(str(random.getrandbits(128))).hexdigest() |
2203
d9972f76322e
added emulation of pull hook for git-backend, and dummy git-push hook
Marcin Kuzminski <marcin@python-works.com>
parents:
2162
diff
changeset
|
126 except AttributeError: # Python < 2.4 |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
718
diff
changeset
|
127 token = hashlib.sha1(str(random.randrange(2 ** 128))).hexdigest() |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
718
diff
changeset
|
128 session[token_key] = token |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
718
diff
changeset
|
129 if hasattr(session, 'save'): |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
718
diff
changeset
|
130 session.save() |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
718
diff
changeset
|
131 return session[token_key] |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
718
diff
changeset
|
132 |
2162
04d3fae0e4c0
imported patch 2260
Marcin Kuzminski <marcin@python-works.com>
parents:
2148
diff
changeset
|
133 |
0 | 134 class _GetError(object): |
899
d65843e07d3c
Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents:
864
diff
changeset
|
135 """Get error from form_errors, and represent it as span wrapped error |
d65843e07d3c
Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents:
864
diff
changeset
|
136 message |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1187
diff
changeset
|
137 |
899
d65843e07d3c
Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents:
864
diff
changeset
|
138 :param field_name: field to fetch errors for |
d65843e07d3c
Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents:
864
diff
changeset
|
139 :param form_errors: form errors dict |
d65843e07d3c
Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents:
864
diff
changeset
|
140 """ |
0 | 141 |
142 def __call__(self, field_name, form_errors): | |
143 tmpl = """<span class="error_msg">%s</span>""" | |
2427
f467c75544af
Added h.tooltip to all places that tooltip_title is used.
Marcin Kuzminski <marcin@python-works.com>
parents:
2416
diff
changeset
|
144 if form_errors and field_name in form_errors: |
0 | 145 return literal(tmpl % form_errors.get(field_name)) |
146 | |
281
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
278
diff
changeset
|
147 get_error = _GetError() |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
278
diff
changeset
|
148 |
2162
04d3fae0e4c0
imported patch 2260
Marcin Kuzminski <marcin@python-works.com>
parents:
2148
diff
changeset
|
149 |
281
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
278
diff
changeset
|
150 class _ToolTip(object): |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
604
diff
changeset
|
151 |
281
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
278
diff
changeset
|
152 def __call__(self, tooltip_title, trim_at=50): |
2427
f467c75544af
Added h.tooltip to all places that tooltip_title is used.
Marcin Kuzminski <marcin@python-works.com>
parents:
2416
diff
changeset
|
153 """ |
f467c75544af
Added h.tooltip to all places that tooltip_title is used.
Marcin Kuzminski <marcin@python-works.com>
parents:
2416
diff
changeset
|
154 Special function just to wrap our text into nice formatted |
905
1294f2baf2bc
added wrapping of long tooltips in index page
Marcin Kuzminski <marcin@python-works.com>
parents:
904
diff
changeset
|
155 autowrapped text |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1187
diff
changeset
|
156 |
604
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
157 :param tooltip_title: |
281
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
278
diff
changeset
|
158 """ |
2427
f467c75544af
Added h.tooltip to all places that tooltip_title is used.
Marcin Kuzminski <marcin@python-works.com>
parents:
2416
diff
changeset
|
159 tooltip_title = escape(tooltip_title) |
f467c75544af
Added h.tooltip to all places that tooltip_title is used.
Marcin Kuzminski <marcin@python-works.com>
parents:
2416
diff
changeset
|
160 tooltip_title = tooltip_title.replace('<', '<').replace('>', '>') |
f467c75544af
Added h.tooltip to all places that tooltip_title is used.
Marcin Kuzminski <marcin@python-works.com>
parents:
2416
diff
changeset
|
161 return tooltip_title |
281
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
278
diff
changeset
|
162 tooltip = _ToolTip() |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
278
diff
changeset
|
163 |
2162
04d3fae0e4c0
imported patch 2260
Marcin Kuzminski <marcin@python-works.com>
parents:
2148
diff
changeset
|
164 |
102
2dc0c8e4f384
Updated tempaltes, added file browser breadcrumbs, and feed icons
Marcin Kuzminski <marcin@python-works.com>
parents:
98
diff
changeset
|
165 class _FilesBreadCrumbs(object): |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
604
diff
changeset
|
166 |
102
2dc0c8e4f384
Updated tempaltes, added file browser breadcrumbs, and feed icons
Marcin Kuzminski <marcin@python-works.com>
parents:
98
diff
changeset
|
167 def __call__(self, repo_name, rev, paths): |
955
129eb072b8a8
fixes for #99, added casting to unicode for int chars as utf-8 files
Marcin Kuzminski <marcin@python-works.com>
parents:
953
diff
changeset
|
168 if isinstance(paths, str): |
1176
014c9a58a0d9
fixes for issues #137 and #116 safe_unicode is now default for handling file names
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
169 paths = safe_unicode(paths) |
287
5827c739b0bd
webhelpers breadcrumbs bugfix
Marcin Kuzminski <marcin@python-works.com>
parents:
286
diff
changeset
|
170 url_l = [link_to(repo_name, url('files_home', |
5827c739b0bd
webhelpers breadcrumbs bugfix
Marcin Kuzminski <marcin@python-works.com>
parents:
286
diff
changeset
|
171 repo_name=repo_name, |
2686
269c6e0b54cc
Reimplemented file-browser using partial-ajax
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
172 revision=rev, f_path=''), |
269c6e0b54cc
Reimplemented file-browser using partial-ajax
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
173 class_='ypjax-link')] |
287
5827c739b0bd
webhelpers breadcrumbs bugfix
Marcin Kuzminski <marcin@python-works.com>
parents:
286
diff
changeset
|
174 paths_l = paths.split('/') |
740
9279dfedcf93
fixed python2.5 incompatible enumerate calls
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
175 for cnt, p in enumerate(paths_l): |
102
2dc0c8e4f384
Updated tempaltes, added file browser breadcrumbs, and feed icons
Marcin Kuzminski <marcin@python-works.com>
parents:
98
diff
changeset
|
176 if p != '': |
1789
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1781
diff
changeset
|
177 url_l.append(link_to(p, |
1766 | 178 url('files_home', |
179 repo_name=repo_name, | |
180 revision=rev, | |
181 f_path='/'.join(paths_l[:cnt + 1]) | |
2686
269c6e0b54cc
Reimplemented file-browser using partial-ajax
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
182 ), |
269c6e0b54cc
Reimplemented file-browser using partial-ajax
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
183 class_='ypjax-link' |
1766 | 184 ) |
185 ) | |
97
be0096a02772
added helper for filesize
Marcin Kuzminski <marcin@python-works.com>
parents:
94
diff
changeset
|
186 |
448
4679105ef03e
more css html fixes (+cleanups), rewrote definition list for files
Marcin Kuzminski <marcin@python-works.com>
parents:
444
diff
changeset
|
187 return literal('/'.join(url_l)) |
98
01d0f363f36d
added pygments webhelper
Marcin Kuzminski <marcin@python-works.com>
parents:
97
diff
changeset
|
188 |
281
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
278
diff
changeset
|
189 files_breadcrumbs = _FilesBreadCrumbs() |
899
d65843e07d3c
Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents:
864
diff
changeset
|
190 |
2162
04d3fae0e4c0
imported patch 2260
Marcin Kuzminski <marcin@python-works.com>
parents:
2148
diff
changeset
|
191 |
505
5aba7adff196
little gui change for file source
Marcin Kuzminski <marcin@python-works.com>
parents:
494
diff
changeset
|
192 class CodeHtmlFormatter(HtmlFormatter): |
2162
04d3fae0e4c0
imported patch 2260
Marcin Kuzminski <marcin@python-works.com>
parents:
2148
diff
changeset
|
193 """ |
04d3fae0e4c0
imported patch 2260
Marcin Kuzminski <marcin@python-works.com>
parents:
2148
diff
changeset
|
194 My code Html Formatter for source codes |
966
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
195 """ |
281
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
278
diff
changeset
|
196 |
505
5aba7adff196
little gui change for file source
Marcin Kuzminski <marcin@python-works.com>
parents:
494
diff
changeset
|
197 def wrap(self, source, outfile): |
5aba7adff196
little gui change for file source
Marcin Kuzminski <marcin@python-works.com>
parents:
494
diff
changeset
|
198 return self._wrap_div(self._wrap_pre(self._wrap_code(source))) |
5aba7adff196
little gui change for file source
Marcin Kuzminski <marcin@python-works.com>
parents:
494
diff
changeset
|
199 |
5aba7adff196
little gui change for file source
Marcin Kuzminski <marcin@python-works.com>
parents:
494
diff
changeset
|
200 def _wrap_code(self, source): |
740
9279dfedcf93
fixed python2.5 incompatible enumerate calls
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
201 for cnt, it in enumerate(source): |
505
5aba7adff196
little gui change for file source
Marcin Kuzminski <marcin@python-works.com>
parents:
494
diff
changeset
|
202 i, t = it |
966
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
203 t = '<div id="L%s">%s</div>' % (cnt + 1, t) |
505
5aba7adff196
little gui change for file source
Marcin Kuzminski <marcin@python-works.com>
parents:
494
diff
changeset
|
204 yield i, t |
966
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
205 |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
206 def _wrap_tablelinenos(self, inner): |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
207 dummyoutfile = StringIO.StringIO() |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
208 lncount = 0 |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
209 for t, line in inner: |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
210 if t: |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
211 lncount += 1 |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
212 dummyoutfile.write(line) |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
213 |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
214 fl = self.linenostart |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
215 mw = len(str(lncount + fl - 1)) |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
216 sp = self.linenospecial |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
217 st = self.linenostep |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
218 la = self.lineanchors |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
219 aln = self.anchorlinenos |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
220 nocls = self.noclasses |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
221 if sp: |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
222 lines = [] |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
223 |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
224 for i in range(fl, fl + lncount): |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
225 if i % st == 0: |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
226 if i % sp == 0: |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
227 if aln: |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
228 lines.append('<a href="#%s%d" class="special">%*d</a>' % |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
229 (la, i, mw, i)) |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
230 else: |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
231 lines.append('<span class="special">%*d</span>' % (mw, i)) |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
232 else: |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
233 if aln: |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
234 lines.append('<a href="#%s%d">%*d</a>' % (la, i, mw, i)) |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
235 else: |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
236 lines.append('%*d' % (mw, i)) |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
237 else: |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
238 lines.append('') |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
239 ls = '\n'.join(lines) |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
240 else: |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
241 lines = [] |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
242 for i in range(fl, fl + lncount): |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
243 if i % st == 0: |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
244 if aln: |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
245 lines.append('<a href="#%s%d">%*d</a>' % (la, i, mw, i)) |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
246 else: |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
247 lines.append('%*d' % (mw, i)) |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
248 else: |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
249 lines.append('') |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
250 ls = '\n'.join(lines) |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
251 |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
252 # in case you wonder about the seemingly redundant <div> here: since the |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
253 # content in the other cell also is wrapped in a div, some browsers in |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
254 # some configurations seem to mess up the formatting... |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
255 if nocls: |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
256 yield 0, ('<table class="%stable">' % self.cssclass + |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
257 '<tr><td><div class="linenodiv" ' |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
258 'style="background-color: #f0f0f0; padding-right: 10px">' |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
259 '<pre style="line-height: 125%">' + |
1320
09c3fb460fcb
Fixed problem with anchor link positioning when passed in ranges.
Marcin Kuzminski <marcin@python-works.com>
parents:
1312
diff
changeset
|
260 ls + '</pre></div></td><td id="hlcode" class="code">') |
966
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
261 else: |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
262 yield 0, ('<table class="%stable">' % self.cssclass + |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
263 '<tr><td class="linenos"><div class="linenodiv"><pre>' + |
1320
09c3fb460fcb
Fixed problem with anchor link positioning when passed in ranges.
Marcin Kuzminski <marcin@python-works.com>
parents:
1312
diff
changeset
|
264 ls + '</pre></div></td><td id="hlcode" class="code">') |
966
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
265 yield 0, dummyoutfile.getvalue() |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
266 yield 0, '</td></tr></table>' |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
267 |
63c91390853c
fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents:
965
diff
changeset
|
268 |
250
be4621c6de58
Pygments code coloring rewrite, annotation was moved to vcs whitch had much better lib for that. Fixed code recognition based on mimetypes of filenodes, for better coloring.
Marcin Kuzminski <marcin@python-works.com>
parents:
165
diff
changeset
|
269 def pygmentize(filenode, **kwargs): |
3375
7000fc4aa569
Add option to define custom lexers for custom extensions for code highlight in rcextension module
Marcin Kuzminski <marcin@python-works.com>
parents:
3367
diff
changeset
|
270 """ |
7000fc4aa569
Add option to define custom lexers for custom extensions for code highlight in rcextension module
Marcin Kuzminski <marcin@python-works.com>
parents:
3367
diff
changeset
|
271 pygmentize function using pygments |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1187
diff
changeset
|
272 |
604
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
273 :param filenode: |
165
ea893ffb7f00
implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents:
104
diff
changeset
|
274 """ |
3375
7000fc4aa569
Add option to define custom lexers for custom extensions for code highlight in rcextension module
Marcin Kuzminski <marcin@python-works.com>
parents:
3367
diff
changeset
|
275 lexer = get_custom_lexer(filenode.extension) or filenode.lexer |
7000fc4aa569
Add option to define custom lexers for custom extensions for code highlight in rcextension module
Marcin Kuzminski <marcin@python-works.com>
parents:
3367
diff
changeset
|
276 return literal(code_highlight(filenode.content, lexer, |
7000fc4aa569
Add option to define custom lexers for custom extensions for code highlight in rcextension module
Marcin Kuzminski <marcin@python-works.com>
parents:
3367
diff
changeset
|
277 CodeHtmlFormatter(**kwargs))) |
165
ea893ffb7f00
implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents:
104
diff
changeset
|
278 |
1781
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
279 |
1171
2ab211e0aecd
changes for #56
Marcin Kuzminski <marcin@python-works.com>
parents:
1159
diff
changeset
|
280 def pygmentize_annotation(repo_name, filenode, **kwargs): |
1781
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
281 """ |
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
282 pygmentize function for annotation |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1187
diff
changeset
|
283 |
604
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
284 :param filenode: |
165
ea893ffb7f00
implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents:
104
diff
changeset
|
285 """ |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
604
diff
changeset
|
286 |
438
0d4fceb91c9c
fixes #24, added generator that generates equally distrybuted colors. Thus skipping creating one large coloring history.
Marcin Kuzminski <marcin@python-works.com>
parents:
428
diff
changeset
|
287 color_dict = {} |
1781
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
288 |
947
99850ac883d1
Fixed whoosh daemon, for depracated walk method
Marcin Kuzminski <marcin@python-works.com>
parents:
946
diff
changeset
|
289 def gen_color(n=10000): |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1187
diff
changeset
|
290 """generator for getting n of evenly distributed colors using |
947
99850ac883d1
Fixed whoosh daemon, for depracated walk method
Marcin Kuzminski <marcin@python-works.com>
parents:
946
diff
changeset
|
291 hsv color and golden ratio. It always return same order of colors |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1187
diff
changeset
|
292 |
947
99850ac883d1
Fixed whoosh daemon, for depracated walk method
Marcin Kuzminski <marcin@python-works.com>
parents:
946
diff
changeset
|
293 :returns: RGB tuple |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
604
diff
changeset
|
294 """ |
1461
e7d9d543364d
removed colorsys import
Marcin Kuzminski <marcin@python-works.com>
parents:
1438
diff
changeset
|
295 |
e7d9d543364d
removed colorsys import
Marcin Kuzminski <marcin@python-works.com>
parents:
1438
diff
changeset
|
296 def hsv_to_rgb(h, s, v): |
1781
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
297 if s == 0.0: |
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
298 return v, v, v |
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
299 i = int(h * 6.0) # XXX assume int() truncates! |
1461
e7d9d543364d
removed colorsys import
Marcin Kuzminski <marcin@python-works.com>
parents:
1438
diff
changeset
|
300 f = (h * 6.0) - i |
e7d9d543364d
removed colorsys import
Marcin Kuzminski <marcin@python-works.com>
parents:
1438
diff
changeset
|
301 p = v * (1.0 - s) |
e7d9d543364d
removed colorsys import
Marcin Kuzminski <marcin@python-works.com>
parents:
1438
diff
changeset
|
302 q = v * (1.0 - s * f) |
e7d9d543364d
removed colorsys import
Marcin Kuzminski <marcin@python-works.com>
parents:
1438
diff
changeset
|
303 t = v * (1.0 - s * (1.0 - f)) |
e7d9d543364d
removed colorsys import
Marcin Kuzminski <marcin@python-works.com>
parents:
1438
diff
changeset
|
304 i = i % 6 |
1781
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
305 if i == 0: |
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
306 return v, t, p |
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
307 if i == 1: |
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
308 return q, v, p |
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
309 if i == 2: |
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
310 return p, v, t |
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
311 if i == 3: |
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
312 return p, q, v |
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
313 if i == 4: |
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
314 return t, p, v |
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
315 if i == 5: |
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
316 return v, p, q |
1461
e7d9d543364d
removed colorsys import
Marcin Kuzminski <marcin@python-works.com>
parents:
1438
diff
changeset
|
317 |
438
0d4fceb91c9c
fixes #24, added generator that generates equally distrybuted colors. Thus skipping creating one large coloring history.
Marcin Kuzminski <marcin@python-works.com>
parents:
428
diff
changeset
|
318 golden_ratio = 0.618033988749895 |
0d4fceb91c9c
fixes #24, added generator that generates equally distrybuted colors. Thus skipping creating one large coloring history.
Marcin Kuzminski <marcin@python-works.com>
parents:
428
diff
changeset
|
319 h = 0.22717784590367374 |
947
99850ac883d1
Fixed whoosh daemon, for depracated walk method
Marcin Kuzminski <marcin@python-works.com>
parents:
946
diff
changeset
|
320 |
1320
09c3fb460fcb
Fixed problem with anchor link positioning when passed in ranges.
Marcin Kuzminski <marcin@python-works.com>
parents:
1312
diff
changeset
|
321 for _ in xrange(n): |
450
c3236d7febad
fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents:
448
diff
changeset
|
322 h += golden_ratio |
438
0d4fceb91c9c
fixes #24, added generator that generates equally distrybuted colors. Thus skipping creating one large coloring history.
Marcin Kuzminski <marcin@python-works.com>
parents:
428
diff
changeset
|
323 h %= 1 |
0d4fceb91c9c
fixes #24, added generator that generates equally distrybuted colors. Thus skipping creating one large coloring history.
Marcin Kuzminski <marcin@python-works.com>
parents:
428
diff
changeset
|
324 HSV_tuple = [h, 0.95, 0.95] |
1461
e7d9d543364d
removed colorsys import
Marcin Kuzminski <marcin@python-works.com>
parents:
1438
diff
changeset
|
325 RGB_tuple = hsv_to_rgb(*HSV_tuple) |
1781
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
326 yield map(lambda x: str(int(x * 256)), RGB_tuple) |
438
0d4fceb91c9c
fixes #24, added generator that generates equally distrybuted colors. Thus skipping creating one large coloring history.
Marcin Kuzminski <marcin@python-works.com>
parents:
428
diff
changeset
|
327 |
0d4fceb91c9c
fixes #24, added generator that generates equally distrybuted colors. Thus skipping creating one large coloring history.
Marcin Kuzminski <marcin@python-works.com>
parents:
428
diff
changeset
|
328 cgenerator = gen_color() |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
604
diff
changeset
|
329 |
165
ea893ffb7f00
implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents:
104
diff
changeset
|
330 def get_color_string(cs): |
1781
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
331 if cs in color_dict: |
165
ea893ffb7f00
implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents:
104
diff
changeset
|
332 col = color_dict[cs] |
ea893ffb7f00
implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents:
104
diff
changeset
|
333 else: |
438
0d4fceb91c9c
fixes #24, added generator that generates equally distrybuted colors. Thus skipping creating one large coloring history.
Marcin Kuzminski <marcin@python-works.com>
parents:
428
diff
changeset
|
334 col = color_dict[cs] = cgenerator.next() |
0d4fceb91c9c
fixes #24, added generator that generates equally distrybuted colors. Thus skipping creating one large coloring history.
Marcin Kuzminski <marcin@python-works.com>
parents:
428
diff
changeset
|
335 return "color: rgb(%s)! important;" % (', '.join(col)) |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
604
diff
changeset
|
336 |
1171
2ab211e0aecd
changes for #56
Marcin Kuzminski <marcin@python-works.com>
parents:
1159
diff
changeset
|
337 def url_func(repo_name): |
1352
79041f2d16f4
wrap_paragraph was to slow for toolip generation and was removed.
Marcin Kuzminski <marcin@python-works.com>
parents:
1342
diff
changeset
|
338 |
1171
2ab211e0aecd
changes for #56
Marcin Kuzminski <marcin@python-works.com>
parents:
1159
diff
changeset
|
339 def _url_func(changeset): |
1352
79041f2d16f4
wrap_paragraph was to slow for toolip generation and was removed.
Marcin Kuzminski <marcin@python-works.com>
parents:
1342
diff
changeset
|
340 author = changeset.author |
79041f2d16f4
wrap_paragraph was to slow for toolip generation and was removed.
Marcin Kuzminski <marcin@python-works.com>
parents:
1342
diff
changeset
|
341 date = changeset.date |
79041f2d16f4
wrap_paragraph was to slow for toolip generation and was removed.
Marcin Kuzminski <marcin@python-works.com>
parents:
1342
diff
changeset
|
342 message = tooltip(changeset.message) |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
604
diff
changeset
|
343 |
1352
79041f2d16f4
wrap_paragraph was to slow for toolip generation and was removed.
Marcin Kuzminski <marcin@python-works.com>
parents:
1342
diff
changeset
|
344 tooltip_html = ("<div style='font-size:0.8em'><b>Author:</b>" |
79041f2d16f4
wrap_paragraph was to slow for toolip generation and was removed.
Marcin Kuzminski <marcin@python-works.com>
parents:
1342
diff
changeset
|
345 " %s<br/><b>Date:</b> %s</b><br/><b>Message:" |
79041f2d16f4
wrap_paragraph was to slow for toolip generation and was removed.
Marcin Kuzminski <marcin@python-works.com>
parents:
1342
diff
changeset
|
346 "</b> %s<br/></div>") |
79041f2d16f4
wrap_paragraph was to slow for toolip generation and was removed.
Marcin Kuzminski <marcin@python-works.com>
parents:
1342
diff
changeset
|
347 |
79041f2d16f4
wrap_paragraph was to slow for toolip generation and was removed.
Marcin Kuzminski <marcin@python-works.com>
parents:
1342
diff
changeset
|
348 tooltip_html = tooltip_html % (author, date, message) |
1171
2ab211e0aecd
changes for #56
Marcin Kuzminski <marcin@python-works.com>
parents:
1159
diff
changeset
|
349 lnk_format = '%5s:%s' % ('r%s' % changeset.revision, |
2ab211e0aecd
changes for #56
Marcin Kuzminski <marcin@python-works.com>
parents:
1159
diff
changeset
|
350 short_id(changeset.raw_id)) |
2ab211e0aecd
changes for #56
Marcin Kuzminski <marcin@python-works.com>
parents:
1159
diff
changeset
|
351 uri = link_to( |
2ab211e0aecd
changes for #56
Marcin Kuzminski <marcin@python-works.com>
parents:
1159
diff
changeset
|
352 lnk_format, |
2ab211e0aecd
changes for #56
Marcin Kuzminski <marcin@python-works.com>
parents:
1159
diff
changeset
|
353 url('changeset_home', repo_name=repo_name, |
2ab211e0aecd
changes for #56
Marcin Kuzminski <marcin@python-works.com>
parents:
1159
diff
changeset
|
354 revision=changeset.raw_id), |
2ab211e0aecd
changes for #56
Marcin Kuzminski <marcin@python-works.com>
parents:
1159
diff
changeset
|
355 style=get_color_string(changeset.raw_id), |
2ab211e0aecd
changes for #56
Marcin Kuzminski <marcin@python-works.com>
parents:
1159
diff
changeset
|
356 class_='tooltip', |
2ab211e0aecd
changes for #56
Marcin Kuzminski <marcin@python-works.com>
parents:
1159
diff
changeset
|
357 title=tooltip_html |
2ab211e0aecd
changes for #56
Marcin Kuzminski <marcin@python-works.com>
parents:
1159
diff
changeset
|
358 ) |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
604
diff
changeset
|
359 |
1171
2ab211e0aecd
changes for #56
Marcin Kuzminski <marcin@python-works.com>
parents:
1159
diff
changeset
|
360 uri += '\n' |
2ab211e0aecd
changes for #56
Marcin Kuzminski <marcin@python-works.com>
parents:
1159
diff
changeset
|
361 return uri |
2ab211e0aecd
changes for #56
Marcin Kuzminski <marcin@python-works.com>
parents:
1159
diff
changeset
|
362 return _url_func |
2ab211e0aecd
changes for #56
Marcin Kuzminski <marcin@python-works.com>
parents:
1159
diff
changeset
|
363 |
2ab211e0aecd
changes for #56
Marcin Kuzminski <marcin@python-works.com>
parents:
1159
diff
changeset
|
364 return literal(annotate_highlight(filenode, url_func(repo_name), **kwargs)) |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
604
diff
changeset
|
365 |
1781
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
366 |
999
1951c35483ab
fixed following js snipet. It' can be called multiple times now next to each repository
Marcin Kuzminski <marcin@python-works.com>
parents:
995
diff
changeset
|
367 def is_following_repo(repo_name, user_id): |
1951c35483ab
fixed following js snipet. It' can be called multiple times now next to each repository
Marcin Kuzminski <marcin@python-works.com>
parents:
995
diff
changeset
|
368 from rhodecode.model.scm import ScmModel |
1951c35483ab
fixed following js snipet. It' can be called multiple times now next to each repository
Marcin Kuzminski <marcin@python-works.com>
parents:
995
diff
changeset
|
369 return ScmModel().is_following_repo(repo_name, user_id) |
1951c35483ab
fixed following js snipet. It' can be called multiple times now next to each repository
Marcin Kuzminski <marcin@python-works.com>
parents:
995
diff
changeset
|
370 |
3924
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
371 class _Message(object): |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
372 """A message returned by ``Flash.pop_messages()``. |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
373 |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
374 Converting the message to a string returns the message text. Instances |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
375 also have the following attributes: |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
376 |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
377 * ``message``: the message text. |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
378 * ``category``: the category specified when the message was created. |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
379 """ |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
380 |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
381 def __init__(self, category, message): |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
382 self.category = category |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
383 self.message = message |
3924
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
384 |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
385 def __str__(self): |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
386 return self.message |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
387 |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
388 __unicode__ = __str__ |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
389 |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
390 def __html__(self): |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
391 return escape(safe_unicode(self.message)) |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
392 |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
393 class Flash(_Flash): |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
394 |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
395 def pop_messages(self): |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
396 """Return all accumulated messages and delete them from the session. |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
397 |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
398 The return value is a list of ``Message`` objects. |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
399 """ |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
400 from pylons import session |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
401 messages = session.pop(self.session_key, []) |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
402 session.save() |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
403 return [_Message(*m) for m in messages] |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
404 |
14afe4d1363d
Fixes #852, created custom Flash() class and Message
Marcin Kuzminski <marcin@python-works.com>
parents:
3915
diff
changeset
|
405 flash = Flash() |
282
237470e64bb8
switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents:
281
diff
changeset
|
406 |
635
fd63782c4426
Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents:
631
diff
changeset
|
407 #============================================================================== |
1356
eec4defdf2b8
Make rhodecode use author/username filter from vcs instead of mercurial
Marcin Kuzminski <marcin@python-works.com>
parents:
1352
diff
changeset
|
408 # SCM FILTERS available via h. |
635
fd63782c4426
Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents:
631
diff
changeset
|
409 #============================================================================== |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
1979
diff
changeset
|
410 from rhodecode.lib.vcs.utils import author_name, author_email |
2109 | 411 from rhodecode.lib.utils2 import credentials_filter, age as _age |
2239
493e03a4d268
added changeset status into changelog view
Marcin Kuzminski <marcin@python-works.com>
parents:
2217
diff
changeset
|
412 from rhodecode.model.db import User, ChangesetStatus |
282
237470e64bb8
switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents:
281
diff
changeset
|
413 |
3557
58dcef7eef03
Implemented show_id function that is a configurable way to display sha hashes in the changelog.
Marcin Kuzminski <marcin@python-works.com>
parents:
3540
diff
changeset
|
414 age = lambda x, y=False: _age(x, y) |
282
237470e64bb8
switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents:
281
diff
changeset
|
415 capitalize = lambda x: x.capitalize() |
1356
eec4defdf2b8
Make rhodecode use author/username filter from vcs instead of mercurial
Marcin Kuzminski <marcin@python-works.com>
parents:
1352
diff
changeset
|
416 email = author_email |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
635
diff
changeset
|
417 short_id = lambda x: x[:12] |
1373
66f03a87141c
Fixes issue #201
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
418 hide_credentials = lambda x: ''.join(credentials_filter(x)) |
660
df61378032f3
#48 rewrote action logger, translated action logger messages, added some extra messages. Linked and showed pushed revisions in logs
Marcin Kuzminski <marcin@python-works.com>
parents:
653
diff
changeset
|
419 |
1764
39b49c999efb
fixes issue #320.
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
420 |
3557
58dcef7eef03
Implemented show_id function that is a configurable way to display sha hashes in the changelog.
Marcin Kuzminski <marcin@python-works.com>
parents:
3540
diff
changeset
|
421 def show_id(cs): |
58dcef7eef03
Implemented show_id function that is a configurable way to display sha hashes in the changelog.
Marcin Kuzminski <marcin@python-works.com>
parents:
3540
diff
changeset
|
422 """ |
58dcef7eef03
Implemented show_id function that is a configurable way to display sha hashes in the changelog.
Marcin Kuzminski <marcin@python-works.com>
parents:
3540
diff
changeset
|
423 Configurable function that shows ID |
58dcef7eef03
Implemented show_id function that is a configurable way to display sha hashes in the changelog.
Marcin Kuzminski <marcin@python-works.com>
parents:
3540
diff
changeset
|
424 by default it's r123:fffeeefffeee |
58dcef7eef03
Implemented show_id function that is a configurable way to display sha hashes in the changelog.
Marcin Kuzminski <marcin@python-works.com>
parents:
3540
diff
changeset
|
425 |
58dcef7eef03
Implemented show_id function that is a configurable way to display sha hashes in the changelog.
Marcin Kuzminski <marcin@python-works.com>
parents:
3540
diff
changeset
|
426 :param cs: changeset instance |
58dcef7eef03
Implemented show_id function that is a configurable way to display sha hashes in the changelog.
Marcin Kuzminski <marcin@python-works.com>
parents:
3540
diff
changeset
|
427 """ |
58dcef7eef03
Implemented show_id function that is a configurable way to display sha hashes in the changelog.
Marcin Kuzminski <marcin@python-works.com>
parents:
3540
diff
changeset
|
428 from rhodecode import CONFIG |
3651
659bd922520e
config: rename options to show_revision_number and show_sha_length
Mads Kiilerich <madski@unity3d.com>
parents:
3631
diff
changeset
|
429 def_len = safe_int(CONFIG.get('show_sha_length', 12)) |
659bd922520e
config: rename options to show_revision_number and show_sha_length
Mads Kiilerich <madski@unity3d.com>
parents:
3631
diff
changeset
|
430 show_rev = str2bool(CONFIG.get('show_revision_number', True)) |
3557
58dcef7eef03
Implemented show_id function that is a configurable way to display sha hashes in the changelog.
Marcin Kuzminski <marcin@python-works.com>
parents:
3540
diff
changeset
|
431 |
58dcef7eef03
Implemented show_id function that is a configurable way to display sha hashes in the changelog.
Marcin Kuzminski <marcin@python-works.com>
parents:
3540
diff
changeset
|
432 raw_id = cs.raw_id[:def_len] |
58dcef7eef03
Implemented show_id function that is a configurable way to display sha hashes in the changelog.
Marcin Kuzminski <marcin@python-works.com>
parents:
3540
diff
changeset
|
433 if show_rev: |
58dcef7eef03
Implemented show_id function that is a configurable way to display sha hashes in the changelog.
Marcin Kuzminski <marcin@python-works.com>
parents:
3540
diff
changeset
|
434 return 'r%s:%s' % (cs.revision, raw_id) |
58dcef7eef03
Implemented show_id function that is a configurable way to display sha hashes in the changelog.
Marcin Kuzminski <marcin@python-works.com>
parents:
3540
diff
changeset
|
435 else: |
58dcef7eef03
Implemented show_id function that is a configurable way to display sha hashes in the changelog.
Marcin Kuzminski <marcin@python-works.com>
parents:
3540
diff
changeset
|
436 return '%s' % (raw_id) |
58dcef7eef03
Implemented show_id function that is a configurable way to display sha hashes in the changelog.
Marcin Kuzminski <marcin@python-works.com>
parents:
3540
diff
changeset
|
437 |
58dcef7eef03
Implemented show_id function that is a configurable way to display sha hashes in the changelog.
Marcin Kuzminski <marcin@python-works.com>
parents:
3540
diff
changeset
|
438 |
2416
44f328d6f209
Added a translatable date formatter for every date displayed.
Vincent Duvert <vincent@duvert.net>
parents:
2376
diff
changeset
|
439 def fmt_date(date): |
44f328d6f209
Added a translatable date formatter for every date displayed.
Vincent Duvert <vincent@duvert.net>
parents:
2376
diff
changeset
|
440 if date: |
3947
ff78716ab3fa
removed bad translation string
Marcin Kuzminski <marcin@python-works.com>
parents:
3924
diff
changeset
|
441 _fmt = u"%a, %d %b %Y %H:%M:%S".encode('utf8') |
2445
9b623dcddb02
Format datetime in notifications according to unified function
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
442 return date.strftime(_fmt).decode('utf8') |
2427
f467c75544af
Added h.tooltip to all places that tooltip_title is used.
Marcin Kuzminski <marcin@python-works.com>
parents:
2416
diff
changeset
|
443 |
2416
44f328d6f209
Added a translatable date formatter for every date displayed.
Vincent Duvert <vincent@duvert.net>
parents:
2376
diff
changeset
|
444 return "" |
44f328d6f209
Added a translatable date formatter for every date displayed.
Vincent Duvert <vincent@duvert.net>
parents:
2376
diff
changeset
|
445 |
44f328d6f209
Added a translatable date formatter for every date displayed.
Vincent Duvert <vincent@duvert.net>
parents:
2376
diff
changeset
|
446 |
1959
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
447 def is_git(repository): |
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
448 if hasattr(repository, 'alias'): |
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
449 _type = repository.alias |
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
450 elif hasattr(repository, 'repo_type'): |
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
451 _type = repository.repo_type |
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
452 else: |
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
453 _type = repository |
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
454 return _type == 'git' |
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
455 |
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
456 |
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
457 def is_hg(repository): |
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
458 if hasattr(repository, 'alias'): |
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
459 _type = repository.alias |
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
460 elif hasattr(repository, 'repo_type'): |
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
461 _type = repository.repo_type |
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
462 else: |
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
463 _type = repository |
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
464 return _type == 'hg' |
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
465 |
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
466 |
1767 | 467 def email_or_none(author): |
2725
3853e37db97c
fixes issue #531, when extracting user email, we check it against the database,
Marcin Kuzminski <marcin@python-works.com>
parents:
2686
diff
changeset
|
468 # extract email from the commit string |
1767 | 469 _email = email(author) |
470 if _email != '': | |
2725
3853e37db97c
fixes issue #531, when extracting user email, we check it against the database,
Marcin Kuzminski <marcin@python-works.com>
parents:
2686
diff
changeset
|
471 # check it against RhodeCode database, and use the MAIN email for this |
3853e37db97c
fixes issue #531, when extracting user email, we check it against the database,
Marcin Kuzminski <marcin@python-works.com>
parents:
2686
diff
changeset
|
472 # user |
3853e37db97c
fixes issue #531, when extracting user email, we check it against the database,
Marcin Kuzminski <marcin@python-works.com>
parents:
2686
diff
changeset
|
473 user = User.get_by_email(_email, case_insensitive=True, cache=True) |
3853e37db97c
fixes issue #531, when extracting user email, we check it against the database,
Marcin Kuzminski <marcin@python-works.com>
parents:
2686
diff
changeset
|
474 if user is not None: |
3853e37db97c
fixes issue #531, when extracting user email, we check it against the database,
Marcin Kuzminski <marcin@python-works.com>
parents:
2686
diff
changeset
|
475 return user.email |
1767 | 476 return _email |
1764
39b49c999efb
fixes issue #320.
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
477 |
39b49c999efb
fixes issue #320.
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
478 # See if it contains a username we can get an email from |
1767 | 479 user = User.get_by_username(author_name(author), case_insensitive=True, |
1764
39b49c999efb
fixes issue #320.
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
480 cache=True) |
39b49c999efb
fixes issue #320.
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
481 if user is not None: |
39b49c999efb
fixes issue #320.
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
482 return user.email |
39b49c999efb
fixes issue #320.
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
483 |
39b49c999efb
fixes issue #320.
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
484 # No valid email, not a valid user in the system, none! |
39b49c999efb
fixes issue #320.
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
485 return None |
39b49c999efb
fixes issue #320.
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
486 |
1781
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
487 |
2731
09d8fec02954
Implemented #532.
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
488 def person(author, show_attr="username_and_name"): |
1764
39b49c999efb
fixes issue #320.
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
489 # attr to return from fetched user |
2731
09d8fec02954
Implemented #532.
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
490 person_getter = lambda usr: getattr(usr, show_attr) |
1781
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1776
diff
changeset
|
491 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
492 # if author is already an instance use it for extraction |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
493 if isinstance(author, User): |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
494 return person_getter(author) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
495 |
1767 | 496 # Valid email in the attribute passed, see if they're in the system |
497 _email = email(author) | |
498 if _email != '': | |
499 user = User.get_by_email(_email, case_insensitive=True, cache=True) | |
1764
39b49c999efb
fixes issue #320.
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
500 if user is not None: |
39b49c999efb
fixes issue #320.
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
501 return person_getter(user) |
39b49c999efb
fixes issue #320.
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
502 |
39b49c999efb
fixes issue #320.
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
503 # Maybe it's a username? |
1767 | 504 _author = author_name(author) |
505 user = User.get_by_username(_author, case_insensitive=True, | |
1764
39b49c999efb
fixes issue #320.
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
506 cache=True) |
39b49c999efb
fixes issue #320.
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
507 if user is not None: |
39b49c999efb
fixes issue #320.
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
508 return person_getter(user) |
39b49c999efb
fixes issue #320.
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
509 |
3766
848492e2aafa
h.person, if author name is empty, use email as a fallback
Marcin Kuzminski <marcin@python-works.com>
parents:
3740
diff
changeset
|
510 # Still nothing? Just pass back the author name if any, else the email |
848492e2aafa
h.person, if author name is empty, use email as a fallback
Marcin Kuzminski <marcin@python-works.com>
parents:
3740
diff
changeset
|
511 return _author or _email |
1764
39b49c999efb
fixes issue #320.
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
512 |
1959
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
513 |
2731
09d8fec02954
Implemented #532.
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
514 def person_by_id(id_, show_attr="username_and_name"): |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2725
diff
changeset
|
515 # attr to return from fetched user |
2731
09d8fec02954
Implemented #532.
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
516 person_getter = lambda usr: getattr(usr, show_attr) |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2725
diff
changeset
|
517 |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2725
diff
changeset
|
518 #maybe it's an ID ? |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2725
diff
changeset
|
519 if str(id_).isdigit() or isinstance(id_, int): |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2725
diff
changeset
|
520 id_ = int(id_) |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2725
diff
changeset
|
521 user = User.get(id_) |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2725
diff
changeset
|
522 if user is not None: |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2725
diff
changeset
|
523 return person_getter(user) |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2725
diff
changeset
|
524 return id_ |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2725
diff
changeset
|
525 |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2725
diff
changeset
|
526 |
2674
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2609
diff
changeset
|
527 def desc_stylize(value): |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2609
diff
changeset
|
528 """ |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2609
diff
changeset
|
529 converts tags from value into html equivalent |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2609
diff
changeset
|
530 |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2609
diff
changeset
|
531 :param value: |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2609
diff
changeset
|
532 """ |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
533 if not value: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
534 return '' |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
535 |
2674
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2609
diff
changeset
|
536 value = re.sub(r'\[see\ \=\>\ *([a-zA-Z0-9\/\=\?\&\ \:\/\.\-]*)\]', |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2609
diff
changeset
|
537 '<div class="metatag" tag="see">see => \\1 </div>', value) |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2609
diff
changeset
|
538 value = re.sub(r'\[license\ \=\>\ *([a-zA-Z0-9\/\=\?\&\ \:\/\.\-]*)\]', |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2609
diff
changeset
|
539 '<div class="metatag" tag="license"><a href="http:\/\/www.opensource.org/licenses/\\1">\\1</a></div>', value) |
3156
1ab01549f1f8
fixes issue #715 Meta-Tagging [requires => Repo-123] not working
Marcin Kuzminski <marcin@python-works.com>
parents:
3149
diff
changeset
|
540 value = re.sub(r'\[(requires|recommends|conflicts|base)\ \=\>\ *([a-zA-Z0-9\-\/]*)\]', |
2674
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2609
diff
changeset
|
541 '<div class="metatag" tag="\\1">\\1 => <a href="/\\2">\\2</a></div>', value) |
2965
d0553004e73d
fixed #623: Lang meta-tag doesn't work with C#/C++
Marcin Kuzminski <marcin@python-works.com>
parents:
2958
diff
changeset
|
542 value = re.sub(r'\[(lang|language)\ \=\>\ *([a-zA-Z\-\/\#\+]*)\]', |
2674
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2609
diff
changeset
|
543 '<div class="metatag" tag="lang">\\2</div>', value) |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2609
diff
changeset
|
544 value = re.sub(r'\[([a-z]+)\]', |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2609
diff
changeset
|
545 '<div class="metatag" tag="\\1">\\1</div>', value) |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2609
diff
changeset
|
546 |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2609
diff
changeset
|
547 return value |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2609
diff
changeset
|
548 |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2609
diff
changeset
|
549 |
3627
32cb8d45f330
helpers: show boolean value of value as icon, not just the True and False singletons
Mads Kiilerich <madski@unity3d.com>
parents:
3599
diff
changeset
|
550 def boolicon(value): |
32cb8d45f330
helpers: show boolean value of value as icon, not just the True and False singletons
Mads Kiilerich <madski@unity3d.com>
parents:
3599
diff
changeset
|
551 """Returns boolean value of a value, represented as small html image of true/false |
712
131c1e335fa7
Added ldap info on admin users, added bool2icon helper for nicer representation of
Marcin Kuzminski <marcin@python-works.com>
parents:
698
diff
changeset
|
552 icons |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1187
diff
changeset
|
553 |
3627
32cb8d45f330
helpers: show boolean value of value as icon, not just the True and False singletons
Mads Kiilerich <madski@unity3d.com>
parents:
3599
diff
changeset
|
554 :param value: value |
712
131c1e335fa7
Added ldap info on admin users, added bool2icon helper for nicer representation of
Marcin Kuzminski <marcin@python-works.com>
parents:
698
diff
changeset
|
555 """ |
131c1e335fa7
Added ldap info on admin users, added bool2icon helper for nicer representation of
Marcin Kuzminski <marcin@python-works.com>
parents:
698
diff
changeset
|
556 |
3627
32cb8d45f330
helpers: show boolean value of value as icon, not just the True and False singletons
Mads Kiilerich <madski@unity3d.com>
parents:
3599
diff
changeset
|
557 if value: |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
558 return HTML.tag('i', class_="icon-ok-sign") |
3627
32cb8d45f330
helpers: show boolean value of value as icon, not just the True and False singletons
Mads Kiilerich <madski@unity3d.com>
parents:
3599
diff
changeset
|
559 else: |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
560 return HTML.tag('i', class_="icon-minus-sign") |
712
131c1e335fa7
Added ldap info on admin users, added bool2icon helper for nicer representation of
Marcin Kuzminski <marcin@python-works.com>
parents:
698
diff
changeset
|
561 |
131c1e335fa7
Added ldap info on admin users, added bool2icon helper for nicer representation of
Marcin Kuzminski <marcin@python-works.com>
parents:
698
diff
changeset
|
562 |
2958
c0a6a2e6bb2e
Use lightweight revisions in journal by default
Marcin Kuzminski <marcin@python-works.com>
parents:
2956
diff
changeset
|
563 def action_parser(user_log, feed=False, parse_cs=False): |
2012
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
564 """ |
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
565 This helper will action_map the specified string action into translated |
660
df61378032f3
#48 rewrote action logger, translated action logger messages, added some extra messages. Linked and showed pushed revisions in logs
Marcin Kuzminski <marcin@python-works.com>
parents:
653
diff
changeset
|
566 fancy names with icons and links |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1187
diff
changeset
|
567 |
899
d65843e07d3c
Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents:
864
diff
changeset
|
568 :param user_log: user log instance |
1087
51076a2a2b64
fixed unicode problems with file paths.
Marcin Kuzminski <marcin@python-works.com>
parents:
1055
diff
changeset
|
569 :param feed: use output for feeds (no html and fancy icons) |
2950
528c7f210b12
added experimental lightweight param to journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2936
diff
changeset
|
570 :param parse_cs: parse Changesets into VCS instances |
660
df61378032f3
#48 rewrote action logger, translated action logger messages, added some extra messages. Linked and showed pushed revisions in logs
Marcin Kuzminski <marcin@python-works.com>
parents:
653
diff
changeset
|
571 """ |
2958
c0a6a2e6bb2e
Use lightweight revisions in journal by default
Marcin Kuzminski <marcin@python-works.com>
parents:
2956
diff
changeset
|
572 |
660
df61378032f3
#48 rewrote action logger, translated action logger messages, added some extra messages. Linked and showed pushed revisions in logs
Marcin Kuzminski <marcin@python-works.com>
parents:
653
diff
changeset
|
573 action = user_log.action |
840
ee6f345736a6
action logger upgrade, for working with migrations
Marcin Kuzminski <marcin@python-works.com>
parents:
817
diff
changeset
|
574 action_params = ' ' |
660
df61378032f3
#48 rewrote action logger, translated action logger messages, added some extra messages. Linked and showed pushed revisions in logs
Marcin Kuzminski <marcin@python-works.com>
parents:
653
diff
changeset
|
575 |
df61378032f3
#48 rewrote action logger, translated action logger messages, added some extra messages. Linked and showed pushed revisions in logs
Marcin Kuzminski <marcin@python-works.com>
parents:
653
diff
changeset
|
576 x = action.split(':') |
df61378032f3
#48 rewrote action logger, translated action logger messages, added some extra messages. Linked and showed pushed revisions in logs
Marcin Kuzminski <marcin@python-works.com>
parents:
653
diff
changeset
|
577 |
df61378032f3
#48 rewrote action logger, translated action logger messages, added some extra messages. Linked and showed pushed revisions in logs
Marcin Kuzminski <marcin@python-works.com>
parents:
653
diff
changeset
|
578 if len(x) > 1: |
df61378032f3
#48 rewrote action logger, translated action logger messages, added some extra messages. Linked and showed pushed revisions in logs
Marcin Kuzminski <marcin@python-works.com>
parents:
653
diff
changeset
|
579 action, action_params = x |
df61378032f3
#48 rewrote action logger, translated action logger messages, added some extra messages. Linked and showed pushed revisions in logs
Marcin Kuzminski <marcin@python-works.com>
parents:
653
diff
changeset
|
580 |
718
7df3855bf6c7
Added fork name to journal
Marcin Kuzminski <marcin@python-works.com>
parents:
714
diff
changeset
|
581 def get_cs_links(): |
2012
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
582 revs_limit = 3 # display this amount always |
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
583 revs_top_limit = 50 # show upto this amount of changesets hidden |
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
584 revs_ids = action_params.split(',') |
2014
8ccac2b0fcf3
fixed cs_links for deleted repos
Marcin Kuzminski <marcin@python-works.com>
parents:
2012
diff
changeset
|
585 deleted = user_log.repository is None |
8ccac2b0fcf3
fixed cs_links for deleted repos
Marcin Kuzminski <marcin@python-works.com>
parents:
2012
diff
changeset
|
586 if deleted: |
8ccac2b0fcf3
fixed cs_links for deleted repos
Marcin Kuzminski <marcin@python-works.com>
parents:
2012
diff
changeset
|
587 return ','.join(revs_ids) |
8ccac2b0fcf3
fixed cs_links for deleted repos
Marcin Kuzminski <marcin@python-works.com>
parents:
2012
diff
changeset
|
588 |
953
def3578dac8c
fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents:
947
diff
changeset
|
589 repo_name = user_log.repository.repo_name |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1041
diff
changeset
|
590 |
2323
6c0f76330d91
fix for issue #450. Rhodecode no longer will crash when bad revision is present in journal data.
Marcin Kuzminski <marcin@python-works.com>
parents:
2203
diff
changeset
|
591 def lnk(rev, repo_name): |
2950
528c7f210b12
added experimental lightweight param to journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2936
diff
changeset
|
592 if isinstance(rev, BaseChangeset) or isinstance(rev, AttributeDict): |
2998
433428ffd13b
fixes #645 Fix git handler when doing delete remote branch
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
593 lazy_cs = True |
433428ffd13b
fixes #645 Fix git handler when doing delete remote branch
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
594 if getattr(rev, 'op', None) and getattr(rev, 'ref_name', None): |
433428ffd13b
fixes #645 Fix git handler when doing delete remote branch
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
595 lazy_cs = False |
433428ffd13b
fixes #645 Fix git handler when doing delete remote branch
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
596 lbl = '?' |
433428ffd13b
fixes #645 Fix git handler when doing delete remote branch
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
597 if rev.op == 'delete_branch': |
433428ffd13b
fixes #645 Fix git handler when doing delete remote branch
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
598 lbl = '%s' % _('Deleted branch: %s') % rev.ref_name |
433428ffd13b
fixes #645 Fix git handler when doing delete remote branch
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
599 title = '' |
433428ffd13b
fixes #645 Fix git handler when doing delete remote branch
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
600 elif rev.op == 'tag': |
433428ffd13b
fixes #645 Fix git handler when doing delete remote branch
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
601 lbl = '%s' % _('Created tag: %s') % rev.ref_name |
433428ffd13b
fixes #645 Fix git handler when doing delete remote branch
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
602 title = '' |
433428ffd13b
fixes #645 Fix git handler when doing delete remote branch
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
603 _url = '#' |
433428ffd13b
fixes #645 Fix git handler when doing delete remote branch
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
604 |
433428ffd13b
fixes #645 Fix git handler when doing delete remote branch
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
605 else: |
433428ffd13b
fixes #645 Fix git handler when doing delete remote branch
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
606 lbl = '%s' % (rev.short_id[:8]) |
433428ffd13b
fixes #645 Fix git handler when doing delete remote branch
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
607 _url = url('changeset_home', repo_name=repo_name, |
433428ffd13b
fixes #645 Fix git handler when doing delete remote branch
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
608 revision=rev.raw_id) |
433428ffd13b
fixes #645 Fix git handler when doing delete remote branch
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
609 title = tooltip(rev.message) |
2323
6c0f76330d91
fix for issue #450. Rhodecode no longer will crash when bad revision is present in journal data.
Marcin Kuzminski <marcin@python-works.com>
parents:
2203
diff
changeset
|
610 else: |
2958
c0a6a2e6bb2e
Use lightweight revisions in journal by default
Marcin Kuzminski <marcin@python-works.com>
parents:
2956
diff
changeset
|
611 ## changeset cannot be found/striped/removed etc. |
2952
029a40c58df7
Added lightweight journal option for visual
Marcin Kuzminski <marcin@python-works.com>
parents:
2950
diff
changeset
|
612 lbl = ('%s' % rev)[:12] |
2323
6c0f76330d91
fix for issue #450. Rhodecode no longer will crash when bad revision is present in journal data.
Marcin Kuzminski <marcin@python-works.com>
parents:
2203
diff
changeset
|
613 _url = '#' |
6c0f76330d91
fix for issue #450. Rhodecode no longer will crash when bad revision is present in journal data.
Marcin Kuzminski <marcin@python-works.com>
parents:
2203
diff
changeset
|
614 title = _('Changeset not found') |
2958
c0a6a2e6bb2e
Use lightweight revisions in journal by default
Marcin Kuzminski <marcin@python-works.com>
parents:
2956
diff
changeset
|
615 if parse_cs: |
c0a6a2e6bb2e
Use lightweight revisions in journal by default
Marcin Kuzminski <marcin@python-works.com>
parents:
2956
diff
changeset
|
616 return link_to(lbl, _url, title=title, class_='tooltip') |
2971
2bfcec6a3985
new tooltip implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
2966
diff
changeset
|
617 return link_to(lbl, _url, raw_id=rev.raw_id, repo_name=repo_name, |
2998
433428ffd13b
fixes #645 Fix git handler when doing delete remote branch
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
618 class_='lazy-cs' if lazy_cs else '') |
2203
d9972f76322e
added emulation of pull hook for git-backend, and dummy git-push hook
Marcin Kuzminski <marcin@python-works.com>
parents:
2162
diff
changeset
|
619 |
3507
71fa9a198ac3
show correct values for compare view when multiple git tags are pushed
Marcin Kuzminski <marcin@python-works.com>
parents:
3415
diff
changeset
|
620 def _get_op(rev_txt): |
71fa9a198ac3
show correct values for compare view when multiple git tags are pushed
Marcin Kuzminski <marcin@python-works.com>
parents:
3415
diff
changeset
|
621 _op = None |
71fa9a198ac3
show correct values for compare view when multiple git tags are pushed
Marcin Kuzminski <marcin@python-works.com>
parents:
3415
diff
changeset
|
622 _name = rev_txt |
71fa9a198ac3
show correct values for compare view when multiple git tags are pushed
Marcin Kuzminski <marcin@python-works.com>
parents:
3415
diff
changeset
|
623 if len(rev_txt.split('=>')) == 2: |
71fa9a198ac3
show correct values for compare view when multiple git tags are pushed
Marcin Kuzminski <marcin@python-works.com>
parents:
3415
diff
changeset
|
624 _op, _name = rev_txt.split('=>') |
71fa9a198ac3
show correct values for compare view when multiple git tags are pushed
Marcin Kuzminski <marcin@python-works.com>
parents:
3415
diff
changeset
|
625 return _op, _name |
71fa9a198ac3
show correct values for compare view when multiple git tags are pushed
Marcin Kuzminski <marcin@python-works.com>
parents:
3415
diff
changeset
|
626 |
2203
d9972f76322e
added emulation of pull hook for git-backend, and dummy git-push hook
Marcin Kuzminski <marcin@python-works.com>
parents:
2162
diff
changeset
|
627 revs = [] |
d9972f76322e
added emulation of pull hook for git-backend, and dummy git-push hook
Marcin Kuzminski <marcin@python-works.com>
parents:
2162
diff
changeset
|
628 if len(filter(lambda v: v != '', revs_ids)) > 0: |
2958
c0a6a2e6bb2e
Use lightweight revisions in journal by default
Marcin Kuzminski <marcin@python-works.com>
parents:
2956
diff
changeset
|
629 repo = None |
2323
6c0f76330d91
fix for issue #450. Rhodecode no longer will crash when bad revision is present in journal data.
Marcin Kuzminski <marcin@python-works.com>
parents:
2203
diff
changeset
|
630 for rev in revs_ids[:revs_top_limit]: |
3507
71fa9a198ac3
show correct values for compare view when multiple git tags are pushed
Marcin Kuzminski <marcin@python-works.com>
parents:
3415
diff
changeset
|
631 _op, _name = _get_op(rev) |
2998
433428ffd13b
fixes #645 Fix git handler when doing delete remote branch
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
632 |
2958
c0a6a2e6bb2e
Use lightweight revisions in journal by default
Marcin Kuzminski <marcin@python-works.com>
parents:
2956
diff
changeset
|
633 # we want parsed changesets, or new log store format is bad |
2950
528c7f210b12
added experimental lightweight param to journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2936
diff
changeset
|
634 if parse_cs: |
528c7f210b12
added experimental lightweight param to journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2936
diff
changeset
|
635 try: |
2958
c0a6a2e6bb2e
Use lightweight revisions in journal by default
Marcin Kuzminski <marcin@python-works.com>
parents:
2956
diff
changeset
|
636 if repo is None: |
c0a6a2e6bb2e
Use lightweight revisions in journal by default
Marcin Kuzminski <marcin@python-works.com>
parents:
2956
diff
changeset
|
637 repo = user_log.repository.scm_instance |
c0a6a2e6bb2e
Use lightweight revisions in journal by default
Marcin Kuzminski <marcin@python-works.com>
parents:
2956
diff
changeset
|
638 _rev = repo.get_changeset(rev) |
c0a6a2e6bb2e
Use lightweight revisions in journal by default
Marcin Kuzminski <marcin@python-works.com>
parents:
2956
diff
changeset
|
639 revs.append(_rev) |
2950
528c7f210b12
added experimental lightweight param to journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2936
diff
changeset
|
640 except ChangesetDoesNotExistError: |
528c7f210b12
added experimental lightweight param to journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2936
diff
changeset
|
641 log.error('cannot find revision %s in this repo' % rev) |
528c7f210b12
added experimental lightweight param to journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2936
diff
changeset
|
642 revs.append(rev) |
528c7f210b12
added experimental lightweight param to journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2936
diff
changeset
|
643 continue |
528c7f210b12
added experimental lightweight param to journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2936
diff
changeset
|
644 else: |
2958
c0a6a2e6bb2e
Use lightweight revisions in journal by default
Marcin Kuzminski <marcin@python-works.com>
parents:
2956
diff
changeset
|
645 _rev = AttributeDict({ |
2950
528c7f210b12
added experimental lightweight param to journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2936
diff
changeset
|
646 'short_id': rev[:12], |
528c7f210b12
added experimental lightweight param to journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2936
diff
changeset
|
647 'raw_id': rev, |
2958
c0a6a2e6bb2e
Use lightweight revisions in journal by default
Marcin Kuzminski <marcin@python-works.com>
parents:
2956
diff
changeset
|
648 'message': '', |
2998
433428ffd13b
fixes #645 Fix git handler when doing delete remote branch
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
649 'op': _op, |
433428ffd13b
fixes #645 Fix git handler when doing delete remote branch
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
650 'ref_name': _name |
2950
528c7f210b12
added experimental lightweight param to journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2936
diff
changeset
|
651 }) |
2958
c0a6a2e6bb2e
Use lightweight revisions in journal by default
Marcin Kuzminski <marcin@python-works.com>
parents:
2956
diff
changeset
|
652 revs.append(_rev) |
3890
f5a1314886ec
replace list appends with list literals when possible
Marcin Kuzminski <marcin@python-works.com>
parents:
3868
diff
changeset
|
653 cs_links = [" " + ', '.join( |
2012
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
654 [lnk(rev, repo_name) for rev in revs[:revs_limit]] |
3890
f5a1314886ec
replace list appends with list literals when possible
Marcin Kuzminski <marcin@python-works.com>
parents:
3868
diff
changeset
|
655 )] |
3507
71fa9a198ac3
show correct values for compare view when multiple git tags are pushed
Marcin Kuzminski <marcin@python-works.com>
parents:
3415
diff
changeset
|
656 _op1, _name1 = _get_op(revs_ids[0]) |
71fa9a198ac3
show correct values for compare view when multiple git tags are pushed
Marcin Kuzminski <marcin@python-works.com>
parents:
3415
diff
changeset
|
657 _op2, _name2 = _get_op(revs_ids[-1]) |
71fa9a198ac3
show correct values for compare view when multiple git tags are pushed
Marcin Kuzminski <marcin@python-works.com>
parents:
3415
diff
changeset
|
658 |
71fa9a198ac3
show correct values for compare view when multiple git tags are pushed
Marcin Kuzminski <marcin@python-works.com>
parents:
3415
diff
changeset
|
659 _rev = '%s...%s' % (_name1, _name2) |
1009
eafe5ae429ea
Added compare view into journal, fixed wrong function call to show compare view
Marcin Kuzminski <marcin@python-works.com>
parents:
999
diff
changeset
|
660 |
2012
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
661 compare_view = ( |
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
662 ' <div class="compare_view tooltip" title="%s">' |
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
663 '<a href="%s">%s</a> </div>' % ( |
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
664 _('Show all combined changesets %s->%s') % ( |
2954
9282b4f38277
shorten the journal compare tooltip
Marcin Kuzminski <marcin@python-works.com>
parents:
2952
diff
changeset
|
665 revs_ids[0][:12], revs_ids[-1][:12] |
2012
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
666 ), |
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
667 url('changeset_home', repo_name=repo_name, |
3507
71fa9a198ac3
show correct values for compare view when multiple git tags are pushed
Marcin Kuzminski <marcin@python-works.com>
parents:
3415
diff
changeset
|
668 revision=_rev |
2012
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
669 ), |
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
670 _('compare view') |
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
671 ) |
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
672 ) |
1009
eafe5ae429ea
Added compare view into journal, fixed wrong function call to show compare view
Marcin Kuzminski <marcin@python-works.com>
parents:
999
diff
changeset
|
673 |
2012
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
674 # if we have exactly one more than normally displayed |
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
675 # just display it, takes less space than displaying |
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
676 # "and 1 more revisions" |
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
677 if len(revs_ids) == revs_limit + 1: |
1979 | 678 rev = revs[revs_limit] |
2012
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
679 cs_links.append(", " + lnk(rev, repo_name)) |
1979 | 680 |
681 # hidden-by-default ones | |
2012
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
682 if len(revs_ids) > revs_limit + 1: |
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
683 uniq_id = revs_ids[0] |
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
684 html_tmpl = ( |
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
685 '<span> %s <a class="show_more" id="_%s" ' |
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
686 'href="#more">%s</a> %s</span>' |
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
687 ) |
1087
51076a2a2b64
fixed unicode problems with file paths.
Marcin Kuzminski <marcin@python-works.com>
parents:
1055
diff
changeset
|
688 if not feed: |
2012
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
689 cs_links.append(html_tmpl % ( |
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
690 _('and'), |
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
691 uniq_id, _('%s more') % (len(revs_ids) - revs_limit), |
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
692 _('revisions') |
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
693 ) |
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
694 ) |
808
1af15d66838f
added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents:
790
diff
changeset
|
695 |
1087
51076a2a2b64
fixed unicode problems with file paths.
Marcin Kuzminski <marcin@python-works.com>
parents:
1055
diff
changeset
|
696 if not feed: |
1979 | 697 html_tmpl = '<span id="%s" style="display:none">, %s </span>' |
1087
51076a2a2b64
fixed unicode problems with file paths.
Marcin Kuzminski <marcin@python-works.com>
parents:
1055
diff
changeset
|
698 else: |
51076a2a2b64
fixed unicode problems with file paths.
Marcin Kuzminski <marcin@python-works.com>
parents:
1055
diff
changeset
|
699 html_tmpl = '<span id="%s"> %s </span>' |
51076a2a2b64
fixed unicode problems with file paths.
Marcin Kuzminski <marcin@python-works.com>
parents:
1055
diff
changeset
|
700 |
2012
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
701 morelinks = ', '.join( |
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
702 [lnk(rev, repo_name) for rev in revs[revs_limit:]] |
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
703 ) |
1979 | 704 |
2012
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
705 if len(revs_ids) > revs_top_limit: |
1979 | 706 morelinks += ', ...' |
707 | |
708 cs_links.append(html_tmpl % (uniq_id, morelinks)) | |
1024
22c147726ea6
hidden compare view link for single revision push
Marcin Kuzminski <marcin@python-works.com>
parents:
1022
diff
changeset
|
709 if len(revs) > 1: |
1359
54fc83f2192c
Removed all string concat for exchange of ''.join()
Marcin Kuzminski <marcin@python-works.com>
parents:
1356
diff
changeset
|
710 cs_links.append(compare_view) |
54fc83f2192c
Removed all string concat for exchange of ''.join()
Marcin Kuzminski <marcin@python-works.com>
parents:
1356
diff
changeset
|
711 return ''.join(cs_links) |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
718
diff
changeset
|
712 |
718
7df3855bf6c7
Added fork name to journal
Marcin Kuzminski <marcin@python-works.com>
parents:
714
diff
changeset
|
713 def get_fork_name(): |
953
def3578dac8c
fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents:
947
diff
changeset
|
714 repo_name = action_params |
2914
1cd1cbe6cdcc
formatting change on helper, remove str() call
Marcin Kuzminski <marcin@python-works.com>
parents:
2866
diff
changeset
|
715 _url = url('summary_home', repo_name=repo_name) |
1cd1cbe6cdcc
formatting change on helper, remove str() call
Marcin Kuzminski <marcin@python-works.com>
parents:
2866
diff
changeset
|
716 return _('fork name %s') % link_to(action_params, _url) |
953
def3578dac8c
fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents:
947
diff
changeset
|
717 |
2375
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2367
diff
changeset
|
718 def get_user_name(): |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2367
diff
changeset
|
719 user_name = action_params |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2367
diff
changeset
|
720 return user_name |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2367
diff
changeset
|
721 |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2367
diff
changeset
|
722 def get_users_group(): |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2367
diff
changeset
|
723 group_name = action_params |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2367
diff
changeset
|
724 return group_name |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2367
diff
changeset
|
725 |
2609
200a5b747e69
- added action when someone closes pull request in journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2532
diff
changeset
|
726 def get_pull_request(): |
200a5b747e69
- added action when someone closes pull request in journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2532
diff
changeset
|
727 pull_request_id = action_params |
3063
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
3012
diff
changeset
|
728 deleted = user_log.repository is None |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
3012
diff
changeset
|
729 if deleted: |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
3012
diff
changeset
|
730 repo_name = user_log.repository_name |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
3012
diff
changeset
|
731 else: |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
3012
diff
changeset
|
732 repo_name = user_log.repository.repo_name |
2609
200a5b747e69
- added action when someone closes pull request in journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2532
diff
changeset
|
733 return link_to(_('Pull request #%s') % pull_request_id, |
200a5b747e69
- added action when someone closes pull request in journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2532
diff
changeset
|
734 url('pullrequest_show', repo_name=repo_name, |
200a5b747e69
- added action when someone closes pull request in journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2532
diff
changeset
|
735 pull_request_id=pull_request_id)) |
200a5b747e69
- added action when someone closes pull request in journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2532
diff
changeset
|
736 |
3868
e262494ca099
store download archive actions in journal
Marcin Kuzminski <marcin@python-works.com>
parents:
3821
diff
changeset
|
737 def get_archive_name(): |
e262494ca099
store download archive actions in journal
Marcin Kuzminski <marcin@python-works.com>
parents:
3821
diff
changeset
|
738 archive_name = action_params |
e262494ca099
store download archive actions in journal
Marcin Kuzminski <marcin@python-works.com>
parents:
3821
diff
changeset
|
739 return archive_name |
e262494ca099
store download archive actions in journal
Marcin Kuzminski <marcin@python-works.com>
parents:
3821
diff
changeset
|
740 |
2375
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2367
diff
changeset
|
741 # action : translated str, callback(extractor), icon |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2367
diff
changeset
|
742 action_map = { |
2491
9fad28af93bd
fixed ico for pull request comment
Marcin Kuzminski <marcin@python-works.com>
parents:
2466
diff
changeset
|
743 'user_deleted_repo': (_('[deleted] repository'), |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
744 None, 'icon-trash'), |
2491
9fad28af93bd
fixed ico for pull request comment
Marcin Kuzminski <marcin@python-works.com>
parents:
2466
diff
changeset
|
745 'user_created_repo': (_('[created] repository'), |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
746 None, 'icon-plus icon-plus-colored'), |
2491
9fad28af93bd
fixed ico for pull request comment
Marcin Kuzminski <marcin@python-works.com>
parents:
2466
diff
changeset
|
747 'user_created_fork': (_('[created] repository as fork'), |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
748 None, 'icon-code-fork'), |
2491
9fad28af93bd
fixed ico for pull request comment
Marcin Kuzminski <marcin@python-works.com>
parents:
2466
diff
changeset
|
749 'user_forked_repo': (_('[forked] repository'), |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
750 get_fork_name, 'icon-code-fork'), |
2491
9fad28af93bd
fixed ico for pull request comment
Marcin Kuzminski <marcin@python-works.com>
parents:
2466
diff
changeset
|
751 'user_updated_repo': (_('[updated] repository'), |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
752 None, 'icon-pencil icon-pencil-colored'), |
3868
e262494ca099
store download archive actions in journal
Marcin Kuzminski <marcin@python-works.com>
parents:
3821
diff
changeset
|
753 'user_downloaded_archive': (_('[downloaded] archive from repository'), |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
754 get_archive_name, 'icon-download-alt'), |
2491
9fad28af93bd
fixed ico for pull request comment
Marcin Kuzminski <marcin@python-works.com>
parents:
2466
diff
changeset
|
755 'admin_deleted_repo': (_('[delete] repository'), |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
756 None, 'icon-trash'), |
2491
9fad28af93bd
fixed ico for pull request comment
Marcin Kuzminski <marcin@python-works.com>
parents:
2466
diff
changeset
|
757 'admin_created_repo': (_('[created] repository'), |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
758 None, 'icon-plus icon-plus-colored'), |
2491
9fad28af93bd
fixed ico for pull request comment
Marcin Kuzminski <marcin@python-works.com>
parents:
2466
diff
changeset
|
759 'admin_forked_repo': (_('[forked] repository'), |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
760 None, 'icon-code-fork icon-fork-colored'), |
2491
9fad28af93bd
fixed ico for pull request comment
Marcin Kuzminski <marcin@python-works.com>
parents:
2466
diff
changeset
|
761 'admin_updated_repo': (_('[updated] repository'), |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
762 None, 'icon-pencil icon-pencil-colored'), |
2491
9fad28af93bd
fixed ico for pull request comment
Marcin Kuzminski <marcin@python-works.com>
parents:
2466
diff
changeset
|
763 'admin_created_user': (_('[created] user'), |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
764 get_user_name, 'icon-user icon-user-colored'), |
2491
9fad28af93bd
fixed ico for pull request comment
Marcin Kuzminski <marcin@python-works.com>
parents:
2466
diff
changeset
|
765 'admin_updated_user': (_('[updated] user'), |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
766 get_user_name, 'icon-user icon-user-colored'), |
3415
b8f929bff7e3
fixed tests and missing replacements from 5f1850e4712a
Marcin Kuzminski <marcin@python-works.com>
parents:
3405
diff
changeset
|
767 'admin_created_users_group': (_('[created] user group'), |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
768 get_users_group, 'icon-pencil icon-pencil-colored'), |
3415
b8f929bff7e3
fixed tests and missing replacements from 5f1850e4712a
Marcin Kuzminski <marcin@python-works.com>
parents:
3405
diff
changeset
|
769 'admin_updated_users_group': (_('[updated] user group'), |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
770 get_users_group, 'icon-pencil icon-pencil-colored'), |
2491
9fad28af93bd
fixed ico for pull request comment
Marcin Kuzminski <marcin@python-works.com>
parents:
2466
diff
changeset
|
771 'user_commented_revision': (_('[commented] on revision in repository'), |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
772 get_cs_links, 'icon-comment icon-comment-colored'), |
2609
200a5b747e69
- added action when someone closes pull request in journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2532
diff
changeset
|
773 'user_commented_pull_request': (_('[commented] on pull request for'), |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
774 get_pull_request, 'icon-comment icon-comment-colored'), |
2609
200a5b747e69
- added action when someone closes pull request in journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2532
diff
changeset
|
775 'user_closed_pull_request': (_('[closed] pull request for'), |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
776 get_pull_request, 'icon-check'), |
2491
9fad28af93bd
fixed ico for pull request comment
Marcin Kuzminski <marcin@python-works.com>
parents:
2466
diff
changeset
|
777 'push': (_('[pushed] into'), |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
778 get_cs_links, 'icon-arrow-up'), |
2491
9fad28af93bd
fixed ico for pull request comment
Marcin Kuzminski <marcin@python-works.com>
parents:
2466
diff
changeset
|
779 'push_local': (_('[committed via RhodeCode] into repository'), |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
780 get_cs_links, 'icon-pencil icon-pencil-colored'), |
2491
9fad28af93bd
fixed ico for pull request comment
Marcin Kuzminski <marcin@python-works.com>
parents:
2466
diff
changeset
|
781 'push_remote': (_('[pulled from remote] into repository'), |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
782 get_cs_links, 'icon-arrow-up'), |
2491
9fad28af93bd
fixed ico for pull request comment
Marcin Kuzminski <marcin@python-works.com>
parents:
2466
diff
changeset
|
783 'pull': (_('[pulled] from'), |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
784 None, 'icon-arrow-down'), |
2491
9fad28af93bd
fixed ico for pull request comment
Marcin Kuzminski <marcin@python-works.com>
parents:
2466
diff
changeset
|
785 'started_following_repo': (_('[started following] repository'), |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
786 None, 'icon-heart icon-heart-colored'), |
2491
9fad28af93bd
fixed ico for pull request comment
Marcin Kuzminski <marcin@python-works.com>
parents:
2466
diff
changeset
|
787 'stopped_following_repo': (_('[stopped following] repository'), |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
788 None, 'icon-heart-empty icon-heart-colored'), |
2375
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2367
diff
changeset
|
789 } |
660
df61378032f3
#48 rewrote action logger, translated action logger messages, added some extra messages. Linked and showed pushed revisions in logs
Marcin Kuzminski <marcin@python-works.com>
parents:
653
diff
changeset
|
790 |
1087
51076a2a2b64
fixed unicode problems with file paths.
Marcin Kuzminski <marcin@python-works.com>
parents:
1055
diff
changeset
|
791 action_str = action_map.get(action, action) |
51076a2a2b64
fixed unicode problems with file paths.
Marcin Kuzminski <marcin@python-works.com>
parents:
1055
diff
changeset
|
792 if feed: |
51076a2a2b64
fixed unicode problems with file paths.
Marcin Kuzminski <marcin@python-works.com>
parents:
1055
diff
changeset
|
793 action = action_str[0].replace('[', '').replace(']', '') |
51076a2a2b64
fixed unicode problems with file paths.
Marcin Kuzminski <marcin@python-works.com>
parents:
1055
diff
changeset
|
794 else: |
2012
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
795 action = action_str[0]\ |
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
796 .replace('[', '<span class="journal_highlight">')\ |
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
797 .replace(']', '</span>') |
1114
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1105
diff
changeset
|
798 |
2012
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
799 action_params_func = lambda: "" |
1052
c96651aebd8a
fixed journal look & feel
Marcin Kuzminski <marcin@python-works.com>
parents:
1050
diff
changeset
|
800 |
1114
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1105
diff
changeset
|
801 if callable(action_str[1]): |
1052
c96651aebd8a
fixed journal look & feel
Marcin Kuzminski <marcin@python-works.com>
parents:
1050
diff
changeset
|
802 action_params_func = action_str[1] |
953
def3578dac8c
fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents:
947
diff
changeset
|
803 |
2375
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2367
diff
changeset
|
804 def action_parser_icon(): |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2367
diff
changeset
|
805 action = user_log.action |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2367
diff
changeset
|
806 action_params = None |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2367
diff
changeset
|
807 x = action.split(':') |
1959
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
808 |
2375
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2367
diff
changeset
|
809 if len(x) > 1: |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2367
diff
changeset
|
810 action, action_params = x |
808
1af15d66838f
added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents:
790
diff
changeset
|
811 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
812 tmpl = """<i class="%s" alt="%s"></i>""" |
2375
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2367
diff
changeset
|
813 ico = action_map.get(action, ['', '', ''])[2] |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
814 return literal(tmpl % (ico, action)) |
2375
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2367
diff
changeset
|
815 |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2367
diff
changeset
|
816 # returned callbacks we need to call to get |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2367
diff
changeset
|
817 return [lambda: literal(action), action_params_func, action_parser_icon] |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2367
diff
changeset
|
818 |
660
df61378032f3
#48 rewrote action logger, translated action logger messages, added some extra messages. Linked and showed pushed revisions in logs
Marcin Kuzminski <marcin@python-works.com>
parents:
653
diff
changeset
|
819 |
df61378032f3
#48 rewrote action logger, translated action logger messages, added some extra messages. Linked and showed pushed revisions in logs
Marcin Kuzminski <marcin@python-works.com>
parents:
653
diff
changeset
|
820 |
635
fd63782c4426
Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents:
631
diff
changeset
|
821 #============================================================================== |
307
504feff57b49
added permission functions to webhelpers, updated dbmanage permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
293
diff
changeset
|
822 # PERMS |
635
fd63782c4426
Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents:
631
diff
changeset
|
823 #============================================================================== |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
824 from rhodecode.lib.auth import HasPermissionAny, HasPermissionAll, \ |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
825 HasRepoPermissionAny, HasRepoPermissionAll, HasRepoGroupPermissionAll, \ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
826 HasRepoGroupPermissionAny |
282
237470e64bb8
switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents:
281
diff
changeset
|
827 |
1959
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
828 |
635
fd63782c4426
Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents:
631
diff
changeset
|
829 #============================================================================== |
398
8c50b164fb58
Implemented basic gravatar support on admin pages only for now
Marcin Kuzminski <marcin@python-works.com>
parents:
307
diff
changeset
|
830 # GRAVATAR URL |
635
fd63782c4426
Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents:
631
diff
changeset
|
831 #============================================================================== |
282
237470e64bb8
switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents:
281
diff
changeset
|
832 |
3905
f7bf0cebe391
Switch gravatar to always use ssl.
Marcin Kuzminski <marcin@python-works.com>
parents:
3890
diff
changeset
|
833 def gravatar_url(email_address, size=30, ssl_enabled=True): |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
834 # doh, we need to re-import those to mock it later |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
835 from pylons import url |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
836 from pylons import tmpl_context as c |
3905
f7bf0cebe391
Switch gravatar to always use ssl.
Marcin Kuzminski <marcin@python-works.com>
parents:
3890
diff
changeset
|
837 |
f7bf0cebe391
Switch gravatar to always use ssl.
Marcin Kuzminski <marcin@python-works.com>
parents:
3890
diff
changeset
|
838 _def = 'anonymous@rhodecode.org' # default gravatar |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
839 _use_gravatar = c.visual.use_gravatar |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
840 _gravatar_url = c.visual.gravatar_url or User.DEFAULT_GRAVATAR_URL |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
841 |
3367
e6c551663a54
#763 gravatar helper function should fallback into default image if somehow email provided is empty.
Marcin Kuzminski <marcin@python-works.com>
parents:
3222
diff
changeset
|
842 email_address = email_address or _def |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
843 if isinstance(email_address, unicode): |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
844 #hashlib crashes on unicode items |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
845 email_address = safe_str(email_address) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
846 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
847 if not _use_gravatar or not email_address or email_address == _def: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
848 # pick best matching size to one given in size param |
3080
39bbe5d31a54
fixes issue #674, alternative gravatar url had an error when there was no valid email in commit data
Marcin Kuzminski <marcin@python-works.com>
parents:
3070
diff
changeset
|
849 f = lambda a, l: min(l, key=lambda x: abs(x - a)) |
39bbe5d31a54
fixes issue #674, alternative gravatar url had an error when there was no valid email in commit data
Marcin Kuzminski <marcin@python-works.com>
parents:
3070
diff
changeset
|
850 return url("/images/user%s.png" % f(size, [14, 16, 20, 24, 30])) |
39bbe5d31a54
fixes issue #674, alternative gravatar url had an error when there was no valid email in commit data
Marcin Kuzminski <marcin@python-works.com>
parents:
3070
diff
changeset
|
851 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
852 if _use_gravatar: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
853 _md5 = lambda s: hashlib.md5(s).hexdigest() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
854 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
855 tmpl = _gravatar_url |
2836
819eb7f8a555
Implemented patch from andrewsh ref #565 Add support for {netloc} and {scheme}
Marcin Kuzminski <marcin@python-works.com>
parents:
2751
diff
changeset
|
856 parsed_url = urlparse.urlparse(url.current(qualified=True)) |
2751
e291f25ea87f
fixes issue #543, un-broken alternative gravatar option
Marcin Kuzminski <marcin@python-works.com>
parents:
2735
diff
changeset
|
857 tmpl = tmpl.replace('{email}', email_address)\ |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
858 .replace('{md5email}', _md5(email_address.lower())) \ |
2836
819eb7f8a555
Implemented patch from andrewsh ref #565 Add support for {netloc} and {scheme}
Marcin Kuzminski <marcin@python-works.com>
parents:
2751
diff
changeset
|
859 .replace('{netloc}', parsed_url.netloc)\ |
819eb7f8a555
Implemented patch from andrewsh ref #565 Add support for {netloc} and {scheme}
Marcin Kuzminski <marcin@python-works.com>
parents:
2751
diff
changeset
|
860 .replace('{scheme}', parsed_url.scheme)\ |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
861 .replace('{size}', safe_str(size)) |
2751
e291f25ea87f
fixes issue #543, un-broken alternative gravatar option
Marcin Kuzminski <marcin@python-works.com>
parents:
2735
diff
changeset
|
862 return tmpl |
e291f25ea87f
fixes issue #543, un-broken alternative gravatar option
Marcin Kuzminski <marcin@python-works.com>
parents:
2735
diff
changeset
|
863 |
3776
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
864 class Page(_Page): |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
865 """ |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
866 Custom pager to match rendering style with YUI paginator |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
867 """ |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
868 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
869 def _get_pos(self, cur_page, max_page, items): |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
870 edge = (items / 2) + 1 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
871 if (cur_page <= edge): |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
872 radius = max(items / 2, items - cur_page) |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
873 elif (max_page - cur_page) < edge: |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
874 radius = (items - 1) - (max_page - cur_page) |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
875 else: |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
876 radius = items / 2 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
877 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
878 left = max(1, (cur_page - (radius))) |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
879 right = min(max_page, cur_page + (radius)) |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
880 return left, cur_page, right |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
881 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
882 def _range(self, regexp_match): |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
883 """ |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
884 Return range of linked pages (e.g. '1 2 [3] 4 5 6 7 8'). |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
885 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
886 Arguments: |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
887 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
888 regexp_match |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
889 A "re" (regular expressions) match object containing the |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
890 radius of linked pages around the current page in |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
891 regexp_match.group(1) as a string |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
892 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
893 This function is supposed to be called as a callable in |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
894 re.sub. |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
895 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
896 """ |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
897 radius = int(regexp_match.group(1)) |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
898 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
899 # Compute the first and last page number within the radius |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
900 # e.g. '1 .. 5 6 [7] 8 9 .. 12' |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
901 # -> leftmost_page = 5 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
902 # -> rightmost_page = 9 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
903 leftmost_page, _cur, rightmost_page = self._get_pos(self.page, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
904 self.last_page, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
905 (radius * 2) + 1) |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
906 nav_items = [] |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
907 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
908 # Create a link to the first page (unless we are on the first page |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
909 # or there would be no need to insert '..' spacers) |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
910 if self.page != self.first_page and self.first_page < leftmost_page: |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
911 nav_items.append(self._pagerlink(self.first_page, self.first_page)) |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
912 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
913 # Insert dots if there are pages between the first page |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
914 # and the currently displayed page range |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
915 if leftmost_page - self.first_page > 1: |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
916 # Wrap in a SPAN tag if nolink_attr is set |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
917 text = '..' |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
918 if self.dotdot_attr: |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
919 text = HTML.span(c=text, **self.dotdot_attr) |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
920 nav_items.append(text) |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
921 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
922 for thispage in xrange(leftmost_page, rightmost_page + 1): |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
923 # Hilight the current page number and do not use a link |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
924 if thispage == self.page: |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
925 text = '%s' % (thispage,) |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
926 # Wrap in a SPAN tag if nolink_attr is set |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
927 if self.curpage_attr: |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
928 text = HTML.span(c=text, **self.curpage_attr) |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
929 nav_items.append(text) |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
930 # Otherwise create just a link to that page |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
931 else: |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
932 text = '%s' % (thispage,) |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
933 nav_items.append(self._pagerlink(thispage, text)) |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
934 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
935 # Insert dots if there are pages between the displayed |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
936 # page numbers and the end of the page range |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
937 if self.last_page - rightmost_page > 1: |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
938 text = '..' |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
939 # Wrap in a SPAN tag if nolink_attr is set |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
940 if self.dotdot_attr: |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
941 text = HTML.span(c=text, **self.dotdot_attr) |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
942 nav_items.append(text) |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
943 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
944 # Create a link to the very last page (unless we are on the last |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
945 # page or there would be no need to insert '..' spacers) |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
946 if self.page != self.last_page and rightmost_page < self.last_page: |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
947 nav_items.append(self._pagerlink(self.last_page, self.last_page)) |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
948 |
3915
a42bfe8a9335
moved make-index command to paster_commands module
Marcin Kuzminski <marcin@python-works.com>
parents:
3905
diff
changeset
|
949 ## prerender links |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
950 #_page_link = url.current() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
951 #nav_items.append(literal('<link rel="prerender" href="%s?page=%s">' % (_page_link, str(int(self.page)+1)))) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4043
diff
changeset
|
952 #nav_items.append(literal('<link rel="prefetch" href="%s?page=%s">' % (_page_link, str(int(self.page)+1)))) |
3776
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
953 return self.separator.join(nav_items) |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
954 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
955 def pager(self, format='~2~', page_param='page', partial_param='partial', |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
956 show_if_single_page=False, separator=' ', onclick=None, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
957 symbol_first='<<', symbol_last='>>', |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
958 symbol_previous='<', symbol_next='>', |
3915
a42bfe8a9335
moved make-index command to paster_commands module
Marcin Kuzminski <marcin@python-works.com>
parents:
3905
diff
changeset
|
959 link_attr={'class': 'pager_link', 'rel': 'prerender'}, |
3776
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
960 curpage_attr={'class': 'pager_curpage'}, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
961 dotdot_attr={'class': 'pager_dotdot'}, **kwargs): |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
962 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
963 self.curpage_attr = curpage_attr |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
964 self.separator = separator |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
965 self.pager_kwargs = kwargs |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
966 self.page_param = page_param |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
967 self.partial_param = partial_param |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
968 self.onclick = onclick |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
969 self.link_attr = link_attr |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
970 self.dotdot_attr = dotdot_attr |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
971 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
972 # Don't show navigator if there is no more than one page |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
973 if self.page_count == 0 or (self.page_count == 1 and not show_if_single_page): |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
974 return '' |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
975 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
976 from string import Template |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
977 # Replace ~...~ in token format by range of pages |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
978 result = re.sub(r'~(\d+)~', self._range, format) |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
979 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
980 # Interpolate '%' variables |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
981 result = Template(result).safe_substitute({ |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
982 'first_page': self.first_page, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
983 'last_page': self.last_page, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
984 'page': self.page, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
985 'page_count': self.page_count, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
986 'items_per_page': self.items_per_page, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
987 'first_item': self.first_item, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
988 'last_item': self.last_item, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
989 'item_count': self.item_count, |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
990 'link_first': self.page > self.first_page and \ |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
991 self._pagerlink(self.first_page, symbol_first) or '', |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
992 'link_last': self.page < self.last_page and \ |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
993 self._pagerlink(self.last_page, symbol_last) or '', |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
994 'link_previous': self.previous_page and \ |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
995 self._pagerlink(self.previous_page, symbol_previous) \ |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
996 or HTML.span(symbol_previous, class_="yui-pg-previous"), |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
997 'link_next': self.next_page and \ |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
998 self._pagerlink(self.next_page, symbol_next) \ |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
999 or HTML.span(symbol_next, class_="yui-pg-next") |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
1000 }) |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
1001 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
1002 return literal(result) |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
1003 |
13241a4075e9
Unified the paginators for pylons and YUI.
Marcin Kuzminski <marcin@python-works.com>
parents:
3766
diff
changeset
|
1004 |
1098
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1005 #============================================================================== |
1342
9dacacc5b7c2
When creating a remote repository, with credentials filled, it's good to hide username and password from the clone url. Only administrators can see this in repository settings page
Marcin Kuzminski <marcin@python-works.com>
parents:
1330
diff
changeset
|
1006 # REPO PAGER, PAGER FOR REPOSITORY |
1098
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1007 #============================================================================== |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1008 class RepoPage(Page): |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1009 |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1010 def __init__(self, collection, page=1, items_per_page=20, |
1656
833f9dec0a06
implemented #44 - branch filtering in changelog, aka branch browser
Marcin Kuzminski <marcin@python-works.com>
parents:
1629
diff
changeset
|
1011 item_count=None, url=None, **kwargs): |
1098
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1012 |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1013 """Create a "RepoPage" instance. special pager for paging |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1014 repository |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1015 """ |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1016 self._url_generator = url |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1017 |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1018 # Safe the kwargs class-wide so they can be used in the pager() method |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1019 self.kwargs = kwargs |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1020 |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1021 # Save a reference to the collection |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1022 self.original_collection = collection |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1023 |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1024 self.collection = collection |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1025 |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1026 # The self.page is the number of the current page. |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1027 # The first page has the number 1! |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1028 try: |
2012
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
1029 self.page = int(page) # make it int() if we get it as a string |
1098
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1030 except (ValueError, TypeError): |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1031 self.page = 1 |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1032 |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1033 self.items_per_page = items_per_page |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1034 |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1035 # Unless the user tells us how many items the collections has |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1036 # we calculate that ourselves. |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1037 if item_count is not None: |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1038 self.item_count = item_count |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1039 else: |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1040 self.item_count = len(self.collection) |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1041 |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1042 # Compute the number of the first and last available page |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1043 if self.item_count > 0: |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1044 self.first_page = 1 |
1422
e69da281e235
fixed issues with repo pager
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
1045 self.page_count = int(math.ceil(float(self.item_count) / |
e69da281e235
fixed issues with repo pager
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
1046 self.items_per_page)) |
1098
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1047 self.last_page = self.first_page + self.page_count - 1 |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1048 |
1818
cf51bbfb120e
auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents:
1789
diff
changeset
|
1049 # Make sure that the requested page number is the range of |
1766 | 1050 # valid pages |
1098
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1051 if self.page > self.last_page: |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1052 self.page = self.last_page |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1053 elif self.page < self.first_page: |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1054 self.page = self.first_page |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1055 |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1056 # Note: the number of items on this page can be less than |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1057 # items_per_page if the last page is not full |
1422
e69da281e235
fixed issues with repo pager
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
1058 self.first_item = max(0, (self.item_count) - (self.page * |
e69da281e235
fixed issues with repo pager
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
1059 items_per_page)) |
e69da281e235
fixed issues with repo pager
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
1060 self.last_item = ((self.item_count - 1) - items_per_page * |
e69da281e235
fixed issues with repo pager
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
1061 (self.page - 1)) |
1098
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1062 |
1670
d2de0c2f02cd
#77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
1656
diff
changeset
|
1063 self.items = list(self.collection[self.first_item:self.last_item + 1]) |
1656
833f9dec0a06
implemented #44 - branch filtering in changelog, aka branch browser
Marcin Kuzminski <marcin@python-works.com>
parents:
1629
diff
changeset
|
1064 |
1098
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1065 # Links to previous and next page |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1066 if self.page > self.first_page: |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1067 self.previous_page = self.page - 1 |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1068 else: |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1069 self.previous_page = None |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1070 |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1071 if self.page < self.last_page: |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1072 self.next_page = self.page + 1 |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1073 else: |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1074 self.next_page = None |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1075 |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1076 # No items available |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1077 else: |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1078 self.first_page = None |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1079 self.page_count = 0 |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1080 self.last_page = None |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1081 self.first_item = None |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1082 self.last_item = None |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1083 self.previous_page = None |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1084 self.next_page = None |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1085 self.items = [] |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1086 |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1087 # This is a subclass of the 'list' type. Initialise the list now. |
1656
833f9dec0a06
implemented #44 - branch filtering in changelog, aka branch browser
Marcin Kuzminski <marcin@python-works.com>
parents:
1629
diff
changeset
|
1088 list.__init__(self, reversed(self.items)) |
1098
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1089 |
91ddd4db4614
Added dedicated repo pager to support reversed new way slicing method of vcs and get_changesets method
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
1090 |
990
7a1df0130533
moved tooltip function from the for loop and from templates to helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
966
diff
changeset
|
1091 def changed_tooltip(nodes): |
1342
9dacacc5b7c2
When creating a remote repository, with credentials filled, it's good to hide username and password from the clone url. Only administrators can see this in repository settings page
Marcin Kuzminski <marcin@python-works.com>
parents:
1330
diff
changeset
|
1092 """ |
9dacacc5b7c2
When creating a remote repository, with credentials filled, it's good to hide username and password from the clone url. Only administrators can see this in repository settings page
Marcin Kuzminski <marcin@python-works.com>
parents:
1330
diff
changeset
|
1093 Generates a html string for changed nodes in changeset page. |
9dacacc5b7c2
When creating a remote repository, with credentials filled, it's good to hide username and password from the clone url. Only administrators can see this in repository settings page
Marcin Kuzminski <marcin@python-works.com>
parents:
1330
diff
changeset
|
1094 It limits the output to 30 entries |
1818
cf51bbfb120e
auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents:
1789
diff
changeset
|
1095 |
1342
9dacacc5b7c2
When creating a remote repository, with credentials filled, it's good to hide username and password from the clone url. Only administrators can see this in repository settings page
Marcin Kuzminski <marcin@python-works.com>
parents:
1330
diff
changeset
|
1096 :param nodes: LazyNodesGenerator |
9dacacc5b7c2
When creating a remote repository, with credentials filled, it's good to hide username and password from the clone url. Only administrators can see this in repository settings page
Marcin Kuzminski <marcin@python-works.com>
parents:
1330
diff
changeset
|
1097 """ |
990
7a1df0130533
moved tooltip function from the for loop and from templates to helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
966
diff
changeset
|
1098 if nodes: |
7a1df0130533
moved tooltip function from the for loop and from templates to helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
966
diff
changeset
|
1099 pref = ': <br/> ' |
7a1df0130533
moved tooltip function from the for loop and from templates to helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
966
diff
changeset
|
1100 suf = '' |
7a1df0130533
moved tooltip function from the for loop and from templates to helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
966
diff
changeset
|
1101 if len(nodes) > 30: |
7a1df0130533
moved tooltip function from the for loop and from templates to helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
966
diff
changeset
|
1102 suf = '<br/>' + _(' and %s more') % (len(nodes) - 30) |
1257
0a2a10a1912f
Implemented --stat for changelog
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
1103 return literal(pref + '<br/> '.join([safe_unicode(x.path) |
0a2a10a1912f
Implemented --stat for changelog
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
1104 for x in nodes[:30]]) + suf) |
990
7a1df0130533
moved tooltip function from the for loop and from templates to helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
966
diff
changeset
|
1105 else: |
7a1df0130533
moved tooltip function from the for loop and from templates to helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
966
diff
changeset
|
1106 return ': ' + _('No Files') |
1159
187a924ed653
Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1154
diff
changeset
|
1107 |
187a924ed653
Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1154
diff
changeset
|
1108 |
3599
8087731920d8
breadcrumbs: make repo names link to summary pages
Mads Kiilerich <madski@unity3d.com>
parents:
3588
diff
changeset
|
1109 def repo_link(groups_and_repos): |
1342
9dacacc5b7c2
When creating a remote repository, with credentials filled, it's good to hide username and password from the clone url. Only administrators can see this in repository settings page
Marcin Kuzminski <marcin@python-works.com>
parents:
1330
diff
changeset
|
1110 """ |
9dacacc5b7c2
When creating a remote repository, with credentials filled, it's good to hide username and password from the clone url. Only administrators can see this in repository settings page
Marcin Kuzminski <marcin@python-works.com>
parents:
1330
diff
changeset
|
1111 Makes a breadcrumbs link to repo within a group |
9dacacc5b7c2
When creating a remote repository, with credentials filled, it's good to hide username and password from the clone url. Only administrators can see this in repository settings page
Marcin Kuzminski <marcin@python-works.com>
parents:
1330
diff
changeset
|
1112 joins » on each group to create a fancy link |
1818
cf51bbfb120e
auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents:
1789
diff
changeset
|
1113 |
1342
9dacacc5b7c2
When creating a remote repository, with credentials filled, it's good to hide username and password from the clone url. Only administrators can see this in repository settings page
Marcin Kuzminski <marcin@python-works.com>
parents:
1330
diff
changeset
|
1114 ex:: |
9dacacc5b7c2
When creating a remote repository, with credentials filled, it's good to hide username and password from the clone url. Only administrators can see this in repository settings page
Marcin Kuzminski <marcin@python-works.com>
parents:
1330
diff
changeset
|
1115 group >> subgroup >> repo |
1818
cf51bbfb120e
auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents:
1789
diff
changeset
|
1116 |
1342
9dacacc5b7c2
When creating a remote repository, with credentials filled, it's good to hide username and password from the clone url. Only administrators can see this in repository settings page
Marcin Kuzminski <marcin@python-works.com>
parents:
1330
diff
changeset
|
1117 :param groups_and_repos: |
3012
58f3bba0ddc1
extend helper for better breadcrumbs for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents:
2998
diff
changeset
|
1118 :param last_url: |
1342
9dacacc5b7c2
When creating a remote repository, with credentials filled, it's good to hide username and password from the clone url. Only administrators can see this in repository settings page
Marcin Kuzminski <marcin@python-works.com>
parents:
1330
diff
changeset
|
1119 """ |
3599
8087731920d8
breadcrumbs: make repo names link to summary pages
Mads Kiilerich <madski@unity3d.com>
parents:
3588
diff
changeset
|
1120 groups, just_name, repo_name = groups_and_repos |
8087731920d8
breadcrumbs: make repo names link to summary pages
Mads Kiilerich <madski@unity3d.com>
parents:
3588
diff
changeset
|
1121 last_url = url('summary_home', repo_name=repo_name) |
8087731920d8
breadcrumbs: make repo names link to summary pages
Mads Kiilerich <madski@unity3d.com>
parents:
3588
diff
changeset
|
1122 last_link = link_to(just_name, last_url) |
1159
187a924ed653
Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1154
diff
changeset
|
1123 |
3599
8087731920d8
breadcrumbs: make repo names link to summary pages
Mads Kiilerich <madski@unity3d.com>
parents:
3588
diff
changeset
|
1124 def make_link(group): |
8087731920d8
breadcrumbs: make repo names link to summary pages
Mads Kiilerich <madski@unity3d.com>
parents:
3588
diff
changeset
|
1125 return link_to(group.name, |
8087731920d8
breadcrumbs: make repo names link to summary pages
Mads Kiilerich <madski@unity3d.com>
parents:
3588
diff
changeset
|
1126 url('repos_group_home', group_name=group.group_name)) |
8087731920d8
breadcrumbs: make repo names link to summary pages
Mads Kiilerich <madski@unity3d.com>
parents:
3588
diff
changeset
|
1127 return literal(' » '.join(map(make_link, groups) + ['<span>%s</span>' % last_link])) |
1257
0a2a10a1912f
Implemented --stat for changelog
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
1128 |
1959
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
1129 |
1257
0a2a10a1912f
Implemented --stat for changelog
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
1130 def fancy_file_stats(stats): |
1342
9dacacc5b7c2
When creating a remote repository, with credentials filled, it's good to hide username and password from the clone url. Only administrators can see this in repository settings page
Marcin Kuzminski <marcin@python-works.com>
parents:
1330
diff
changeset
|
1131 """ |
9dacacc5b7c2
When creating a remote repository, with credentials filled, it's good to hide username and password from the clone url. Only administrators can see this in repository settings page
Marcin Kuzminski <marcin@python-works.com>
parents:
1330
diff
changeset
|
1132 Displays a fancy two colored bar for number of added/deleted |
9dacacc5b7c2
When creating a remote repository, with credentials filled, it's good to hide username and password from the clone url. Only administrators can see this in repository settings page
Marcin Kuzminski <marcin@python-works.com>
parents:
1330
diff
changeset
|
1133 lines of code on file |
1818
cf51bbfb120e
auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents:
1789
diff
changeset
|
1134 |
1342
9dacacc5b7c2
When creating a remote repository, with credentials filled, it's good to hide username and password from the clone url. Only administrators can see this in repository settings page
Marcin Kuzminski <marcin@python-works.com>
parents:
1330
diff
changeset
|
1135 :param stats: two element list of added/deleted lines of code |
9dacacc5b7c2
When creating a remote repository, with credentials filled, it's good to hide username and password from the clone url. Only administrators can see this in repository settings page
Marcin Kuzminski <marcin@python-works.com>
parents:
1330
diff
changeset
|
1136 """ |
3821
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1137 from rhodecode.lib.diffs import NEW_FILENODE, DEL_FILENODE, \ |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1138 MOD_FILENODE, RENAMED_FILENODE, CHMOD_FILENODE, BIN_FILENODE |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1139 |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2971
diff
changeset
|
1140 def cgen(l_type, a_v, d_v): |
2118 | 1141 mapping = {'tr': 'top-right-rounded-corner-mid', |
1142 'tl': 'top-left-rounded-corner-mid', | |
1143 'br': 'bottom-right-rounded-corner-mid', | |
1144 'bl': 'bottom-left-rounded-corner-mid'} | |
1959
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
1145 map_getter = lambda x: mapping[x] |
1257
0a2a10a1912f
Implemented --stat for changelog
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
1146 |
0a2a10a1912f
Implemented --stat for changelog
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
1147 if l_type == 'a' and d_v: |
0a2a10a1912f
Implemented --stat for changelog
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
1148 #case when added and deleted are present |
0a2a10a1912f
Implemented --stat for changelog
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
1149 return ' '.join(map(map_getter, ['tl', 'bl'])) |
0a2a10a1912f
Implemented --stat for changelog
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
1150 |
0a2a10a1912f
Implemented --stat for changelog
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
1151 if l_type == 'a' and not d_v: |
0a2a10a1912f
Implemented --stat for changelog
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
1152 return ' '.join(map(map_getter, ['tr', 'br', 'tl', 'bl'])) |
0a2a10a1912f
Implemented --stat for changelog
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
1153 |
0a2a10a1912f
Implemented --stat for changelog
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
1154 if l_type == 'd' and a_v: |
0a2a10a1912f
Implemented --stat for changelog
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
1155 return ' '.join(map(map_getter, ['tr', 'br'])) |
0a2a10a1912f
Implemented --stat for changelog
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
1156 |
0a2a10a1912f
Implemented --stat for changelog
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
1157 if l_type == 'd' and not a_v: |
0a2a10a1912f
Implemented --stat for changelog
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
1158 return ' '.join(map(map_getter, ['tr', 'br', 'tl', 'bl'])) |
0a2a10a1912f
Implemented --stat for changelog
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
1159 |
3821
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1160 a, d = stats['added'], stats['deleted'] |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2971
diff
changeset
|
1161 width = 100 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2971
diff
changeset
|
1162 |
3821
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1163 if stats['binary']: |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2971
diff
changeset
|
1164 #binary mode |
3821
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1165 lbl = '' |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1166 bin_op = 1 |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1167 |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1168 if BIN_FILENODE in stats['ops']: |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1169 lbl = 'bin+' |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1170 |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1171 if NEW_FILENODE in stats['ops']: |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1172 lbl += _('new file') |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1173 bin_op = NEW_FILENODE |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1174 elif MOD_FILENODE in stats['ops']: |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1175 lbl += _('mod') |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1176 bin_op = MOD_FILENODE |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1177 elif DEL_FILENODE in stats['ops']: |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1178 lbl += _('del') |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1179 bin_op = DEL_FILENODE |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1180 elif RENAMED_FILENODE in stats['ops']: |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1181 lbl += _('rename') |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1182 bin_op = RENAMED_FILENODE |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1183 |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1184 #chmod can go with other operations |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1185 if CHMOD_FILENODE in stats['ops']: |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1186 _org_lbl = _('chmod') |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1187 lbl += _org_lbl if lbl.endswith('+') else '+%s' % _org_lbl |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1188 |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1189 #import ipdb;ipdb.set_trace() |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1190 b_d = '<div class="bin bin%s %s" style="width:100%%">%s</div>' % (bin_op, cgen('a', a_v='', d_v=0), lbl) |
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1191 b_a = '<div class="bin bin1" style="width:0%%"></div>' |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2971
diff
changeset
|
1192 return literal('<div style="width:%spx">%s%s</div>' % (width, b_a, b_d)) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2971
diff
changeset
|
1193 |
3821
ce4b7023a492
diff parser: redefined operations stats for changes
Marcin Kuzminski <marcin@python-works.com>
parents:
3776
diff
changeset
|
1194 t = stats['added'] + stats['deleted'] |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2971
diff
changeset
|
1195 unit = float(width) / (t or 1) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2971
diff
changeset
|
1196 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2971
diff
changeset
|
1197 # needs > 9% of width to be visible or 0 to be hidden |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2971
diff
changeset
|
1198 a_p = max(9, unit * a) if a > 0 else 0 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2971
diff
changeset
|
1199 d_p = max(9, unit * d) if d > 0 else 0 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2971
diff
changeset
|
1200 p_sum = a_p + d_p |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2971
diff
changeset
|
1201 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2971
diff
changeset
|
1202 if p_sum > width: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2971
diff
changeset
|
1203 #adjust the percentage to be == 100% since we adjusted to 9 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2971
diff
changeset
|
1204 if a_p > d_p: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2971
diff
changeset
|
1205 a_p = a_p - (p_sum - width) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2971
diff
changeset
|
1206 else: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2971
diff
changeset
|
1207 d_p = d_p - (p_sum - width) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2971
diff
changeset
|
1208 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2971
diff
changeset
|
1209 a_v = a if a > 0 else '' |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2971
diff
changeset
|
1210 d_v = d if d > 0 else '' |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2971
diff
changeset
|
1211 |
1959
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
1212 d_a = '<div class="added %s" style="width:%s%%">%s</div>' % ( |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2971
diff
changeset
|
1213 cgen('a', a_v, d_v), a_p, a_v |
1959
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
1214 ) |
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
1215 d_d = '<div class="deleted %s" style="width:%s%%">%s</div>' % ( |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2971
diff
changeset
|
1216 cgen('d', a_v, d_v), d_p, d_v |
1959
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
1217 ) |
1257
0a2a10a1912f
Implemented --stat for changelog
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
1218 return literal('<div style="width:%spx">%s%s</div>' % (width, d_a, d_d)) |
1438
002f4f465b58
Links in summary page are now active
Marcin Kuzminski <marcin@python-works.com>
parents:
1422
diff
changeset
|
1219 |
002f4f465b58
Links in summary page are now active
Marcin Kuzminski <marcin@python-works.com>
parents:
1422
diff
changeset
|
1220 |
3399
5ff79fad209c
don't use double literal() calls on urlify functions
Marcin Kuzminski <marcin@python-works.com>
parents:
3398
diff
changeset
|
1221 def urlify_text(text_, safe=True): |
3398
1ca82b6a6349
urlify commit function also should extract normal links
Marcin Kuzminski <marcin@python-works.com>
parents:
3385
diff
changeset
|
1222 """ |
1ca82b6a6349
urlify commit function also should extract normal links
Marcin Kuzminski <marcin@python-works.com>
parents:
3385
diff
changeset
|
1223 Extrac urls from text and make html links out of them |
1ca82b6a6349
urlify commit function also should extract normal links
Marcin Kuzminski <marcin@python-works.com>
parents:
3385
diff
changeset
|
1224 |
1ca82b6a6349
urlify commit function also should extract normal links
Marcin Kuzminski <marcin@python-works.com>
parents:
3385
diff
changeset
|
1225 :param text_: |
1ca82b6a6349
urlify commit function also should extract normal links
Marcin Kuzminski <marcin@python-works.com>
parents:
3385
diff
changeset
|
1226 """ |
1438
002f4f465b58
Links in summary page are now active
Marcin Kuzminski <marcin@python-works.com>
parents:
1422
diff
changeset
|
1227 |
1766 | 1228 url_pat = re.compile(r'''(http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]''' |
1229 '''|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+)''') | |
1438
002f4f465b58
Links in summary page are now active
Marcin Kuzminski <marcin@python-works.com>
parents:
1422
diff
changeset
|
1230 |
002f4f465b58
Links in summary page are now active
Marcin Kuzminski <marcin@python-works.com>
parents:
1422
diff
changeset
|
1231 def url_func(match_obj): |
002f4f465b58
Links in summary page are now active
Marcin Kuzminski <marcin@python-works.com>
parents:
1422
diff
changeset
|
1232 url_full = match_obj.groups()[0] |
1868
f26acc1b27e2
added repository name into issue tracker link to support different projects issues tracker mapping
Marcin Kuzminski <marcin@python-works.com>
parents:
1865
diff
changeset
|
1233 return '<a href="%(url)s">%(url)s</a>' % ({'url': url_full}) |
3399
5ff79fad209c
don't use double literal() calls on urlify functions
Marcin Kuzminski <marcin@python-works.com>
parents:
3398
diff
changeset
|
1234 _newtext = url_pat.sub(url_func, text_) |
5ff79fad209c
don't use double literal() calls on urlify functions
Marcin Kuzminski <marcin@python-works.com>
parents:
3398
diff
changeset
|
1235 if safe: |
5ff79fad209c
don't use double literal() calls on urlify functions
Marcin Kuzminski <marcin@python-works.com>
parents:
3398
diff
changeset
|
1236 return literal(_newtext) |
5ff79fad209c
don't use double literal() calls on urlify functions
Marcin Kuzminski <marcin@python-works.com>
parents:
3398
diff
changeset
|
1237 return _newtext |
1656
833f9dec0a06
implemented #44 - branch filtering in changelog, aka branch browser
Marcin Kuzminski <marcin@python-works.com>
parents:
1629
diff
changeset
|
1238 |
1959
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
1239 |
1913
08344d037ba1
added links to revisions in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1912
diff
changeset
|
1240 def urlify_changesets(text_, repository): |
2111
122f15a8f6ec
fixed issue with escaping < and > in changeset commits
Marcin Kuzminski <marcin@python-works.com>
parents:
2109
diff
changeset
|
1241 """ |
122f15a8f6ec
fixed issue with escaping < and > in changeset commits
Marcin Kuzminski <marcin@python-works.com>
parents:
2109
diff
changeset
|
1242 Extract revision ids from changeset and make link from them |
2125
097327aaf2ad
more detailed logging on auth system
Marcin Kuzminski <marcin@python-works.com>
parents:
2118
diff
changeset
|
1243 |
2111
122f15a8f6ec
fixed issue with escaping < and > in changeset commits
Marcin Kuzminski <marcin@python-works.com>
parents:
2109
diff
changeset
|
1244 :param text_: |
3398
1ca82b6a6349
urlify commit function also should extract normal links
Marcin Kuzminski <marcin@python-works.com>
parents:
3385
diff
changeset
|
1245 :param repository: repo name to build the URL with |
2111
122f15a8f6ec
fixed issue with escaping < and > in changeset commits
Marcin Kuzminski <marcin@python-works.com>
parents:
2109
diff
changeset
|
1246 """ |
3385
d21c762f5c4b
revision extraction function shouldn't be so eager, just extract commits that are
Marcin Kuzminski <marcin@python-works.com>
parents:
3382
diff
changeset
|
1247 from pylons import url # doh, we need to re-import url to mock it later |
3405
a9adca4ba3c9
fixed urlify changesets regex + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
3399
diff
changeset
|
1248 URL_PAT = re.compile(r'(^|\s)([0-9a-fA-F]{12,40})($|\s)') |
1913
08344d037ba1
added links to revisions in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1912
diff
changeset
|
1249 |
08344d037ba1
added links to revisions in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1912
diff
changeset
|
1250 def url_func(match_obj): |
3405
a9adca4ba3c9
fixed urlify changesets regex + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
3399
diff
changeset
|
1251 rev = match_obj.groups()[1] |
a9adca4ba3c9
fixed urlify changesets regex + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
3399
diff
changeset
|
1252 pref = match_obj.groups()[0] |
a9adca4ba3c9
fixed urlify changesets regex + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
3399
diff
changeset
|
1253 suf = match_obj.groups()[2] |
a9adca4ba3c9
fixed urlify changesets regex + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
3399
diff
changeset
|
1254 |
1913
08344d037ba1
added links to revisions in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1912
diff
changeset
|
1255 tmpl = ( |
08344d037ba1
added links to revisions in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1912
diff
changeset
|
1256 '%(pref)s<a class="%(cls)s" href="%(url)s">' |
3405
a9adca4ba3c9
fixed urlify changesets regex + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
3399
diff
changeset
|
1257 '%(rev)s</a>%(suf)s' |
1913
08344d037ba1
added links to revisions in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1912
diff
changeset
|
1258 ) |
08344d037ba1
added links to revisions in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1912
diff
changeset
|
1259 return tmpl % { |
08344d037ba1
added links to revisions in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1912
diff
changeset
|
1260 'pref': pref, |
08344d037ba1
added links to revisions in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1912
diff
changeset
|
1261 'cls': 'revision-link', |
08344d037ba1
added links to revisions in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1912
diff
changeset
|
1262 'url': url('changeset_home', repo_name=repository, revision=rev), |
08344d037ba1
added links to revisions in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1912
diff
changeset
|
1263 'rev': rev, |
3385
d21c762f5c4b
revision extraction function shouldn't be so eager, just extract commits that are
Marcin Kuzminski <marcin@python-works.com>
parents:
3382
diff
changeset
|
1264 'suf': suf |
1913
08344d037ba1
added links to revisions in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1912
diff
changeset
|
1265 } |
08344d037ba1
added links to revisions in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1912
diff
changeset
|
1266 |
08344d037ba1
added links to revisions in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1912
diff
changeset
|
1267 newtext = URL_PAT.sub(url_func, text_) |
08344d037ba1
added links to revisions in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1912
diff
changeset
|
1268 |
08344d037ba1
added links to revisions in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1912
diff
changeset
|
1269 return newtext |
1868
f26acc1b27e2
added repository name into issue tracker link to support different projects issues tracker mapping
Marcin Kuzminski <marcin@python-works.com>
parents:
1865
diff
changeset
|
1270 |
1959
7a7ffe24b82c
optimized speed for browsing git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1944
diff
changeset
|
1271 |
1878
287eff9614fa
changelog: make messages be links again, and somewhat co-exist with issue tracker links (those are bold now)
Aras Pranckevicius <aras@unity3d.com>
parents:
1868
diff
changeset
|
1272 def urlify_commit(text_, repository=None, link_=None): |
2028
ef3114b01c7c
fixed issues when urlify commit created empty links when link_ param was empty
Marcin Kuzminski <marcin@python-works.com>
parents:
2014
diff
changeset
|
1273 """ |
ef3114b01c7c
fixed issues when urlify commit created empty links when link_ param was empty
Marcin Kuzminski <marcin@python-works.com>
parents:
2014
diff
changeset
|
1274 Parses given text message and makes proper links. |
ef3114b01c7c
fixed issues when urlify commit created empty links when link_ param was empty
Marcin Kuzminski <marcin@python-works.com>
parents:
2014
diff
changeset
|
1275 issues are linked to given issue-server, and rest is a changeset link |
ef3114b01c7c
fixed issues when urlify commit created empty links when link_ param was empty
Marcin Kuzminski <marcin@python-works.com>
parents:
2014
diff
changeset
|
1276 if link_ is given, in other case it's a plain text |
ef3114b01c7c
fixed issues when urlify commit created empty links when link_ param was empty
Marcin Kuzminski <marcin@python-works.com>
parents:
2014
diff
changeset
|
1277 |
ef3114b01c7c
fixed issues when urlify commit created empty links when link_ param was empty
Marcin Kuzminski <marcin@python-works.com>
parents:
2014
diff
changeset
|
1278 :param text_: |
ef3114b01c7c
fixed issues when urlify commit created empty links when link_ param was empty
Marcin Kuzminski <marcin@python-works.com>
parents:
2014
diff
changeset
|
1279 :param repository: |
ef3114b01c7c
fixed issues when urlify commit created empty links when link_ param was empty
Marcin Kuzminski <marcin@python-works.com>
parents:
2014
diff
changeset
|
1280 :param link_: changeset link |
ef3114b01c7c
fixed issues when urlify commit created empty links when link_ param was empty
Marcin Kuzminski <marcin@python-works.com>
parents:
2014
diff
changeset
|
1281 """ |
1837
a6a30c919513
#73 mapping of commited issues from commit message into issue tracker url.
Marcin Kuzminski <marcin@python-works.com>
parents:
1832
diff
changeset
|
1282 import traceback |
3398
1ca82b6a6349
urlify commit function also should extract normal links
Marcin Kuzminski <marcin@python-works.com>
parents:
3385
diff
changeset
|
1283 from pylons import url # doh, we need to re-import url to mock it later |
2125
097327aaf2ad
more detailed logging on auth system
Marcin Kuzminski <marcin@python-works.com>
parents:
2118
diff
changeset
|
1284 |
2111
122f15a8f6ec
fixed issue with escaping < and > in changeset commits
Marcin Kuzminski <marcin@python-works.com>
parents:
2109
diff
changeset
|
1285 def escaper(string): |
122f15a8f6ec
fixed issue with escaping < and > in changeset commits
Marcin Kuzminski <marcin@python-works.com>
parents:
2109
diff
changeset
|
1286 return string.replace('<', '<').replace('>', '>') |
2125
097327aaf2ad
more detailed logging on auth system
Marcin Kuzminski <marcin@python-works.com>
parents:
2118
diff
changeset
|
1287 |
2012
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
1288 def linkify_others(t, l): |
1913
08344d037ba1
added links to revisions in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1912
diff
changeset
|
1289 urls = re.compile(r'(\<a.*?\<\/a\>)',) |
08344d037ba1
added links to revisions in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1912
diff
changeset
|
1290 links = [] |
08344d037ba1
added links to revisions in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1912
diff
changeset
|
1291 for e in urls.split(t): |
08344d037ba1
added links to revisions in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1912
diff
changeset
|
1292 if not urls.match(e): |
2012
ca39c02c7c3e
speed up generating changesets in journal log
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
1293 links.append('<a class="message-link" href="%s">%s</a>' % (l, e)) |
1913
08344d037ba1
added links to revisions in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1912
diff
changeset
|
1294 else: |
1944
5fc9c92025c1
white space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
1933
diff
changeset
|
1295 links.append(e) |
5fc9c92025c1
white space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
1933
diff
changeset
|
1296 |
1913
08344d037ba1
added links to revisions in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1912
diff
changeset
|
1297 return ''.join(links) |
2125
097327aaf2ad
more detailed logging on auth system
Marcin Kuzminski <marcin@python-works.com>
parents:
2118
diff
changeset
|
1298 |
2111
122f15a8f6ec
fixed issue with escaping < and > in changeset commits
Marcin Kuzminski <marcin@python-works.com>
parents:
2109
diff
changeset
|
1299 # urlify changesets - extrac revisions and make link out of them |
2865
6d9b3ade3051
Allowing multiple issue servers to be autolinked in the changeset view;
Zachary Auclair <zach101@gmail.com>
parents:
2836
diff
changeset
|
1300 newtext = urlify_changesets(escaper(text_), repository) |
2111
122f15a8f6ec
fixed issue with escaping < and > in changeset commits
Marcin Kuzminski <marcin@python-works.com>
parents:
2109
diff
changeset
|
1301 |
3398
1ca82b6a6349
urlify commit function also should extract normal links
Marcin Kuzminski <marcin@python-works.com>
parents:
3385
diff
changeset
|
1302 # extract http/https links and make them real urls |
3399
5ff79fad209c
don't use double literal() calls on urlify functions
Marcin Kuzminski <marcin@python-works.com>
parents:
3398
diff
changeset
|
1303 newtext = urlify_text(newtext, safe=False) |
3398
1ca82b6a6349
urlify commit function also should extract normal links
Marcin Kuzminski <marcin@python-works.com>
parents:
3385
diff
changeset
|
1304 |
1837
a6a30c919513
#73 mapping of commited issues from commit message into issue tracker url.
Marcin Kuzminski <marcin@python-works.com>
parents:
1832
diff
changeset
|
1305 try: |
3382
b8cb1fe622e9
don't use global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
3375
diff
changeset
|
1306 from rhodecode import CONFIG |
b8cb1fe622e9
don't use global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
3375
diff
changeset
|
1307 conf = CONFIG |
1868
f26acc1b27e2
added repository name into issue tracker link to support different projects issues tracker mapping
Marcin Kuzminski <marcin@python-works.com>
parents:
1865
diff
changeset
|
1308 |
2865
6d9b3ade3051
Allowing multiple issue servers to be autolinked in the changeset view;
Zachary Auclair <zach101@gmail.com>
parents:
2836
diff
changeset
|
1309 # allow multiple issue servers to be used |
6d9b3ade3051
Allowing multiple issue servers to be autolinked in the changeset view;
Zachary Auclair <zach101@gmail.com>
parents:
2836
diff
changeset
|
1310 valid_indices = [ |
2866
736678a8c881
#518 multiple issues patterns
Marcin Kuzminski <marcin@python-works.com>
parents:
2865
diff
changeset
|
1311 x.group(1) |
736678a8c881
#518 multiple issues patterns
Marcin Kuzminski <marcin@python-works.com>
parents:
2865
diff
changeset
|
1312 for x in map(lambda x: re.match(r'issue_pat(.*)', x), conf.keys()) |
736678a8c881
#518 multiple issues patterns
Marcin Kuzminski <marcin@python-works.com>
parents:
2865
diff
changeset
|
1313 if x and 'issue_server_link%s' % x.group(1) in conf |
736678a8c881
#518 multiple issues patterns
Marcin Kuzminski <marcin@python-works.com>
parents:
2865
diff
changeset
|
1314 and 'issue_prefix%s' % x.group(1) in conf |
736678a8c881
#518 multiple issues patterns
Marcin Kuzminski <marcin@python-works.com>
parents:
2865
diff
changeset
|
1315 ] |
2865
6d9b3ade3051
Allowing multiple issue servers to be autolinked in the changeset view;
Zachary Auclair <zach101@gmail.com>
parents:
2836
diff
changeset
|
1316 |
2866
736678a8c881
#518 multiple issues patterns
Marcin Kuzminski <marcin@python-works.com>
parents:
2865
diff
changeset
|
1317 log.debug('found issue server suffixes `%s` during valuation of: %s' |
736678a8c881
#518 multiple issues patterns
Marcin Kuzminski <marcin@python-works.com>
parents:
2865
diff
changeset
|
1318 % (','.join(valid_indices), newtext)) |
1868
f26acc1b27e2
added repository name into issue tracker link to support different projects issues tracker mapping
Marcin Kuzminski <marcin@python-works.com>
parents:
1865
diff
changeset
|
1319 |
2865
6d9b3ade3051
Allowing multiple issue servers to be autolinked in the changeset view;
Zachary Auclair <zach101@gmail.com>
parents:
2836
diff
changeset
|
1320 for pattern_index in valid_indices: |
2866
736678a8c881
#518 multiple issues patterns
Marcin Kuzminski <marcin@python-works.com>
parents:
2865
diff
changeset
|
1321 ISSUE_PATTERN = conf.get('issue_pat%s' % pattern_index) |
736678a8c881
#518 multiple issues patterns
Marcin Kuzminski <marcin@python-works.com>
parents:
2865
diff
changeset
|
1322 ISSUE_SERVER_LNK = conf.get('issue_server_link%s' % pattern_index) |
736678a8c881
#518 multiple issues patterns
Marcin Kuzminski <marcin@python-works.com>
parents:
2865
diff
changeset
|
1323 ISSUE_PREFIX = conf.get('issue_prefix%s' % pattern_index) |
2865
6d9b3ade3051
Allowing multiple issue servers to be autolinked in the changeset view;
Zachary Auclair <zach101@gmail.com>
parents:
2836
diff
changeset
|
1324 |
2866
736678a8c881
#518 multiple issues patterns
Marcin Kuzminski <marcin@python-works.com>
parents:
2865
diff
changeset
|
1325 log.debug('pattern suffix `%s` PAT:%s SERVER_LINK:%s PREFIX:%s' |
736678a8c881
#518 multiple issues patterns
Marcin Kuzminski <marcin@python-works.com>
parents:
2865
diff
changeset
|
1326 % (pattern_index, ISSUE_PATTERN, ISSUE_SERVER_LNK, |
736678a8c881
#518 multiple issues patterns
Marcin Kuzminski <marcin@python-works.com>
parents:
2865
diff
changeset
|
1327 ISSUE_PREFIX)) |
2865
6d9b3ade3051
Allowing multiple issue servers to be autolinked in the changeset view;
Zachary Auclair <zach101@gmail.com>
parents:
2836
diff
changeset
|
1328 |
6d9b3ade3051
Allowing multiple issue servers to be autolinked in the changeset view;
Zachary Auclair <zach101@gmail.com>
parents:
2836
diff
changeset
|
1329 URL_PAT = re.compile(r'%s' % ISSUE_PATTERN) |
1868
f26acc1b27e2
added repository name into issue tracker link to support different projects issues tracker mapping
Marcin Kuzminski <marcin@python-works.com>
parents:
1865
diff
changeset
|
1330 |
1837
a6a30c919513
#73 mapping of commited issues from commit message into issue tracker url.
Marcin Kuzminski <marcin@python-works.com>
parents:
1832
diff
changeset
|
1331 def url_func(match_obj): |
1912
32e1e0745d3c
fixes issue with whitespace for referenced tasks in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1884
diff
changeset
|
1332 pref = '' |
32e1e0745d3c
fixes issue with whitespace for referenced tasks in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1884
diff
changeset
|
1333 if match_obj.group().startswith(' '): |
32e1e0745d3c
fixes issue with whitespace for referenced tasks in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1884
diff
changeset
|
1334 pref = ' ' |
32e1e0745d3c
fixes issue with whitespace for referenced tasks in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1884
diff
changeset
|
1335 |
1933
3da456a3a211
changed default issue tracker links pattern
Marcin Kuzminski <marcin@python-works.com>
parents:
1927
diff
changeset
|
1336 issue_id = ''.join(match_obj.groups()) |
1840
87920d4f58c5
added class into issue tracker link
Marcin Kuzminski <marcin@python-works.com>
parents:
1837
diff
changeset
|
1337 tmpl = ( |
1912
32e1e0745d3c
fixes issue with whitespace for referenced tasks in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1884
diff
changeset
|
1338 '%(pref)s<a class="%(cls)s" href="%(url)s">' |
1865 | 1339 '%(issue-prefix)s%(id-repr)s' |
1840
87920d4f58c5
added class into issue tracker link
Marcin Kuzminski <marcin@python-works.com>
parents:
1837
diff
changeset
|
1340 '</a>' |
87920d4f58c5
added class into issue tracker link
Marcin Kuzminski <marcin@python-works.com>
parents:
1837
diff
changeset
|
1341 ) |
1868
f26acc1b27e2
added repository name into issue tracker link to support different projects issues tracker mapping
Marcin Kuzminski <marcin@python-works.com>
parents:
1865
diff
changeset
|
1342 url = ISSUE_SERVER_LNK.replace('{id}', issue_id) |
f26acc1b27e2
added repository name into issue tracker link to support different projects issues tracker mapping
Marcin Kuzminski <marcin@python-works.com>
parents:
1865
diff
changeset
|
1343 if repository: |
f26acc1b27e2
added repository name into issue tracker link to support different projects issues tracker mapping
Marcin Kuzminski <marcin@python-works.com>
parents:
1865
diff
changeset
|
1344 url = url.replace('{repo}', repository) |
2339
79b3c9c66c54
Added optional repo_name into issue tracker url to get just the name of repo without group prefix
Marcin Kuzminski <marcin@python-works.com>
parents:
2323
diff
changeset
|
1345 repo_name = repository.split(URL_SEP)[-1] |
79b3c9c66c54
Added optional repo_name into issue tracker url to get just the name of repo without group prefix
Marcin Kuzminski <marcin@python-works.com>
parents:
2323
diff
changeset
|
1346 url = url.replace('{repo_name}', repo_name) |
2865
6d9b3ade3051
Allowing multiple issue servers to be autolinked in the changeset view;
Zachary Auclair <zach101@gmail.com>
parents:
2836
diff
changeset
|
1347 |
1913
08344d037ba1
added links to revisions in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1912
diff
changeset
|
1348 return tmpl % { |
1912
32e1e0745d3c
fixes issue with whitespace for referenced tasks in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1884
diff
changeset
|
1349 'pref': pref, |
1868
f26acc1b27e2
added repository name into issue tracker link to support different projects issues tracker mapping
Marcin Kuzminski <marcin@python-works.com>
parents:
1865
diff
changeset
|
1350 'cls': 'issue-tracker-link', |
f26acc1b27e2
added repository name into issue tracker link to support different projects issues tracker mapping
Marcin Kuzminski <marcin@python-works.com>
parents:
1865
diff
changeset
|
1351 'url': url, |
f26acc1b27e2
added repository name into issue tracker link to support different projects issues tracker mapping
Marcin Kuzminski <marcin@python-works.com>
parents:
1865
diff
changeset
|
1352 'id-repr': issue_id, |
f26acc1b27e2
added repository name into issue tracker link to support different projects issues tracker mapping
Marcin Kuzminski <marcin@python-works.com>
parents:
1865
diff
changeset
|
1353 'issue-prefix': ISSUE_PREFIX, |
f26acc1b27e2
added repository name into issue tracker link to support different projects issues tracker mapping
Marcin Kuzminski <marcin@python-works.com>
parents:
1865
diff
changeset
|
1354 'serv': ISSUE_SERVER_LNK, |
1913
08344d037ba1
added links to revisions in commit messages
Marcin Kuzminski <marcin@python-works.com>
parents:
1912
diff
changeset
|
1355 } |
2865
6d9b3ade3051
Allowing multiple issue servers to be autolinked in the changeset view;
Zachary Auclair <zach101@gmail.com>
parents:
2836
diff
changeset
|
1356 newtext = URL_PAT.sub(url_func, newtext) |
2866
736678a8c881
#518 multiple issues patterns
Marcin Kuzminski <marcin@python-works.com>
parents:
2865
diff
changeset
|
1357 log.debug('processed prefix:`%s` => %s' % (pattern_index, newtext)) |
1944
5fc9c92025c1
white space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
1933
diff
changeset
|
1358 |
2865
6d9b3ade3051
Allowing multiple issue servers to be autolinked in the changeset view;
Zachary Auclair <zach101@gmail.com>
parents:
2836
diff
changeset
|
1359 # if we actually did something above |
2956
a2ecf8a530b9
don't check for url issue links, since we always want to linkify changeset into a repo link, fixes issue
Marcin Kuzminski <marcin@python-works.com>
parents:
2954
diff
changeset
|
1360 if link_: |
a2ecf8a530b9
don't check for url issue links, since we always want to linkify changeset into a repo link, fixes issue
Marcin Kuzminski <marcin@python-works.com>
parents:
2954
diff
changeset
|
1361 # wrap not links into final link => link_ |
a2ecf8a530b9
don't check for url issue links, since we always want to linkify changeset into a repo link, fixes issue
Marcin Kuzminski <marcin@python-works.com>
parents:
2954
diff
changeset
|
1362 newtext = linkify_others(newtext, link_) |
3631
10b4e34841a4
Don't catch all exceptions
Marcin Kuzminski <marcin@python-works.com>
parents:
3627
diff
changeset
|
1363 except Exception: |
1837
a6a30c919513
#73 mapping of commited issues from commit message into issue tracker url.
Marcin Kuzminski <marcin@python-works.com>
parents:
1832
diff
changeset
|
1364 log.error(traceback.format_exc()) |
a6a30c919513
#73 mapping of commited issues from commit message into issue tracker url.
Marcin Kuzminski <marcin@python-works.com>
parents:
1832
diff
changeset
|
1365 pass |
a6a30c919513
#73 mapping of commited issues from commit message into issue tracker url.
Marcin Kuzminski <marcin@python-works.com>
parents:
1832
diff
changeset
|
1366 |
2966
566f0166f21e
yet another fix for commit linkifications
Marcin Kuzminski <marcin@python-works.com>
parents:
2965
diff
changeset
|
1367 return literal(newtext) |
1670
d2de0c2f02cd
#77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
1656
diff
changeset
|
1368 |
1868
f26acc1b27e2
added repository name into issue tracker link to support different projects issues tracker mapping
Marcin Kuzminski <marcin@python-works.com>
parents:
1865
diff
changeset
|
1369 |
1670
d2de0c2f02cd
#77 code review
Marcin Kuzminski <marcin@python-works.com>
parents:
1656
diff
changeset
|
1370 def rst(source): |
1789
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1781
diff
changeset
|
1371 return literal('<div class="rst-block">%s</div>' % |
1766 | 1372 MarkupRenderer.rst(source)) |
1789
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1781
diff
changeset
|
1373 |
1868
f26acc1b27e2
added repository name into issue tracker link to support different projects issues tracker mapping
Marcin Kuzminski <marcin@python-works.com>
parents:
1865
diff
changeset
|
1374 |
1769
025f3333c769
@mention highlighting
Marcin Kuzminski <marcin@python-works.com>
parents:
1767
diff
changeset
|
1375 def rst_w_mentions(source): |
025f3333c769
@mention highlighting
Marcin Kuzminski <marcin@python-works.com>
parents:
1767
diff
changeset
|
1376 """ |
025f3333c769
@mention highlighting
Marcin Kuzminski <marcin@python-works.com>
parents:
1767
diff
changeset
|
1377 Wrapped rst renderer with @mention highlighting |
1818
cf51bbfb120e
auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents:
1789
diff
changeset
|
1378 |
1769
025f3333c769
@mention highlighting
Marcin Kuzminski <marcin@python-works.com>
parents:
1767
diff
changeset
|
1379 :param source: |
025f3333c769
@mention highlighting
Marcin Kuzminski <marcin@python-works.com>
parents:
1767
diff
changeset
|
1380 """ |
1789
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1781
diff
changeset
|
1381 return literal('<div class="rst-block">%s</div>' % |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1781
diff
changeset
|
1382 MarkupRenderer.rst_with_mentions(source)) |
2217
76947224bf27
Implemented initial code-review status of changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2203
diff
changeset
|
1383 |
76947224bf27
Implemented initial code-review status of changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2203
diff
changeset
|
1384 |
76947224bf27
Implemented initial code-review status of changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2203
diff
changeset
|
1385 def changeset_status(repo, revision): |
76947224bf27
Implemented initial code-review status of changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2203
diff
changeset
|
1386 return ChangesetStatusModel().get_status(repo, revision) |
2239
493e03a4d268
added changeset status into changelog view
Marcin Kuzminski <marcin@python-works.com>
parents:
2217
diff
changeset
|
1387 |
493e03a4d268
added changeset status into changelog view
Marcin Kuzminski <marcin@python-works.com>
parents:
2217
diff
changeset
|
1388 |
493e03a4d268
added changeset status into changelog view
Marcin Kuzminski <marcin@python-works.com>
parents:
2217
diff
changeset
|
1389 def changeset_status_lbl(changeset_status): |
493e03a4d268
added changeset status into changelog view
Marcin Kuzminski <marcin@python-works.com>
parents:
2217
diff
changeset
|
1390 return dict(ChangesetStatus.STATUSES).get(changeset_status) |
2532
19de74e33fb0
Better descriptions of given permission overview in edit user view
Marcin Kuzminski <marcin@python-works.com>
parents:
2491
diff
changeset
|
1391 |
19de74e33fb0
Better descriptions of given permission overview in edit user view
Marcin Kuzminski <marcin@python-works.com>
parents:
2491
diff
changeset
|
1392 |
19de74e33fb0
Better descriptions of given permission overview in edit user view
Marcin Kuzminski <marcin@python-works.com>
parents:
2491
diff
changeset
|
1393 def get_permission_name(key): |
19de74e33fb0
Better descriptions of given permission overview in edit user view
Marcin Kuzminski <marcin@python-works.com>
parents:
2491
diff
changeset
|
1394 return dict(Permission.PERMS).get(key) |
3070
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
1395 |
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
1396 |
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
1397 def journal_filter_help(): |
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
1398 return _(textwrap.dedent(''' |
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
1399 Example filter terms: |
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
1400 repository:vcs |
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
1401 username:marcin |
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
1402 action:*push* |
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
1403 ip:127.0.0.1 |
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
1404 date:20120101 |
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
1405 date:[20120101100000 TO 20120102] |
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
1406 |
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
1407 Generate wildcards using '*' character: |
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
1408 "repositroy:vcs*" - search everything starting with 'vcs' |
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
1409 "repository:*vcs*" - search for repository containing 'vcs' |
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
1410 |
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
1411 Optional AND / OR operators in queries |
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
1412 "repository:vcs OR repository:test" |
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
1413 "username:test AND repository:test*" |
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
1414 ''')) |
3110
144128efc6ab
- #683 fixed difference between messages about not mapped repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3080
diff
changeset
|
1415 |
144128efc6ab
- #683 fixed difference between messages about not mapped repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3080
diff
changeset
|
1416 |
144128efc6ab
- #683 fixed difference between messages about not mapped repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3080
diff
changeset
|
1417 def not_mapped_error(repo_name): |
144128efc6ab
- #683 fixed difference between messages about not mapped repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3080
diff
changeset
|
1418 flash(_('%s repository is not mapped to db perhaps' |
144128efc6ab
- #683 fixed difference between messages about not mapped repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3080
diff
changeset
|
1419 ' it was created or renamed from the filesystem' |
144128efc6ab
- #683 fixed difference between messages about not mapped repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3080
diff
changeset
|
1420 ' please run the application again' |
144128efc6ab
- #683 fixed difference between messages about not mapped repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3080
diff
changeset
|
1421 ' in order to rescan repositories') % repo_name, category='error') |
3125
9b92cf5a0cca
Added UserIpMap interface for allowed IP addresses and IP restriction access
Marcin Kuzminski <marcin@python-works.com>
parents:
3110
diff
changeset
|
1422 |
9b92cf5a0cca
Added UserIpMap interface for allowed IP addresses and IP restriction access
Marcin Kuzminski <marcin@python-works.com>
parents:
3110
diff
changeset
|
1423 |
9b92cf5a0cca
Added UserIpMap interface for allowed IP addresses and IP restriction access
Marcin Kuzminski <marcin@python-works.com>
parents:
3110
diff
changeset
|
1424 def ip_range(ip_addr): |
9b92cf5a0cca
Added UserIpMap interface for allowed IP addresses and IP restriction access
Marcin Kuzminski <marcin@python-works.com>
parents:
3110
diff
changeset
|
1425 from rhodecode.model.db import UserIpMap |
9b92cf5a0cca
Added UserIpMap interface for allowed IP addresses and IP restriction access
Marcin Kuzminski <marcin@python-works.com>
parents:
3110
diff
changeset
|
1426 s, e = UserIpMap._get_ip_range(ip_addr) |
9b92cf5a0cca
Added UserIpMap interface for allowed IP addresses and IP restriction access
Marcin Kuzminski <marcin@python-works.com>
parents:
3110
diff
changeset
|
1427 return '%s - %s' % (s, e) |