From: Michael Tremer Date: Sat, 1 Jul 2023 10:51:07 +0000 (+0000) Subject: docs: Move file listing handler X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=efaf0fa679da965c72274cc342a3291e56c283b7;p=ipfire.org.git docs: Move file listing handler Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index 5c45458e..8fd73cab 100644 --- a/Makefile.am +++ b/Makefile.am @@ -214,7 +214,8 @@ templates_docs_DATA = \ templates_docsdir = $(templatesdir)/docs templates_docs_files_DATA = \ - src/templates/docs/files/detail.html + src/templates/docs/files/detail.html \ + src/templates/docs/files/index.html templates_docs_filesdir = $(templates_docsdir)/files @@ -350,11 +351,6 @@ templates_voip_modulesdir = $(templates_voipdir)/modules templates_wikidir = $(templatesdir)/wiki -templates_wiki_files_DATA = \ - src/templates/wiki/files/index.html - -templates_wiki_filesdir = $(templates_wikidir)/files - templates_wiki_messages_DATA = \ src/templates/wiki/messages/page-changed.txt diff --git a/src/templates/wiki/files/index.html b/src/templates/docs/files/index.html similarity index 100% rename from src/templates/wiki/files/index.html rename to src/templates/docs/files/index.html diff --git a/src/web/__init__.py b/src/web/__init__.py index 4e50a2c3..81733e4e 100644 --- a/src/web/__init__.py +++ b/src/web/__init__.py @@ -151,6 +151,7 @@ class Application(tornado.web.Application): (r"/docs/([A-Za-z0-9\-_\/]+)?/_(watch|unwatch)", docs.WatchHandler), (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\-_\/]+)?/_files", docs.FilesHandler), (r"/docs([A-Za-z0-9\-_\/]+)?", docs.PageHandler), # Downloads @@ -353,9 +354,6 @@ class Application(tornado.web.Application): (r"/actions/restore", wiki.ActionRestoreHandler), (r"/actions/upload", wiki.ActionUploadHandler), - # Media - (r"([A-Za-z0-9\-_\/]+)?/_files", wiki.FilesHandler), - # Serve any static files (r"/static/(.*)", tornado.web.StaticFileHandler, { "path" : self.settings.get("static_path") }), diff --git a/src/web/docs.py b/src/web/docs.py index 27f89281..e3f68475 100644 --- a/src/web/docs.py +++ b/src/web/docs.py @@ -89,6 +89,21 @@ class PageHandler(base.BaseHandler): self.render("docs/page.html", page=page, latest_revision=latest_revision) +class FilesHandler(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)) + + files = self.backend.wiki.get_files(path) + + self.render("docs/files/index.html", path=path, files=files) + + class FileHandler(base.BaseHandler): @property def action(self): diff --git a/src/web/wiki.py b/src/web/wiki.py index ba914ba1..8d6faad0 100644 --- a/src/web/wiki.py +++ b/src/web/wiki.py @@ -62,21 +62,6 @@ class ActionRestoreHandler(base.BaseHandler): self.redirect(page.page) -class FilesHandler(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)) - - files = self.backend.wiki.get_files(path) - - self.render("wiki/files/index.html", path=path, files=files) - - class WikiListModule(ui_modules.UIModule): def render(self, pages, link_revision=False, show_breadcrumbs=True, show_author=True, show_changes=False):