Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New] Able to search in page content too #199

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions realms/modules/search/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,25 @@ def wiki(self, query):
for entry in g.current_wiki.get_index():
name = filename_to_cname(entry['name'])
name = re.sub(r"//+", '/', name)
if set(query.split()).intersection(name.replace('/', '-').split('-')):
page = g.current_wiki.get_page(name)

# this can be None, not sure how
if page:
res.append(dict(name=name, content=page.data))
toremove = '/-_'
for char in toremove:
nametmp = name.replace(char, '-')
page = g.current_wiki.get_page(name)
for tag in query.split():
found = False
for word in nametmp.split('-'):
if tag in word:
if not dict(name=name, content=page.data) in res:
res.append(dict(name=name, content=page.data))
found = True
break
if not found:
for word in page.data.split():
if tag in word:
if not dict(name=name, content=page.data) in res:
res.append(dict(name=name, content=page.data))
found = True
break
return res

def users(self, query):
Expand Down