From: Michael Tremer Date: Wed, 8 May 2019 16:57:32 +0000 (+0100) Subject: wiki: Add watchlist X-Git-Url: http://git.ipfire.org/?p=ipfire.org.git;a=commitdiff_plain;h=2f23c5584b25886f9667db05f0c94d1c96c1658a wiki: Add watchlist Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index 70872e13..a5db487b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -272,7 +272,8 @@ templates_wiki_DATA = \ src/templates/wiki/page.html \ src/templates/wiki/recent-changes.html \ src/templates/wiki/revisions.html \ - src/templates/wiki/search-results.html + src/templates/wiki/search-results.html \ + src/templates/wiki/watchlist.html templates_wikidir = $(templatesdir)/wiki diff --git a/src/backend/wiki.py b/src/backend/wiki.py index 5416f389..3dc8a71f 100644 --- a/src/backend/wiki.py +++ b/src/backend/wiki.py @@ -138,6 +138,18 @@ class Wiki(misc.Object): """ self.db.execute("REFRESH MATERIALIZED VIEW wiki_search_index") + def get_watchlist(self, account): + pages = self._get_pages( + "WITH pages AS (SELECT * FROM wiki_current \ + LEFT JOIN wiki ON wiki_current.id = wiki.id) \ + SELECT * FROM wiki_watchlist watchlist \ + LEFT JOIN pages ON watchlist.page = pages.page \ + WHERE watchlist.uid = %s", + account.uid, + ) + + return sorted(pages) + # ACL def check_acl(self, page, account): diff --git a/src/templates/base.html b/src/templates/base.html index 449f53cd..71ceefc8 100644 --- a/src/templates/base.html +++ b/src/templates/base.html @@ -206,6 +206,12 @@ {{ _("Recent Changes") }} + +
diff --git a/src/templates/wiki/watchlist.html b/src/templates/wiki/watchlist.html new file mode 100644 index 00000000..a8f0ada4 --- /dev/null +++ b/src/templates/wiki/watchlist.html @@ -0,0 +1,21 @@ +{% extends "base.html" %} + +{% block title %}{{ _("Your Watchlist") }}{% end block %} + +{% block sidebar %} + {% set help = backend.wiki.get_page("/wiki/watchlist") %} + + {% if help %} + {% raw help.html %} + {% end %} +{% end block %} + +{% block main %} +
+
+
{{ _("Your Watchlist") }}
+ + {% module WikiList(pages) %} +
+
+{% end block %} diff --git a/src/web/__init__.py b/src/web/__init__.py index b8b363f4..ae86c52c 100644 --- a/src/web/__init__.py +++ b/src/web/__init__.py @@ -296,6 +296,7 @@ class Application(tornado.web.Application): # Handlers (r"/recent\-changes", wiki.RecentChangesHandler), (r"/search", wiki.SearchHandler), + (r"/watchlist", wiki.WatchlistHandler), # Media (r"([A-Za-z0-9\-_\/]+)?/files", wiki.FilesHandler), diff --git a/src/web/wiki.py b/src/web/wiki.py index a997ed4a..bce58ca1 100644 --- a/src/web/wiki.py +++ b/src/web/wiki.py @@ -238,6 +238,14 @@ class RecentChangesHandler(auth.CacheMixin, base.BaseHandler): self.render("wiki/recent-changes.html", recent_changes=recent_changes) +class WatchlistHandler(auth.CacheMixin, base.BaseHandler): + @tornado.web.authenticated + def get(self): + pages = self.backend.wiki.get_watchlist(self.current_user) + + self.render("wiki/watchlist.html", pages=pages) + + class WikiDiffModule(ui_modules.UIModule): differ = difflib.Differ()