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

Use OL for homepage carousels #9972

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion openlibrary/macros/RawQueryCarousel.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

$code:
# Limit to just fields needed to render carousels
params = { 'q': query, 'fields': 'key,title,subtitle,author_name,cover_i,ia,availability,id_project_gutenberg,id_librivox,id_standard_ebooks,id_openstax' }
params = { 'q': query, 'fields': 'key,title,subtitle,author_name,cover_i,ia,availability,id_project_gutenberg,id_librivox,id_standard_ebooks,id_openstax', 'sort': sort }
# Don't need fields in the search UI url, since they don't do anything there
url = url or "/search?" + urlencode({'q': query})
if has_fulltext_only:
Expand Down
11 changes: 1 addition & 10 deletions openlibrary/plugins/openlibrary/tests/test_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,8 @@ def spoofed_generic_carousel(*args, **kwargs):
]

html = str(render_template("home/index", stats=stats, test=True))
headers = [
"Books We Love",
"Recently Returned",
"Kids",
"Thrillers",
"Romance",
"Textbooks",
]
for h in headers:
assert h in html

assert "Recently Returned" in html
assert "Around the Library" in html
assert "About the Project" in html

Expand Down
13 changes: 7 additions & 6 deletions openlibrary/templates/home/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,20 @@

$:macros.QueryCarousel(query="ddc:8* first_publish_year:[* TO 1950] publish_year:[2000 TO *] NOT public_scan_b:false", title=_('Classic Books'), key="public_domain", url="/read", sort='random.hourly', use_cache=False)

$:render_template("home/custom_ia_carousel", title=_('Books We Love'), key="staff_picks", query='languageSorter:("English")', subject="openlibrary_staff_picks", sorts=["lending___last_browse desc"], limit=18, test=test)
$:macros.QueryCarousel(title=_('Books We Love'), key="staff_picks", query='subject_key:open_library_staff_picks', sort='random.hourly', use_cache=False)

$:render_template("home/custom_ia_carousel", title=_('Recently Returned'), key="recently_returned", sorts=["lending___last_browse desc"], limit=18, test=test)

$:render_template("home/custom_ia_carousel", title=_('Romance'), key="romance", query="subject:(romance)", sorts=["lending___last_browse desc"], limit=18, test=test)
$if not test:
$:macros.QueryCarousel(title=_('Romance'), key="romance", query="subject:romance AND ebook_access:[borrowable TO *]", sort='random.hourly', use_cache=False)

$:render_template("home/custom_ia_carousel", title=_('Kids'), key="children", query="subject:(Juvenile Fiction)", sorts=["lending___last_browse desc"], limit=18, test=test)
$:macros.QueryCarousel(title=_('Kids'), key="children", query="subject:juvenile AND ebook_access:[borrowable TO *]", sort='random.hourly', use_cache=False)

$:render_template("home/custom_ia_carousel", title=_('Thrillers'), key="thrillers", query="preset:thrillers", sorts=["downloads desc"], limit=18, test=test)
$:macros.QueryCarousel(title=_('Thrillers'), key="thrillers", query="subject:thriller AND ebook_access:[borrowable TO *]", sort='random.hourly', use_cache=False)

$:render_template("home/custom_ia_carousel", title=_('Textbooks'), key="textbooks", subject="textbooks", sorts=["lending___last_browse desc"], limit=18, test=test)
$:macros.QueryCarousel(title=_('Textbooks'), key="textbooks", query="subject:textbook AND ebook_access:[borrowable TO *]", sort='random.hourly', use_cache=False)

$:render_template("home/custom_ia_carousel", title="Authors Alliance & MIT Press", key="authorsalliance_mit_press", query="preset:authorsalliance_mitpress", limit=18, test=test)
$:macros.QueryCarousel(title="Authors Alliance & MIT Press", key="authorsalliance_mit_press", query='(subject:authorsalliance OR publisher:"MIT Press" OR subject:mitpress) AND ebook_access:[borrowable TO *]', sort='random.hourly', use_cache=False)

$:render_template("home/categories", test=test)

Expand Down
Loading