##// END OF EJS Templates
fixes #24, added generator that generates equally distrybuted colors. Thus skipping creating one large coloring history.
marcink -
r438:0d4fceb9 default
parent child Browse files
Show More
@@ -27,7 +27,7 b' from pylons import request, response, se'
27 from pylons.controllers.util import redirect
27 from pylons.controllers.util import redirect
28 from pylons_app.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
28 from pylons_app.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
29 from pylons_app.lib.base import BaseController, render
29 from pylons_app.lib.base import BaseController, render
30 from pylons_app.lib.utils import EmptyChangeset, get_repo_slug
30 from pylons_app.lib.utils import EmptyChangeset
31 from pylons_app.model.hg_model import HgModel
31 from pylons_app.model.hg_model import HgModel
32 from vcs.exceptions import RepositoryError, ChangesetError
32 from vcs.exceptions import RepositoryError, ChangesetError
33 from vcs.nodes import FileNode
33 from vcs.nodes import FileNode
@@ -17,9 +17,7 b' class Globals(object):'
17
17
18 """
18 """
19 self.cache = CacheManager(**parse_cache_config_options(config))
19 self.cache = CacheManager(**parse_cache_config_options(config))
20 self.changeset_annotation_colors = {}
21 self.available_permissions = None # propagated after init_model
20 self.available_permissions = None # propagated after init_model
22 self.app_title = None # propagated after init_model
23 self.baseui = None # propagated after init_model
21 self.baseui = None # propagated after init_model
24
22
25 @LazyProperty
23 @LazyProperty
@@ -24,7 +24,6 b' from webhelpers.text import chop_at, col'
24 convert_misc_entities, lchop, plural, rchop, remove_formatting, \
24 convert_misc_entities, lchop, plural, rchop, remove_formatting, \
25 replace_whitespace, urlify, truncate, wrap_paragraphs
25 replace_whitespace, urlify, truncate, wrap_paragraphs
26
26
27
28 #Custom helpers here :)
27 #Custom helpers here :)
29 class _Link(object):
28 class _Link(object):
30 '''
29 '''
@@ -229,17 +228,31 b' def pygmentize_annotation(filenode, **kw'
229 @param filenode:
228 @param filenode:
230 """
229 """
231
230
232 color_dict = g.changeset_annotation_colors
231 color_dict = {}
233 def gen_color():
232 def gen_color():
234 import random
233 """generator for getting 10k of evenly distibuted colors using hsv color
235 return [str(random.randrange(10, 235)) for _ in xrange(3)]
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 def get_color_string(cs):
250 def get_color_string(cs):
237 if color_dict.has_key(cs):
251 if color_dict.has_key(cs):
238 col = color_dict[cs]
252 col = color_dict[cs]
239 else:
253 else:
240 color_dict[cs] = gen_color()
254 col = color_dict[cs] = cgenerator.next()
241 col = color_dict[cs]
255 return "color: rgb(%s)! important;" % (', '.join(col))
242 return "color: rgb(%s) ! important;" % (', '.join(col))
243
256
244 def url_func(changeset):
257 def url_func(changeset):
245 tooltip_html = "<div style='font-size:0.8em'><b>Author:</b>"+\
258 tooltip_html = "<div style='font-size:0.8em'><b>Author:</b>"+\
@@ -248,7 +261,7 b' def pygmentize_annotation(filenode, **kw'
248 tooltip_html = tooltip_html % (changeset.author,
261 tooltip_html = tooltip_html % (changeset.author,
249 changeset.date,
262 changeset.date,
250 tooltip(changeset.message))
263 tooltip(changeset.message))
251 lnk_format = 'r%s:%s' % (changeset.revision,
264 lnk_format = 'r%-5s:%s' % (changeset.revision,
252 changeset.raw_id)
265 changeset.raw_id)
253 uri = link_to(
266 uri = link_to(
254 lnk_format,
267 lnk_format,
General Comments 0
You need to be logged in to leave comments. Login now