templates_docs_DATA = \
src/templates/docs/404.html \
src/templates/docs/base.html \
+ src/templates/docs/confirm-delete.html \
src/templates/docs/confirm-restore.html \
src/templates/docs/diff.html \
src/templates/docs/edit.html \
templates_voip_modulesdir = $(templates_voipdir)/modules
-templates_wiki_DATA = \
- src/templates/wiki/confirm-delete.html
-
templates_wikidir = $(templatesdir)/wiki
templates_wiki_files_DATA = \
(r"/docs/([A-Za-z0-9\-_\/]+)?/_edit", docs.ActionEditHandler),
(r"/docs/([A-Za-z0-9\-_\/]+)?/_render", docs.ActionRenderHandler),
(r"/docs/([A-Za-z0-9\-_\/]+)?/_(watch|unwatch)", docs.ActionWatchHandler),
+ (r"/docs/((?:[A-Za-z0-9\-_\/]+)?(?:.*)\.(?:\w+))/_delete", docs.DeleteFileHandler),
(r"/docs((?:[A-Za-z0-9\-_\/]+)?(?:.*)\.(?:\w+))$", docs.FileHandler),
(r"/docs([A-Za-z0-9\-_\/]+)?", docs.PageHandler),
authentication_handlers + [
# Actions
- (r"((?:[A-Za-z0-9\-_\/]+)?(?:.*)\.(?:\w+))/_delete", wiki.ActionDeleteHandler),
(r"/actions/restore", wiki.ActionRestoreHandler),
(r"/actions/upload", wiki.ActionUploadHandler),
self.redirect(page.url)
+class DeleteFileHandler(base.BaseHandler):
+ @tornado.web.authenticated
+ def get(self, path):
+ # Check permissions
+ if not self.backend.wiki.check_acl(path, self.current_user):
+ raise tornado.web.HTTPError(403, "Access to %s not allowed for %s" % (path, self.current_user))
+
+ # Fetch the file
+ file = self.backend.wiki.get_file_by_path(path)
+ if not file:
+ raise tornado.web.HTTPError(404, "Could not find %s" % path)
+
+ self.render("docs/confirm-delete.html", file=file)
+
+ @tornado.web.authenticated
+ @base.ratelimit(minutes=60, requests=24)
+ def post(self, path):
+ # Check permissions
+ if not self.backend.wiki.check_acl(path, self.current_user):
+ raise tornado.web.HTTPError(403, "Access to %s not allowed for %s" % (path, self.current_user))
+
+ # Fetch the file
+ file = self.backend.wiki.get_file_by_path(path)
+ if not file:
+ raise tornado.web.HTTPError(404, "Could not find %s" % path)
+
+ with self.db.transaction():
+ file.delete(self.current_user)
+
+ self.redirect("%s/_files" % file.path)
+
+
class SearchHandler(base.BaseHandler):
@base.ratelimit(minutes=5, requests=25)
def get(self):
self.redirect("%s/_files" % path)
-class ActionDeleteHandler(base.BaseHandler):
- @tornado.web.authenticated
- def get(self, path):
- # Check permissions
- if not self.backend.wiki.check_acl(path, self.current_user):
- raise tornado.web.HTTPError(403, "Access to %s not allowed for %s" % (path, self.current_user))
-
- # Fetch the file
- file = self.backend.wiki.get_file_by_path(path)
- if not file:
- raise tornado.web.HTTPError(404, "Could not find %s" % path)
-
- self.render("wiki/confirm-delete.html", file=file)
-
- @tornado.web.authenticated
- @base.ratelimit(minutes=60, requests=24)
- def post(self, path):
- # Check permissions
- if not self.backend.wiki.check_acl(path, self.current_user):
- raise tornado.web.HTTPError(403, "Access to %s not allowed for %s" % (path, self.current_user))
-
- # Fetch the file
- file = self.backend.wiki.get_file_by_path(path)
- if not file:
- raise tornado.web.HTTPError(404, "Could not find %s" % path)
-
- with self.db.transaction():
- file.delete(self.current_user)
-
- self.redirect("%s/_files" % file.path)
-
-
class ActionRestoreHandler(base.BaseHandler):
@tornado.web.authenticated
@base.ratelimit(minutes=60, requests=24)