##// END OF EJS Templates
Added last change translation to 'time ago', added generation of enabled zip archives
Marcin Kuzminski -
r56:bf1b6404 default
parent child Browse files
Show More
@@ -29,7 +29,7 b' full_stack = true'
29 static_files = true
29 static_files = true
30 lang=en
30 lang=en
31 cache_dir = %(here)s/data
31 cache_dir = %(here)s/data
32 repos_name = etelko
32 repos_name = Etelko
33
33
34 ####################################
34 ####################################
35 ### BEAKER CACHE ####
35 ### BEAKER CACHE ####
@@ -29,7 +29,7 b' full_stack = true'
29 static_files = true
29 static_files = true
30 lang=en
30 lang=en
31 cache_dir = %(here)s/data
31 cache_dir = %(here)s/data
32 repos_name = etelko
32 repos_name = Etelko
33
33
34 ####################################
34 ####################################
35 ### BEAKER CACHE ####
35 ### BEAKER CACHE ####
@@ -14,7 +14,7 b' except ImportError:'
14 print 'You have to import vcs module'
14 print 'You have to import vcs module'
15 from mercurial.util import matchdate, Abort, makedate
15 from mercurial.util import matchdate, Abort, makedate
16 from mercurial.hgweb.common import get_contact
16 from mercurial.hgweb.common import get_contact
17
17 from mercurial.templatefilters import age
18 log = logging.getLogger(__name__)
18 log = logging.getLogger(__name__)
19
19
20 class HgController(BaseController):
20 class HgController(BaseController):
@@ -32,18 +32,28 b' class HgController(BaseController):'
32 return os.stat(cl_path).st_mtime
32 return os.stat(cl_path).st_mtime
33 else:
33 else:
34 return os.stat(spath).st_mtime
34 return os.stat(spath).st_mtime
35
35
36 def archivelist(ui, nodeid, url):
37 allowed = g.baseui.configlist("web", "allow_archive", untrusted=True)
38 for i in [('zip', '.zip'), ('gz', '.tar.gz'), ('bz2', '.tar.bz2')]:
39 if i[0] in allowed or ui.configbool("web", "allow" + i[0],
40 untrusted=True):
41 yield {"type" : i[0], "extension": i[1],
42 "node": nodeid, "url": url}
43
36 for name, r in get_repositories(g.paths[0][0], g.paths[0][1]).items():
44 for name, r in get_repositories(g.paths[0][0], g.paths[0][1]).items():
37 last_change = (get_mtime(r.spath), makedate()[1])
45 last_change = (get_mtime(r.spath), makedate()[1])
38 tmp = {}
39 tmp['name'] = name
40 tmp['desc'] = r.ui.config('web', 'description', 'Unknown', untrusted=True)
41 tmp['last_change'] = last_change,
42 tip = r.changectx('tip')
46 tip = r.changectx('tip')
43 tmp['tip'] = tip.__str__(),
47 tmp_d = {}
44 tmp['rev'] = tip.rev()
48 tmp_d['name'] = name
45 tmp['contact'] = get_contact(r.ui.config)
49 tmp_d['desc'] = r.ui.config('web', 'description', 'Unknown', untrusted=True)
46 c.repos_list.append(tmp)
50 tmp_d['last_change'] = age(last_change)
51 tmp_d['tip'] = str(tip)
52 tmp_d['rev'] = tip.rev()
53 tmp_d['contact'] = get_contact(r.ui.config)
54 tmp_d['repo_archives'] = archivelist(r.ui, "tip", 'sa')
55
56 c.repos_list.append(tmp_d)
47 return render('/index.html')
57 return render('/index.html')
48
58
49 def view(self, *args, **kwargs):
59 def view(self, *args, **kwargs):
@@ -43,7 +43,7 b' class Globals(object):'
43 baseui.setconfig('web', k, v)
43 baseui.setconfig('web', k, v)
44 #magic trick to make our custom template dir working
44 #magic trick to make our custom template dir working
45 templater.path.append(cfg.get('web', 'templates', None))
45 templater.path.append(cfg.get('web', 'templates', None))
46
46 self.baseui = baseui
47 #baseui.setconfig('web', 'description', '')
47 #baseui.setconfig('web', 'description', '')
48 #baseui.setconfig('web', 'name', '')
48 #baseui.setconfig('web', 'name', '')
49 #baseui.setconfig('web', 'contact', '')
49 #baseui.setconfig('web', 'contact', '')
@@ -13,7 +13,11 b''
13 </%def>
13 </%def>
14 <%def name="main()">
14 <%def name="main()">
15 <%def name="get_sort(name)">
15 <%def name="get_sort(name)">
16 <a href="?sort=${name.lower().replace(' ','-')}">${name}</a>
16 <%name_slug = name.lower().replace(' ','-') %>
17 %if not name_slug.startswith('-') and c.current_sort:
18 <%name_slug = '-'+name_slug%>
19 %endif
20 <a href="?sort=${name_slug}">${name}</a>
17 </%def>
21 </%def>
18 <table>
22 <table>
19 <tr>
23 <tr>
@@ -28,12 +32,12 b''
28 <td><a href="/${repo['name']}">${repo['name']}</a></td>
32 <td><a href="/${repo['name']}">${repo['name']}</a></td>
29 <td>${repo['desc']}</td>
33 <td>${repo['desc']}</td>
30 <td>${repo['last_change']}</td>
34 <td>${repo['last_change']}</td>
31 <td>r${repo['rev']}:${repo['tip']}</td>
35 <td>r${repo['rev']}:<a href="/${repo['name']}/rev/${repo['tip']}/">${repo['tip']}</a></td>
32 <td>${repo['contact']}</td>
36 <td>${repo['contact']}</td>
33 <td class="indexlinks">
37 <td class="indexlinks">
34 <a href="/${repo['name']}/archive/tip.zip">zip</a>
38 %for archive in repo['repo_archives']:
35 <a href="/${repo['name']}/archive/tip.tar.gz">gz</a>
39 <a href="/${repo['name']}/archive/${archive['node']}${archive['extension']}">${archive['type']}</a>
36 <a href="/${repo['name']}/archive/tip.tar.bz2">bz2</a>
40 %endfor
37 </td>
41 </td>
38 <td>
42 <td>
39 <div class="rss_logo">
43 <div class="rss_logo">
General Comments 0
You need to be logged in to leave comments. Login now