Conversation
This makes more sense for browse-ish carousels
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## edition-aware-carousels #10472 +/- ##
==========================================================
Coverage ? 17.27%
==========================================================
Files ? 87
Lines ? 4845
Branches ? 860
==========================================================
Hits ? 837
Misses ? 3477
Partials ? 531 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
702a924 to
be9f271
Compare
a191464 to
b38a1a4
Compare
|
So, this mostly works so far. I'm still ironing out a few kinks. I've stopped it from breaking the current macro, but haven't yet figured out why the addition of 'lang' causes problems. Also, it doesn't yet show editions, which is a problem. |
…ibraryfork into edition-aware-carousels
This reverts commit e1e5c1e.
|
Alright, everything should be good to go here. The commit history is slightly messy, but nothing that should cause a problem. It's been tested on my end, and works fine. |
|
It looks like our Trusted Book Providers and/or Direct Provider books may show up as EDIT: Books from trusted & direct book providers should already be in solr via the In |
--- a/openlibrary/macros/LoanStatus.html
+++ b/openlibrary/macros/LoanStatus.html
@@ -59,6 +59,10 @@ $elif availability.get('is_readable') or availability.get('status') == 'open':
$if secondary_action:
$:macros.BookSearchInside(ocaid)
+$elif is_edition and doc.get('ebook_access') == 'public'):
+ $ olid = doc.key.split('/')[2]
+ $:macros.TrustedBookProviderReadButton(olid, title=doc.get('title'))
+
$elif ocaid and ctx.user and ctx.user.is_printdisabled():
$# Exemptions for patrons with Print Disabilities
$ pd_eligible = availability and availability.get('is_printdisabled')
diff --git a/openlibrary/macros/TrustedBookProviderReadButton.html b/openlibrary/macros/TrustedBookProviderReadButton.html
new file mode 100644
index 000000000..2078d240b
--- /dev/null
+++ b/openlibrary/macros/TrustedBookProviderReadButton.html
@@ -0,0 +1,13 @@
+$def with(olid, title="ebook", provider="Trusted Book Provider")
+
+$ stream_url = "/books/%s/-/borrow?ref=ol" % olid
+$ action = "read"
+$ label = _("Read")
+$ atitle = _("Read '%s' using %s" % (title, provider))
+
+<div class="cta-button-group">
+ <a href="/books/$olid/-/borrow?action=$action" title="$atitle"
+ $:analytics_attr('Read') target="_blank"
+ aria-haspopup="true" aria-controls="direct-provider-toast-$(olid)"
+ class="cta-btn cta-btn--available cta-btn--read cta-btn--external cta-btn--direct">$label</a>
+</div> |
|
Another possible blocker: On The templates in our js are out of date Options
|
|
Thanks @benbdeitch! I'm going to go ahead and merge this into the |
## Implement Unified Read Button Changes Creates a Unified Read Button Dropper that works across the Books Page, Authors Page, and Search Page. This includes the Book Page editions table. Currently uses a conditional check to avoid rendering in carousels because (a) carousels have not yet been made #10472 Edition-Aware and also because the styling is broken. The dropper shows the right primary action based on the case (e.g. Borrow, Read, Special Access) The dropdown options (which display in cases other than carousels) show `locate` and `listen` where applicable, with icons, and will soon show `search inside` and `download` options. We switched the Locate feature to use a new /borrow?action=locate method if an OCLC or ISBN identifier exists for an edition and simplified the code logic away from WorldcatURL.html. --------- Co-authored-by: Mek <[email protected]>

Addresses #7252
As of this moment, carousels link to and display works, rather than specific editions. This prevents users from specifically locating given editions of works on carousels, which is not ideal. This PR alters the functionality of carousels to link to and show covers of editions rather than works.
Technical
This issue originally called for restricting the editions that show to ones matching the user's language. In the name of getting this feature out sooner, that has been left out on Drini's advice, to be achieved in a later PR.
Testing
Create a new page on your local version, and create a Carousel macro.
{{QueryCarousel("*")}}should be a functional command.Screenshot
And when clicked:
Stakeholders
@jimchamp