From 739fff7641aea9a1f36fb507839693cf49bc5cdb Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 1 Jul 2023 10:13:43 +0000 Subject: [PATCH] docs: Move the diff UI module Signed-off-by: Michael Tremer --- Makefile.am | 2 +- src/templates/docs/diff.html | 2 +- src/templates/{wiki => docs}/modules/diff.html | 0 src/web/__init__.py | 2 +- src/web/docs.py | 12 ++++++++++++ src/web/wiki.py | 13 ------------- 6 files changed, 15 insertions(+), 16 deletions(-) rename src/templates/{wiki => docs}/modules/diff.html (100%) diff --git a/Makefile.am b/Makefile.am index 539cb70a..03a1d205 100644 --- a/Makefile.am +++ b/Makefile.am @@ -207,6 +207,7 @@ templates_docs_DATA = \ templates_docsdir = $(templatesdir)/docs templates_docs_modules_DATA = \ + src/templates/docs/modules/diff.html \ src/templates/docs/modules/header.html templates_docs_modulesdir = $(templates_docsdir)/modules @@ -358,7 +359,6 @@ templates_wiki_messages_DATA = \ templates_wiki_messagesdir = $(templates_wikidir)/messages templates_wiki_modules_DATA = \ - src/templates/wiki/modules/diff.html \ src/templates/wiki/modules/list.html templates_wiki_modulesdir = $(templates_wikidir)/modules diff --git a/src/templates/docs/diff.html b/src/templates/docs/diff.html index 71f171d5..80b6b523 100644 --- a/src/templates/docs/diff.html +++ b/src/templates/docs/diff.html @@ -37,7 +37,7 @@ {% end %} - {% module WikiDiff(a, b) %} + {% module DocsDiff(a, b) %} {% end block %} diff --git a/src/templates/wiki/modules/diff.html b/src/templates/docs/modules/diff.html similarity index 100% rename from src/templates/wiki/modules/diff.html rename to src/templates/docs/modules/diff.html diff --git a/src/web/__init__.py b/src/web/__init__.py index 144787af..f21f2822 100644 --- a/src/web/__init__.py +++ b/src/web/__init__.py @@ -75,6 +75,7 @@ class Application(tornado.web.Application): "BootMenuSeparator" : boot.MenuSeparatorModule, # Docs + "DocsDiff" : docs.DiffModule, "DocsHeader" : docs.HeaderModule, # Nopaste @@ -96,7 +97,6 @@ class Application(tornado.web.Application): "VoIPRegistrations" : voip.RegistrationsModule, # Wiki - "WikiDiff" : wiki.WikiDiffModule, "WikiList" : wiki.WikiListModule, # Misc diff --git a/src/web/docs.py b/src/web/docs.py index 1f60d13f..ef1c969a 100644 --- a/src/web/docs.py +++ b/src/web/docs.py @@ -161,3 +161,15 @@ class HeaderModule(ui_modules.UIModule): return self.render_string("docs/modules/header.html", breadcrumbs=breadcrumbs, page=self.page, page_title=title, suffix=suffix) + + +class DiffModule(ui_modules.UIModule): + differ = difflib.Differ() + + def render(self, a, b): + diff = self.differ.compare( + a.markdown.splitlines(), + b.markdown.splitlines(), + ) + + return self.render_string("docs/modules/diff.html", diff=diff) diff --git a/src/web/wiki.py b/src/web/wiki.py index d90fcacb..bf9fe54e 100644 --- a/src/web/wiki.py +++ b/src/web/wiki.py @@ -1,6 +1,5 @@ #!/usr/bin/python3 -import difflib import tornado.web from . import base @@ -241,18 +240,6 @@ class WatchlistHandler(base.BaseHandler): self.render("wiki/watchlist.html", pages=pages) -class WikiDiffModule(ui_modules.UIModule): - differ = difflib.Differ() - - def render(self, a, b): - diff = self.differ.compare( - a.markdown.splitlines(), - b.markdown.splitlines(), - ) - - return self.render_string("wiki/modules/diff.html", diff=diff) - - class WikiListModule(ui_modules.UIModule): def render(self, pages, link_revision=False, show_breadcrumbs=True, show_author=True, show_changes=False): -- 2.47.3