18
18
"""Utility functions for filesystem views."""
20
def make_path_segments(path, revno=None):
21
"""Return a dict representation of information about a paths segments.
23
Splits a path into its segments, and returns useful paths and URLs
30
pathlist = path.split("/")
32
for path_seg in pathlist:
37
nav_path = nav_path + '/' + path_seg
38
href_path = href_path + '/' + path_seg
40
new_seg['path'] = path_seg
41
new_seg['nav_path'] = nav_path
42
new_seg['href_path'] = href_path
44
new_seg['href_path'] += '?r=%d' % revno
20
from ivle.webapp.publisher import ROOT
22
class FileBreadcrumb(object):
23
def __init__(self, req, pathsegments, revno=None, final=False,suffix=None):
25
self.pathsegments = pathsegments
32
url = self.req.publisher.generate(ROOT, None, ('files',) +
34
if self.revno is not None:
35
url += '?r=%d' % self.revno
40
text = self.pathsegments[-1]
41
if self.final and self.revno is not None:
42
text += (' (revision %d)' % self.revno)
44
text += ' ' + self.suffix
47
def make_path_breadcrumbs(req, pathsegments, revno=None, suffix=None):
48
"""Return breadcrumbs for the segments of the given path."""
51
for i in range(1, len(pathsegments)):
52
crumbs.append(FileBreadcrumb(req, pathsegments[:i], revno))
53
crumbs.append(FileBreadcrumb(req, pathsegments, revno, True, suffix))