1
0
mirror of https://github.com/tiyn/amphora-wiki.git synced 2026-02-22 12:54:48 +01:00

Namespaces: added feature to show folder structure

Namespaces are an important feature to have a hierarchic structure for the wiki.
A new site was added that can display and navigate the folder structure.
This commit is contained in:
TiynGER
2020-10-24 17:38:40 +02:00
parent 91d2e940b0
commit 5a9ed40251
7 changed files with 122 additions and 9 deletions

View File

@@ -14,11 +14,12 @@ ENTRY_DIR = config.ENTRY_DIR
def createSearchableData(root):
'''
"""
Schema definition: title(name of file), path(as ID), content(indexed but not stored), textdata (stored text content)
source:
https://appliedmachinelearning.blog/2018/07/31/developing-a-fast-indexing-and-full-text-search-engine-with-whoosh-a-pure-pythhon-library/
'''
"""
schema = Schema(title=TEXT(stored=True),
path=ID(stored=True), content=TEXT)
if not os.path.exists(INDEX_DIR):
@@ -37,6 +38,16 @@ def createSearchableData(root):
def search_times(query_str, topN):
"""
Search for a given term and returns a specific amount of results.
Parameters:
query_str (string): term to search for
topN (int): number of results to return
Returns:
string: html-formatted string including the hits of the search
"""
ix = open_dir(INDEX_DIR)
results = []
with ix.searcher(weighting=scoring.BM25F) as s:
@@ -49,6 +60,15 @@ def search_times(query_str, topN):
def search(query_str):
"""
Search for a given term and show the predefined amount of results.
Parameters:
query_str (string): term to search for
Returns:
string: html-formatted string including the hits of the search
"""
return search_times(query_str, DEF_TOPN)