mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Server: Fix error caused by libraries that have books with empty author fields (although this should be impossible). Fixes #1703064 [calibre-server 3.2.1 on FreeBSD: TypeError: Cannot read property 'join' of undefined](https://bugs.launchpad.net/calibre/+bug/1703064)
This commit is contained in:
parent
42543e57ec
commit
21f37bde8c
@ -403,10 +403,11 @@ def render_book(container_id, book_id):
|
||||
return
|
||||
metadata = book_metadata(book_id)
|
||||
set_title(c, metadata.title)
|
||||
alt = _('{} by {}').format(metadata.title, metadata.authors.join(' & '))
|
||||
authors = metadata.authors.join(' & ') if metadata.authors else _('Unknown')
|
||||
alt = _('{} by {}').format(metadata.title, authors)
|
||||
imgdiv = E.div(
|
||||
E.img(
|
||||
alt=alt, title=alt, data_title=metadata.title, data_authors=metadata.authors.join(' & '),
|
||||
alt=alt, title=alt, data_title=metadata.title, data_authors=authors,
|
||||
style='border-radius: 20px; max-width: calc(100vw - 2em); max-height: calc(100vh - 4ex - {}); display: block; width:auto; height:auto; border-radius: 20px'.format(get_font_size('title')
|
||||
))
|
||||
)
|
||||
@ -592,7 +593,7 @@ def search_internet(container_id):
|
||||
container = document.getElementById(container_id)
|
||||
create_top_bar(container, title=_('Search the internet'), action=back, icon='close')
|
||||
mi = book_metadata(render_book.book_id)
|
||||
data = {'title':mi.title, 'author':mi.authors[0]}
|
||||
data = {'title':mi.title, 'author':mi.authors[0] if mi.authors else _('Unknown')}
|
||||
|
||||
def link_for(name, template):
|
||||
return E.a(name, class_='simple-link', href=url_for(template, data), target="_blank")
|
||||
|
@ -60,7 +60,7 @@ def on_img_load(img, load_type):
|
||||
set_css(div, border='dashed 1px currentColor', border_radius=BORDER_RADIUS+'px')
|
||||
|
||||
def create_item(book_id, metadata, create_image, show_book_details):
|
||||
authors = metadata.authors.join(' & ')
|
||||
authors = metadata.authors.join(' & ') if metadata.authors else _('Unknown')
|
||||
img = create_image(book_id, THUMBNAIL_MAX_WIDTH, THUMBNAIL_MAX_HEIGHT, on_img_load)
|
||||
img.setAttribute('alt', _('{} by {}').format(metadata.title, authors))
|
||||
img.dataset.title, img.dataset.authors = metadata.title, authors
|
||||
|
@ -63,7 +63,7 @@ def on_img_load(img, load_type):
|
||||
|
||||
|
||||
def create_item(book_id, metadata, create_image, show_book_details):
|
||||
authors = metadata.authors.join(' & ')
|
||||
authors = metadata.authors.join(' & ') if metadata.authors else _('Unknown')
|
||||
img = create_image(book_id, THUMBNAIL_MAX_WIDTH, THUMBNAIL_MAX_HEIGHT, on_img_load)
|
||||
img.setAttribute('alt', _('{} by {}').format(metadata.title, authors))
|
||||
img.dataset.title, img.dataset.authors = metadata.title, authors
|
||||
@ -90,7 +90,7 @@ def create_item(book_id, metadata, create_image, show_book_details):
|
||||
class_='details-list-right',
|
||||
E.div(style='display:flex; justify-content: space-between; overflow: hidden',
|
||||
E.div(
|
||||
E.b(metadata.title or _('Unknown')), E.br(), metadata.authors.join(' & '),
|
||||
E.b(metadata.title or _('Unknown')), E.br(), authors,
|
||||
),
|
||||
extra_data
|
||||
),
|
||||
|
@ -107,8 +107,9 @@ def show_recent_stage2(books):
|
||||
if username and to_sync.length < 10:
|
||||
lr = book.last_read[username_key(username)] or new Date(0) # noqa: unused-local
|
||||
to_sync.push(v'[book.key, lr]')
|
||||
authors = book.metadata.authors.join(' & ') if book.metadata.authors else _('Unknown')
|
||||
img = E.img(
|
||||
alt=_('{} by {}').format(book.metadata.title, book.metadata.authors.join(' & '))
|
||||
alt=_('{} by {}').format(book.metadata.title, authors)
|
||||
)
|
||||
img_id = ensure_id(img)
|
||||
images.appendChild(E.div(style='margin: 0 1em',
|
||||
|
@ -55,8 +55,9 @@ def create_image(book_idx, max_width, max_height, on_load):
|
||||
on_load(this, 'load')
|
||||
book = book_list_data.book_data[book_idx]
|
||||
if book?.metadata:
|
||||
authors = book.metadata.authors.join(' & ') if book.metadata.authors else _('Unknown')
|
||||
img.setAttribute('alt', _('{} by {}').format(
|
||||
book.metadata.title, book.metadata.authors.join(' & ')))
|
||||
book.metadata.title, authors))
|
||||
if book?.cover_name:
|
||||
img_id = ensure_id(img, 'local-cover-')
|
||||
get_db().get_file(book, book.cover_name, show_cover.bind(img_id))
|
||||
|
Loading…
x
Reference in New Issue
Block a user