~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/templatefunctions.py

  • Committer: Robey Pointer
  • Date: 2006-12-20 03:05:27 UTC
  • Revision ID: robey@lag.net-20061220030527-h9fh8fztifgne8q7
slowly moving the branch-specific stuff into a common structure...
the changes cache is now its own class (ChangeCache) like TextIndex, and
both are fields in History.  almost all of the cache rebuilding logic, etc,
has been moved there and out of __init__.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import os
2
 
from loggerhead.zptsupport import zpt
3
 
 
4
 
templatefunctions = {}
5
 
def templatefunc(func):
6
 
    templatefunctions[func.__name__] = func
7
 
    return func
8
 
 
9
 
 
10
 
_base = os.path.dirname(__file__)
11
 
def _pt(name):
12
 
    return zpt(os.path.join(_base, 'templates', name + '.pt'))
13
 
 
14
 
 
15
 
templatefunctions['macros'] = _pt('macros').macros
16
 
 
17
 
@templatefunc
18
 
def file_change_summary(url, entry, modified_file_link):
19
 
    return _pt('revisionfilechanges').expand(
20
 
        url=url, entry=entry, modified_file_link=modified_file_link,
21
 
        **templatefunctions)
22
 
 
23
 
@templatefunc
24
 
def revisioninfo(url, branch, entry, modified_file_link=None):
25
 
    from loggerhead import util
26
 
    return _pt('revisioninfo').expand(
27
 
        url=url, change=entry, branch=branch, util=util,
28
 
        modified_file_link=modified_file_link,
29
 
        **templatefunctions)
30
 
 
31
 
@templatefunc
32
 
def collapse_button(group, name, branch, normal='block'):
33
 
    return _pt('collapse-button').expand(
34
 
        group=group, name=name, normal=normal, branch=branch,
35
 
        **templatefunctions)
36
 
 
37
 
@templatefunc
38
 
def collapse_all_button(group, branch, normal='block'):
39
 
    return _pt('collapse-all-button').expand(
40
 
        group=group, normal=normal, branch=branch,
41
 
        **templatefunctions)
42
 
 
43
 
@templatefunc
44
 
def revno_with_nick(entry):
45
 
    if entry.branch_nick:
46
 
        extra = ' ' + entry.branch_nick
47
 
    else:
48
 
        extra = ''
49
 
    return '(%s%s)'%(entry.revno, extra)
50
 
 
51
 
@templatefunc
52
 
def modified_file_link_rev(url, entry, item):
53
 
    return _pt('modified-file-link-rev').expand(
54
 
        url=url, entry=entry, item=item,
55
 
        **templatefunctions)
56
 
 
57
 
@templatefunc
58
 
def modified_file_link_log(url, entry, item):
59
 
    return _pt('modified-file-link-log').expand(
60
 
        url=url, entry=entry, item=item,
61
 
        **templatefunctions)