$def with(books=[], title="", url="", key="", min_books=1, load_more=None, test=False, compact_mode=False) $ 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 render_carousel_cover(book, lazy, index): $ 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 = 'https://archive.org/download/%s/page/cover_w180_h360.jpg'% book.get('ia')[0] $elif book.get('cover_edition_key'): $ cover_url = '%s/b/olid/%s-M.jpg'%(cover_host, book.get('cover_edition_key')) $else: $ cover_url = fallback_cover $if book.get('authors'): $ author_names = [author.name 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') $ last_book = '' $if index==4: $ last_book = 'last-book'
$if cover_url: $title$byline $else: src="$(cover_url)"/> $else:
$if test or (books and len(books) >= min_books):