Mercurial > dandelion
changeset 487:a1eeb01c1e42
Only show old pages as subpages of history
| author | sheep@ghostwheel |
|---|---|
| date | Wed, 08 Oct 2008 16:56:55 +0200 |
| parents | b0396a89818f |
| children | ea71d3ed8f79 |
| files | dandelion/history.py dandelion/wiki.py dandelion/wikipage.py |
| diffstat | 3 files changed, 27 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/dandelion/history.py Tue Oct 07 19:38:08 2008 +0200 +++ b/dandelion/history.py Wed Oct 08 16:56:55 2008 +0200 @@ -8,18 +8,35 @@ from werkzeug import Response, redirect from werkzeug.exceptions import NotFound +import viewer + def history_action(wiki, request): """ Display the history of changes to a page, with links for viewing the revisions and optional diffs, if the diff action is available. """ page = request.page - if page.current is None: + try: + rev = int(request.args["rev"]) + except (ValueError, KeyError): + if page.current is None: + raise NotFound() + stream = wiki.template_stream("history.html", page, changes=list(page)) + html = wiki.template("page.html", page, content=stream, + title="History of %s" % page.title) + return Response(html, mimetype="text/html") + page = page[rev] + if rev not in page: raise NotFound() - stream = wiki.template_stream("history.html", page, changes=list(page)) - html = wiki.template("page.html", page, content=stream, - title="History of %s" % page.title) - return Response(html, mimetype="text/html") + mime = page.get_mime() + major, minor = mime.split('/') + viewer = (wiki.viewers.get(mime, None) + or wiki.viewers.get(major, viewer.binary_viewer)) + try: + content = viewer(wiki, page) + except IndexError: + raise NotFound() + return Response(content, mimetype="text/html") def changes_action(wiki, request): """ Display list of recent changes in the wiki.
--- a/dandelion/wiki.py Tue Oct 07 19:38:08 2008 +0200 +++ b/dandelion/wiki.py Wed Oct 08 16:56:55 2008 +0200 @@ -31,6 +31,8 @@ >>> c = Client(Wiki().application) >>> r = c.get('/') >>> assert(r[1] in ('200 OK', '404 Not found')) + >>> r = c.get('/edit/') + >>> assert(r[1] in ('200 OK', '404 Not found')) """ def __init__(self, cfg=None): if cfg is None:
--- a/dandelion/wikipage.py Tue Oct 07 19:38:08 2008 +0200 +++ b/dandelion/wikipage.py Wed Oct 08 16:56:55 2008 +0200 @@ -18,10 +18,11 @@ parts = [self.wiki.root_url] if action is not None: parts.append(url_quote(action, safe="")) + elif rev is not None: + parts.append(url_quote("history", safe="")) + kw['rev'] = rev parts.append(url_quote(self.title, safe="")) url = "/".join(parts) - if rev is not None: - kw['rev'] = rev args = "&".join("%s=%s" % (url_quote(k), url_quote(v)) for k, v in kw.iteritems()) if args: url = "%s?%s" % (url, args)
