fix search for real
This commit is contained in:
parent
9096df2da1
commit
af0f4fa052
3 changed files with 4 additions and 3 deletions
|
@ -29,6 +29,7 @@ SEARCHABLE_ATTRIBUTES = [
|
|||
"pub_house",
|
||||
"company",
|
||||
"publisher",
|
||||
"host",
|
||||
"isbn",
|
||||
"imdb",
|
||||
"barcode",
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -59,9 +59,9 @@ class Tag(List):
|
|||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue