diff --git a/openlibrary/macros/DownloadOptions.html b/openlibrary/macros/DownloadOptions.html new file mode 100644 index 00000000000..9b2177f3302 --- /dev/null +++ b/openlibrary/macros/DownloadOptions.html @@ -0,0 +1,24 @@ +$def with(page) + +$ downloadbook = page.get_ia_download_link(".pdf") +$ pdfbw = page.get_ia_download_link("_bw.pdf") +$ epub = page.get_ia_download_link(".epub") +$ mobi = page.get_ia_download_link(".mobi") +$ kindle = "https://www.amazon.com/gp/digital/fiona/web-to-kindle?clientid=IA&itemid=XXX&docid=XXX" +$ djvutxt = page.get_ia_download_link("_djvu.txt") + +$if downloadbook or djvutxt or epub or mobi: +
+
+

Download Options

+ +
diff --git a/openlibrary/macros/LoanStatus.html b/openlibrary/macros/LoanStatus.html index b75bfd496ef..fa3772cc93a 100644 --- a/openlibrary/macros/LoanStatus.html +++ b/openlibrary/macros/LoanStatus.html @@ -1,22 +1,27 @@ -$def with (page, ebook_text, user, current_and_available_loans, contributor, line_break = '', editions_page=False, isbn=None, oclc_numbers=None) - -$# TODO construct list of available formats from available_loans +$def with (page, user, editions_page=False) $ work = page.works and page.works[0] - -$if current_and_available_loans: - $ current_loans = current_and_available_loans[0] -$else: - $ current_loans = [] - +$ meta_fields = page.get_ia_meta_fields() or {} +$ contributor = meta_fields.get('contributor') +$ user_loan = None +$ waiting_loan = ctx.user and ctx.user.get_waiting_loan_for(page) +$ my_turn_to_borrow = waiting_loan and waiting_loan['status'] == 'available' and waiting_loan['position'] == 1 $ realtime_availability = page.get_realtime_availability() $ availability = realtime_availability.get('status', 'error') $ wlsize = realtime_availability.get('num_waitlist', 0) -$ waiting_loan = ctx.user and ctx.user.get_waiting_loan_for(page) -$ my_turn_to_borrow = waiting_loan and waiting_loan['status'] == 'available' and waiting_loan['position'] == 1 +$ current_and_available_loans = [] +$if page.get('ocaid'): + $ current_and_available_loans = page.get_current_and_available_loans() + $ user_loan = None + $if ctx.user: + $for current_loan in current_and_available_loans[0]: + $if current_loan['user'] == ctx.user.key: + $ user_loan = current_loan + $ break + +$ current_loans = current_and_available_loans[0] if current_and_available_loans else [] -$ user_loan = None $if user: $for current_loan in current_loans: $if current_loan['user'] == user.key: @@ -25,81 +30,69 @@ $ borrow_link = page.url() + '/borrow' -
- $if user_loan: -

- Read eBook -

- $ return_url = page.url().rsplit('/', 1)[0] + '/do_return/borrow' -
- - -
- $:macros.daisy(page) +$if user_loan: +

+ Read eBook +

+ $ return_url = page.url().rsplit('/', 1)[0] + '/do_return/borrow' +
+ + +
+ +$elif (availability == 'borrow_available') or my_turn_to_borrow: +

+ + Borrow eBook + +

+ +$elif (availability == 'borrow_unavailable'): + $if waiting_loan: +

+ $ spot = ctx.user.get_waiting_loan_for(page)['position'] + $if spot == 1: + You are next on the waiting list + $else: + You are #$(spot) of $(wlsize) on the waiting list. +

+
+ + +
- $elif (availability == 'borrow_available') or my_turn_to_borrow: -

- - Borrow eBook - -

- $:macros.daisy(page) + $else: +

+ $("Readers waiting for this title: %s" % wlsize if wlsize else "You'll be next in line.") +

+
+ + +
- $else: - $if waiting_loan: -

