$def with (list, is_owner)
$ title = list.name
$ title_with_site = _("%(name)s | Lists | Open Library", name=title)
$ component_times = {}
$ component_times['TotalTime'] = time()
$ page = safeint(query_param('page'), 1) - 1
$ page_size = 50
$ meta_cover_url = None # Add metatag for image at end of this template, if a cover image is present
$ meta_description = title
$if list.description:
$ meta_description = _("%(title)s: %(description)s", title=title, description=list.description)
$putctx("description", meta_description)
$if days_since(list.created) < 30:
$ putctx('robots', 'noindex')
$add_metatag(property="twitter:card", content="summary")
$add_metatag(property="twitter:site", content="@openlibrary")
$add_metatag(property="twitter:title", content=title_with_site)
$add_metatag(property="twitter:description", content= _("View the list on Open Library."))
$add_metatag(property="og:title", content=title_with_site)
$add_metatag(property="og:type", content="website")
$add_metatag(property="og:url", content=request.canonical_url)
$add_metatag(property="og:site_name", content="Open Library")
$add_metatag(property="og:description", content=meta_description)
$set_share_links(url=request.canonical_url, title=title, view_context=ctx)
$jsdef render_seed_count(seed_count):
$ungettext("1 item", "%(count)d items", seed_count, count=seed_count)
$if not is_owner:
$:macros.databarView(list)
$list.name
$ component_times['render_seed_count'] = time()
$:render_seed_count(len(list.seeds))
$ component_times['render_seed_count'] = time() - component_times['render_seed_count']
$_('Are you sure you want to remove this item from the list?')
$_('You are about to remove the last item in the list. That will delete the whole list. Are you sure you want to continue?')
$def render_authors(authors):
$if not authors:
$_('Unknown authors')
$else:
$for a in authors:
$a.name$cond(loop.last, "", ", ")
$if list.description:
$:format(list.description)
$ component_times['get_seeds'] = time()
$ seeds = list.get_seeds(sort=True, resolve_redirects=True)[page*page_size:page*page_size+page_size]
$ component_times['get_seeds'] = time() - component_times['get_seeds']
$for seed in seeds:
-
$ default_image = "https://openlibrary.org/images/icons/avatar_book-sm.png"
$ cover = seed.get_cover()
$if cover:
$ cover_url = item_image(cover.url("M"), default=default_image)
$else:
$ cover_url = default_image
$# Use first found image as the OpenGraph image
$if not meta_cover_url:
$ meta_cover_url = cover_url
$seed.key
$if seed.type in ['edition', 'work']:
$ doc = seed.document
$if seed.type in ['edition', 'work'] and doc.subtitle:
$doc.subtitle
$if seed.type in ['edition', 'work']:
$if seed.type == "work":
$ authors = seed.document.get_authors()
$else:
$if seed.document.works:
$ authors = seed.document.works[0].get_authors()
$else:
$ authors = seed.document.get_authors()
$:_('by %(name)s', name=render_authors(authors))
$seed.type
$if seed.last_update:
$:_('Last updated %(date)s', date=datestr(seed.last_update))
$if ctx.user and ctx.user.key == list.get_owner().key:
$_('Remove this item?')
$:render_template("type/list/exports", list)
$_('List Metadata')
$_('Derived from seed metadata')
$def render_subjects(label, subjects):
$if subjects:
$ subjects = list.get_subjects()
$:render_subjects(_("Subjects"), subjects.subjects)
$:render_subjects(_("People"), subjects.people)
$:render_subjects(_("Places"), subjects.places)
$:render_subjects(_("Times"), subjects.times)
$:macros.Pager(page+1, len(list.seeds), page_size)
$ component_times['TotalTime'] = time() - component_times['TotalTime']
$if query_param('debug'):
$:macros.Profile(component_times)
$:render_template("lib/history", list)
$if meta_cover_url is not None:
$add_metatag(property="og:image", content=meta_cover_url)
$add_metatag(property="twitter:image", content=meta_cover_url)