annotate rhodecode/lib/helpers.py @ 947:99850ac883d1 beta

Fixed whoosh daemon, for depracated walk method
author Marcin Kuzminski <marcin@python-works.com>
date Fri, 21 Jan 2011 00:00:20 +0100
parents f12cd4707301
children def3578dac8c
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
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
8 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
9 from pygments import highlight as code_highlight
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
10 from pylons import url, app_globals as g
97
be0096a02772 added helper for filesize
Marcin Kuzminski <marcin@python-works.com>
parents: 94
diff changeset
11 from pylons.i18n.translation import _, ungettext
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
12 from vcs.utils.annotate import annotate_highlight
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
13 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
14 from webhelpers.html.tools import *
98
01d0f363f36d added pygments webhelper
Marcin Kuzminski <marcin@python-works.com>
parents: 97
diff changeset
15 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
16 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
17 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
18 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
19 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
20 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
21 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
22 from webhelpers.number import format_byte_size, format_bit_size
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
23 from webhelpers.pylonslib import Flash as _Flash
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
24 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
25 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
26 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
27 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
28 from webhelpers.date import time_ago_in_words
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
29
698
4cd0709b6d4b fixes #65, Added reset buttons to edit forms
Marcin Kuzminski <marcin@python-works.com>
parents: 668
diff changeset
30 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
31 convert_boolean_attrs, NotGiven
4cd0709b6d4b fixes #65, Added reset buttons to edit forms
Marcin Kuzminski <marcin@python-works.com>
parents: 668
diff changeset
32
4cd0709b6d4b fixes #65, Added reset buttons to edit forms
Marcin Kuzminski <marcin@python-works.com>
parents: 668
diff changeset
33 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
34 """Reset button
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
35 """
698
4cd0709b6d4b fixes #65, Added reset buttons to edit forms
Marcin Kuzminski <marcin@python-works.com>
parents: 668
diff changeset
36 _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
37 _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
38 convert_boolean_attrs(attrs, ["disabled"])
4cd0709b6d4b fixes #65, Added reset buttons to edit forms
Marcin Kuzminski <marcin@python-works.com>
parents: 668
diff changeset
39 return HTML.input(**attrs)
4cd0709b6d4b fixes #65, Added reset buttons to edit forms
Marcin Kuzminski <marcin@python-works.com>
parents: 668
diff changeset
40
4cd0709b6d4b fixes #65, Added reset buttons to edit forms
Marcin Kuzminski <marcin@python-works.com>
parents: 668
diff changeset
41 reset = _reset
4cd0709b6d4b fixes #65, Added reset buttons to edit forms
Marcin Kuzminski <marcin@python-works.com>
parents: 668
diff changeset
42
734
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
43
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
44 def get_token():
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
45 """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
46 already exist.
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
47 """
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
48 token_key = "_authentication_token"
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
49 from pylons import session
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
50 if not token_key in session:
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
51 try:
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
52 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
53 except AttributeError: # Python < 2.4
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
54 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
55 session[token_key] = token
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
56 if hasattr(session, 'save'):
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
57 session.save()
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
58 return session[token_key]
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
59
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
60 class _GetError(object):
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
61 """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
62 message
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
63
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
64 :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
65 :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
66 """
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
67
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
68 def __call__(self, field_name, form_errors):
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
69 tmpl = """<span class="error_msg">%s</span>"""
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
70 if form_errors and form_errors.has_key(field_name):
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
71 return literal(tmpl % form_errors.get(field_name))
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
72
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
73 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
74
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
75 def recursive_replace(str, replace=' '):
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
76 """Recursive replace of given sign to just one instance
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
77
604
5cc96df705b9 fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
78 :param str: given string
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
79 :param replace: char to find and replace multiple instances
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
80
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
81 Examples::
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
82 >>> recursive_replace("Mighty---Mighty-Bo--sstones",'-')
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
83 'Mighty-Mighty-Bo-sstones'
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
84 """
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
85
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
86 if str.find(replace * 2) == -1:
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
87 return str
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
88 else:
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
89 str = str.replace(replace * 2, replace)
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
90 return recursive_replace(str, replace)
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
91
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
92 class _ToolTip(object):
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 __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
95 """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
96 autowrapped text
1294f2baf2bc added wrapping of long tooltips in index page
Marcin Kuzminski <marcin@python-works.com>
parents: 904
diff changeset
97
604
5cc96df705b9 fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
98 :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
99 """
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
100
444
0668919c307c fixed escaping in tooltip
Marcin Kuzminski <marcin@python-works.com>
parents: 443
diff changeset
101 return wrap_paragraphs(escape(tooltip_title), trim_at)\
0668919c307c fixed escaping in tooltip
Marcin Kuzminski <marcin@python-works.com>
parents: 443
diff changeset
102 .replace('\n', '<br/>')
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
103
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
104 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
105 """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
106 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
107 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
108 """
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
109
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
110 js = '''
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
111 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
112 function toolTipsId(){
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
113 var ids = [];
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
114 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
115
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
116 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
117 //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
118
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
119 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
120 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
121 }
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
122 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
123 }
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
124 return ids
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
125 };
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
126 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
127 context: toolTipsId(),
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
128 monitorresize:false,
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
129 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
130 autodismissdelay:300000,
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
131 hidedelay:5,
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
132 showdelay:20,
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
133 });
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
134
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
135 // 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
136 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
137 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
138
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
139 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
140
904
82aaf4e71817 reimplemented tooltip, refactored tooltip_title into title for proper html,
Marcin Kuzminski <marcin@python-works.com>
parents: 899
diff changeset
141 //positioning of tooltip
82aaf4e71817 reimplemented tooltip, refactored tooltip_title into title for proper html,
Marcin Kuzminski <marcin@python-works.com>
parents: 899
diff changeset
142 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
143 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
144
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
145 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
146 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
147
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
148 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
149 var pos_y = YAHOO.util.Dom.getY(context);
286
6603c9891b91 tooltip display bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 284
diff changeset
150
904
82aaf4e71817 reimplemented tooltip, refactored tooltip_title into title for proper html,
Marcin Kuzminski <marcin@python-works.com>
parents: 899
diff changeset
151 var display_strategy = 'right';
293
68dc70295a76 Ie graph support.
Marcin Kuzminski <marcin@python-works.com>
parents: 292
diff changeset
152 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
153 switch (display_strategy){
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
154
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
155 case 'top':
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+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
157 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
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 'bottom':
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/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
162 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
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;
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
165 case 'left':
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
166 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
167 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
168 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
169 break;
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
170 case 'right':
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
171 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
172 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
173 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
174 break;
293
68dc70295a76 Ie graph support.
Marcin Kuzminski <marcin@python-works.com>
parents: 292
diff changeset
175 default:
68dc70295a76 Ie graph support.
Marcin Kuzminski <marcin@python-works.com>
parents: 292
diff changeset
176 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
177 var cur_y = pos_y-tt_h-4;
68dc70295a76 Ie graph support.
Marcin Kuzminski <marcin@python-works.com>
parents: 292
diff changeset
178 xy_pos = [cur_x,cur_y];
68dc70295a76 Ie graph support.
Marcin Kuzminski <marcin@python-works.com>
parents: 292
diff changeset
179 break;
68dc70295a76 Ie graph support.
Marcin Kuzminski <marcin@python-works.com>
parents: 292
diff changeset
180
292
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
181 }
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
182
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
183 this.cfg.setProperty("xy",xy_pos);
286
6603c9891b91 tooltip display bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 284
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 });
292
d7aeae23c56d tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents: 287
diff changeset
186
286
6603c9891b91 tooltip display bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 284
diff changeset
187 //Mouse out
6603c9891b91 tooltip display bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 284
diff changeset
188 myToolTips.contextMouseOutEvent.subscribe(
6603c9891b91 tooltip display bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 284
diff changeset
189 function(type, args) {
6603c9891b91 tooltip display bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 284
diff changeset
190 var context = args[0];
6603c9891b91 tooltip display bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 284
diff changeset
191
6603c9891b91 tooltip display bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 284
diff changeset
192 });
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
193 });
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
194 '''
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
195 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
196
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
197 tooltip = _ToolTip()
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
198
102
2dc0c8e4f384 Updated tempaltes, added file browser breadcrumbs, and feed icons
Marcin Kuzminski <marcin@python-works.com>
parents: 98
diff changeset
199 class _FilesBreadCrumbs(object):
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
200
102
2dc0c8e4f384 Updated tempaltes, added file browser breadcrumbs, and feed icons
Marcin Kuzminski <marcin@python-works.com>
parents: 98
diff changeset
201 def __call__(self, repo_name, rev, paths):
287
5827c739b0bd webhelpers breadcrumbs bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 286
diff changeset
202 url_l = [link_to(repo_name, url('files_home',
5827c739b0bd webhelpers breadcrumbs bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 286
diff changeset
203 repo_name=repo_name,
5827c739b0bd webhelpers breadcrumbs bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 286
diff changeset
204 revision=rev, f_path=''))]
5827c739b0bd webhelpers breadcrumbs bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 286
diff changeset
205 paths_l = paths.split('/')
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
206
740
9279dfedcf93 fixed python2.5 incompatible enumerate calls
Marcin Kuzminski <marcin@python-works.com>
parents: 735
diff changeset
207 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
208 if p != '':
287
5827c739b0bd webhelpers breadcrumbs bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 286
diff changeset
209 url_l.append(link_to(p, url('files_home',
5827c739b0bd webhelpers breadcrumbs bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 286
diff changeset
210 repo_name=repo_name,
5827c739b0bd webhelpers breadcrumbs bugfix
Marcin Kuzminski <marcin@python-works.com>
parents: 286
diff changeset
211 revision=rev,
740
9279dfedcf93 fixed python2.5 incompatible enumerate calls
Marcin Kuzminski <marcin@python-works.com>
parents: 735
diff changeset
212 f_path='/'.join(paths_l[:cnt + 1]))))
97
be0096a02772 added helper for filesize
Marcin Kuzminski <marcin@python-works.com>
parents: 94
diff changeset
213
448
4679105ef03e more css html fixes (+cleanups), rewrote definition list for files
Marcin Kuzminski <marcin@python-works.com>
parents: 444
diff changeset
214 return literal('/'.join(url_l))
98
01d0f363f36d added pygments webhelper
Marcin Kuzminski <marcin@python-works.com>
parents: 97
diff changeset
215
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
216 files_breadcrumbs = _FilesBreadCrumbs()
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
217
505
5aba7adff196 little gui change for file source
Marcin Kuzminski <marcin@python-works.com>
parents: 494
diff changeset
218 class CodeHtmlFormatter(HtmlFormatter):
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
219
505
5aba7adff196 little gui change for file source
Marcin Kuzminski <marcin@python-works.com>
parents: 494
diff changeset
220 def wrap(self, source, outfile):
5aba7adff196 little gui change for file source
Marcin Kuzminski <marcin@python-works.com>
parents: 494
diff changeset
221 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
222
5aba7adff196 little gui change for file source
Marcin Kuzminski <marcin@python-works.com>
parents: 494
diff changeset
223 def _wrap_code(self, source):
740
9279dfedcf93 fixed python2.5 incompatible enumerate calls
Marcin Kuzminski <marcin@python-works.com>
parents: 735
diff changeset
224 for cnt, it in enumerate(source):
505
5aba7adff196 little gui change for file source
Marcin Kuzminski <marcin@python-works.com>
parents: 494
diff changeset
225 i, t = it
740
9279dfedcf93 fixed python2.5 incompatible enumerate calls
Marcin Kuzminski <marcin@python-works.com>
parents: 735
diff changeset
226 t = '<div id="#S-%s">%s</div>' % (cnt + 1, t)
505
5aba7adff196 little gui change for file source
Marcin Kuzminski <marcin@python-works.com>
parents: 494
diff changeset
227 yield i, t
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
228 def pygmentize(filenode, **kwargs):
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
229 """pygmentize function using pygments
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
230
604
5cc96df705b9 fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
231 :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
232 """
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
233
450
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
234 return literal(code_highlight(filenode.content,
505
5aba7adff196 little gui change for file source
Marcin Kuzminski <marcin@python-works.com>
parents: 494
diff changeset
235 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
236
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
237 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
238 """pygmentize function for annotation
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
239
604
5cc96df705b9 fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
240 :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
241 """
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
242
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
243 color_dict = {}
947
99850ac883d1 Fixed whoosh daemon, for depracated walk method
Marcin Kuzminski <marcin@python-works.com>
parents: 946
diff changeset
244 def gen_color(n=10000):
99850ac883d1 Fixed whoosh daemon, for depracated walk method
Marcin Kuzminski <marcin@python-works.com>
parents: 946
diff changeset
245 """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
246 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
247
99850ac883d1 Fixed whoosh daemon, for depracated walk method
Marcin Kuzminski <marcin@python-works.com>
parents: 946
diff changeset
248 :returns: RGB tuple
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
249 """
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
250 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
251 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
252 h = 0.22717784590367374
947
99850ac883d1 Fixed whoosh daemon, for depracated walk method
Marcin Kuzminski <marcin@python-works.com>
parents: 946
diff changeset
253
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
254 for c in xrange(n):
450
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
255 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
256 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
257 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
258 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
259 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
260
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
261 cgenerator = gen_color()
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
262
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
263 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
264 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
265 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
266 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
267 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
268 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
269
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
270 def url_func(changeset):
450
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
271 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
272 " %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
273
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
274 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
275 changeset.date,
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
276 tooltip(changeset.message))
662
373ee7031003 fixed annotation bug, added history to annotation.
Marcin Kuzminski <marcin@python-works.com>
parents: 660
diff changeset
277 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
278 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
279 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
280 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
281 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
282 revision=changeset.raw_id),
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 635
diff changeset
283 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
284 class_='tooltip',
904
82aaf4e71817 reimplemented tooltip, refactored tooltip_title into title for proper html,
Marcin Kuzminski <marcin@python-works.com>
parents: 899
diff changeset
285 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
286 )
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
287
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
288 uri += '\n'
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
289 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
290 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
291
260
6ada8c223374 made global funcion to clean repo names, and remove all special chars from the name.
Marcin Kuzminski <marcin@python-works.com>
parents: 250
diff changeset
292 def repo_name_slug(value):
481
4187d93c7c04 reimplemented name slug to accept capitalized repositories names
Marcin Kuzminski <marcin@python-works.com>
parents: 450
diff changeset
293 """Return slug of name of repository
4187d93c7c04 reimplemented name slug to accept capitalized repositories names
Marcin Kuzminski <marcin@python-works.com>
parents: 450
diff changeset
294 This function is called on each creation/modification
4187d93c7c04 reimplemented name slug to accept capitalized repositories names
Marcin Kuzminski <marcin@python-works.com>
parents: 450
diff changeset
295 of repository to prevent bad names in repo
260
6ada8c223374 made global funcion to clean repo names, and remove all special chars from the name.
Marcin Kuzminski <marcin@python-works.com>
parents: 250
diff changeset
296 """
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
297
481
4187d93c7c04 reimplemented name slug to accept capitalized repositories names
Marcin Kuzminski <marcin@python-works.com>
parents: 450
diff changeset
298 slug = remove_formatting(value)
4187d93c7c04 reimplemented name slug to accept capitalized repositories names
Marcin Kuzminski <marcin@python-works.com>
parents: 450
diff changeset
299 slug = strip_tags(slug)
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
300
481
4187d93c7c04 reimplemented name slug to accept capitalized repositories names
Marcin Kuzminski <marcin@python-works.com>
parents: 450
diff changeset
301 for c in """=[]\;'"<>,/~!@#$%^&*()+{}|: """:
260
6ada8c223374 made global funcion to clean repo names, and remove all special chars from the name.
Marcin Kuzminski <marcin@python-works.com>
parents: 250
diff changeset
302 slug = slug.replace(c, '-')
6ada8c223374 made global funcion to clean repo names, and remove all special chars from the name.
Marcin Kuzminski <marcin@python-works.com>
parents: 250
diff changeset
303 slug = recursive_replace(slug, '-')
481
4187d93c7c04 reimplemented name slug to accept capitalized repositories names
Marcin Kuzminski <marcin@python-works.com>
parents: 450
diff changeset
304 slug = collapse(slug, '-')
260
6ada8c223374 made global funcion to clean repo names, and remove all special chars from the name.
Marcin Kuzminski <marcin@python-works.com>
parents: 250
diff changeset
305 return slug
281
cd2ee462fc2c implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents: 278
diff changeset
306
450
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
307 def get_changeset_safe(repo, rev):
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
308 from vcs.backends.base import BaseRepository
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
309 from vcs.exceptions import RepositoryError
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
310 if not isinstance(repo, BaseRepository):
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
311 raise Exception('You must pass an Repository '
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
312 '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
313
450
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
314 try:
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
315 cs = repo.get_changeset(rev)
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
316 except RepositoryError:
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 512
diff changeset
317 from rhodecode.lib.utils import EmptyChangeset
450
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
318 cs = EmptyChangeset()
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
319 return cs
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
320
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
321
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
322 flash = _Flash()
282
237470e64bb8 switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents: 281
diff changeset
323
237470e64bb8 switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents: 281
diff changeset
324
635
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
325 #==============================================================================
282
237470e64bb8 switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents: 281
diff changeset
326 # 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
327 #==============================================================================
282
237470e64bb8 switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents: 281
diff changeset
328 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
329 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
330
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
331 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
332 """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
333
643
9dc1d92d82ed updated setup for all newest versions
Marcin Kuzminski <marcin@python-works.com>
parents: 636
diff changeset
334 if not curdate:
9dc1d92d82ed updated setup for all newest versions
Marcin Kuzminski <marcin@python-works.com>
parents: 636
diff changeset
335 return ''
282
237470e64bb8 switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents: 281
diff changeset
336
635
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
337 from datetime import timedelta, datetime
643
9dc1d92d82ed updated setup for all newest versions
Marcin Kuzminski <marcin@python-works.com>
parents: 636
diff changeset
338
635
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
339 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
340 ("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
341 ("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
342 ("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
343 ("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
344 ("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
345
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
346 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
347 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
348 pos = 1
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
349 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
350 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
351 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
352 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
353 pos += 1
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
354
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
355 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
356
635
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
357 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
358 capitalize = lambda x: x.capitalize()
237470e64bb8 switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents: 281
diff changeset
359 email = util.email
401
b1debb6c5a09 implemented gravatars to changesets, updated styling for changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 400
diff changeset
360 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
361 person = lambda x: _person(x)
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 635
diff changeset
362 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
363
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
364
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
365 def bool2icon(value):
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
366 """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
367 icons
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
368
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
369 :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
370 """
131c1e335fa7 Added ldap info on admin users, added bool2icon helper for nicer representation of
Marcin Kuzminski <marcin@python-works.com>
parents: 698
diff changeset
371
131c1e335fa7 Added ldap info on admin users, added bool2icon helper for nicer representation of
Marcin Kuzminski <marcin@python-works.com>
parents: 698
diff changeset
372 if value is True:
714
e002951ba66d html w3c fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 712
diff changeset
373 return HTML.tag('img', src="/images/icons/accept.png", 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
374
131c1e335fa7 Added ldap info on admin users, added bool2icon helper for nicer representation of
Marcin Kuzminski <marcin@python-works.com>
parents: 698
diff changeset
375 if value is False:
714
e002951ba66d html w3c fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 712
diff changeset
376 return HTML.tag('img', src="/images/icons/cancel.png", 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
377
131c1e335fa7 Added ldap info on admin users, added bool2icon helper for nicer representation of
Marcin Kuzminski <marcin@python-works.com>
parents: 698
diff changeset
378 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
379
131c1e335fa7 Added ldap info on admin users, added bool2icon helper for nicer representation of
Marcin Kuzminski <marcin@python-works.com>
parents: 698
diff changeset
380
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
381 def action_parser(user_log):
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
382 """This helper will 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
383 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
384
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
385 :param user_log: user log instance
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
386 """
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
387
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
388 action = user_log.action
840
ee6f345736a6 action logger upgrade, for working with migrations
Marcin Kuzminski <marcin@python-works.com>
parents: 817
diff changeset
389 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
390
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
391 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
392
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
393 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
394 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
395
718
7df3855bf6c7 Added fork name to journal
Marcin Kuzminski <marcin@python-works.com>
parents: 714
diff changeset
396 def get_cs_links():
7df3855bf6c7 Added fork name to journal
Marcin Kuzminski <marcin@python-works.com>
parents: 714
diff changeset
397 if action == 'push':
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
398 revs_limit = 5 #display this amount always
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
399 revs_top_limit = 50 #show upto this amount of changesets hidden
718
7df3855bf6c7 Added fork name to journal
Marcin Kuzminski <marcin@python-works.com>
parents: 714
diff changeset
400 revs = action_params.split(',')
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
401 repo_name = user_log.repository.repo_name
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
402 from rhodecode.model.scm import ScmModel
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
403
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
404 message = lambda rev: get_changeset_safe(ScmModel().get(repo_name),
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
405 rev).message
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
406
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
407 cs_links = " " + ', '.join ([link_to(rev,
718
7df3855bf6c7 Added fork name to journal
Marcin Kuzminski <marcin@python-works.com>
parents: 714
diff changeset
408 url('changeset_home',
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
409 repo_name=repo_name,
911
435882d9e3bf added wrapping into journal tooltips
Marcin Kuzminski <marcin@python-works.com>
parents: 905
diff changeset
410 revision=rev), title=tooltip(message(rev)),
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
411 class_='tooltip') for rev in revs[:revs_limit] ])
718
7df3855bf6c7 Added fork name to journal
Marcin Kuzminski <marcin@python-works.com>
parents: 714
diff changeset
412 if len(revs) > revs_limit:
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
413 uniq_id = revs[0]
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
414 html_tmpl = ('<span> %s '
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
415 '<a class="show_more" id="_%s" href="#">%s</a> '
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
416 '%s</span>')
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
417 cs_links += html_tmpl % (_('and'), uniq_id, _('%s more') \
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
418 % (len(revs) - revs_limit),
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
419 _('revisions'))
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
420
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
421 html_tmpl = '<span id="%s" style="display:none"> %s </span>'
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
422 cs_links += html_tmpl % (uniq_id, ', '.join([link_to(rev,
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
423 url('changeset_home',
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
424 repo_name=repo_name, revision=rev),
904
82aaf4e71817 reimplemented tooltip, refactored tooltip_title into title for proper html,
Marcin Kuzminski <marcin@python-works.com>
parents: 899
diff changeset
425 title=message(rev), class_='tooltip')
899
d65843e07d3c Added message tooltip into journal revisions in push.
Marcin Kuzminski <marcin@python-works.com>
parents: 864
diff changeset
426 for rev in revs[revs_limit:revs_top_limit]]))
734
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
427
790
0142dac6f3c7 fixed journal helper, little test update,
Marcin Kuzminski <marcin@python-works.com>
parents: 788
diff changeset
428 return cs_links
718
7df3855bf6c7 Added fork name to journal
Marcin Kuzminski <marcin@python-works.com>
parents: 714
diff changeset
429 return ''
734
49eb69d78988 implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents: 718
diff changeset
430
718
7df3855bf6c7 Added fork name to journal
Marcin Kuzminski <marcin@python-works.com>
parents: 714
diff changeset
431 def get_fork_name():
7df3855bf6c7 Added fork name to journal
Marcin Kuzminski <marcin@python-works.com>
parents: 714
diff changeset
432 if action == 'user_forked_repo':
7df3855bf6c7 Added fork name to journal
Marcin Kuzminski <marcin@python-works.com>
parents: 714
diff changeset
433 from rhodecode.model.scm import ScmModel
7df3855bf6c7 Added fork name to journal
Marcin Kuzminski <marcin@python-works.com>
parents: 714
diff changeset
434 repo_name = action_params
7df3855bf6c7 Added fork name to journal
Marcin Kuzminski <marcin@python-works.com>
parents: 714
diff changeset
435 repo = ScmModel().get(repo_name)
7df3855bf6c7 Added fork name to journal
Marcin Kuzminski <marcin@python-works.com>
parents: 714
diff changeset
436 if repo is None:
7df3855bf6c7 Added fork name to journal
Marcin Kuzminski <marcin@python-works.com>
parents: 714
diff changeset
437 return repo_name
7df3855bf6c7 Added fork name to journal
Marcin Kuzminski <marcin@python-works.com>
parents: 714
diff changeset
438 return link_to(action_params, url('summary_home',
7df3855bf6c7 Added fork name to journal
Marcin Kuzminski <marcin@python-works.com>
parents: 714
diff changeset
439 repo_name=repo.name,),
7df3855bf6c7 Added fork name to journal
Marcin Kuzminski <marcin@python-works.com>
parents: 714
diff changeset
440 title=repo.dbrepo.description)
7df3855bf6c7 Added fork name to journal
Marcin Kuzminski <marcin@python-works.com>
parents: 714
diff changeset
441 return ''
764
5c87d5ad1b5e some stylings to journal
Marcin Kuzminski <marcin@python-works.com>
parents: 740
diff changeset
442 map = {'user_deleted_repo':_('User [deleted] repository'),
5c87d5ad1b5e some stylings to journal
Marcin Kuzminski <marcin@python-works.com>
parents: 740
diff changeset
443 'user_created_repo':_('User [created] repository'),
790
0142dac6f3c7 fixed journal helper, little test update,
Marcin Kuzminski <marcin@python-works.com>
parents: 788
diff changeset
444 'user_forked_repo':_('User [forked] repository as: %s') % get_fork_name(),
764
5c87d5ad1b5e some stylings to journal
Marcin Kuzminski <marcin@python-works.com>
parents: 740
diff changeset
445 'user_updated_repo':_('User [updated] repository'),
5c87d5ad1b5e some stylings to journal
Marcin Kuzminski <marcin@python-works.com>
parents: 740
diff changeset
446 'admin_deleted_repo':_('Admin [delete] repository'),
5c87d5ad1b5e some stylings to journal
Marcin Kuzminski <marcin@python-works.com>
parents: 740
diff changeset
447 'admin_created_repo':_('Admin [created] repository'),
5c87d5ad1b5e some stylings to journal
Marcin Kuzminski <marcin@python-works.com>
parents: 740
diff changeset
448 'admin_forked_repo':_('Admin [forked] repository'),
5c87d5ad1b5e some stylings to journal
Marcin Kuzminski <marcin@python-works.com>
parents: 740
diff changeset
449 'admin_updated_repo':_('Admin [updated] repository'),
790
0142dac6f3c7 fixed journal helper, little test update,
Marcin Kuzminski <marcin@python-works.com>
parents: 788
diff changeset
450 'push':_('[Pushed] %s') % get_cs_links(),
788
873611d6ff71 css update for journal
Marcin Kuzminski <marcin@python-works.com>
parents: 764
diff changeset
451 'pull':_('[Pulled]'),
764
5c87d5ad1b5e some stylings to journal
Marcin Kuzminski <marcin@python-works.com>
parents: 740
diff changeset
452 'started_following_repo':_('User [started following] repository'),
5c87d5ad1b5e some stylings to journal
Marcin Kuzminski <marcin@python-works.com>
parents: 740
diff changeset
453 'stopped_following_repo':_('User [stopped following] repository'),
735
dbec976d9975 added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents: 734
diff changeset
454 }
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
455
764
5c87d5ad1b5e some stylings to journal
Marcin Kuzminski <marcin@python-works.com>
parents: 740
diff changeset
456 action_str = map.get(action, action)
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
457 return literal(action_str.replace('[', '<span class="journal_highlight">')\
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
458 .replace(']', '</span>'))
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
459
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
460 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
461 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
462 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
463 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
464
1af15d66838f added icons to journal, extend show more to actually show more pushed revisions,
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
465 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
466 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
467
817
09e58532d4f7 fixed some w3c html
Marcin Kuzminski <marcin@python-works.com>
parents: 808
diff changeset
468 tmpl = """<img src="/images/icons/%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
469 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
470 '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
471 '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
472 '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
473 '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
474 '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
475 '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
476 '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
477 '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
478 '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
479 '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
480 '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
481 }
817
09e58532d4f7 fixed some w3c html
Marcin Kuzminski <marcin@python-works.com>
parents: 808
diff changeset
482 return literal(tmpl % (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
483
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
484
635
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
485 #==============================================================================
307
504feff57b49 added permission functions to webhelpers, updated dbmanage permissions
Marcin Kuzminski <marcin@python-works.com>
parents: 293
diff changeset
486 # PERMS
635
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
487 #==============================================================================
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 512
diff changeset
488 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
489 HasRepoPermissionAny, HasRepoPermissionAll
282
237470e64bb8 switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents: 281
diff changeset
490
635
fd63782c4426 Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents: 631
diff changeset
491 #==============================================================================
398
8c50b164fb58 Implemented basic gravatar support on admin pages only for now
Marcin Kuzminski <marcin@python-works.com>
parents: 307
diff changeset
492 # 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
493 #==============================================================================
398
8c50b164fb58 Implemented basic gravatar support on admin pages only for now
Marcin Kuzminski <marcin@python-works.com>
parents: 307
diff changeset
494 import hashlib
8c50b164fb58 Implemented basic gravatar support on admin pages only for now
Marcin Kuzminski <marcin@python-works.com>
parents: 307
diff changeset
495 import urllib
400
7eba3d1e4227 webhelpers import bugfix for gravatar
Marcin Kuzminski <marcin@python-works.com>
parents: 398
diff changeset
496 from pylons import request
282
237470e64bb8 switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents: 281
diff changeset
497
401
b1debb6c5a09 implemented gravatars to changesets, updated styling for changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 400
diff changeset
498 def gravatar_url(email_address, size=30):
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
499 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
500 default = 'identicon'
8c50b164fb58 Implemented basic gravatar support on admin pages only for now
Marcin Kuzminski <marcin@python-works.com>
parents: 307
diff changeset
501 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
502 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
503 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
504
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
505
398
8c50b164fb58 Implemented basic gravatar support on admin pages only for now
Marcin Kuzminski <marcin@python-works.com>
parents: 307
diff changeset
506 # construct the url
401
b1debb6c5a09 implemented gravatars to changesets, updated styling for changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 400
diff changeset
507 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
508 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
509
8c50b164fb58 Implemented basic gravatar support on admin pages only for now
Marcin Kuzminski <marcin@python-works.com>
parents: 307
diff changeset
510 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
511
e5157e2a530e added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents: 438
diff changeset
512 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
513 """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
514 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
515 string_escape decoding """
631
05528ad948c4 Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
516
443
e5157e2a530e added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents: 438
diff changeset
517 try:
e5157e2a530e added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents: 438
diff changeset
518 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
519 except UnicodeDecodeError:
e5157e2a530e added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents: 438
diff changeset
520 try:
e5157e2a530e added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents: 438
diff changeset
521 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
522 except UnicodeDecodeError:
e5157e2a530e added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents: 438
diff changeset
523 #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
524 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
525
450
c3236d7febad fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 448
diff changeset
526 return u_str