Skip to content

Commit

Permalink
fix search for real
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name authored and alphatownsman committed Jul 19, 2024
1 parent 9096df2 commit af0f4fa
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions catalog/search/typesense.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"pub_house",
"company",
"publisher",
"host",
"isbn",
"imdb",
"barcode",
Expand Down
2 changes: 1 addition & 1 deletion catalog/search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def search(request):
except Exception:
categories = visible_categories(request)
tag = request.GET.get("tag", default="").strip()
tag = Tag.deep_cleanup_title(tag)
tag = Tag.deep_cleanup_title(tag, default="")
p = request.GET.get("page", default="1")
p = int(p) if p.isdigit() else 1
if not (keywords or tag):
Expand Down
4 changes: 2 additions & 2 deletions journal/models/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ def cleanup_title(title, replace=True):
return "_" if not t and replace else t

@staticmethod
def deep_cleanup_title(title):
def deep_cleanup_title(title, default="_"):
"""Remove all non-word characters, only for public index purpose"""
return re.sub(r"\W+", " ", title).rstrip().lstrip("# ").lower()[:100] or "_"
return re.sub(r"\W+", " ", title).rstrip().lstrip("# ").lower()[:100] or default

def update(
self, title: str, visibility: int | None = None, pinned: bool | None = None
Expand Down

0 comments on commit af0f4fa

Please sign in to comment.