$def with (doc, decorations=None, cta=True, availability=None, extra=None) $ availability = availability or doc.get('availability') or {} $ ocaid = availability.get('identifier') $ is_work = doc.get('type', {}).get('key') == '/type/work' $ book_url = doc.url() if is_work else doc.key $ cover_ids = [cover for cover in doc.get('covers', []) if cover != -1]
  • $if availability and availability.get('identifier'): $if availability.get('openlibrary_edition'): $ cover = get_coverstore_url() + "/b/olid/%s-M.jpg" % availability.get('openlibrary_edition') $elif ocaid: $ cover = "//archive.org/download/%s/page/cover_w60_h60.jpg" % ocaid $elif doc.get('cover_i') or cover_ids: $ cover = get_coverstore_url() + "/b/id/%s-M.jpg" % (doc.cover_i or cover_ids[0]) $elif doc.get('cover_edition_key'): $ cover = get_coverstore_url() + "/b/olid/%s-M.jpg" % doc.cover_edition_key $elif doc.get('ocaid'): $ cover = "//archive.org/download/%s/page/cover_w60_h60.jpg" % doc.get('ocaid') $else: $ cover = "/images/icons/avatar_book-sm.png" Cover of: $doc.title$(': ' + doc.subtitle if doc.get('subtitle', None) else '')

    $if doc.get('publish_date'): ($(doc['publish_date']))

    $if doc.get('first_publish_year'): $_('First published in %(year)s', year=doc.first_publish_year) $if doc.get('edition_count'): $ungettext('1 edition', '%(count)d editions', doc.edition_count, count=doc.edition_count) $if doc.get('languages'): $_('in') $(len(doc.languages)) $_('languages') $if doc.get('ia'): — $_('%s previewable', len(doc.get('ia'))) $if len(doc.get('ia')) > 1: $for x, i in enumerate(doc.get('ia')[1:10]): Cover of edition $i $if extra:
    $:extra
    $if decorations: $# should show reading log status widget if there is one in decorations, or read, or return, or leave waitlist
    $:decorations
    $if cta: $ doc['availability'] = doc.get('availability', {}) $:macros.LoanStatus(doc, work_key=doc.key)