- $ spot = ctx.user.get_waiting_loan_for(page)['position'] - $if spot == 1: - You are next on the waiting list - $else: - You are #$(spot) of $(wlsize) on the waiting list. -

-
- - -
- $:macros.daisy(page) - $else: -

- $("Readers waiting for this title: %s" % wlsize if wlsize else "You'll be next in line.") -

-
- - -
- $:macros.daisy(page) +$elif page.get('ocaid') and not page.is_access_restricted() and editions_page: + $ viewbook = "//%s/stream/XXX?ref=ol" % bookreader_host() +

Read eBook

- $if editions_page: - $ checkedout = current_and_available_loans[0] if current_and_available_loans else [] - $if checkedout and not user_loan: - $if work and work.edition_count > 1: -
-

- Other editions of this book may be available: -

-

- Check Other Editions -

-
+$elif (not page.get('ocaid') or page.is_access_restricted()) and editions_page: +

No ebook available.

-$if editions_page: - $:macros.WorldcatLink(isbn=isbn, oclc_numbers=oclc_numbers) -$if editions_page: - $ share_links = ctx.get('share_links') - $if share_links: -
- +$if editions_page and page.get('ocaid'): + $:macros.daisy(page) -
+ $# If waitlisted, show other possible editions after daisy download link + $if (availability == 'borrow_unavailble'): + $ checkedout = current_and_available_loans[0] if current_and_available_loans else [] + $if checkedout and not user_loan: + $if work and work.edition_count > 1: +
+

+ Other editions of this book may be available: +

+

+ Check Other Editions +

+
diff --git a/openlibrary/macros/SocialShare.html b/openlibrary/macros/SocialShare.html new file mode 100644 index 00000000000..3f9f2c2fbef --- /dev/null +++ b/openlibrary/macros/SocialShare.html @@ -0,0 +1,15 @@ +$def with() + + $ share_links = ctx.get('share_links') + $if share_links: +
+ diff --git a/openlibrary/macros/daisy.html b/openlibrary/macros/daisy.html index c445a5848f5..f5cc630caa4 100644 --- a/openlibrary/macros/daisy.html +++ b/openlibrary/macros/daisy.html @@ -2,10 +2,11 @@ $ daisy = page.get_ia_download_link("_daisy.zip") - +$if daisy: + diff --git a/openlibrary/macros/databarWork.html b/openlibrary/macros/databarWork.html index 35a5afd2894..1ab5be39251 100644 --- a/openlibrary/macros/databarWork.html +++ b/openlibrary/macros/databarWork.html @@ -8,23 +8,8 @@ $ edit_url = page.key + "?m=edit" $ work = page.works and page.works[0] -$ worldcat = "https://worldcat.org/isbn/XXX" -$ worldcatoclc = "https://worldcat.org/oclc/XXX" -$ bookmooch = "http://www.bookmooch.com/m/mooch_choice?asin=XXX" -$ titletrader = "http://www.titletrader.com/invinfo/XXX.html" - $ viewbook = "//%s/stream/XXX?ref=ol" % bookreader_host() $ prices = page.key.startswith('/books/') -$ downloadbook = page.get_ia_download_link(".pdf") -$ pdfbw = page.get_ia_download_link("_bw.pdf") -$ daisy = page.get_ia_download_link("_daisy.zip") -$ epub = page.get_ia_download_link(".epub") -$ mobi = page.get_ia_download_link(".mobi") -$ kindle = "https://www.amazon.com/gp/digital/fiona/web-to-kindle?clientid=IA&itemid=XXX&docid=XXX" - -$ djvutxt = page.get_ia_download_link("_djvu.txt") -$ seeall = "//archive.org/download/XXX" -$ google = "" $ isbn = (page.isbn_10 and page.isbn_10[0]) or (page.isbn_13 and page.isbn_13[0]) or "" $ isbn = isbn.replace("-", "") @@ -47,7 +32,6 @@ $if isbn_10 and not asin: $ asin = isbn_10 -$ library = None