annotate rhodecode/lib/helpers.py @ 1110:5351a3a32381 beta

#21 added optional flag to disable gravatar, and use local icon
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 02 Mar 2011 11:50:13 +0100
parents 61c5f0ab24b9
children fcb5054937f6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
1 """Helper functions
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
2
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
3 Consists of functions to typically be used within templates, but also
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
4 available to Controllers. This module is available to both as 'h'.
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
5 """
734
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
6 import random
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
7 import hashlib
966
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
8 import StringIO
1101
c1080b42a7cb fixed problem with int. chars in gravatars
Marcin Kuzminski <marcin@python-works.com>
parents: 1100
diff changeset
9 import urllib
c1080b42a7cb fixed problem with int. chars in gravatars
Marcin Kuzminski <marcin@python-works.com>
parents: 1100
diff changeset
10
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
11 from pygments.formatters import HtmlFormatter
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
12 from pygments import highlight as code_highlight
1110
5351a3a32381 #21 added optional flag to disable gravatar, and use local icon
Marcin Kuzminski <marcin@python-works.com>
parents: 1105
diff changeset
13 from pylons import url, request, config
97
be0096a02772 added helper for filesize
Marcin Kuzminski <marcin@python-works.com>
parents: 94
diff changeset
14 from pylons.i18n.translation import _, ungettext
1022
4f834b0abcd3 Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents: 1009
diff changeset
15
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
16 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
17 from webhelpers.html.tools import *
98
01d0f363f36d added pygments webhelper
Marcin Kuzminski <marcin@python-works.com>
parents: 97
diff changeset
18 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
19 from webhelpers.html.tags import auto_discovery_link, checkbox, css_classes, \
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
20 end_form, file, form, hidden, image, javascript_link, link_to, link_to_if, \
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
21 link_to_unless, ol, required_legend, select, stylesheet_link, submit, text, \
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
22 password, textarea, title, ul, xml_declaration, radio
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
23 from webhelpers.html.tools import auto_link, button_to, highlight, js_obfuscate, \
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
24 mail_to, strip_links, strip_tags, tag_re
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
25 from webhelpers.number import format_byte_size, format_bit_size
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
26 from webhelpers.pylonslib import Flash as _Flash
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
27 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
28 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
29 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
30 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
31 from webhelpers.date import time_ago_in_words
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
32 from webhelpers.paginate import Page
698
4cd0709b6d4b fixes #65, Added reset buttons to edit forms
Marcin Kuzminski <marcin@python-works.com>
parents: 668
diff changeset
33 from webhelpers.html.tags import _set_input_attrs, _set_id_attr, \
4cd0709b6d4b fixes #65, Added reset buttons to edit forms
Marcin Kuzminski <marcin@python-works.com>
parents: 668
diff changeset
34 convert_boolean_attrs, NotGiven
4cd0709b6d4b fixes #65, Added reset buttons to edit forms
Marcin Kuzminski <marcin@python-works.com>
parents: 668
diff changeset
35
1101
c1080b42a7cb fixed problem with int. chars in gravatars
Marcin Kuzminski <marcin@python-works.com>
parents: 1100
diff changeset
36 from vcs.utils.annotate import annotate_highlight
c1080b42a7cb fixed problem with int. chars in gravatars
Marcin Kuzminski <marcin@python-works.com>
parents: 1100
diff changeset
37 from rhodecode.lib.utils import repo_name_slug
1110
5351a3a32381 #21 added optional flag to disable gravatar, and use local icon
Marcin Kuzminski <marcin@python-works.com>
parents: 1105
diff changeset
38 from rhodecode.lib import str2bool
1101
c1080b42a7cb fixed problem with int. chars in gravatars
Marcin Kuzminski <marcin@python-works.com>
parents: 1100
diff changeset
39
698
4cd0709b6d4b fixes #65, Added reset buttons to edit forms
Marcin Kuzminski <marcin@python-works.com>
parents: 668
diff changeset
40 def _reset(name, value=None, id=NotGiven, type="reset", **attrs):
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
41 """Reset button
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
42 """
698
4cd0709b6d4b fixes #65, Added reset buttons to edit forms
Marcin Kuzminski <marcin@python-works.com>
parents: 668
diff changeset
43 _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
44 _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
45 convert_boolean_attrs(attrs, ["disabled"])
4cd0709b6d4b fixes #65, Added reset buttons to edit forms
Marcin Kuzminski <marcin@python-works.com>
parents: 668
diff changeset
46 return HTML.input(**attrs)
4cd0709b6d4b fixes #65, Added reset buttons to edit forms
Marcin Kuzminski <marcin@python-works.com>
parents: 668
diff changeset
47
4cd0709b6d4b fixes #65, Added reset buttons to edit forms
Marcin Kuzminski <marcin@python-works.com>
parents: 668
diff changeset
48 reset = _reset
4cd0709b6d4b fixes #65, Added reset buttons to edit forms
Marcin Kuzminski <marcin@python-works.com>
parents: 668
diff changeset
49
734
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
50
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
51 def get_token():
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
52 """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
53 already exist.
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
54 """
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
55 token_key = "_authentication_token"
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
56 from pylons import session
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
57 if not token_key in session:
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
58 try:
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
59 token = hashlib.sha1(str(random.getrandbits(128))).hexdigest()
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
60 except AttributeError: # Python < 2.4
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
61 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
62 session[token_key] = token
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
63 if hasattr(session, 'save'):
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
64 session.save()
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
65 return session[token_key]
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
66
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
67 class _GetError(object):
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
68 """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
69 message
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
70
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
71 :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
72 :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
73 """
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
74
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
75 def __call__(self, field_name, form_errors):
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
76 tmpl = """<span class="error_msg">%s</span>"""
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
77 if form_errors and form_errors.has_key(field_name):
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
78 return literal(tmpl % form_errors.get(field_name))
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
79
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
80 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
81
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
82 class _ToolTip(object):
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
83
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
84 def __call__(self, tooltip_title, trim_at=50):
905
1294f2baf2bc added wrapping of long tooltips in index page
Marcin Kuzminski <marcin@python-works.com>
parents: 904
diff changeset
85 """Special function just to wrap our text into nice formatted
1294f2baf2bc added wrapping of long tooltips in index page
Marcin Kuzminski <marcin@python-works.com>
parents: 904
diff changeset
86 autowrapped text
1294f2baf2bc added wrapping of long tooltips in index page
Marcin Kuzminski <marcin@python-works.com>
parents: 904
diff changeset
87
604
5cc96df705b9 fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
88 :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
89 """
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
90
444
0668919c307c fixed escaping in tooltip
Marcin Kuzminski <marcin@python-works.com>
parents: 443
diff changeset
91 return wrap_paragraphs(escape(tooltip_title), trim_at)\
0668919c307c fixed escaping in tooltip
Marcin Kuzminski <marcin@python-works.com>
parents: 443
diff changeset
92 .replace('\n', '<br/>')
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
93
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
94 def activate(self):
904
82aaf4e71817 reimplemented tooltip, refactored tooltip_title into title for proper html,
Marcin Kuzminski <marcin@python-works.com>
parents: 899
diff changeset
95 """Adds tooltip mechanism to the given Html all tooltips have to have
82aaf4e71817 reimplemented tooltip, refactored tooltip_title into title for proper html,
Marcin Kuzminski <marcin@python-works.com>
parents: 899
diff changeset
96 set class `tooltip` and set attribute `tooltip_title`.
82aaf4e71817 reimplemented tooltip, refactored tooltip_title into title for proper html,
Marcin Kuzminski <marcin@python-works.com>
parents: 899
diff changeset
97 Then a tooltip will be generated based on that. All with yui js tooltip
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
98 """
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
99
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
100 js = '''
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
101 YAHOO.util.Event.onDOMReady(function(){
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
102 function toolTipsId(){
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
103 var ids = [];
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
104 var tts = YAHOO.util.Dom.getElementsByClassName('tooltip');
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
105
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
106 for (var i = 0; i < tts.length; i++) {
904
82aaf4e71817 reimplemented tooltip, refactored tooltip_title into title for proper html,
Marcin Kuzminski <marcin@python-works.com>
parents: 899
diff changeset
107 //if element doesn't not have and id autogenerate one for tooltip
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
108
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
109 if (!tts[i].id){
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
110 tts[i].id='tt'+i*100;
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
111 }
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
112 ids.push(tts[i].id);
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
113 }
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
114 return ids
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
115 };
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
116 var myToolTips = new YAHOO.widget.Tooltip("tooltip", {
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
117 context: toolTipsId(),
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
118 monitorresize:false,
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
119 xyoffset :[0,0],
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
120 autodismissdelay:300000,
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
121 hidedelay:5,
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
122 showdelay:20,
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
123 });
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
124
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
125 // Set the text for the tooltip just before we display it. Lazy method
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
126 myToolTips.contextTriggerEvent.subscribe(
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
127 function(type, args) {
292
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
128
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
129 var context = args[0];
292
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
130
904
82aaf4e71817 reimplemented tooltip, refactored tooltip_title into title for proper html,
Marcin Kuzminski <marcin@python-works.com>
parents: 899
diff changeset
131 //positioning of tooltip
82aaf4e71817 reimplemented tooltip, refactored tooltip_title into title for proper html,
Marcin Kuzminski <marcin@python-works.com>
parents: 899
diff changeset
132 var tt_w = this.element.clientWidth;//tooltip width
82aaf4e71817 reimplemented tooltip, refactored tooltip_title into title for proper html,
Marcin Kuzminski <marcin@python-works.com>
parents: 899
diff changeset
133 var tt_h = this.element.clientHeight;//tooltip height
292
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
134
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
135 var context_w = context.offsetWidth;
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
136 var context_h = context.offsetHeight;
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
137
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
138 var pos_x = YAHOO.util.Dom.getX(context);
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
139 var pos_y = YAHOO.util.Dom.getY(context);
286
6603c9891b91 tooltip display bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 284
diff changeset
140
904
82aaf4e71817 reimplemented tooltip, refactored tooltip_title into title for proper html,
Marcin Kuzminski <marcin@python-works.com>
parents: 899
diff changeset
141 var display_strategy = 'right';
293
68dc70295a76 Ie graph support.
Marcin Kuzminski <marcin@python-works.com>
parents: 292
diff changeset
142 var xy_pos = [0,0];
292
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
143 switch (display_strategy){
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
144
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
145 case 'top':
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
146 var cur_x = (pos_x+context_w/2)-(tt_w/2);
904
82aaf4e71817 reimplemented tooltip, refactored tooltip_title into title for proper html,
Marcin Kuzminski <marcin@python-works.com>
parents: 899
diff changeset
147 var cur_y = (pos_y-tt_h-4);
292
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
148 xy_pos = [cur_x,cur_y];
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
149 break;
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
150 case 'bottom':
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
151 var cur_x = (pos_x+context_w/2)-(tt_w/2);
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
152 var cur_y = pos_y+context_h+4;
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
153 xy_pos = [cur_x,cur_y];
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
154 break;
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
155 case 'left':
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
156 var cur_x = (pos_x-tt_w-4);
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
157 var cur_y = pos_y-((tt_h/2)-context_h/2);
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
158 xy_pos = [cur_x,cur_y];
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
159 break;
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
160 case 'right':
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
161 var cur_x = (pos_x+context_w+4);
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
162 var cur_y = pos_y-((tt_h/2)-context_h/2);
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
163 xy_pos = [cur_x,cur_y];
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
164 break;
293
68dc70295a76 Ie graph support.
Marcin Kuzminski <marcin@python-works.com>
parents: 292
diff changeset
165 default:
68dc70295a76 Ie graph support.
Marcin Kuzminski <marcin@python-works.com>
parents: 292
diff changeset
166 var cur_x = (pos_x+context_w/2)-(tt_w/2);
68dc70295a76 Ie graph support.
Marcin Kuzminski <marcin@python-works.com>
parents: 292
diff changeset
167 var cur_y = pos_y-tt_h-4;
68dc70295a76 Ie graph support.
Marcin Kuzminski <marcin@python-works.com>
parents: 292
diff changeset
168 xy_pos = [cur_x,cur_y];
68dc70295a76 Ie graph support.
Marcin Kuzminski <marcin@python-works.com>
parents: 292
diff changeset
169 break;
68dc70295a76 Ie graph support.
Marcin Kuzminski <marcin@python-works.com>
parents: 292
diff changeset
170
292
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
171 }
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
172
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
173 this.cfg.setProperty("xy",xy_pos);
286
6603c9891b91 tooltip display bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 284
diff changeset
174
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
175 });
292
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
176
286
6603c9891b91 tooltip display bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 284
diff changeset
177 //Mouse out
6603c9891b91 tooltip display bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 284
diff changeset
178 myToolTips.contextMouseOutEvent.subscribe(
6603c9891b91 tooltip display bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 284
diff changeset
179 function(type, args) {
6603c9891b91 tooltip display bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 284
diff changeset
180 var context = args[0];
6603c9891b91 tooltip display bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 284
diff changeset
181
6603c9891b91 tooltip display bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 284
diff changeset
182 });
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
183 });
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
184 '''
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
185 return literal(js)
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
186
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
187 tooltip = _ToolTip()
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
188
102
2dc0c8e4f384 Updated tempaltes, added file browser breadcrumbs, and feed icons
Marcin Kuzminski <marcin@python-works.com>
parents: 98
diff changeset
189 class _FilesBreadCrumbs(object):
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
190
102
2dc0c8e4f384 Updated tempaltes, added file browser breadcrumbs, and feed icons
Marcin Kuzminski <marcin@python-works.com>
parents: 98
diff changeset
191 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
192 if isinstance(paths, str):
1100
e7d7f05217c1 replaced all decode('utf-8') instances with .decode('utf-8','replace') for more error prof setup,
Marcin Kuzminski <marcin@python-works.com>
parents: 1098
diff changeset
193 paths = paths.decode('utf-8', 'replace')
287
5827c739b0bd webhelpers breadcrumbs bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 286
diff changeset
194 url_l = [link_to(repo_name, url('files_home',
5827c739b0bd webhelpers breadcrumbs bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 286
diff changeset
195 repo_name=repo_name,
5827c739b0bd webhelpers breadcrumbs bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 286
diff changeset
196 revision=rev, f_path=''))]
5827c739b0bd webhelpers breadcrumbs bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 286
diff changeset
197 paths_l = paths.split('/')
740
9279dfedcf93 fixed python2.5 incompatible enumerate calls
Marcin Kuzminski <marcin@python-works.com>
parents: 735
diff changeset
198 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
199 if p != '':
287
5827c739b0bd webhelpers breadcrumbs bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 286
diff changeset
200 url_l.append(link_to(p, url('files_home',
5827c739b0bd webhelpers breadcrumbs bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 286
diff changeset
201 repo_name=repo_name,
5827c739b0bd webhelpers breadcrumbs bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 286
diff changeset
202 revision=rev,
740
9279dfedcf93 fixed python2.5 incompatible enumerate calls
Marcin Kuzminski <marcin@python-works.com>
parents: 735
diff changeset
203 f_path='/'.join(paths_l[:cnt + 1]))))
97
be0096a02772 added helper for filesize
Marcin Kuzminski <marcin@python-works.com>
parents: 94
diff changeset
204
448
4679105ef03e more css html fixes (+cleanups), rewrote definition list for files
Marcin Kuzminski <marcin@python-works.com>
parents: 444
diff changeset
205 return literal('/'.join(url_l))
98
01d0f363f36d added pygments webhelper
Marcin Kuzminski <marcin@python-works.com>
parents: 97
diff changeset
206
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
207 files_breadcrumbs = _FilesBreadCrumbs()
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
208
505
5aba7adff196 little gui change for file source
Marcin Kuzminski <marcin@python-works.com>
parents: 494
diff changeset
209 class CodeHtmlFormatter(HtmlFormatter):
966
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
210 """My code Html Formatter for source codes
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
211 """
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
212
505
5aba7adff196 little gui change for file source
Marcin Kuzminski <marcin@python-works.com>
parents: 494
diff changeset
213 def wrap(self, source, outfile):
5aba7adff196 little gui change for file source
Marcin Kuzminski <marcin@python-works.com>
parents: 494
diff changeset
214 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
215
5aba7adff196 little gui change for file source
Marcin Kuzminski <marcin@python-works.com>
parents: 494
diff changeset
216 def _wrap_code(self, source):
740
9279dfedcf93 fixed python2.5 incompatible enumerate calls
Marcin Kuzminski <marcin@python-works.com>
parents: 735
diff changeset
217 for cnt, it in enumerate(source):
505
5aba7adff196 little gui change for file source
Marcin Kuzminski <marcin@python-works.com>
parents: 494
diff changeset
218 i, t = it
966
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
219 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
220 yield i, t
966
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
221
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
222 def _wrap_tablelinenos(self, inner):
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
223 dummyoutfile = StringIO.StringIO()
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
224 lncount = 0
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
225 for t, line in inner:
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
226 if t:
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
227 lncount += 1
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
228 dummyoutfile.write(line)
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
229
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
230 fl = self.linenostart
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
231 mw = len(str(lncount + fl - 1))
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
232 sp = self.linenospecial
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
233 st = self.linenostep
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
234 la = self.lineanchors
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
235 aln = self.anchorlinenos
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
236 nocls = self.noclasses
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
237 if sp:
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
238 lines = []
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
239
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
240 for i in range(fl, fl + lncount):
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
241 if i % st == 0:
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
242 if i % sp == 0:
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
243 if aln:
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
244 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
245 (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('<span class="special">%*d</span>' % (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 if aln:
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
250 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
251 else:
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
252 lines.append('%*d' % (mw, i))
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
253 else:
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
254 lines.append('')
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
255 ls = '\n'.join(lines)
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
256 else:
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
257 lines = []
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
258 for i in range(fl, fl + lncount):
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
259 if i % st == 0:
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
260 if aln:
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
261 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
262 else:
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
263 lines.append('%*d' % (mw, i))
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
264 else:
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
265 lines.append('')
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
266 ls = '\n'.join(lines)
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 # 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
269 # 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
270 # some configurations seem to mess up the formatting...
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
271 if nocls:
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
272 yield 0, ('<table class="%stable">' % self.cssclass +
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
273 '<tr><td><div class="linenodiv" '
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
274 'style="background-color: #f0f0f0; padding-right: 10px">'
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
275 '<pre style="line-height: 125%">' +
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
276 ls + '</pre></div></td><td class="code">')
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
277 else:
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
278 yield 0, ('<table class="%stable">' % self.cssclass +
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
279 '<tr><td class="linenos"><div class="linenodiv"><pre>' +
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
280 ls + '</pre></div></td><td class="code">')
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
281 yield 0, dummyoutfile.getvalue()
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
282 yield 0, '</td></tr></table>'
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
283
63c91390853c fixed line number look
Marcin Kuzminski <marcin@python-works.com>
parents: 965
diff changeset
284
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
285 def pygmentize(filenode, **kwargs):
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
286 """pygmentize function using pygments
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
287
604
5cc96df705b9 fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
288 :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
289 """
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
290
450
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
291 return literal(code_highlight(filenode.content,
505
5aba7adff196 little gui change for file source
Marcin Kuzminski <marcin@python-works.com>
parents: 494
diff changeset
292 filenode.lexer, 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
293
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
294 def pygmentize_annotation(filenode, **kwargs):
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
295 """pygmentize function for annotation
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
296
604
5cc96df705b9 fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
297 :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
298 """
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
299
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
300 color_dict = {}
947
99850ac883d1 Fixed whoosh daemon, for depracated walk method
Marcin Kuzminski <marcin@python-works.com>
parents: 946
diff changeset
301 def gen_color(n=10000):
99850ac883d1 Fixed whoosh daemon, for depracated walk method
Marcin Kuzminski <marcin@python-works.com>
parents: 946
diff changeset
302 """generator for getting n of evenly distributed colors using
99850ac883d1 Fixed whoosh daemon, for depracated walk method
Marcin Kuzminski <marcin@python-works.com>
parents: 946
diff changeset
303 hsv color and golden ratio. It always return same order of colors
99850ac883d1 Fixed whoosh daemon, for depracated walk method
Marcin Kuzminski <marcin@python-works.com>
parents: 946
diff changeset
304
99850ac883d1 Fixed whoosh daemon, for depracated walk method
Marcin Kuzminski <marcin@python-works.com>
parents: 946
diff changeset
305 :returns: RGB tuple
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
306 """
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
307 import colorsys
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
308 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
309 h = 0.22717784590367374
947
99850ac883d1 Fixed whoosh daemon, for depracated walk method
Marcin Kuzminski <marcin@python-works.com>
parents: 946
diff changeset
310
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
311 for c in xrange(n):
450
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
312 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
313 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
314 HSV_tuple = [h, 0.95, 0.95]
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
315 RGB_tuple = colorsys.hsv_to_rgb(*HSV_tuple)
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
316 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
317
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 cgenerator = gen_color()
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
319
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
320 def get_color_string(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
321 if color_dict.has_key(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
322 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
323 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
324 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
325 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
326
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
327 def url_func(changeset):
450
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
328 tooltip_html = "<div style='font-size:0.8em'><b>Author:</b>" + \
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
329 " %s<br/><b>Date:</b> %s</b><br/><b>Message:</b> %s<br/></div>"
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
330
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
331 tooltip_html = tooltip_html % (changeset.author,
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
332 changeset.date,
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
333 tooltip(changeset.message))
662
373ee7031003 fixed annotation bug, added history to annotation.
Marcin Kuzminski <marcin@python-works.com>
parents: 660
diff changeset
334 lnk_format = '%5s:%s' % ('r%s' % changeset.revision,
373ee7031003 fixed annotation bug, added history to annotation.
Marcin Kuzminski <marcin@python-works.com>
parents: 660
diff changeset
335 short_id(changeset.raw_id))
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
336 uri = link_to(
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
337 lnk_format,
428
dee0e7eb0370 removed decodes, thus it should be implemented on vcs side
*** failed to import extension hggit: No module named hggit
parents: 401
diff changeset
338 url('changeset_home', repo_name=changeset.repository.name,
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 635
diff changeset
339 revision=changeset.raw_id),
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 635
diff changeset
340 style=get_color_string(changeset.raw_id),
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
341 class_='tooltip',
904
82aaf4e71817 reimplemented tooltip, refactored tooltip_title into title for proper html,
Marcin Kuzminski <marcin@python-works.com>
parents: 899
diff changeset
342 title=tooltip_html
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
343 )
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
344
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
345 uri += '\n'
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
346 return uri
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
347 return literal(annotate_highlight(filenode, url_func, **kwargs))
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
348
450
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
349 def get_changeset_safe(repo, rev):
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
350 from vcs.backends.base import BaseRepository
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
351 from vcs.exceptions import RepositoryError
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
352 if not isinstance(repo, BaseRepository):
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
353 raise Exception('You must pass an Repository '
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
354 'object as first argument got %s', type(repo))
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
355
450
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
356 try:
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
357 cs = repo.get_changeset(rev)
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
358 except RepositoryError:
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 512
diff changeset
359 from rhodecode.lib.utils import EmptyChangeset
450
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
360 cs = EmptyChangeset()
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
361 return cs
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
362
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
363
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
364 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
365 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
366 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
367
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
368 flash = _Flash()
282
237470e64bb8 switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents: 281
diff changeset
369
237470e64bb8 switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents: 281
diff changeset
370
635
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
371 #==============================================================================
282
237470e64bb8 switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents: 281
diff changeset
372 # MERCURIAL 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
373 #==============================================================================
282
237470e64bb8 switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents: 281
diff changeset
374 from mercurial import util
635
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
375 from mercurial.templatefilters import person as _person
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
376
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
377 def _age(curdate):
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
378 """turns a datetime into an age string."""
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
379
643
9dc1d92d82ed updated setup for all newest versions
Marcin Kuzminski <marcin@python-works.com>
parents: 636
diff changeset
380 if not curdate:
9dc1d92d82ed updated setup for all newest versions
Marcin Kuzminski <marcin@python-works.com>
parents: 636
diff changeset
381 return ''
282
237470e64bb8 switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents: 281
diff changeset
382
635
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
383 from datetime import timedelta, datetime
643
9dc1d92d82ed updated setup for all newest versions
Marcin Kuzminski <marcin@python-works.com>
parents: 636
diff changeset
384
635
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
385 agescales = [("year", 3600 * 24 * 365),
653
4a3291628f09 fixed a bug when age of last change is less than one minute
Marcin Kuzminski <marcin@python-works.com>
parents: 643
diff changeset
386 ("month", 3600 * 24 * 30),
4a3291628f09 fixed a bug when age of last change is less than one minute
Marcin Kuzminski <marcin@python-works.com>
parents: 643
diff changeset
387 ("day", 3600 * 24),
4a3291628f09 fixed a bug when age of last change is less than one minute
Marcin Kuzminski <marcin@python-works.com>
parents: 643
diff changeset
388 ("hour", 3600),
4a3291628f09 fixed a bug when age of last change is less than one minute
Marcin Kuzminski <marcin@python-works.com>
parents: 643
diff changeset
389 ("minute", 60),
4a3291628f09 fixed a bug when age of last change is less than one minute
Marcin Kuzminski <marcin@python-works.com>
parents: 643
diff changeset
390 ("second", 1), ]
635
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
391
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
392 age = datetime.now() - curdate
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
393 age_seconds = (age.days * agescales[2][1]) + age.seconds
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
394 pos = 1
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
395 for scale in agescales:
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
396 if scale[1] <= age_seconds:
653
4a3291628f09 fixed a bug when age of last change is less than one minute
Marcin Kuzminski <marcin@python-works.com>
parents: 643
diff changeset
397 if pos == 6:pos = 5
668
dff6d5cb8bba fixed deletion of repository on filesystem, works based on scm type for git and hg.
Marcin Kuzminski <marcin@python-works.com>
parents: 662
diff changeset
398 return time_ago_in_words(curdate, agescales[pos][0]) + ' ' + _('ago')
635
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
399 pos += 1
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
400
668
dff6d5cb8bba fixed deletion of repository on filesystem, works based on scm type for git and hg.
Marcin Kuzminski <marcin@python-works.com>
parents: 662
diff changeset
401 return _('just now')
dff6d5cb8bba fixed deletion of repository on filesystem, works based on scm type for git and hg.
Marcin Kuzminski <marcin@python-works.com>
parents: 662
diff changeset
402
635
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
403 age = lambda x:_age(x)
282
237470e64bb8 switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents: 281
diff changeset
404 capitalize = lambda x: x.capitalize()
237470e64bb8 switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents: 281
diff changeset
405 email = util.email
401
b1debb6c5a09 implemented gravatars to changesets, updated styling for changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 400
diff changeset
406 email_or_none = lambda x: util.email(x) if util.email(x) != x else None
282
237470e64bb8 switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents: 281
diff changeset
407 person = lambda x: _person(x)
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 635
diff changeset
408 short_id = lambda x: x[:12]
282
237470e64bb8 switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents: 281
diff changeset
409
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
410
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
411 def bool2icon(value):
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
412 """Returns True/False values 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
413 icons
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
414
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
415 :param value: bool value
131c1e335fa7 Added ldap info on admin users, added bool2icon helper for nicer representation of
Marcin Kuzminski <marcin@python-works.com>
parents: 698
diff changeset
416 """
131c1e335fa7 Added ldap info on admin users, added bool2icon helper for nicer representation of
Marcin Kuzminski <marcin@python-works.com>
parents: 698
diff changeset
417
131c1e335fa7 Added ldap info on admin users, added bool2icon helper for nicer representation of
Marcin Kuzminski <marcin@python-works.com>
parents: 698
diff changeset
418 if value is True:
1050
cabe887a9829 removed obsolete _static flag from url, and fixed urls in webhelpers
Marcin Kuzminski <marcin@python-works.com>
parents: 1045
diff changeset
419 return HTML.tag('img', src=url("/images/icons/accept.png"),
cabe887a9829 removed obsolete _static flag from url, and fixed urls in webhelpers
Marcin Kuzminski <marcin@python-works.com>
parents: 1045
diff changeset
420 alt=_('True'))
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
421
131c1e335fa7 Added ldap info on admin users, added bool2icon helper for nicer representation of
Marcin Kuzminski <marcin@python-works.com>
parents: 698
diff changeset
422 if value is False:
1050
cabe887a9829 removed obsolete _static flag from url, and fixed urls in webhelpers
Marcin Kuzminski <marcin@python-works.com>
parents: 1045
diff changeset
423 return HTML.tag('img', src=url("/images/icons/cancel.png"),
cabe887a9829 removed obsolete _static flag from url, and fixed urls in webhelpers
Marcin Kuzminski <marcin@python-works.com>
parents: 1045
diff changeset
424 alt=_('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
425
131c1e335fa7 Added ldap info on admin users, added bool2icon helper for nicer representation of
Marcin Kuzminski <marcin@python-works.com>
parents: 698
diff changeset
426 return value
131c1e335fa7 Added ldap info on admin users, added bool2icon helper for nicer representation of
Marcin Kuzminski <marcin@python-works.com>
parents: 698
diff changeset
427
131c1e335fa7 Added ldap info on admin users, added bool2icon helper for nicer representation of
Marcin Kuzminski <marcin@python-works.com>
parents: 698
diff changeset
428
1087
51076a2a2b64 fixed unicode problems with file paths.
Marcin Kuzminski <marcin@python-works.com>
parents: 1055
diff changeset
429 def action_parser(user_log, feed=False):
51076a2a2b64 fixed unicode problems with file paths.
Marcin Kuzminski <marcin@python-works.com>
parents: 1055
diff changeset
430 """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
431 fancy names with icons and links
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
432
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
433 :param user_log: user log instance
1087
51076a2a2b64 fixed unicode problems with file paths.
Marcin Kuzminski <marcin@python-works.com>
parents: 1055
diff changeset
434 :param feed: use output for feeds (no html and fancy icons)
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
435 """
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
436
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
437 action = user_log.action
840
ee6f345736a6 action logger upgrade, for working with migrations
Marcin Kuzminski <marcin@python-works.com>
parents: 817
diff changeset
438 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
439
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
440 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
441
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
442 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
443 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
444
718
7df3855bf6c7 Added fork name to journal
Marcin Kuzminski <marcin@python-works.com>
parents: 714
diff changeset
445 def get_cs_links():
953
def3578dac8c fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents: 947
diff changeset
446 revs_limit = 5 #display this amount always
def3578dac8c fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents: 947
diff changeset
447 revs_top_limit = 50 #show upto this amount of changesets hidden
def3578dac8c fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents: 947
diff changeset
448 revs = action_params.split(',')
def3578dac8c fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents: 947
diff changeset
449 repo_name = user_log.repository.repo_name
1045
3fc9183e05dd another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents: 1041
diff changeset
450
953
def3578dac8c fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents: 947
diff changeset
451 from rhodecode.model.scm import ScmModel
1045
3fc9183e05dd another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents: 1041
diff changeset
452 repo, dbrepo = ScmModel().get(repo_name, retval='repo',
3fc9183e05dd another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents: 1041
diff changeset
453 invalidation_list=[])
3fc9183e05dd another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents: 1041
diff changeset
454
1040
8e49b6ceffe1 fixes fixes fixes ! optimized queries on journal
Marcin Kuzminski <marcin@python-works.com>
parents: 1038
diff changeset
455 message = lambda rev: get_changeset_safe(repo, rev).message
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
456
953
def3578dac8c fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents: 947
diff changeset
457 cs_links = " " + ', '.join ([link_to(rev,
def3578dac8c fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents: 947
diff changeset
458 url('changeset_home',
def3578dac8c fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents: 947
diff changeset
459 repo_name=repo_name,
def3578dac8c fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents: 947
diff changeset
460 revision=rev), title=tooltip(message(rev)),
def3578dac8c fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents: 947
diff changeset
461 class_='tooltip') for rev in revs[:revs_limit] ])
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
462
eafe5ae429ea Added compare view into journal, fixed wrong function call to show compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 999
diff changeset
463 compare_view = (' <div class="compare_view tooltip" title="%s">'
eafe5ae429ea Added compare view into journal, fixed wrong function call to show compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 999
diff changeset
464 '<a href="%s">%s</a> '
eafe5ae429ea Added compare view into journal, fixed wrong function call to show compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 999
diff changeset
465 '</div>' % (_('Show all combined changesets %s->%s' \
eafe5ae429ea Added compare view into journal, fixed wrong function call to show compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 999
diff changeset
466 % (revs[0], revs[-1])),
eafe5ae429ea Added compare view into journal, fixed wrong function call to show compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 999
diff changeset
467 url('changeset_home', repo_name=repo_name,
eafe5ae429ea Added compare view into journal, fixed wrong function call to show compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 999
diff changeset
468 revision='%s...%s' % (revs[0], revs[-1])
eafe5ae429ea Added compare view into journal, fixed wrong function call to show compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 999
diff changeset
469 ),
eafe5ae429ea Added compare view into journal, fixed wrong function call to show compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 999
diff changeset
470 _('compare view'))
eafe5ae429ea Added compare view into journal, fixed wrong function call to show compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 999
diff changeset
471 )
eafe5ae429ea Added compare view into journal, fixed wrong function call to show compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 999
diff changeset
472
953
def3578dac8c fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents: 947
diff changeset
473 if len(revs) > revs_limit:
def3578dac8c fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents: 947
diff changeset
474 uniq_id = revs[0]
def3578dac8c fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents: 947
diff changeset
475 html_tmpl = ('<span> %s '
995
d14723711d17 fixes for journal, added paging now it's possible to view whole journal
Marcin Kuzminski <marcin@python-works.com>
parents: 990
diff changeset
476 '<a class="show_more" id="_%s" href="#more">%s</a> '
953
def3578dac8c fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents: 947
diff changeset
477 '%s</span>')
1087
51076a2a2b64 fixed unicode problems with file paths.
Marcin Kuzminski <marcin@python-works.com>
parents: 1055
diff changeset
478 if not feed:
51076a2a2b64 fixed unicode problems with file paths.
Marcin Kuzminski <marcin@python-works.com>
parents: 1055
diff changeset
479 cs_links += html_tmpl % (_('and'), uniq_id, _('%s more') \
953
def3578dac8c fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents: 947
diff changeset
480 % (len(revs) - revs_limit),
def3578dac8c fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents: 947
diff changeset
481 _('revisions'))
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
482
1087
51076a2a2b64 fixed unicode problems with file paths.
Marcin Kuzminski <marcin@python-works.com>
parents: 1055
diff changeset
483 if not feed:
51076a2a2b64 fixed unicode problems with file paths.
Marcin Kuzminski <marcin@python-works.com>
parents: 1055
diff changeset
484 html_tmpl = '<span id="%s" style="display:none"> %s </span>'
51076a2a2b64 fixed unicode problems with file paths.
Marcin Kuzminski <marcin@python-works.com>
parents: 1055
diff changeset
485 else:
51076a2a2b64 fixed unicode problems with file paths.
Marcin Kuzminski <marcin@python-works.com>
parents: 1055
diff changeset
486 html_tmpl = '<span id="%s"> %s </span>'
51076a2a2b64 fixed unicode problems with file paths.
Marcin Kuzminski <marcin@python-works.com>
parents: 1055
diff changeset
487
953
def3578dac8c fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents: 947
diff changeset
488 cs_links += html_tmpl % (uniq_id, ', '.join([link_to(rev,
def3578dac8c fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents: 947
diff changeset
489 url('changeset_home',
def3578dac8c fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents: 947
diff changeset
490 repo_name=repo_name, revision=rev),
def3578dac8c fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents: 947
diff changeset
491 title=message(rev), class_='tooltip')
def3578dac8c fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents: 947
diff changeset
492 for rev in revs[revs_limit:revs_top_limit]]))
1024
22c147726ea6 hidden compare view link for single revision push
Marcin Kuzminski <marcin@python-works.com>
parents: 1022
diff changeset
493 if len(revs) > 1:
22c147726ea6 hidden compare view link for single revision push
Marcin Kuzminski <marcin@python-works.com>
parents: 1022
diff changeset
494 cs_links += compare_view
953
def3578dac8c fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents: 947
diff changeset
495 return cs_links
734
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
496
718
7df3855bf6c7 Added fork name to journal
Marcin Kuzminski <marcin@python-works.com>
parents: 714
diff changeset
497 def get_fork_name():
953
def3578dac8c fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents: 947
diff changeset
498 repo_name = action_params
1055
903aadbf9047 updated changelog, small fix for journal
Marcin Kuzminski <marcin@python-works.com>
parents: 1053
diff changeset
499 return _('fork name ') + str(link_to(action_params, url('summary_home',
1045
3fc9183e05dd another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents: 1041
diff changeset
500 repo_name=repo_name,)))
953
def3578dac8c fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents: 947
diff changeset
501
1087
51076a2a2b64 fixed unicode problems with file paths.
Marcin Kuzminski <marcin@python-works.com>
parents: 1055
diff changeset
502 action_map = {'user_deleted_repo':(_('[deleted] repository'), None),
1041
98be43b888c4 Updated new Journal with users and dates aggregates
Marcin Kuzminski <marcin@python-works.com>
parents: 1040
diff changeset
503 'user_created_repo':(_('[created] repository'), None),
1055
903aadbf9047 updated changelog, small fix for journal
Marcin Kuzminski <marcin@python-works.com>
parents: 1053
diff changeset
504 'user_forked_repo':(_('[forked] repository'), get_fork_name),
1041
98be43b888c4 Updated new Journal with users and dates aggregates
Marcin Kuzminski <marcin@python-works.com>
parents: 1040
diff changeset
505 'user_updated_repo':(_('[updated] repository'), None),
98be43b888c4 Updated new Journal with users and dates aggregates
Marcin Kuzminski <marcin@python-works.com>
parents: 1040
diff changeset
506 'admin_deleted_repo':(_('[delete] repository'), None),
98be43b888c4 Updated new Journal with users and dates aggregates
Marcin Kuzminski <marcin@python-works.com>
parents: 1040
diff changeset
507 'admin_created_repo':(_('[created] repository'), None),
98be43b888c4 Updated new Journal with users and dates aggregates
Marcin Kuzminski <marcin@python-works.com>
parents: 1040
diff changeset
508 'admin_forked_repo':(_('[forked] repository'), None),
98be43b888c4 Updated new Journal with users and dates aggregates
Marcin Kuzminski <marcin@python-works.com>
parents: 1040
diff changeset
509 'admin_updated_repo':(_('[updated] repository'), None),
1052
c96651aebd8a fixed journal look & feel
Marcin Kuzminski <marcin@python-works.com>
parents: 1050
diff changeset
510 'push':(_('[pushed] into'), get_cs_links),
1053
aa01004399a5 typo fix for journal action
Marcin Kuzminski <marcin@python-works.com>
parents: 1052
diff changeset
511 'pull':(_('[pulled] from'), None),
1041
98be43b888c4 Updated new Journal with users and dates aggregates
Marcin Kuzminski <marcin@python-works.com>
parents: 1040
diff changeset
512 'started_following_repo':(_('[started following] repository'), None),
98be43b888c4 Updated new Journal with users and dates aggregates
Marcin Kuzminski <marcin@python-works.com>
parents: 1040
diff changeset
513 'stopped_following_repo':(_('[stopped following] repository'), None),
735
dbec976d9975 added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents: 734
diff changeset
514 }
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
515
1087
51076a2a2b64 fixed unicode problems with file paths.
Marcin Kuzminski <marcin@python-works.com>
parents: 1055
diff changeset
516 action_str = action_map.get(action, action)
51076a2a2b64 fixed unicode problems with file paths.
Marcin Kuzminski <marcin@python-works.com>
parents: 1055
diff changeset
517 if feed:
51076a2a2b64 fixed unicode problems with file paths.
Marcin Kuzminski <marcin@python-works.com>
parents: 1055
diff changeset
518 action = action_str[0].replace('[', '').replace(']', '')
51076a2a2b64 fixed unicode problems with file paths.
Marcin Kuzminski <marcin@python-works.com>
parents: 1055
diff changeset
519 else:
51076a2a2b64 fixed unicode problems with file paths.
Marcin Kuzminski <marcin@python-works.com>
parents: 1055
diff changeset
520 action = action_str[0].replace('[', '<span class="journal_highlight">')\
953
def3578dac8c fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents: 947
diff changeset
521 .replace(']', '</span>')
1052
c96651aebd8a fixed journal look & feel
Marcin Kuzminski <marcin@python-works.com>
parents: 1050
diff changeset
522 action_params_func = lambda :""
c96651aebd8a fixed journal look & feel
Marcin Kuzminski <marcin@python-works.com>
parents: 1050
diff changeset
523
953
def3578dac8c fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents: 947
diff changeset
524 if action_str[1] is not None:
1052
c96651aebd8a fixed journal look & feel
Marcin Kuzminski <marcin@python-works.com>
parents: 1050
diff changeset
525 action_params_func = action_str[1]
953
def3578dac8c fixed vcs import.
Marcin Kuzminski <marcin@python-works.com>
parents: 947
diff changeset
526
1052
c96651aebd8a fixed journal look & feel
Marcin Kuzminski <marcin@python-works.com>
parents: 1050
diff changeset
527 return [literal(action), action_params_func]
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
528
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
529 def action_parser_icon(user_log):
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
530 action = user_log.action
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
531 action_params = None
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
532 x = action.split(':')
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
533
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
534 if len(x) > 1:
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
535 action, action_params = x
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
536
1050
cabe887a9829 removed obsolete _static flag from url, and fixed urls in webhelpers
Marcin Kuzminski <marcin@python-works.com>
parents: 1045
diff changeset
537 tmpl = """<img src="%s/%s" alt="%s"/>"""
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
538 map = {'user_deleted_repo':'database_delete.png',
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
539 'user_created_repo':'database_add.png',
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
540 'user_forked_repo':'arrow_divide.png',
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
541 'user_updated_repo':'database_edit.png',
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
542 'admin_deleted_repo':'database_delete.png',
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
543 'admin_created_repo':'database_add.png',
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
544 'admin_forked_repo':'arrow_divide.png',
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
545 'admin_updated_repo':'database_edit.png',
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
546 'push':'script_add.png',
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
547 'pull':'down_16.png',
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
548 'started_following_repo':'heart_add.png',
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
549 'stopped_following_repo':'heart_delete.png',
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
550 }
1050
cabe887a9829 removed obsolete _static flag from url, and fixed urls in webhelpers
Marcin Kuzminski <marcin@python-works.com>
parents: 1045
diff changeset
551 return literal(tmpl % ((url('/images/icons/')),
cabe887a9829 removed obsolete _static flag from url, and fixed urls in webhelpers
Marcin Kuzminski <marcin@python-works.com>
parents: 1045
diff changeset
552 map.get(action, action), action))
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
553
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
554
635
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
555 #==============================================================================
307
504feff57b49 added permission functions to webhelpers, updated dbmanage permissions
Marcin Kuzminski <marcin@python-works.com>
parents: 293
diff changeset
556 # PERMS
635
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
557 #==============================================================================
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 512
diff changeset
558 from rhodecode.lib.auth import HasPermissionAny, HasPermissionAll, \
307
504feff57b49 added permission functions to webhelpers, updated dbmanage permissions
Marcin Kuzminski <marcin@python-works.com>
parents: 293
diff changeset
559 HasRepoPermissionAny, HasRepoPermissionAll
282
237470e64bb8 switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents: 281
diff changeset
560
635
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
561 #==============================================================================
398
8c50b164fb58 Implemented basic gravatar support on admin pages only for now
Marcin Kuzminski <marcin@python-works.com>
parents: 307
diff changeset
562 # 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
563 #==============================================================================
282
237470e64bb8 switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents: 281
diff changeset
564
401
b1debb6c5a09 implemented gravatars to changesets, updated styling for changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 400
diff changeset
565 def gravatar_url(email_address, size=30):
1110
5351a3a32381 #21 added optional flag to disable gravatar, and use local icon
Marcin Kuzminski <marcin@python-works.com>
parents: 1105
diff changeset
566 if not str2bool(config['app_conf'].get('use_gravatar')):
5351a3a32381 #21 added optional flag to disable gravatar, and use local icon
Marcin Kuzminski <marcin@python-works.com>
parents: 1105
diff changeset
567 return "/images/user%s.png" % size
5351a3a32381 #21 added optional flag to disable gravatar, and use local icon
Marcin Kuzminski <marcin@python-works.com>
parents: 1105
diff changeset
568
946
f12cd4707301 patched gravatar url generation to properly support new https force flag from settings.
Marcin Kuzminski <marcin@python-works.com>
parents: 911
diff changeset
569 ssl_enabled = 'https' == request.environ.get('wsgi.url_scheme')
398
8c50b164fb58 Implemented basic gravatar support on admin pages only for now
Marcin Kuzminski <marcin@python-works.com>
parents: 307
diff changeset
570 default = 'identicon'
8c50b164fb58 Implemented basic gravatar support on admin pages only for now
Marcin Kuzminski <marcin@python-works.com>
parents: 307
diff changeset
571 baseurl_nossl = "http://www.gravatar.com/avatar/"
8c50b164fb58 Implemented basic gravatar support on admin pages only for now
Marcin Kuzminski <marcin@python-works.com>
parents: 307
diff changeset
572 baseurl_ssl = "https://secure.gravatar.com/avatar/"
8c50b164fb58 Implemented basic gravatar support on admin pages only for now
Marcin Kuzminski <marcin@python-works.com>
parents: 307
diff changeset
573 baseurl = baseurl_ssl if ssl_enabled else baseurl_nossl
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
574
1101
c1080b42a7cb fixed problem with int. chars in gravatars
Marcin Kuzminski <marcin@python-works.com>
parents: 1100
diff changeset
575 if isinstance(email_address, unicode):
c1080b42a7cb fixed problem with int. chars in gravatars
Marcin Kuzminski <marcin@python-works.com>
parents: 1100
diff changeset
576 #hashlib crashes on unicode items
c1080b42a7cb fixed problem with int. chars in gravatars
Marcin Kuzminski <marcin@python-works.com>
parents: 1100
diff changeset
577 email_address = email_address.encode('utf8', 'replace')
398
8c50b164fb58 Implemented basic gravatar support on admin pages only for now
Marcin Kuzminski <marcin@python-works.com>
parents: 307
diff changeset
578 # construct the url
401
b1debb6c5a09 implemented gravatars to changesets, updated styling for changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 400
diff changeset
579 gravatar_url = baseurl + hashlib.md5(email_address.lower()).hexdigest() + "?"
398
8c50b164fb58 Implemented basic gravatar support on admin pages only for now
Marcin Kuzminski <marcin@python-works.com>
parents: 307
diff changeset
580 gravatar_url += urllib.urlencode({'d':default, 's':str(size)})
8c50b164fb58 Implemented basic gravatar support on admin pages only for now
Marcin Kuzminski <marcin@python-works.com>
parents: 307
diff changeset
581
8c50b164fb58 Implemented basic gravatar support on admin pages only for now
Marcin Kuzminski <marcin@python-works.com>
parents: 307
diff changeset
582 return gravatar_url
443
e5157e2a530e added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents: 438
diff changeset
583
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
584
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
585 #==============================================================================
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
586 # REPO PAGER
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
587 #==============================================================================
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
588 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
589
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
590 def __init__(self, collection, page=1, items_per_page=20,
1105
61c5f0ab24b9 Added branch filter to repo pager
Marcin Kuzminski <marcin@python-works.com>
parents: 1101
diff changeset
591 item_count=None, url=None, branch_name=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
592
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
593 """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
594 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
595 """
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
596 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
597
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
598 # 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
599 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
600
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
601 # 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
602 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
603
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
604 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
605
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
606 # 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
607 # 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
608 try:
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
609 self.page = int(page) # make it int() if we get it as a string
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
610 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
611 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
612
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
613 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
614
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
615 # 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
616 # 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
617 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
618 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
619 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
620 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
621
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
622 # 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
623 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
624 self.first_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
625 self.page_count = ((self.item_count - 1) / self.items_per_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
626 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
627
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
628 # Make sure that the requested page number is the range of valid pages
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
629 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
630 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
631 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
632 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
633
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
634 # 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
635 # items_per_page if the last page is not full
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
636 self.first_item = max(0, (self.item_count) - (self.page * items_per_page))
1105
61c5f0ab24b9 Added branch filter to repo pager
Marcin Kuzminski <marcin@python-works.com>
parents: 1101
diff changeset
637 self.last_item = ((self.item_count - 1) - items_per_page * (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
638
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
639 iterator = self.collection.get_changesets(start=self.first_item,
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
640 end=self.last_item,
1105
61c5f0ab24b9 Added branch filter to repo pager
Marcin Kuzminski <marcin@python-works.com>
parents: 1101
diff changeset
641 reverse=True,
61c5f0ab24b9 Added branch filter to repo pager
Marcin Kuzminski <marcin@python-works.com>
parents: 1101
diff changeset
642 branch_name=branch_name)
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
643 self.items = list(iterator)
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
644
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
645 # 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
646 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
647 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
648 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
649 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
650
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
651 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
652 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
653 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
654 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
655
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
656 # 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
657 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
658 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
659 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
660 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
661 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
662 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
663 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
664 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
665 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
666
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
667 # This is a subclass of the 'list' type. Initialise the list now.
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
668 list.__init__(self, 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
669
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
670
443
e5157e2a530e added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents: 438
diff changeset
671 def safe_unicode(str):
e5157e2a530e added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents: 438
diff changeset
672 """safe unicode function. In case of UnicodeDecode error we try to return
e5157e2a530e added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents: 438
diff changeset
673 unicode with errors replace, if this failes we return unicode with
e5157e2a530e added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents: 438
diff changeset
674 string_escape decoding """
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
675
443
e5157e2a530e added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents: 438
diff changeset
676 try:
e5157e2a530e added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents: 438
diff changeset
677 u_str = unicode(str)
e5157e2a530e added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents: 438
diff changeset
678 except UnicodeDecodeError:
e5157e2a530e added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents: 438
diff changeset
679 try:
e5157e2a530e added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents: 438
diff changeset
680 u_str = unicode(str, 'utf-8', 'replace')
e5157e2a530e added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents: 438
diff changeset
681 except UnicodeDecodeError:
e5157e2a530e added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents: 438
diff changeset
682 #incase we have a decode error just represent as byte string
e5157e2a530e added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents: 438
diff changeset
683 u_str = unicode(str(str).encode('string_escape'))
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
684
450
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
685 return u_str
990
7a1df0130533 moved tooltip function from the for loop and from templates to helpers
Marcin Kuzminski <marcin@python-works.com>
parents: 966
diff changeset
686
7a1df0130533 moved tooltip function from the for loop and from templates to helpers
Marcin Kuzminski <marcin@python-works.com>
parents: 966
diff changeset
687 def changed_tooltip(nodes):
7a1df0130533 moved tooltip function from the for loop and from templates to helpers
Marcin Kuzminski <marcin@python-works.com>
parents: 966
diff changeset
688 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
689 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
690 suf = ''
7a1df0130533 moved tooltip function from the for loop and from templates to helpers
Marcin Kuzminski <marcin@python-works.com>
parents: 966
diff changeset
691 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
692 suf = '<br/>' + _(' and %s more') % (len(nodes) - 30)
1100
e7d7f05217c1 replaced all decode('utf-8') instances with .decode('utf-8','replace') for more error prof setup,
Marcin Kuzminski <marcin@python-works.com>
parents: 1098
diff changeset
693 return literal(pref + '<br/> '.join([x.path.decode('utf-8', 'replace') 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
694 else:
7a1df0130533 moved tooltip function from the for loop and from templates to helpers
Marcin Kuzminski <marcin@python-works.com>
parents: 966
diff changeset
695 return ': ' + _('No Files')