$def with(books=[], title="", url="", key="", min_books=1, load_more=None, test=False, compact_mode=False, secondary_action=False, layout='carousel') $if layout == 'carousel': $ ctx.setdefault("links", []) $# Apparently fonts always need crossorigin for some reason $ slick_font = '' $if slick_font not in ctx.links: $ ctx.links.append(slick_font) $def carousel_i18n_input(): $ show_carousel_i18n_strings= { $ "open": _("Read"), $ "borrow_available": _("Borrow"), $ "borrow_unavailable": _("Join Waitlist"), $ "error": _("Not in Library"), $ "loading": _("Loading...") $ } $if render_once('books/custom_carousel.i18n-strings'): $:carousel_i18n_input() $def render_carousel_cover(book, lazy, layout): $ fallback_cover = 'https://openlibrary.org/images/icons/avatar_book.png' $ cover_host = '//covers.openlibrary.org' $ url = book.get('key') or book.url $ title = book.title $ cover_id = book.get('cover_id') or book.get('cover_i') or book.get('covers') and book['covers'][0] $if book.get('cover_url'): $ cover_url = book.get('cover_url') $elif cover_id and cover_id != -1: $ cover_url = '%s/b/id/%s-M.jpg'%(cover_host, cover_id) $elif book.get('ia'): $ cover_url = '%s/b/ia/%s-M.jpg?default=%s'%(cover_host, book.get('ia')[0], fallback_cover) $elif book.get('cover_edition_key'): $ cover_url = '%s/b/olid/%s-M.jpg'%(cover_host, book.get('cover_edition_key')) $else: $ cover_url = False $if book.get('authors'): $ author_names = [author.name or _('name missing') for author in book.authors] $elif book.get('author_name'): $ author_names = book.get('author_name', []) $else: $ author_names = [] $if author_names: $ byline = _(' by %(name)s', name=', '.join(author_names)) $else: $ byline = '' $ modifier = '' $ work_key = book.key if book.key.startswith('/work') else book.get('work_key') $if test or (books and len(books) >= min_books):