Show More
@@ -27,7 +27,7 b' from pylons import request, response, se' | |||
|
27 | 27 | from pylons.controllers.util import redirect |
|
28 | 28 | from pylons_app.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator |
|
29 | 29 | from pylons_app.lib.base import BaseController, render |
|
30 |
from pylons_app.lib.utils import EmptyChangeset |
|
|
30 | from pylons_app.lib.utils import EmptyChangeset | |
|
31 | 31 | from pylons_app.model.hg_model import HgModel |
|
32 | 32 | from vcs.exceptions import RepositoryError, ChangesetError |
|
33 | 33 | from vcs.nodes import FileNode |
@@ -17,9 +17,7 b' class Globals(object):' | |||
|
17 | 17 | |
|
18 | 18 | """ |
|
19 | 19 | self.cache = CacheManager(**parse_cache_config_options(config)) |
|
20 | self.changeset_annotation_colors = {} | |
|
21 | 20 | self.available_permissions = None # propagated after init_model |
|
22 | self.app_title = None # propagated after init_model | |
|
23 | 21 | self.baseui = None # propagated after init_model |
|
24 | 22 | |
|
25 | 23 | @LazyProperty |
@@ -24,7 +24,6 b' from webhelpers.text import chop_at, col' | |||
|
24 | 24 | convert_misc_entities, lchop, plural, rchop, remove_formatting, \ |
|
25 | 25 | replace_whitespace, urlify, truncate, wrap_paragraphs |
|
26 | 26 | |
|
27 | ||
|
28 | 27 | #Custom helpers here :) |
|
29 | 28 | class _Link(object): |
|
30 | 29 | ''' |
@@ -229,16 +228,30 b' def pygmentize_annotation(filenode, **kw' | |||
|
229 | 228 | @param filenode: |
|
230 | 229 | """ |
|
231 | 230 | |
|
232 | color_dict = g.changeset_annotation_colors | |
|
231 | color_dict = {} | |
|
233 | 232 | def gen_color(): |
|
234 | import random | |
|
235 | return [str(random.randrange(10, 235)) for _ in xrange(3)] | |
|
233 | """generator for getting 10k of evenly distibuted colors using hsv color | |
|
234 | and golden ratio. | |
|
235 | """ | |
|
236 | import colorsys | |
|
237 | n = 10000 | |
|
238 | golden_ratio = 0.618033988749895 | |
|
239 | h = 0.22717784590367374 | |
|
240 | #generate 10k nice web friendly colors in the same order | |
|
241 | for c in xrange(n): | |
|
242 | h +=golden_ratio | |
|
243 | h %= 1 | |
|
244 | HSV_tuple = [h, 0.95, 0.95] | |
|
245 | RGB_tuple = colorsys.hsv_to_rgb(*HSV_tuple) | |
|
246 | yield map(lambda x:str(int(x*256)),RGB_tuple) | |
|
247 | ||
|
248 | cgenerator = gen_color() | |
|
249 | ||
|
236 | 250 | def get_color_string(cs): |
|
237 | 251 | if color_dict.has_key(cs): |
|
238 | 252 | col = color_dict[cs] |
|
239 | 253 | else: |
|
240 |
color_dict[cs] = |
|
|
241 | col = color_dict[cs] | |
|
254 | col = color_dict[cs] = cgenerator.next() | |
|
242 | 255 |
return "color: rgb(%s) |
|
243 | 256 | |
|
244 | 257 | def url_func(changeset): |
@@ -248,7 +261,7 b' def pygmentize_annotation(filenode, **kw' | |||
|
248 | 261 | tooltip_html = tooltip_html % (changeset.author, |
|
249 | 262 | changeset.date, |
|
250 | 263 | tooltip(changeset.message)) |
|
251 | lnk_format = 'r%s:%s' % (changeset.revision, | |
|
264 | lnk_format = 'r%-5s:%s' % (changeset.revision, | |
|
252 | 265 | changeset.raw_id) |
|
253 | 266 | uri = link_to( |
|
254 | 267 | lnk_format, |
General Comments 0
You need to be logged in to leave comments.
Login now