From 6a401f322fbf723929932dedf15324c548fbedb5 Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Fri, 11 Oct 2024 14:39:25 +0200 Subject: [PATCH] Help for tagging (search) added. --- pages/help.py | 6 ++++-- pages/search.py | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pages/help.py b/pages/help.py index 1b8bfff..1fd9e6c 100644 --- a/pages/help.py +++ b/pages/help.py @@ -42,12 +42,13 @@ ACCESS = mycreole.render_simple(_(""" SEARCH = mycreole.render_simple(_( """ = Search -The search looks up full words in //title (page basename)// and //page_src (the creole source)// without giving \ -special search commands in the search string. +The search looks up full words in //title (page basename)//, //page_src (the creole source)// and //tag (page tags)// \ +without giving special search commands in the search string. === Search fields * title (TEXT) * page_src (TEXT) +* tag (TEXT) * creation_time (DATETIME) * modified_time (DATETIME) * modified_user (TEXT) @@ -80,6 +81,7 @@ This search pattern can also be combined with other search text via logical oper == Examples * [[/search/?q=modified_user:system-page|modified_user:system-page]] results in a list of all system pages. * [[/search/?q=modified_time%3A%5B-5d+to+now%5D| modified_time:[-5d to now] ]] results in a list of all pages which have been modified within the last 5 days. +* [[/search/?q=tag%3Afoo| tag:foo ]] results in a list of all pages which are tagged with //foo//. """)) BACKUP = mycreole.render_simple(_( diff --git a/pages/search.py b/pages/search.py index 30f2433..04a4a38 100644 --- a/pages/search.py +++ b/pages/search.py @@ -18,7 +18,7 @@ SCHEMA = Schema( # Page title=TEXT, page_src=TEXT, - page_tags=TEXT, + tag=TEXT, # metadata creation_time=DATETIME, modified_time=DATETIME, @@ -64,7 +64,7 @@ def add_item(ix, bp: base_page): # title=bp.title, page_src=bp.raw_page_src, - page_tags=bp.page_tags, + tag=bp.page_tags, # creation_time=datetime.fromtimestamp(bp._meta_data.get(bp._meta_data.KEY_CREATION_TIME)), modified_time=datetime.fromtimestamp(bp._meta_data.get(bp._meta_data.KEY_MODIFIED_TIME)), @@ -79,7 +79,7 @@ def add_item(ix, bp: base_page): def whoosh_search(search_txt): ix = load_index() - qp = qparser.MultifieldParser(['title', 'page_src', 'page_tags'], ix.schema) + qp = qparser.MultifieldParser(['title', 'page_src', 'tag'], ix.schema) qp.add_plugin(DateParserPlugin(free=True)) try: q = qp.parse(search_txt)