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 BasePlugin
30
from ivle.webapp.errors import NotFound, BadRequest
32
class SubversionLogView(XHTMLView):
33
template = 'template.html'
35
def populate(self, req, ctx):
36
req.styles = ["/media/svn/log.css"]
38
svnlogservice_path = os.path.join(ivle.conf.share_path,
39
'services/svnlogservice')
41
user_jail_dir = os.path.join(ivle.conf.jail_base, req.user.login)
42
(out, err) = ivle.interpret.execute_raw(req.user, user_jail_dir,
43
'/home', svnlogservice_path, [self.path])
46
response = cjson.decode(out)
47
if 'error' in response:
48
if response['error'] == 'notfound':
51
raise AssertionError('Unknown error from svnlogservice: %s' %
54
# No error. We must be safe.
55
ctx['path'] = self.path
56
ctx['url'] = ivle.util.make_path(os.path.join('svnlog', self.path))
58
sr = ivle.svn.revision_from_string(
59
req.get_fieldstorage().getfirst("r"))
60
ctx['revno'] = sr.number if sr and \
61
sr.kind == pysvn.opt_revision_kind.number else None
62
ctx['logs'] = response['logs']
64
# Create URLs for each of the versioned files.
65
# XXX: This scheme only works for stuff/!
66
for log in ctx['logs']:
67
log['date'] = ivle.date.make_date_nice(log['date'])
68
for pathaction in log['paths']:
69
pathaction.append(ivle.util.make_path(os.path.join('files',
70
ivle.util.split_path(req.path)[0],
71
pathaction[0][1:])) + '?r=%d' % log['revno'])
73
class Plugin(BasePlugin):
75
('/svnlog', SubversionLogView, {'path': ''}),
76
('/svnlog/*path', SubversionLogView),