1099.1.10
by chadnickbok at gmail
ivle.webapp.browser: Add, a port of the old www/apps/browser. |
1 |
# IVLE - Informatics Virtual Learning Environment
|
2 |
# Copyright (C) 2007-2009 The University of Melbourne
|
|
136
by mattgiuca
Added File Browser (browser) application. (Currently just stub). |
3 |
#
|
4 |
# This program is free software; you can redistribute it and/or modify
|
|
5 |
# it under the terms of the GNU General Public License as published by
|
|
6 |
# the Free Software Foundation; either version 2 of the License, or
|
|
7 |
# (at your option) any later version.
|
|
8 |
#
|
|
9 |
# This program is distributed in the hope that it will be useful,
|
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
# GNU General Public License for more details.
|
|
13 |
#
|
|
14 |
# You should have received a copy of the GNU General Public License
|
|
15 |
# along with this program; if not, write to the Free Software
|
|
16 |
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17 |
||
1099.1.10
by chadnickbok at gmail
ivle.webapp.browser: Add, a port of the old www/apps/browser. |
18 |
# Author: Matt Giuca, Nick Chadwick
|
19 |
||
20 |
"""
|
|
21 |
The file browser application. Presents an Ajax-based interface to the
|
|
22 |
student's subversion workspace.
|
|
23 |
||
24 |
Note that there is virtually no server-side code for this application. It
|
|
25 |
simply presents static HTML and JavaScript, and all server-side activities
|
|
26 |
take place in the FileService app (for handling Ajax requests).
|
|
27 |
"""
|
|
28 |
||
1099.1.99
by William Grant
Require that plugins providing media subclass MediaPlugin. |
29 |
from ivle.webapp.base.plugins import ViewPlugin, CookiePlugin, MediaPlugin |
1099.1.34
by William Grant
Split up ivle.webapp.base.views into ivle.webapp.base.{rest,xhtml}, as it was |
30 |
from ivle.webapp.base.xhtml import XHTMLView |
1211
by William Grant
Fixed missing exception import in filebrowser. |
31 |
from ivle.webapp.errors import NotFound |
1252
by William Grant
Move BrowserView's path segmentation/linking function into ivle.webapp.filesystem. |
32 |
from ivle.webapp.filesystem import make_path_segments |
136
by mattgiuca
Added File Browser (browser) application. (Currently just stub). |
33 |
|
595
by mattgiuca
browser: Removed the browser.js ability to generate path links at the top. |
34 |
import os.path |
35 |
import cgi |
|
36 |
||
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
37 |
import ivle.svn |
136
by mattgiuca
Added File Browser (browser) application. (Currently just stub). |
38 |
|
1099.1.10
by chadnickbok at gmail
ivle.webapp.browser: Add, a port of the old www/apps/browser. |
39 |
class BrowserView(XHTMLView): |
40 |
"""
|
|
41 |
The view for the browser
|
|
42 |
"""
|
|
1099.1.35
by William Grant
ivle.webapp.base.xhtml#XHTMLView: Rename app_template to template (the things |
43 |
template = 'template.html' |
1116
by William Grant
Move the old tutorial views into the 'subjects' tab, so they get the right |
44 |
tab = 'files' |
1099.1.107
by William Grant
Remove some dummy help files, and register the only remaining one (browser). |
45 |
help = 'Filesystem/Browser' |
1099.1.12
by William Grant
ivle/webapp/browser#BrowserTemplate: Fix some formatting, and redirect properly |
46 |
|
1099.1.110
by William Grant
Implement an authorization system in the new framework. This breaks the REST |
47 |
def authorize(self, req): |
48 |
return req.user is not None |
|
49 |
||
1099.1.10
by chadnickbok at gmail
ivle.webapp.browser: Add, a port of the old www/apps/browser. |
50 |
def populate(self, req, ctx): |
1099.1.12
by William Grant
ivle/webapp/browser#BrowserTemplate: Fix some formatting, and redirect properly |
51 |
if not hasattr(self, 'path'): |
1099.1.10
by chadnickbok at gmail
ivle.webapp.browser: Add, a port of the old www/apps/browser. |
52 |
# If no path specified, default to the user's home directory
|
1210
by William Grant
Use Request.make_path everywhere. |
53 |
redirectPath = req.make_path(os.path.join('files', req.user.login)) |
54 |
req.throw_redirect(redirectPath) |
|
1099.1.10
by chadnickbok at gmail
ivle.webapp.browser: Add, a port of the old www/apps/browser. |
55 |
|
56 |
# Set request attributes
|
|
1099.1.68
by William Grant
Move the remaining images to the new framework, in the new ivle.webapp.core |
57 |
self.plugin_styles[Plugin] = ['browser.css', |
58 |
'listing.css', |
|
59 |
'editor.css'] |
|
60 |
self.plugin_scripts[Plugin] = ['browser.js', |
|
61 |
'listing.js', |
|
62 |
'editor.js', |
|
1099.1.106
by William Grant
Move codepress into ivle.webapp.filesystem.browser's media directory. |
63 |
'specialhome.js', |
64 |
'codepress/codepress.js'] |
|
1282.1.3
by William Grant
Replace req.scripts_init with self.scripts_init in the two users. |
65 |
self.scripts_init = ["browser_init"] |
1099.1.10
by chadnickbok at gmail
ivle.webapp.browser: Add, a port of the old www/apps/browser. |
66 |
|
67 |
# Start writing data
|
|
68 |
||
1266
by William Grant
Always set isdir = False in the file browser template filling. |
69 |
# TODO: Set this properly. We can't get into the jail from server-side
|
70 |
# code at the moment, so we can't determine this.
|
|
71 |
isdir = False |
|
1117
by William Grant
Deal with Unicode paths in BrowserView properly again. |
72 |
|
1252
by William Grant
Move BrowserView's path segmentation/linking function into ivle.webapp.filesystem. |
73 |
revision = ivle.svn.revision_from_string( |
74 |
req.get_fieldstorage().getfirst('r')) |
|
75 |
try: |
|
76 |
revno = revision.number |
|
77 |
except: |
|
78 |
revno = None |
|
79 |
||
1099.1.10
by chadnickbok at gmail
ivle.webapp.browser: Add, a port of the old www/apps/browser. |
80 |
ctx['isdir'] = isdir |
1252
by William Grant
Move BrowserView's path segmentation/linking function into ivle.webapp.filesystem. |
81 |
ctx['revno'] = revno |
82 |
||
1307
by William Grant
Correct unicode issue in generating breadcrumbs in the file browser. |
83 |
ctx['paths'] = make_path_segments(self.path, revno) |
1252
by William Grant
Move BrowserView's path segmentation/linking function into ivle.webapp.filesystem. |
84 |
|
1099.1.10
by chadnickbok at gmail
ivle.webapp.browser: Add, a port of the old www/apps/browser. |
85 |
self.gen_actions(req, ctx) |
1099.1.12
by William Grant
ivle/webapp/browser#BrowserTemplate: Fix some formatting, and redirect properly |
86 |
|
1099.1.159
by William Grant
Display the current path as the filebrowser title again. Broke in genshi port. |
87 |
# The page title should contain the name of the file being browsed
|
1291
by William Grant
Fix browser/diff/svnlog titles for paths with trailing slashes. |
88 |
ctx['title'] = os.path.normpath(self.path).rsplit('/', 1)[-1] |
1099.1.159
by William Grant
Display the current path as the filebrowser title again. Broke in genshi port. |
89 |
|
1210
by William Grant
Use Request.make_path everywhere. |
90 |
ctx['fileservice_action'] = req.make_path(os.path.join("fileservice", |
1117
by William Grant
Deal with Unicode paths in BrowserView properly again. |
91 |
self.path)) |
92 |
ctx['filename'] = cgi.escape(self.path) |
|
1099.1.10
by chadnickbok at gmail
ivle.webapp.browser: Add, a port of the old www/apps/browser. |
93 |
|
1099.1.12
by William Grant
ivle/webapp/browser#BrowserTemplate: Fix some formatting, and redirect properly |
94 |
#TODO: Move all this logic into the template
|
1099.1.10
by chadnickbok at gmail
ivle.webapp.browser: Add, a port of the old www/apps/browser. |
95 |
def gen_actions(self, req, ctx): |
96 |
"""
|
|
97 |
Presents a set of links/buttons for the "actions1" row of the top bar.
|
|
98 |
This is always exactly the same - the JavaScript will customize it later.
|
|
99 |
"""
|
|
100 |
# Set up our actions. The second field of each group is whether to disable
|
|
101 |
# the items by default.
|
|
102 |
ctx['moreactions'] = [ |
|
103 |
('Publishing', True, [ |
|
104 |
('publish', ['Publish', 'Make it so this directory can be seen by anyone on the web']), |
|
105 |
('share', ['Share this file', 'Get a link to this published file, to give to friends']), |
|
1165.1.34
by William Grant
Retitle the Submit action to indicate its projectness. |
106 |
('submit', ['Submit', 'Submit the selected files for a project']) |
1099.1.10
by chadnickbok at gmail
ivle.webapp.browser: Add, a port of the old www/apps/browser. |
107 |
]),
|
108 |
('File actions', True, [ |
|
109 |
('rename', ['Rename', 'Change the name of this file']), |
|
110 |
('delete', ['Delete', 'Delete the selected files']), |
|
111 |
('copy', ['Copy', 'Prepare to copy the selected files to another directory']), |
|
112 |
('cut', ['Cut', 'Prepare to move the selected files to another directory']) |
|
113 |
]),
|
|
114 |
('Directory actions', False, [ |
|
115 |
('paste', ['Paste', 'Paste the copied or cut files into the current directory']), |
|
116 |
('newfile', ['New File', 'Open a new file for editing in the current directory']), |
|
117 |
('mkdir', ['New Directory', 'Make a new subdirectory in the current directory']), |
|
118 |
('upload', ['Upload File', 'Upload a file to the current directory']) |
|
119 |
]),
|
|
120 |
('Subversion', True, [ |
|
121 |
('svncut', ['Svn Cut', 'Prepare to move the selected files to another directory, maintaining history']), |
|
122 |
('svncopy', ['Svn Copy', 'Prepare to copy the selected files to another directory, maintaining history']), |
|
123 |
('svnadd', ['Add', 'Schedule the selected temporary files to be added permanently']), |
|
124 |
('svnremove', ['Remove', 'Schedule the selected permanent files to be removed']), |
|
125 |
('svndiff', ['Diff', 'View any changes to the selected file since its last committed state']), |
|
126 |
('svnrevert', ['Revert', 'Restore the selected files back to their last committed state']), |
|
127 |
('svnupdate', ['Update', 'Update your files with changes from the permanent repository']), |
|
128 |
('svncommit', ['Commit', 'Commit any changes to the permanent repository']), |
|
129 |
('svnresolved', ['Mark Resolved', 'Mark a conflicted file as being resolved']), |
|
130 |
('svnlog', ['View Log', 'View the log of commits of the selected file']), |
|
1318.1.2
by David Coles
Add Subversion Cleanup to web UI |
131 |
('svncleanup', ['Cleanup', 'Clear stale Subversion locks']), |
1099.1.10
by chadnickbok at gmail
ivle.webapp.browser: Add, a port of the old www/apps/browser. |
132 |
])
|
133 |
]
|
|
1099.1.12
by William Grant
ivle/webapp/browser#BrowserTemplate: Fix some formatting, and redirect properly |
134 |
|
1099.1.99
by William Grant
Require that plugins providing media subclass MediaPlugin. |
135 |
class Plugin(ViewPlugin, CookiePlugin, MediaPlugin): |
1099.1.10
by chadnickbok at gmail
ivle.webapp.browser: Add, a port of the old www/apps/browser. |
136 |
"""
|
137 |
The Plugin class for the user plugin.
|
|
138 |
"""
|
|
139 |
# Magic attribute: urls
|
|
140 |
# Sequence of pairs/triples of
|
|
141 |
# (regex str, handler class, kwargs dict)
|
|
142 |
# The kwargs dict is passed to the __init__ of the view object
|
|
143 |
urls = [ |
|
144 |
('files/*(path)', BrowserView), |
|
145 |
('files/', BrowserView), |
|
1099.1.119
by William Grant
Add a route from / to the browser redirection view. |
146 |
('/', BrowserView), |
1099.1.10
by chadnickbok at gmail
ivle.webapp.browser: Add, a port of the old www/apps/browser. |
147 |
]
|
1099.1.68
by William Grant
Move the remaining images to the new framework, in the new ivle.webapp.core |
148 |
|
1099.1.115
by William Grant
Add tabs to the new framework. Move the app icons into the apps themselves. |
149 |
tabs = [ |
1118
by matt.giuca
Rewrote tooltips for the four tabs visible by default. |
150 |
('files', 'Files', 'Access and edit your files', |
151 |
'browser.png', 'files', 1) |
|
1099.1.115
by William Grant
Add tabs to the new framework. Move the app icons into the apps themselves. |
152 |
]
|
153 |
||
1099.1.80
by William Grant
Port the forum app to the new framework. With it also comes new cookie |
154 |
cookies = {'clipboard': None} |
155 |
||
1099.1.107
by William Grant
Remove some dummy help files, and register the only remaining one (browser). |
156 |
help = {'Filesystem': {'Browser': 'help.html'}} |
157 |
||
1099.1.68
by William Grant
Move the remaining images to the new framework, in the new ivle.webapp.core |
158 |
media = 'media' |