src/templates/docs/base.html \
src/templates/docs/confirm-restore.html \
src/templates/docs/diff.html \
+ src/templates/docs/edit.html \
src/templates/docs/page.html \
src/templates/docs/recent-changes.html \
src/templates/docs/revisions.html \
templates_voip_modulesdir = $(templates_voipdir)/modules
templates_wiki_DATA = \
- src/templates/wiki/confirm-delete.html \
- src/templates/wiki/edit.html
+ src/templates/wiki/confirm-delete.html
templates_wikidir = $(templatesdir)/wiki
(r"/docs/search", docs.SearchHandler),
(r"/docs/tree", docs.TreeHandler),
(r"/docs/watchlist", docs.WatchlistHandler),
+ (r"/docs/([A-Za-z0-9\-_\/]+)?/_edit", docs.ActionEditHandler),
+ (r"/docs/([A-Za-z0-9\-_\/]+)?/_render", docs.ActionRenderHandler),
(r"/docs((?:[A-Za-z0-9\-_\/]+)?(?:.*)\.(?:\w+))$", docs.FileHandler),
(r"/docs([A-Za-z0-9\-_\/]+)?", docs.PageHandler),
# Actions
(r"((?:[A-Za-z0-9\-_\/]+)?(?:.*)\.(?:\w+))/_delete", wiki.ActionDeleteHandler),
- (r"([A-Za-z0-9\-_\/]+)?/_edit", wiki.ActionEditHandler),
- (r"([A-Za-z0-9\-_\/]+)?/_render", wiki.ActionRenderHandler),
(r"([A-Za-z0-9\-_\/]+)?/_(watch|unwatch)", wiki.ActionWatchHandler),
(r"/actions/restore", wiki.ActionRestoreHandler),
(r"/actions/upload", wiki.ActionUploadHandler),
self.finish(blob)
+class ActionEditHandler(base.BaseHandler):
+ @tornado.web.authenticated
+ def get(self, path):
+ if path is None:
+ 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 wiki page
+ page = self.backend.wiki.get_page(path)
+
+ # Empty page if it was deleted
+ if page and page.was_deleted():
+ page = None
+
+ # Render page
+ self.render("docs/edit.html", page=page, path=path)
+
+ @tornado.web.authenticated
+ def post(self, path):
+ if path is None:
+ 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))
+
+ content = self.get_argument("content", None)
+ changes = self.get_argument("changes")
+
+ # Create a new page in the database
+ with self.db.transaction():
+ page = self.backend.wiki.create_page(path,
+ self.current_user, content, changes=changes, address=self.get_remote_ip())
+
+ # Add user as a watcher if wanted
+ watch = self.get_argument("watch", False)
+ if watch:
+ page.add_watcher(self.current_user)
+
+ # Redirect back
+ if page.was_deleted():
+ self.redirect("/")
+ else:
+ self.redirect(page.url)
+
+ def on_finish(self):
+ """
+ Updates the search index after the page has been edited
+ """
+ # This is being executed in the background and after
+ # the response has been set to the client
+ with self.db.transaction():
+ self.backend.wiki.refresh()
+
+
+class ActionRenderHandler(base.BaseHandler):
+ def check_xsrf_cookie(self):
+ pass # disabled
+
+ @tornado.web.authenticated
+ @base.ratelimit(minutes=5, requests=180)
+ def post(self, path):
+ if path is None:
+ path = "/"
+
+ content = self.get_argument("content")
+
+ # Render the content
+ html = self.backend.wiki.render(path, content)
+
+ self.finish(html)
+
+
class SearchHandler(base.BaseHandler):
@base.ratelimit(minutes=5, requests=25)
def get(self):
from . import base
from . import ui_modules
-class ActionEditHandler(base.BaseHandler):
- @tornado.web.authenticated
- def get(self, path):
- if path is None:
- 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 wiki page
- page = self.backend.wiki.get_page(path)
-
- # Empty page if it was deleted
- if page and page.was_deleted():
- page = None
-
- # Render page
- self.render("wiki/edit.html", page=page, path=path)
-
- @tornado.web.authenticated
- def post(self, path):
- if path is None:
- 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))
-
- content = self.get_argument("content", None)
- changes = self.get_argument("changes")
-
- # Create a new page in the database
- with self.db.transaction():
- page = self.backend.wiki.create_page(path,
- self.current_user, content, changes=changes, address=self.get_remote_ip())
-
- # Add user as a watcher if wanted
- watch = self.get_argument("watch", False)
- if watch:
- page.add_watcher(self.current_user)
-
- # Redirect back
- if page.was_deleted():
- self.redirect("/")
- else:
- self.redirect(page.url)
-
- def on_finish(self):
- """
- Updates the search index after the page has been edited
- """
- # This is being executed in the background and after
- # the response has been set to the client
- with self.db.transaction():
- self.backend.wiki.refresh()
-
-
class ActionUploadHandler(base.BaseHandler):
@tornado.web.authenticated
@base.ratelimit(minutes=60, requests=24)
self.redirect(page.url)
-class ActionRenderHandler(base.BaseHandler):
- def check_xsrf_cookie(self):
- pass # disabled
-
- @tornado.web.authenticated
- @base.ratelimit(minutes=5, requests=180)
- def post(self, path):
- if path is None:
- path = "/"
-
- content = self.get_argument("content")
-
- # Render the content
- html = self.backend.wiki.render(path, content)
-
- self.finish(html)
-
-
class FilesHandler(base.BaseHandler):
@tornado.web.authenticated
def get(self, path):