Mercurial > public > src > rhodecode
annotate pylons_app/lib/helpers.py @ 491:c3236d7febad
fixed, empty cs bug.
Implemented as webhlepers function
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 03 Sep 2010 09:55:48 +0200 |
parents | 4679105ef03e |
children | 4187d93c7c04 |
rev | line source |
---|---|
0 | 1 """Helper functions |
2 | |
3 Consists of functions to typically be used within templates, but also | |
4 available to Controllers. This module is available to both as 'h'. | |
5 """ | |
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
|
6 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
|
7 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
|
8 from pylons import url, app_globals as g |
97
be0096a02772
added helper for filesize
Marcin Kuzminski <marcin@python-works.com>
parents:
94
diff
changeset
|
9 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
|
10 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
|
11 from webhelpers.html import literal, HTML, escape |
288
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
12 from webhelpers.html.tools import * |
98
01d0f363f36d
added pygments webhelper
Marcin Kuzminski <marcin@python-works.com>
parents:
97
diff
changeset
|
13 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
|
14 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
|
15 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
|
16 link_to_unless, ol, required_legend, select, stylesheet_link, submit, text, \ |
288
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
17 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
|
18 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
|
19 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
|
20 from webhelpers.number import format_byte_size, format_bit_size |
0 | 21 from webhelpers.pylonslib import Flash as _Flash |
22 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
|
23 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
|
24 convert_misc_entities, lchop, plural, rchop, remove_formatting, \ |
288
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
25 replace_whitespace, urlify, truncate, wrap_paragraphs |
0 | 26 |
288
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
27 #Custom helpers here :) |
0 | 28 class _Link(object): |
29 ''' | |
30 Make a url based on label and url with help of url_for | |
31 @param label:name of link if not defined url is used | |
32 @param url: the url for link | |
33 ''' | |
34 | |
43 | 35 def __call__(self, label='', *url_, **urlargs): |
0 | 36 if label is None or '': |
37 label = url | |
43 | 38 link_fn = link_to(label, url(*url_, **urlargs)) |
0 | 39 return link_fn |
40 | |
288
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
41 link = _Link() |
0 | 42 |
43 class _GetError(object): | |
44 | |
45 def __call__(self, field_name, form_errors): | |
46 tmpl = """<span class="error_msg">%s</span>""" | |
47 if form_errors and form_errors.has_key(field_name): | |
48 return literal(tmpl % form_errors.get(field_name)) | |
49 | |
288
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
50 get_error = _GetError() |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
51 |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
52 def recursive_replace(str, replace=' '): |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
53 """ |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
54 Recursive replace of given sign to just one instance |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
55 @param str: given string |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
56 @param replace:char to find and replace multiple instances |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
57 |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
58 Examples:: |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
59 >>> 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:
284
diff
changeset
|
60 'Mighty-Mighty-Bo-sstones' |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
61 """ |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
62 |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
63 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:
284
diff
changeset
|
64 return str |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
65 else: |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
66 str = str.replace(replace * 2, replace) |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
67 return recursive_replace(str, replace) |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
68 |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
69 class _ToolTip(object): |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
70 |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
71 def __call__(self, tooltip_title, trim_at=50): |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
72 """ |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
73 Special function just to wrap our text into nice formatted autowrapped |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
74 text |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
75 @param tooltip_title: |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
76 """ |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
77 |
483
0668919c307c
fixed escaping in tooltip
Marcin Kuzminski <marcin@python-works.com>
parents:
482
diff
changeset
|
78 return wrap_paragraphs(escape(tooltip_title), trim_at)\ |
0668919c307c
fixed escaping in tooltip
Marcin Kuzminski <marcin@python-works.com>
parents:
482
diff
changeset
|
79 .replace('\n', '<br/>') |
288
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
80 |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
81 def activate(self): |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
82 """ |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
83 Adds tooltip mechanism to the given Html all tooltips have to have |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
84 set class tooltip and set attribute tooltip_title. |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
85 Then a tooltip will be generated based on that |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
86 All with yui js tooltip |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
87 """ |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
88 |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
89 js = ''' |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
90 YAHOO.util.Event.onDOMReady(function(){ |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
91 function toolTipsId(){ |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
92 var ids = []; |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
93 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:
284
diff
changeset
|
94 |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
95 for (var i = 0; i < tts.length; i++) { |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
96 //if element doesn not have and id autgenerate one for tooltip |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
97 |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
98 if (!tts[i].id){ |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
99 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:
284
diff
changeset
|
100 } |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
101 ids.push(tts[i].id); |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
102 } |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
103 return ids |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
104 }; |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
105 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:
284
diff
changeset
|
106 context: toolTipsId(), |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
107 monitorresize:false, |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
108 xyoffset :[0,0], |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
109 autodismissdelay:300000, |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
110 hidedelay:5, |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
111 showdelay:20, |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
112 }); |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
113 |
292
c4caeca9dd66
fixed paragraphs wrapping for ultralong commit messages. Disabled tooltips for new repos without a last commit message. ie. when tooltip_title is empty (there is a strange bug on empty tooltip_title)
Marcin Kuzminski <marcin@python-works.com>
parents:
289
diff
changeset
|
114 //Mouse Over event disabled for new repositories since they dont |
c4caeca9dd66
fixed paragraphs wrapping for ultralong commit messages. Disabled tooltips for new repos without a last commit message. ie. when tooltip_title is empty (there is a strange bug on empty tooltip_title)
Marcin Kuzminski <marcin@python-works.com>
parents:
289
diff
changeset
|
115 //have last commit message |
288
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
116 myToolTips.contextMouseOverEvent.subscribe( |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
117 function(type, args) { |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
118 var context = args[0]; |
292
c4caeca9dd66
fixed paragraphs wrapping for ultralong commit messages. Disabled tooltips for new repos without a last commit message. ie. when tooltip_title is empty (there is a strange bug on empty tooltip_title)
Marcin Kuzminski <marcin@python-works.com>
parents:
289
diff
changeset
|
119 var txt = context.getAttribute('tooltip_title'); |
303
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
120 if(txt){ |
292
c4caeca9dd66
fixed paragraphs wrapping for ultralong commit messages. Disabled tooltips for new repos without a last commit message. ie. when tooltip_title is empty (there is a strange bug on empty tooltip_title)
Marcin Kuzminski <marcin@python-works.com>
parents:
289
diff
changeset
|
121 return true; |
c4caeca9dd66
fixed paragraphs wrapping for ultralong commit messages. Disabled tooltips for new repos without a last commit message. ie. when tooltip_title is empty (there is a strange bug on empty tooltip_title)
Marcin Kuzminski <marcin@python-works.com>
parents:
289
diff
changeset
|
122 } |
c4caeca9dd66
fixed paragraphs wrapping for ultralong commit messages. Disabled tooltips for new repos without a last commit message. ie. when tooltip_title is empty (there is a strange bug on empty tooltip_title)
Marcin Kuzminski <marcin@python-works.com>
parents:
289
diff
changeset
|
123 else{ |
c4caeca9dd66
fixed paragraphs wrapping for ultralong commit messages. Disabled tooltips for new repos without a last commit message. ie. when tooltip_title is empty (there is a strange bug on empty tooltip_title)
Marcin Kuzminski <marcin@python-works.com>
parents:
289
diff
changeset
|
124 return false; |
c4caeca9dd66
fixed paragraphs wrapping for ultralong commit messages. Disabled tooltips for new repos without a last commit message. ie. when tooltip_title is empty (there is a strange bug on empty tooltip_title)
Marcin Kuzminski <marcin@python-works.com>
parents:
289
diff
changeset
|
125 } |
288
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
126 }); |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
127 |
296
6603c9891b91
tooltip display bugfix
Marcin Kuzminski <marcin@python-works.com>
parents:
292
diff
changeset
|
128 |
288
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
129 // 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:
284
diff
changeset
|
130 myToolTips.contextTriggerEvent.subscribe( |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
131 function(type, args) { |
303
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
132 |
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
133 |
288
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
134 var context = args[0]; |
303
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
135 |
288
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
136 var txt = context.getAttribute('tooltip_title'); |
296
6603c9891b91
tooltip display bugfix
Marcin Kuzminski <marcin@python-works.com>
parents:
292
diff
changeset
|
137 this.cfg.setProperty("text", txt); |
303
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
138 |
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
139 |
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
140 // positioning of tooltip |
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
141 var tt_w = this.element.clientWidth; |
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
142 var tt_h = this.element.clientHeight; |
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
143 |
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
144 var context_w = context.offsetWidth; |
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
145 var context_h = context.offsetHeight; |
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
146 |
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
147 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:
297
diff
changeset
|
148 var pos_y = YAHOO.util.Dom.getY(context); |
296
6603c9891b91
tooltip display bugfix
Marcin Kuzminski <marcin@python-works.com>
parents:
292
diff
changeset
|
149 |
303
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
150 var display_strategy = 'top'; |
305
68dc70295a76
Ie graph support.
Marcin Kuzminski <marcin@python-works.com>
parents:
303
diff
changeset
|
151 var xy_pos = [0,0]; |
303
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
152 switch (display_strategy){ |
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
153 |
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
154 case 'top': |
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
155 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:
297
diff
changeset
|
156 var cur_y = pos_y-tt_h-4; |
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
157 xy_pos = [cur_x,cur_y]; |
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
158 break; |
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
159 case 'bottom': |
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
160 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:
297
diff
changeset
|
161 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:
297
diff
changeset
|
162 xy_pos = [cur_x,cur_y]; |
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
163 break; |
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
164 case 'left': |
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
165 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:
297
diff
changeset
|
166 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:
297
diff
changeset
|
167 xy_pos = [cur_x,cur_y]; |
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
168 break; |
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
169 case 'right': |
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
170 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:
297
diff
changeset
|
171 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:
297
diff
changeset
|
172 xy_pos = [cur_x,cur_y]; |
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
173 break; |
305
68dc70295a76
Ie graph support.
Marcin Kuzminski <marcin@python-works.com>
parents:
303
diff
changeset
|
174 default: |
68dc70295a76
Ie graph support.
Marcin Kuzminski <marcin@python-works.com>
parents:
303
diff
changeset
|
175 var cur_x = (pos_x+context_w/2)-(tt_w/2); |
68dc70295a76
Ie graph support.
Marcin Kuzminski <marcin@python-works.com>
parents:
303
diff
changeset
|
176 var cur_y = pos_y-tt_h-4; |
68dc70295a76
Ie graph support.
Marcin Kuzminski <marcin@python-works.com>
parents:
303
diff
changeset
|
177 xy_pos = [cur_x,cur_y]; |
68dc70295a76
Ie graph support.
Marcin Kuzminski <marcin@python-works.com>
parents:
303
diff
changeset
|
178 break; |
68dc70295a76
Ie graph support.
Marcin Kuzminski <marcin@python-works.com>
parents:
303
diff
changeset
|
179 |
303
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
180 } |
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
181 |
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
182 this.cfg.setProperty("xy",xy_pos); |
296
6603c9891b91
tooltip display bugfix
Marcin Kuzminski <marcin@python-works.com>
parents:
292
diff
changeset
|
183 |
288
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
184 }); |
303
d7aeae23c56d
tooltip updates, added display layout managment inspired by jQuerys tipsy.
Marcin Kuzminski <marcin@python-works.com>
parents:
297
diff
changeset
|
185 |
296
6603c9891b91
tooltip display bugfix
Marcin Kuzminski <marcin@python-works.com>
parents:
292
diff
changeset
|
186 //Mouse out |
6603c9891b91
tooltip display bugfix
Marcin Kuzminski <marcin@python-works.com>
parents:
292
diff
changeset
|
187 myToolTips.contextMouseOutEvent.subscribe( |
6603c9891b91
tooltip display bugfix
Marcin Kuzminski <marcin@python-works.com>
parents:
292
diff
changeset
|
188 function(type, args) { |
6603c9891b91
tooltip display bugfix
Marcin Kuzminski <marcin@python-works.com>
parents:
292
diff
changeset
|
189 var context = args[0]; |
6603c9891b91
tooltip display bugfix
Marcin Kuzminski <marcin@python-works.com>
parents:
292
diff
changeset
|
190 |
6603c9891b91
tooltip display bugfix
Marcin Kuzminski <marcin@python-works.com>
parents:
292
diff
changeset
|
191 }); |
288
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
192 }); |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
193 ''' |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
194 return literal(js) |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
195 |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
196 tooltip = _ToolTip() |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
197 |
102
2dc0c8e4f384
Updated tempaltes, added file browser breadcrumbs, and feed icons
Marcin Kuzminski <marcin@python-works.com>
parents:
98
diff
changeset
|
198 class _FilesBreadCrumbs(object): |
2dc0c8e4f384
Updated tempaltes, added file browser breadcrumbs, and feed icons
Marcin Kuzminski <marcin@python-works.com>
parents:
98
diff
changeset
|
199 |
2dc0c8e4f384
Updated tempaltes, added file browser breadcrumbs, and feed icons
Marcin Kuzminski <marcin@python-works.com>
parents:
98
diff
changeset
|
200 def __call__(self, repo_name, rev, paths): |
297
5827c739b0bd
webhelpers breadcrumbs bugfix
Marcin Kuzminski <marcin@python-works.com>
parents:
296
diff
changeset
|
201 url_l = [link_to(repo_name, url('files_home', |
5827c739b0bd
webhelpers breadcrumbs bugfix
Marcin Kuzminski <marcin@python-works.com>
parents:
296
diff
changeset
|
202 repo_name=repo_name, |
5827c739b0bd
webhelpers breadcrumbs bugfix
Marcin Kuzminski <marcin@python-works.com>
parents:
296
diff
changeset
|
203 revision=rev, f_path=''))] |
5827c739b0bd
webhelpers breadcrumbs bugfix
Marcin Kuzminski <marcin@python-works.com>
parents:
296
diff
changeset
|
204 paths_l = paths.split('/') |
102
2dc0c8e4f384
Updated tempaltes, added file browser breadcrumbs, and feed icons
Marcin Kuzminski <marcin@python-works.com>
parents:
98
diff
changeset
|
205 |
2dc0c8e4f384
Updated tempaltes, added file browser breadcrumbs, and feed icons
Marcin Kuzminski <marcin@python-works.com>
parents:
98
diff
changeset
|
206 for cnt, p in enumerate(paths_l, 1): |
2dc0c8e4f384
Updated tempaltes, added file browser breadcrumbs, and feed icons
Marcin Kuzminski <marcin@python-works.com>
parents:
98
diff
changeset
|
207 if p != '': |
297
5827c739b0bd
webhelpers breadcrumbs bugfix
Marcin Kuzminski <marcin@python-works.com>
parents:
296
diff
changeset
|
208 url_l.append(link_to(p, url('files_home', |
5827c739b0bd
webhelpers breadcrumbs bugfix
Marcin Kuzminski <marcin@python-works.com>
parents:
296
diff
changeset
|
209 repo_name=repo_name, |
5827c739b0bd
webhelpers breadcrumbs bugfix
Marcin Kuzminski <marcin@python-works.com>
parents:
296
diff
changeset
|
210 revision=rev, |
5827c739b0bd
webhelpers breadcrumbs bugfix
Marcin Kuzminski <marcin@python-works.com>
parents:
296
diff
changeset
|
211 f_path='/'.join(paths_l[:cnt])))) |
97
be0096a02772
added helper for filesize
Marcin Kuzminski <marcin@python-works.com>
parents:
94
diff
changeset
|
212 |
488
4679105ef03e
more css html fixes (+cleanups), rewrote definition list for files
Marcin Kuzminski <marcin@python-works.com>
parents:
483
diff
changeset
|
213 return literal('/'.join(url_l)) |
98
01d0f363f36d
added pygments webhelper
Marcin Kuzminski <marcin@python-works.com>
parents:
97
diff
changeset
|
214 |
288
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
215 files_breadcrumbs = _FilesBreadCrumbs() |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
216 |
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
|
217 def pygmentize(filenode, **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
|
218 """ |
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
|
219 pygmentize function using pygments |
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
|
220 @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
|
221 """ |
491
c3236d7febad
fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents:
488
diff
changeset
|
222 return literal(code_highlight(filenode.content, |
466
dee0e7eb0370
removed decodes, thus it should be implemented on vcs side
*** failed to import extension hggit: No module named hggit
parents:
434
diff
changeset
|
223 filenode.lexer, HtmlFormatter(**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
|
224 |
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
|
225 def pygmentize_annotation(filenode, **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
|
226 """ |
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
|
227 pygmentize function for annotation |
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 @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
|
229 """ |
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
|
230 |
476
0d4fceb91c9c
fixes #24, added generator that generates equally distrybuted colors. Thus skipping creating one large coloring history.
Marcin Kuzminski <marcin@python-works.com>
parents:
466
diff
changeset
|
231 color_dict = {} |
165
ea893ffb7f00
implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents:
104
diff
changeset
|
232 def gen_color(): |
476
0d4fceb91c9c
fixes #24, added generator that generates equally distrybuted colors. Thus skipping creating one large coloring history.
Marcin Kuzminski <marcin@python-works.com>
parents:
466
diff
changeset
|
233 """generator for getting 10k of evenly distibuted colors using hsv color |
0d4fceb91c9c
fixes #24, added generator that generates equally distrybuted colors. Thus skipping creating one large coloring history.
Marcin Kuzminski <marcin@python-works.com>
parents:
466
diff
changeset
|
234 and golden ratio. |
0d4fceb91c9c
fixes #24, added generator that generates equally distrybuted colors. Thus skipping creating one large coloring history.
Marcin Kuzminski <marcin@python-works.com>
parents:
466
diff
changeset
|
235 """ |
0d4fceb91c9c
fixes #24, added generator that generates equally distrybuted colors. Thus skipping creating one large coloring history.
Marcin Kuzminski <marcin@python-works.com>
parents:
466
diff
changeset
|
236 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:
466
diff
changeset
|
237 n = 10000 |
0d4fceb91c9c
fixes #24, added generator that generates equally distrybuted colors. Thus skipping creating one large coloring history.
Marcin Kuzminski <marcin@python-works.com>
parents:
466
diff
changeset
|
238 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:
466
diff
changeset
|
239 h = 0.22717784590367374 |
0d4fceb91c9c
fixes #24, added generator that generates equally distrybuted colors. Thus skipping creating one large coloring history.
Marcin Kuzminski <marcin@python-works.com>
parents:
466
diff
changeset
|
240 #generate 10k nice web friendly colors in the same order |
0d4fceb91c9c
fixes #24, added generator that generates equally distrybuted colors. Thus skipping creating one large coloring history.
Marcin Kuzminski <marcin@python-works.com>
parents:
466
diff
changeset
|
241 for c in xrange(n): |
491
c3236d7febad
fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents:
488
diff
changeset
|
242 h += golden_ratio |
476
0d4fceb91c9c
fixes #24, added generator that generates equally distrybuted colors. Thus skipping creating one large coloring history.
Marcin Kuzminski <marcin@python-works.com>
parents:
466
diff
changeset
|
243 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:
466
diff
changeset
|
244 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:
466
diff
changeset
|
245 RGB_tuple = colorsys.hsv_to_rgb(*HSV_tuple) |
491
c3236d7febad
fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents:
488
diff
changeset
|
246 yield map(lambda x:str(int(x * 256)), RGB_tuple) |
476
0d4fceb91c9c
fixes #24, added generator that generates equally distrybuted colors. Thus skipping creating one large coloring history.
Marcin Kuzminski <marcin@python-works.com>
parents:
466
diff
changeset
|
247 |
0d4fceb91c9c
fixes #24, added generator that generates equally distrybuted colors. Thus skipping creating one large coloring history.
Marcin Kuzminski <marcin@python-works.com>
parents:
466
diff
changeset
|
248 cgenerator = gen_color() |
0d4fceb91c9c
fixes #24, added generator that generates equally distrybuted colors. Thus skipping creating one large coloring history.
Marcin Kuzminski <marcin@python-works.com>
parents:
466
diff
changeset
|
249 |
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
|
250 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
|
251 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
|
252 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
|
253 else: |
476
0d4fceb91c9c
fixes #24, added generator that generates equally distrybuted colors. Thus skipping creating one large coloring history.
Marcin Kuzminski <marcin@python-works.com>
parents:
466
diff
changeset
|
254 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:
466
diff
changeset
|
255 return "color: rgb(%s)! important;" % (', '.join(col)) |
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
|
256 |
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
|
257 def url_func(changeset): |
491
c3236d7febad
fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents:
488
diff
changeset
|
258 tooltip_html = "<div style='font-size:0.8em'><b>Author:</b>" + \ |
466
dee0e7eb0370
removed decodes, thus it should be implemented on vcs side
*** failed to import extension hggit: No module named hggit
parents:
434
diff
changeset
|
259 " %s<br/><b>Date:</b> %s</b><br/><b>Message:</b> %s<br/></div>" |
288
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
260 |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
261 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:
284
diff
changeset
|
262 changeset.date, |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
263 tooltip(changeset.message)) |
476
0d4fceb91c9c
fixes #24, added generator that generates equally distrybuted colors. Thus skipping creating one large coloring history.
Marcin Kuzminski <marcin@python-works.com>
parents:
466
diff
changeset
|
264 lnk_format = 'r%-5s:%s' % (changeset.revision, |
288
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
265 changeset.raw_id) |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
266 uri = link_to( |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
267 lnk_format, |
466
dee0e7eb0370
removed decodes, thus it should be implemented on vcs side
*** failed to import extension hggit: No module named hggit
parents:
434
diff
changeset
|
268 url('changeset_home', repo_name=changeset.repository.name, |
288
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
269 revision=changeset.raw_id), |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
270 style=get_color_string(changeset.raw_id), |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
271 class_='tooltip', |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
272 tooltip_title=tooltip_html |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
273 ) |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
274 |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
275 uri += '\n' |
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
276 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
|
277 return literal(annotate_highlight(filenode, url_func, **kwargs)) |
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
|
278 |
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
|
279 def repo_name_slug(value): |
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
|
280 """ |
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
|
281 Return slug of name of repository |
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
|
282 """ |
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
|
283 slug = urlify(value) |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
260
diff
changeset
|
284 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
|
285 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
|
286 slug = recursive_replace(slug, '-') |
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
|
287 return slug |
288
cd2ee462fc2c
implemented yui tooltip, and added it into annotation and main page.
Marcin Kuzminski <marcin@python-works.com>
parents:
284
diff
changeset
|
288 |
491
c3236d7febad
fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents:
488
diff
changeset
|
289 def get_changeset_safe(repo, rev): |
c3236d7febad
fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents:
488
diff
changeset
|
290 from vcs.backends.base import BaseRepository |
c3236d7febad
fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents:
488
diff
changeset
|
291 from vcs.exceptions import RepositoryError |
c3236d7febad
fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents:
488
diff
changeset
|
292 if not isinstance(repo, BaseRepository): |
c3236d7febad
fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents:
488
diff
changeset
|
293 raise Exception('You must pass an Repository ' |
c3236d7febad
fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents:
488
diff
changeset
|
294 'object as first argument got %s', type(repo)) |
c3236d7febad
fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents:
488
diff
changeset
|
295 |
c3236d7febad
fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents:
488
diff
changeset
|
296 try: |
c3236d7febad
fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents:
488
diff
changeset
|
297 cs = repo.get_changeset(rev) |
c3236d7febad
fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents:
488
diff
changeset
|
298 except RepositoryError: |
c3236d7febad
fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents:
488
diff
changeset
|
299 from pylons_app.lib.utils import EmptyChangeset |
c3236d7febad
fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents:
488
diff
changeset
|
300 cs = EmptyChangeset() |
c3236d7febad
fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents:
488
diff
changeset
|
301 return cs |
c3236d7febad
fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents:
488
diff
changeset
|
302 |
c3236d7febad
fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents:
488
diff
changeset
|
303 |
0 | 304 flash = _Flash() |
289
237470e64bb8
switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents:
288
diff
changeset
|
305 |
237470e64bb8
switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents:
288
diff
changeset
|
306 |
237470e64bb8
switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents:
288
diff
changeset
|
307 #=============================================================================== |
237470e64bb8
switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents:
288
diff
changeset
|
308 # MERCURIAL FILTERS available via h. |
237470e64bb8
switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents:
288
diff
changeset
|
309 #=============================================================================== |
237470e64bb8
switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents:
288
diff
changeset
|
310 from mercurial import util |
237470e64bb8
switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents:
288
diff
changeset
|
311 from mercurial.templatefilters import age as _age, person as _person |
237470e64bb8
switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents:
288
diff
changeset
|
312 |
237470e64bb8
switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents:
288
diff
changeset
|
313 age = lambda x:_age(x) |
237470e64bb8
switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents:
288
diff
changeset
|
314 capitalize = lambda x: x.capitalize() |
237470e64bb8
switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents:
288
diff
changeset
|
315 date = lambda x: util.datestr(x) |
237470e64bb8
switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents:
288
diff
changeset
|
316 email = util.email |
434
b1debb6c5a09
implemented gravatars to changesets, updated styling for changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
433
diff
changeset
|
317 email_or_none = lambda x: util.email(x) if util.email(x) != x else None |
289
237470e64bb8
switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents:
288
diff
changeset
|
318 person = lambda x: _person(x) |
237470e64bb8
switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents:
288
diff
changeset
|
319 hgdate = lambda x: "%d %d" % x |
237470e64bb8
switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents:
288
diff
changeset
|
320 isodate = lambda x: util.datestr(x, '%Y-%m-%d %H:%M %1%2') |
237470e64bb8
switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents:
288
diff
changeset
|
321 isodatesec = lambda x: util.datestr(x, '%Y-%m-%d %H:%M:%S %1%2') |
237470e64bb8
switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents:
288
diff
changeset
|
322 localdate = lambda x: (x[0], util.makedate()[1]) |
237470e64bb8
switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents:
288
diff
changeset
|
323 rfc822date = lambda x: util.datestr(x, "%a, %d %b %Y %H:%M:%S %1%2") |
237470e64bb8
switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents:
288
diff
changeset
|
324 rfc3339date = lambda x: util.datestr(x, "%Y-%m-%dT%H:%M:%S%1:%2") |
237470e64bb8
switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents:
288
diff
changeset
|
325 time_ago = lambda x: util.datestr(_age(x), "%a, %d %b %Y %H:%M:%S %1%2") |
237470e64bb8
switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents:
288
diff
changeset
|
326 |
237470e64bb8
switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents:
288
diff
changeset
|
327 |
320
504feff57b49
added permission functions to webhelpers, updated dbmanage permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
305
diff
changeset
|
328 #=============================================================================== |
504feff57b49
added permission functions to webhelpers, updated dbmanage permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
305
diff
changeset
|
329 # PERMS |
504feff57b49
added permission functions to webhelpers, updated dbmanage permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
305
diff
changeset
|
330 #=============================================================================== |
504feff57b49
added permission functions to webhelpers, updated dbmanage permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
305
diff
changeset
|
331 from pylons_app.lib.auth import HasPermissionAny, HasPermissionAll, \ |
504feff57b49
added permission functions to webhelpers, updated dbmanage permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
305
diff
changeset
|
332 HasRepoPermissionAny, HasRepoPermissionAll |
289
237470e64bb8
switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents:
288
diff
changeset
|
333 |
431
8c50b164fb58
Implemented basic gravatar support on admin pages only for now
Marcin Kuzminski <marcin@python-works.com>
parents:
320
diff
changeset
|
334 #=============================================================================== |
8c50b164fb58
Implemented basic gravatar support on admin pages only for now
Marcin Kuzminski <marcin@python-works.com>
parents:
320
diff
changeset
|
335 # GRAVATAR URL |
8c50b164fb58
Implemented basic gravatar support on admin pages only for now
Marcin Kuzminski <marcin@python-works.com>
parents:
320
diff
changeset
|
336 #=============================================================================== |
8c50b164fb58
Implemented basic gravatar support on admin pages only for now
Marcin Kuzminski <marcin@python-works.com>
parents:
320
diff
changeset
|
337 import hashlib |
8c50b164fb58
Implemented basic gravatar support on admin pages only for now
Marcin Kuzminski <marcin@python-works.com>
parents:
320
diff
changeset
|
338 import urllib |
433
7eba3d1e4227
webhelpers import bugfix for gravatar
Marcin Kuzminski <marcin@python-works.com>
parents:
431
diff
changeset
|
339 from pylons import request |
289
237470e64bb8
switched filters into webhelpers for easy of usage.
Marcin Kuzminski <marcin@python-works.com>
parents:
288
diff
changeset
|
340 |
434
b1debb6c5a09
implemented gravatars to changesets, updated styling for changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
433
diff
changeset
|
341 def gravatar_url(email_address, size=30): |
431
8c50b164fb58
Implemented basic gravatar support on admin pages only for now
Marcin Kuzminski <marcin@python-works.com>
parents:
320
diff
changeset
|
342 ssl_enabled = 'https' == request.environ.get('HTTP_X_URL_SCHEME') |
8c50b164fb58
Implemented basic gravatar support on admin pages only for now
Marcin Kuzminski <marcin@python-works.com>
parents:
320
diff
changeset
|
343 default = 'identicon' |
8c50b164fb58
Implemented basic gravatar support on admin pages only for now
Marcin Kuzminski <marcin@python-works.com>
parents:
320
diff
changeset
|
344 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:
320
diff
changeset
|
345 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:
320
diff
changeset
|
346 baseurl = baseurl_ssl if ssl_enabled else baseurl_nossl |
8c50b164fb58
Implemented basic gravatar support on admin pages only for now
Marcin Kuzminski <marcin@python-works.com>
parents:
320
diff
changeset
|
347 |
8c50b164fb58
Implemented basic gravatar support on admin pages only for now
Marcin Kuzminski <marcin@python-works.com>
parents:
320
diff
changeset
|
348 |
8c50b164fb58
Implemented basic gravatar support on admin pages only for now
Marcin Kuzminski <marcin@python-works.com>
parents:
320
diff
changeset
|
349 # construct the url |
434
b1debb6c5a09
implemented gravatars to changesets, updated styling for changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
433
diff
changeset
|
350 gravatar_url = baseurl + hashlib.md5(email_address.lower()).hexdigest() + "?" |
431
8c50b164fb58
Implemented basic gravatar support on admin pages only for now
Marcin Kuzminski <marcin@python-works.com>
parents:
320
diff
changeset
|
351 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:
320
diff
changeset
|
352 |
8c50b164fb58
Implemented basic gravatar support on admin pages only for now
Marcin Kuzminski <marcin@python-works.com>
parents:
320
diff
changeset
|
353 return gravatar_url |
482
e5157e2a530e
added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents:
476
diff
changeset
|
354 |
e5157e2a530e
added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents:
476
diff
changeset
|
355 def safe_unicode(str): |
e5157e2a530e
added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents:
476
diff
changeset
|
356 """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:
476
diff
changeset
|
357 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:
476
diff
changeset
|
358 string_escape decoding """ |
e5157e2a530e
added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents:
476
diff
changeset
|
359 |
e5157e2a530e
added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents:
476
diff
changeset
|
360 try: |
e5157e2a530e
added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents:
476
diff
changeset
|
361 u_str = unicode(str) |
e5157e2a530e
added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents:
476
diff
changeset
|
362 except UnicodeDecodeError: |
e5157e2a530e
added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents:
476
diff
changeset
|
363 try: |
e5157e2a530e
added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents:
476
diff
changeset
|
364 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:
476
diff
changeset
|
365 except UnicodeDecodeError: |
e5157e2a530e
added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents:
476
diff
changeset
|
366 #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:
476
diff
changeset
|
367 u_str = unicode(str(str).encode('string_escape')) |
e5157e2a530e
added safe unicode funtion, and implemented it in whoosh indexer
Marcin Kuzminski <marcin@python-works.com>
parents:
476
diff
changeset
|
368 |
491
c3236d7febad
fixed, empty cs bug.
Marcin Kuzminski <marcin@python-works.com>
parents:
488
diff
changeset
|
369 return u_str |