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

Author Search: Implement alphabet index with a path search #160

Merged
merged 1 commit into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions src/recensio/plone/browser/authorsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def __call__(self):
def authors(self):
catalog = getToolByName(self.context, "portal_catalog")
author_string = safe_unicode(self.request.get("authors"))
letter = safe_unicode(self.request.get("letter"))
b_start = int(self.request.get("b_start", 0))
b_size = int(self.request.get("b_size", 30))
query = {
Expand All @@ -53,6 +54,10 @@ def authors(self):
query["path"] = navigation_root
if author_string:
query["SearchableText"] = author_string.strip("\"'")
if letter and letter in self.ALPHABET:
# XXX conflicts with navigation root
context_path = "/".join(self.context.getPhysicalPath())
query["path"] = f"{context_path}/gnd/{letter.lower()}"
return catalog(query)

@property
Expand Down
6 changes: 4 additions & 2 deletions src/recensio/plone/browser/templates/authorsearch.pt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
"
>

<form class="crossportalsearchform">
<form class="crossportalsearchform"
tal:condition="python:False"
>
<input ;=""
name="authors"
type="hidden"
Expand Down Expand Up @@ -112,7 +114,7 @@
<a href="#"
tal:content="letter"
tal:attributes="
href python:request.getURL() + '?authors=' + letter + '*&use_navigation_root:boolean=' + str(request.get('use_navigation_root', True));
href python:request.getURL() + '?letter=' + letter + '&use_navigation_root:boolean=' + str(request.get('use_navigation_root', True));
"
></a>
</tal:block>
Expand Down
Loading