diff --git a/openlibrary/templates/site/neck.html b/openlibrary/templates/site/neck.html index 202494f03ca..e85883e8dda 100644 --- a/openlibrary/templates/site/neck.html +++ b/openlibrary/templates/site/neck.html @@ -8,7 +8,7 @@ $if ctx.get("description"): - $:title ($_("Open Library")) + $:title | $_("Open Library") $for link in ctx.get("links", []): $:link diff --git a/openlibrary/templates/type/edition/view.html b/openlibrary/templates/type/edition/view.html index 7b3ffe175bf..9487765be5f 100644 --- a/openlibrary/templates/type/edition/view.html +++ b/openlibrary/templates/type/edition/view.html @@ -1,6 +1,7 @@ $def with (page) -$var title: $page.title +$ title_suffix = cond(page.publish_date, "({0} edition)".format(page.publish_date), "(edition)") +$var title: $page.title $title_suffix $add_metatag(property="twitter:card", content="summary") $add_metatag(property="twitter:site", content="@openlibrary") @@ -42,6 +43,18 @@ return meta putctx("description", get_description(page)) +$code: + def get_authors_byline(page, include_schema=False): + work = page.works and page.works[0] + schema_attribute = cond(include_schema, ' itemprop="author"', '') + authors = cond(work, work and work.get_authors(), page.get_authors()) + if authors: + return ', '.join('%s' % (a.url(), schema_attribute, truncate(a.name, 40)) for a in authors) + elif page.author_names: + return ('' % (schema_attribute)) + ", ".join(page.author_names) + "" + else: + return None + $def display_value(label, value, itemprop=None): $if value: @@ -198,12 +211,9 @@ $truncate(work.title or "", 60) $else: $:_('1 edition') record for of $page.title - $ authors = cond(work, work and work.get_authors(), page.get_authors()) - $if authors: - $ author_list = ', '.join('%s' % (a.url(), truncate(a.name, 40)) for a in authors) - $_("by") $:author_list - $elif page.author_names: - by $", ".join(page.author_names) + $ authors_byline = get_authors_byline(page) + $if authors_byline: + $_("by") $:authors_byline $else: $:_("by an unknown author") $if work: @@ -265,8 +275,9 @@


$page.subtitle $if page.edition_title or page.edition_name:
$page.edition_title $page.edition_name - $if page.by_statement: -
$page.by_statement + $ authors_byline = get_authors_byline(page, include_schema=True) + $if authors_byline: +
$_("by") $:authors_byline

$if page.publish_date or page.publishers or page.publish_places: @@ -287,7 +298,7 @@

$p$cond(loop.last, "", ", ") . $if page.languages: -
Written in $:thingrepr(page.languages). +
Written in $:thingrepr(page.languages).