~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/webapp/filesystem/browser/__init__.py

  • Committer: William Grant
  • Date: 2009-05-18 12:00:46 UTC
  • Revision ID: grantw@unimelb.edu.au-20090518120046-ktu60qvdi6cf01v0
Move BrowserView's path segmentation/linking function into ivle.webapp.filesystem.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
from ivle.webapp.base.plugins import ViewPlugin, CookiePlugin, MediaPlugin
30
30
from ivle.webapp.base.xhtml import XHTMLView
31
31
from ivle.webapp.errors import NotFound
 
32
from ivle.webapp.filesystem import make_path_segments
32
33
 
33
34
import os.path
34
35
import cgi
81
82
        except OSError:
82
83
            isdir = False
83
84
 
 
85
        revision = ivle.svn.revision_from_string(
 
86
                         req.get_fieldstorage().getfirst('r'))
 
87
        try:
 
88
            revno = revision.number
 
89
        except:
 
90
            revno = None
 
91
 
84
92
        ctx['isdir'] = isdir
85
 
        self.gen_path(req, ctx)
 
93
        ctx['revno'] = revno
 
94
 
 
95
        ctx['paths'] = make_path_segments(req.path, revno)
 
96
 
86
97
        self.gen_actions(req, ctx)
87
98
 
88
99
        # The page title should contain the name of the file being browsed
93
104
        ctx['filename'] = cgi.escape(self.path)
94
105
 
95
106
    #TODO: Move all this logic into the template
96
 
    def gen_path(self, req, ctx):
97
 
 
98
 
        href_path = req.make_path('files')
99
 
        nav_path = ""
100
 
        revision = ivle.svn.revision_from_string(
101
 
                         req.get_fieldstorage().getfirst('r'))
102
 
        try:
103
 
            revno = revision.number
104
 
        except:
105
 
            revno = None
106
 
 
107
 
        ctx['revno'] = revno
108
 
 
109
 
        # Create all of the paths
110
 
        pathlist = self.path.split("/")
111
 
        ctx['paths'] = []
112
 
        for path_seg in pathlist:
113
 
            if path_seg == "":
114
 
                continue
115
 
            new_seg = {}
116
 
 
117
 
            nav_path = nav_path + path_seg
118
 
            href_path = href_path + '/' + path_seg
119
 
 
120
 
            new_seg['path'] = path_seg
121
 
            new_seg['nav_path'] = nav_path
122
 
            new_seg['href_path'] = href_path
123
 
            if revno is not None:
124
 
                new_seg['href_path'] += '?r=%d' % revno
125
 
 
126
 
            ctx['paths'].append(new_seg)
127
 
 
128
107
    def gen_actions(self, req, ctx):
129
108
        """
130
109
        Presents a set of links/buttons for the "actions1" row of the top bar.