Fetching contributors…
Cannot retrieve contributors at this time
465 lines (414 sloc) 19 KB
$def with (page)
$ title_suffix = cond(page.publish_date, "({0} edition)".format(page.publish_date), "(edition)")
$ title = page.title + " " + title_suffix
$ title_with_site = title + " | Open Library"
$ meta_cover_url = item_image(page.get_cover_url("M"), default="")
$var title: $title
def has_any(*keys):
return any(page[k] for k in keys)
def get_description(book):
if book.publishers and book.publish_date:
edition = book.publish_date + ', ' + ', '.join(book.publishers)
elif book.publish_date:
edition = book.publish_date
elif book.publishers:
edition = ', '.join(book.publishers)
edition = 'unknown'
work = and[0]
title = cond(work, work.title, book.title)
authors = cond(work, work and work.get_authors(), book.get_authors())
author_info = " by " + ", ".join( for a in authors)
format = ""
if book.physical_format:
format += book.physical_format.replace('[', '').replace(']', '')
if book.languages:
format += ' in ' + ', '.join( for lang in book.languages)
if book.edition_name:
format += " - " + book.edition_name
meta = title + author_info + ", " + edition + " edition, " + format
return meta
description = get_description(page)
putctx("description", description)
def get_authors_byline(page, include_schema=False):
work = and[0]
schema_attribute = cond(include_schema, ' itemprop="author"', '')
authors = cond(work, work and work.get_authors(), page.get_authors())
if authors:
return ', '.join('<a href="%s"%s>%s</a>' % (a.url(), schema_attribute, truncate(, 40)) for a in authors)
elif page.author_names:
return ('<span%s>' % (schema_attribute)) + ", ".join(page.author_names) + "</span>"
return None
$def display_value(label, value, itemprop=None):
$if value:
<td class="title"><span class="title">$label</span></td>
$if itemprop:
<td><span itemprop="$itemprop" class="object">$:thingrepr(value)</span></td>
<td><span class="object">$:thingrepr(value)</span></td>
$def display_identifiers(label, ids, itemprop=None):
$if label != "Goodreads":
$ all_ids = [-1!=id['value'].find('openlib-') for id in ids]
$if (True in all_ids) and (1==len(all_ids)):
<td class="title"><span class="title">$label</span></td>
<td class="object"><span class="object" $:cond(itemprop, 'itemprop="%s"' % itemprop, '')>
$for id in ids:
$ sep = cond(loop.last, "", ", ")
$if -1 != id.value.find('openlib-'):
$if id.url:
<a href="$id.url">$id.value</a>$sep
$def display_goodreads(label, ids):
$if label == "Goodreads":
<table class="meta collapse">
<td class="title"><span class="title">$label</span></td>
<td class="object">
<span class="object">
$for id in ids:
<a href="$id.url">$id.value</a>
<div id="gr_add_to_books">
<div class="gr_custom_each_container_">
<iframe height="110" width="280" frameborder="0" scrolling="no" src="//$id.value" /></iframe>
$def display_contributor(c):
<li><span>$c.role</span><br />$ </li>
$ work = and[0] or None
$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 book on Open Library.")
$add_metatag(property="twitter:image", content=meta_cover_url)
$add_metatag(property="og:title", content=title_with_site)
$add_metatag(property="og:type", content="")
$add_metatag(property="og:image", content=meta_cover_url)
$add_metatag(property="og:url", content=request.canonical_url)
$add_metatag(property="og:site_name", content="Open Library")
$add_metatag(property="og:description", content=description)
$set_share_links(url=request.canonical_url, title=title, view_context=ctx)
<style type="text/css">
.page-banner {
background: #95A865;
color: black;
background: #036DAA;
color: white;
text-align: left;
padding: 20px;
.page-banner a {
color: white;
.page-banner .button {
background: #62AAD4;
color: white;
border-radius: 5px;
padding: 10px;
cursor: pointer;
display: inline;
border: 1px solid #389AD4;
color: #95A865;
.page-banner a.button {
color: #95A865;
color: white;
text-decoration: none;
color: #95A865;
background: #389AD4;
color: #ffe;
.page-banner a.button:hover {
/*background: #95A865;*/
background: #62AAD4;
color: white;
$ ebook_status = page.get_ebook_status()
$if ebook_status == "read-online":
<div class="page-banner sansserief">
This title is part of the <a href="">classic eBook collection</a>.
$ read_url = "https://%s/stream/%s?ref=ol" % (bookreader_host(), page.ocaid)
<a class="button" target="_blank" href="$read_url">Read online now!</a>
$elif ebook_status == "borrow-available":
<div class="page-banner sansserief">
This title is part of the <a href="">Lending Library collection</a>.
<a class="button borrow-link" href="$page.url('/borrow')">Borrow eBook</a>
$elif ebook_status == "borrow-checkedout":
<div class="page-banner sansserief">
This title from the <a href="">Lending Library collection</a> is already checked out.
<a class="button borrow-link" href="$page.url('/borrow')">Join the waiting list</a>
$elif ebook_status == "borrow-user-waiting":
<div class="page-banner sansserief">
$ position = page.get_waitinglist_position(ctx.user)
$if position == 1:
You are waiting for this book and you are the next person to get this book.
$elif position == 2:
You are waiting for this book and one person ahead of you in the waiting list.
You are waiting for this book and $(position-1) people are ahead of you in the waiting list.your loans?
<a href="/account/loans">Review your loans?</a>
$elif ebook_status == "borrow-user-checkedout":
<div class="page-banner sansserief">
You have checked out this book. <a href="/account/loans">Review your loans?</a>
<div id="contentHead">
<table width="100%"><tbody><tr>
<td valign="top" style="padding-right:10px;">
$ cover_url = None
$# optimization to avoid solr query to find work cover
$if work and work.edition_count == 1:
$ cover_url = work.get_cover_url('S', use_solr=False) or page.get_cover_url('S')
$:render_template('covers/book_cover_small',[0], cover_url=cover_url)
$ item_id = None
$if 'ocaid' in page:
$ item_id = page['ocaid']
$ meta_fields = page.get_ia_meta_fields()
$if meta_fields:
$ collection = meta_fields.get('collection', [])
$if 'printdisabled' in collection or 'lendinglibrary' in collection:
$ item_id = None
<td valign="top" width="100%">
<div class="navEdition brown sansserif small">
$ work = and[0]
$if work:
<strong>$work.edition_count edition$("s" if work.edition_count != 1 else "")</strong> of
<span title="$_('Go to the main page for %s', page.title)"><a href="$work.url()">$truncate(work.title or "", 60)</a></span>
<strong>$:_('1 edition')</strong> record for of $page.title
$ authors_byline = get_authors_byline(page)
$if authors_byline:
$_("by") <span title="$_('Author')">$:authors_byline</span>
$:_("by an <em>unknown author</em>")
$if work:
<span class="smaller">&nbsp;&bull;&nbsp;<a href="/books/add?work=$work.key" title="$_('Add another edition of') $page.title">$_("Add edition")</a>?</span>
<br />
<div class="shift">
$if page.ocaid:
An ebook is available for this edition.
<a href="#read">Go to the read section to download</a>.
No ebook is available for this edition.
$if[0].edition_count > 1:
$ prev = page.get_prev()
$ next = page.get_next()
$if prev:
<a href="/books/$prev" title="$:_('View the previous edition of %s', page.title)">&larr; $_("Previous")</a>&nbsp;|
&larr; $_("Previous")&nbsp;|
$if next:
<a href="/books/$next" title="$:_('View the next edition of %s', page.title)">$_("Next") &rarr;</a>
$_("Next") &rarr;
<div id="contentBody" itemscope itemtype="">
<div class="workDetails">
<div class="editionCover">
<div class="illustration edition-cover">
$:render_template('covers/book_cover', page)
$# Don't display add/change cover link for /books/ia:foo00bar pages
$if not page.is_fake_record():
$:render_template('covers/change', page, ".edition-cover .bookCover img")
$ contributors = page.get('contributors', [])
$if contributors:
<div class="section">
<h3 class="collapse">$_("Contributors")</h3>
<ul class="contributors">
$for c in contributors:
<div class="editionAbout">
<div class="section sansserif">
<h1 class="edition">
<strong itemprop="name">$page.title</strong>
$if page.subtitle:
<br /><em>$page.subtitle</em>
$if page.edition_title or page.edition_name:
<br />$page.edition_title $page.edition_name
$ authors_byline = get_authors_byline(page, include_schema=True)
$if authors_byline:
<br />$_("by") $:authors_byline
<h4 class="publisher">
$if page.publish_date or page.publishers or page.publish_places:
$if page.publish_date:
<strong itemprop="datePublished">$page.publish_date</strong>
$if page.publishers:
$for p in page.publishers:
$if "publishers" in ctx.features:
<a itemprop="publisher" href="/publishers/$p.replace(' ', '_')" title="$_('Show for other books from %s', p)">$p</a>$cond(loop.last, "", ", ")
<a itemprop="publisher" href="/search?publisher_facet=$p.replace('&','%26')" title="$_('Search for other books from') $p">$p</a>$cond(loop.last, "", ", ")
$if page.publish_places:
$for p in page.publish_places:
<a href="/search/subjects?q=$p.replace('&','%26')" title="$_('Search for subjects about') $p">$p</a>$cond(loop.last, "", ", ")
<span class="adjust">.</span>
$if page.languages:
<br/>Written in <span itemprop="In language">$:thingrepr(page.languages)</span>.
$if page.description:
<h3 class="collapse">$_("About the Book")</h3>
$if page.first_sentence:
<h3 class="collapse">$_("First Sentence")</h3>
$ table_of_contents = page.get_table_of_contents()
$if table_of_contents and len(table_of_contents) > 1:
<div class="section">
<h3 class="collapse">$_("Table of Contents")</h3>
<table class="meta sansserif" id="toc-table">
$for toc in table_of_contents:
<tr class="toc-level-$toc.level">
<td class="toc-label">$toc.label</td>
$if item_id and toc.pagenum.isdigit():
<td class="toc-title"><a href="//$item_id#page/$toc.pagenum">$toc.title</a></td>
<td class="toc-title">$toc.title</td>
<td class="toc-pagenum">$toc.pagenum</td>
$if page.notes or page.series or page.volume or page.genres or page.other_titles or page.copyright_date or page.translation_of or page.translated_from:
<div class="section">
<h3 class="collapse">$_("Edition Notes")</h3>
$if page.notes:
<span class="sansserif">$:format(page.notes)</span>
<table class="meta">
$:display_value(_("Series"), page.series)
$:display_value(_("Volume"), page.volume)
$:display_value(_("Genre"), page.genres)
$:display_value(_("Other Titles"), page.other_titles)
$:display_value(_("Copyright Date"), page.copyright_date)
$:display_value(_("Translation Of"), page.translation_of)
$:display_value(_("Translated From"), page.translated_from)
$ classifications = page.get_classifications().multi_items()
$if classifications:
<div class="section">
<h3 class="collapse">$_("Classifications")</h3>
<table class="meta">
$for name, values in classifications:
$:display_identifiers(values[0].label, values)
$if has_any("physical_format", "pagination", "physical_dimensions", "weight"):
<div class="section">
<h3 class="collapse">$_("The Physical Object")</h3>
<table class="meta">
$:display_value(_("Format"), page.physical_format)
$:display_value(_("Pagination"), page.pagination)
$:display_value(_("Number of pages"), page.number_of_pages, itemprop="numberOfPages")
$:display_value(_("Dimensions"), page.physical_dimensions)
$:display_value(_("Weight"), page.weight)
<div class="section">
<h3 class="collapse">$_("ID Numbers")</h3>
<table class="meta">
$:display_identifiers("Open Library", [storage(url=None, value=page.key.split("/")[-1])])
$for name, values in page.get_identifiers().multi_items():
$ identifier_label = values[0].label
$if not (page.is_in_private_collection() and identifier_label == 'Internet Archive'):
$:display_identifiers(identifier_label, values, itemprop=cond(name in ["isbn_10", "isbn_13"], "isbn", None))
$:display_goodreads("Open Library", [storage(url=None, value=page.key.split("/")[-1])])
$for name, values in page.get_identifiers().multi_items():
$:display_goodreads(values[0].label, values)
<div class="editionTools">
$# pages like /books/ia:foo00bar are fake records created from metadata API.
$# Adding them to lists doesn't work. Disabling it to avoid any issues.
$if "lists" in ctx.features and not page.is_fake_record():
<div class="Tools">
$:render_template("lists/widget", page)
$ links = page.get_links()
$if links:
<div class="section">
<h3>Links <span class="gray small sansserif">($_("that leave Open Library"))</span></h3>
<ul class="booklinks sansserif">
$for link in links:
<li><a href="$link.url">$link.title</a></li>
$if ctx.user and ctx.user.is_admin():
<div class="small sansserif clearfix"><br/><span class="adminOnly"><a href="$page.url('/borrow_admin')">View loan debugging information</a></span></div>
$:render_template("lib/history", page)
<script type="text/javascript">
\$('#historyTools').append('| <a href="javascript:;" id="wikilink" title="Cite this on Wikipedia">Wikipedia citation</a>');
<div class="hidden">
<div class="coverFloat" id="wikicode">
<div class="coverFloatHead">
Wikipedia citation
<a class="floaterShut" href="javascript:;" onclick="\$.fn.colorbox.close();"><span class="shift">Close</span></a>
<p>Copy and paste this code into your Wikipedia page. <a href="" target="_new" title="Get instructions at Wikipedia in a new window">Need help</a>?</p>
<form method="get" action="">
<textarea cols="30" rows="20" readonly="readonly" id="wikiselect">{{Citation
$for k, v in page.wp_citation_fields.iteritems():
|$k = $v
<!-- source_records: $page.get('source_records', []) -->