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

6938/feature/google analytics html for facet #7042

Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 20 additions & 3 deletions openlibrary/templates/work_search.html
Expand Up @@ -13,7 +13,24 @@
if k != 'has_fulltext':
return changequery(page=None,**{k:[i for i in param.get(k, []) if i != v]})
else:
return changequery(page=None,**{k:None})
return changequery(page=None,**{k:None}
)
def add_track(key: str) -> str:
cdrini marked this conversation as resolved.
Show resolved Hide resolved
"""
KeyError will be raised if key is not in the following dict.
"""
facets = {
"has_fulltext": "Ebook",
"author_key": "Author",
"subject_facet": "Subjects",
"person_facet": "People",
"place_facet": "Places",
"time_facet": "Times",
"first_publish_year": "FirstPublished",
"publisher_facet": "Publisher",
"language_facet": "Language",
}
return f"SearchFacet|{facets[key]}"

$ param = {}
$for p in ['q', 'title', 'author', 'page', 'sort', 'isbn', 'oclc', 'contributor', 'publish_place', 'lccn', 'ia', 'first_sentence', 'publisher', 'author_key', 'debug', 'subject', 'place', 'person', 'time'] + facet_fields:
Expand Down Expand Up @@ -229,9 +246,9 @@ <h4 class="facetHead">$label</h4>
$ display = _('yes')
$else:
$ display = _('no')
<span class="small"><a href="$add_facet_url(header, k)" title="$_('Filter results for ebook availability')">$display</a></span>&nbsp;<span class="smaller gray">$commify(count)</span>
<span class="small"><a href="$add_facet_url(header, k)" title="$_('Filter results for ebook availability')" data-ol-link-track="$add_track(header)" >$display</a></span>&nbsp;<span class="smaller gray">$commify(count)</span>
$else:
<span class="small"><a href="$add_facet_url(header, k)" title="$_('Filter results for %(facet)s', facet=display)">$display</a></span>&nbsp;<span class="smaller gray">$commify(count)</span>
<span class="small"><a href="$add_facet_url(header, k)" title="$_('Filter results for %(facet)s', facet=display)" data-ol-link-track="$add_track(header)">$display </a></span>&nbsp;<span class="smaller gray">$commify(count)</span>
</div>
$if len(counts) > start_facet_count:
<div class="facetMoreLess">
Expand Down