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 |
1294.2.102
by William Grant
Replace the breadcrumb-h1 with proper breadcrumbs throughout the filesystem views. |
32 |
from ivle.webapp.filesystem import make_path_breadcrumbs |
1294.2.55
by William Grant
Port the filebrowser too. |
33 |
from ivle.webapp import ApplicationRoot |
136
by mattgiuca
Added File Browser (browser) application. (Currently just stub). |
34 |
|
595
by mattgiuca
browser: Removed the browser.js ability to generate path links at the top. |
35 |
import os.path |
36 |
import cgi |
|
37 |
||
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
38 |
import ivle.svn |
136
by mattgiuca
Added File Browser (browser) application. (Currently just stub). |
39 |
|
1099.1.10
by chadnickbok at gmail
ivle.webapp.browser: Add, a port of the old www/apps/browser. |
40 |
class BrowserView(XHTMLView): |
41 |
"""
|
|
42 |
The view for the browser
|
|
43 |
"""
|
|
1099.1.35
by William Grant
ivle.webapp.base.xhtml#XHTMLView: Rename app_template to template (the things |
44 |
template = 'template.html' |
1116
by William Grant
Move the old tutorial views into the 'subjects' tab, so they get the right |
45 |
tab = 'files' |
1752
by William Grant
Fix filebrowser help link. |
46 |
help = 'Files/Browser' |
1294.2.132
by William Grant
Add couple of view breadcrumbs. |
47 |
breadcrumb_text = 'Files' |
1099.1.12
by William Grant
ivle/webapp/browser#BrowserTemplate: Fix some formatting, and redirect properly |
48 |
|
1294.2.60
by William Grant
Move the already-ported filesystem views to use subpaths. |
49 |
subpath_allowed = True |
50 |
||
1099.1.110
by William Grant
Implement an authorization system in the new framework. This breaks the REST |
51 |
def authorize(self, req): |
52 |
return req.user is not None |
|
53 |
||
1099.1.10
by chadnickbok at gmail
ivle.webapp.browser: Add, a port of the old www/apps/browser. |
54 |
def populate(self, req, ctx): |
1294.2.60
by William Grant
Move the already-ported filesystem views to use subpaths. |
55 |
if len(self.path) == 0: |
1099.1.10
by chadnickbok at gmail
ivle.webapp.browser: Add, a port of the old www/apps/browser. |
56 |
# If no path specified, default to the user's home directory
|
1210
by William Grant
Use Request.make_path everywhere. |
57 |
redirectPath = req.make_path(os.path.join('files', req.user.login)) |
58 |
req.throw_redirect(redirectPath) |
|
1099.1.10
by chadnickbok at gmail
ivle.webapp.browser: Add, a port of the old www/apps/browser. |
59 |
|
60 |
# Set request attributes
|
|
1099.1.68
by William Grant
Move the remaining images to the new framework, in the new ivle.webapp.core |
61 |
self.plugin_styles[Plugin] = ['browser.css', |
62 |
'listing.css', |
|
63 |
'editor.css'] |
|
64 |
self.plugin_scripts[Plugin] = ['browser.js', |
|
65 |
'listing.js', |
|
66 |
'editor.js', |
|
1099.1.106
by William Grant
Move codepress into ivle.webapp.filesystem.browser's media directory. |
67 |
'specialhome.js', |
68 |
'codepress/codepress.js'] |
|
1282.1.3
by William Grant
Replace req.scripts_init with self.scripts_init in the two users. |
69 |
self.scripts_init = ["browser_init"] |
1099.1.10
by chadnickbok at gmail
ivle.webapp.browser: Add, a port of the old www/apps/browser. |
70 |
|
71 |
# Start writing data
|
|
72 |
||
1266
by William Grant
Always set isdir = False in the file browser template filling. |
73 |
# TODO: Set this properly. We can't get into the jail from server-side
|
74 |
# code at the moment, so we can't determine this.
|
|
75 |
isdir = False |
|
1117
by William Grant
Deal with Unicode paths in BrowserView properly again. |
76 |
|
1252
by William Grant
Move BrowserView's path segmentation/linking function into ivle.webapp.filesystem. |
77 |
revision = ivle.svn.revision_from_string( |
78 |
req.get_fieldstorage().getfirst('r')) |
|
79 |
try: |
|
80 |
revno = revision.number |
|
81 |
except: |
|
82 |
revno = None |
|
83 |
||
1099.1.10
by chadnickbok at gmail
ivle.webapp.browser: Add, a port of the old www/apps/browser. |
84 |
ctx['isdir'] = isdir |
1252
by William Grant
Move BrowserView's path segmentation/linking function into ivle.webapp.filesystem. |
85 |
ctx['revno'] = revno |
86 |
||
1294.2.102
by William Grant
Replace the breadcrumb-h1 with proper breadcrumbs throughout the filesystem views. |
87 |
self.extra_breadcrumbs = make_path_breadcrumbs(req, self.subpath,revno) |
1252
by William Grant
Move BrowserView's path segmentation/linking function into ivle.webapp.filesystem. |
88 |
|
1099.1.10
by chadnickbok at gmail
ivle.webapp.browser: Add, a port of the old www/apps/browser. |
89 |
self.gen_actions(req, ctx) |
1099.1.12
by William Grant
ivle/webapp/browser#BrowserTemplate: Fix some formatting, and redirect properly |
90 |
|
1099.1.159
by William Grant
Display the current path as the filebrowser title again. Broke in genshi port. |
91 |
# The page title should contain the name of the file being browsed
|
1294.2.60
by William Grant
Move the already-ported filesystem views to use subpaths. |
92 |
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. |
93 |
|
1210
by William Grant
Use Request.make_path everywhere. |
94 |
ctx['fileservice_action'] = req.make_path(os.path.join("fileservice", |
1294.2.60
by William Grant
Move the already-ported filesystem views to use subpaths. |
95 |
self.path)) |
96 |
ctx['filename'] = cgi.escape(self.path) |
|
97 |
||
98 |
@property
|
|
99 |
def path(self): |
|
100 |
return os.path.join(*self.subpath) if self.subpath else '' |
|
1099.1.10
by chadnickbok at gmail
ivle.webapp.browser: Add, a port of the old www/apps/browser. |
101 |
|
1099.1.12
by William Grant
ivle/webapp/browser#BrowserTemplate: Fix some formatting, and redirect properly |
102 |
#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. |
103 |
def gen_actions(self, req, ctx): |
104 |
"""
|
|
105 |
Presents a set of links/buttons for the "actions1" row of the top bar.
|
|
106 |
This is always exactly the same - the JavaScript will customize it later.
|
|
107 |
"""
|
|
108 |
# Set up our actions. The second field of each group is whether to disable
|
|
109 |
# the items by default.
|
|
110 |
ctx['moreactions'] = [ |
|
111 |
('Publishing', True, [ |
|
112 |
('publish', ['Publish', 'Make it so this directory can be seen by anyone on the web']), |
|
113 |
('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. |
114 |
('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. |
115 |
]),
|
116 |
('File actions', True, [ |
|
117 |
('rename', ['Rename', 'Change the name of this file']), |
|
118 |
('delete', ['Delete', 'Delete the selected files']), |
|
119 |
('copy', ['Copy', 'Prepare to copy the selected files to another directory']), |
|
120 |
('cut', ['Cut', 'Prepare to move the selected files to another directory']) |
|
121 |
]),
|
|
122 |
('Directory actions', False, [ |
|
123 |
('paste', ['Paste', 'Paste the copied or cut files into the current directory']), |
|
124 |
('newfile', ['New File', 'Open a new file for editing in the current directory']), |
|
125 |
('mkdir', ['New Directory', 'Make a new subdirectory in the current directory']), |
|
126 |
('upload', ['Upload File', 'Upload a file to the current directory']) |
|
127 |
]),
|
|
128 |
('Subversion', True, [ |
|
129 |
('svncut', ['Svn Cut', 'Prepare to move the selected files to another directory, maintaining history']), |
|
130 |
('svncopy', ['Svn Copy', 'Prepare to copy the selected files to another directory, maintaining history']), |
|
131 |
('svnadd', ['Add', 'Schedule the selected temporary files to be added permanently']), |
|
132 |
('svnremove', ['Remove', 'Schedule the selected permanent files to be removed']), |
|
133 |
('svndiff', ['Diff', 'View any changes to the selected file since its last committed state']), |
|
134 |
('svnrevert', ['Revert', 'Restore the selected files back to their last committed state']), |
|
135 |
('svnupdate', ['Update', 'Update your files with changes from the permanent repository']), |
|
136 |
('svncommit', ['Commit', 'Commit any changes to the permanent repository']), |
|
137 |
('svnresolved', ['Mark Resolved', 'Mark a conflicted file as being resolved']), |
|
138 |
('svnlog', ['View Log', 'View the log of commits of the selected file']), |
|
1318.1.2
by David Coles
Add Subversion Cleanup to web UI |
139 |
('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. |
140 |
])
|
141 |
]
|
|
1099.1.12
by William Grant
ivle/webapp/browser#BrowserTemplate: Fix some formatting, and redirect properly |
142 |
|
1294.2.55
by William Grant
Port the filebrowser too. |
143 |
class BrowserRedirectView(XHTMLView): |
144 |
def authorize(self, req): |
|
145 |
return req.user is not None |
|
146 |
||
147 |
def render(self, req): |
|
148 |
redirect_path = req.make_path(os.path.join('files', req.user.login)) |
|
149 |
req.throw_redirect(redirect_path) |
|
150 |
||
1099.1.99
by William Grant
Require that plugins providing media subclass MediaPlugin. |
151 |
class Plugin(ViewPlugin, CookiePlugin, MediaPlugin): |
1294.2.60
by William Grant
Move the already-ported filesystem views to use subpaths. |
152 |
views = [(ApplicationRoot, 'files', BrowserView), |
1294.2.55
by William Grant
Port the filebrowser too. |
153 |
(ApplicationRoot, '+index', BrowserRedirectView), |
154 |
]
|
|
1099.1.68
by William Grant
Move the remaining images to the new framework, in the new ivle.webapp.core |
155 |
|
1099.1.115
by William Grant
Add tabs to the new framework. Move the app icons into the apps themselves. |
156 |
tabs = [ |
1118
by matt.giuca
Rewrote tooltips for the four tabs visible by default. |
157 |
('files', 'Files', 'Access and edit your files', |
158 |
'browser.png', 'files', 1) |
|
1099.1.115
by William Grant
Add tabs to the new framework. Move the app icons into the apps themselves. |
159 |
]
|
160 |
||
1099.1.80
by William Grant
Port the forum app to the new framework. With it also comes new cookie |
161 |
cookies = {'clipboard': None} |
162 |
||
1658
by Matt Giuca
Help: Renamed 'Tutorial' to 'Worksheets' and 'Filesystem' to 'Files'. |
163 |
help = {'Files': {'Browser': 'help.html', |
164 |
'Running and Serving': 'help-run-serve.html', |
|
165 |
'Subversion': 'help-svn.html', |
|
166 |
}}
|
|
1099.1.107
by William Grant
Remove some dummy help files, and register the only remaining one (browser). |
167 |
|
1099.1.68
by William Grant
Move the remaining images to the new framework, in the new ivle.webapp.core |
168 |
media = 'media' |