15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
# App: SVN Log Service
19
18
# Author: William Grant
22
# This is merely a wrapper around the trampolined svnlogservice.
27
27
import ivle.interpret
30
"""Handler for Subversion log functionality."""
31
req.styles = ["media/svn/log.css"]
32
req.write_html_head_foot = True
35
req.throw_redirect(os.path.join(req.uri, req.user.login))
36
interpreter = ivle.interpret.interpreter_objects["cgi-python"]
37
jail_dir = os.path.join(ivle.conf.jail_base, req.user.login)
38
ivle.interpret.interpret_file(req, req.user, jail_dir,
39
os.path.join(ivle.conf.share_path, 'services/svnlogservice'),
28
from ivle.webapp.base.xhtml import XHTMLView
29
from ivle.webapp.base.plugins import ViewPlugin, MediaPlugin
30
from ivle.webapp.errors import NotFound, BadRequest
32
class SubversionLogView(XHTMLView):
33
template = 'template.html'
35
def authorize(self, req):
36
return req.user is not None
38
def populate(self, req, ctx):
39
self.plugin_styles[Plugin] = ['log.css']
41
svnlogservice_path = os.path.join(ivle.conf.share_path,
42
'services/svnlogservice')
44
user_jail_dir = os.path.join(ivle.conf.jail_base, req.user.login)
45
(out, err) = ivle.interpret.execute_raw(req.user, user_jail_dir,
46
'/home', svnlogservice_path, [self.path])
49
response = cjson.decode(out)
50
if 'error' in response:
51
if response['error'] == 'notfound':
54
raise AssertionError('Unknown error from svnlogservice: %s' %
57
# No error. We must be safe.
58
ctx['path'] = self.path
59
ctx['url'] = ivle.util.make_path(os.path.join('svnlog', self.path))
61
sr = ivle.svn.revision_from_string(
62
req.get_fieldstorage().getfirst("r"))
63
ctx['revno'] = sr.number if sr and \
64
sr.kind == pysvn.opt_revision_kind.number else None
65
ctx['logs'] = response['logs']
67
# Create URLs for each of the versioned files.
68
# XXX: This scheme only works for stuff/!
69
for log in ctx['logs']:
70
log['date'] = ivle.date.make_date_nice(log['date'])
71
for pathaction in log['paths']:
72
pathaction.append(ivle.util.make_path(os.path.join('files',
73
ivle.util.split_path(req.path)[0],
74
pathaction[0][1:])) + '?r=%d' % log['revno'])
76
class Plugin(ViewPlugin, MediaPlugin):
78
('/svnlog', SubversionLogView, {'path': ''}),
79
('/svnlog/*path', SubversionLogView),