This commit is contained in:
Kovid Goyal 2016-02-17 11:15:28 +05:30
parent c239646375
commit 8304f14c7d

View File

@ -139,20 +139,21 @@ def render_metadata(mi, interface_data, table, field_list=None):
add_row(name, val) add_row(name, val)
def process_identifiers(field, fm, name, val): def process_identifiers(field, fm, name, val):
if val and val.length: if val:
table.appendChild(E.tr(E.td(name + ':'), E.td()))
url_map = {k:v'[text, url]' for text, k, val, url in mi.urls_from_identifiers or v'[]'}
td = table.lastChild.lastChild
keys = Object.keys(val) keys = Object.keys(val)
for k in keys: if keys.length:
idval = val[k] table.appendChild(E.tr(E.td(name + ':'), E.td()))
x = url_map[k] url_map = {k:v'[text, url]' for text, k, val, url in mi.urls_from_identifiers or v'[]'}
if isinstance(x, list) and x.length == 2: td = table.lastChild.lastChild
td.appendChild(E.a(title=str.format('{}:{}', k, idval), target='_new', href=x[1], x[0])) for k in keys:
else: idval = val[k]
td.appendChild(E.span(k, ':', idval)) x = url_map[k]
if k is not keys[-1]: if isinstance(x, list) and x.length == 2:
td.appendChild(document.createTextNode(', ')) td.appendChild(E.a(title=str.format('{}:{}', k, idval), target='_new', href=x[1], x[0]))
else:
td.appendChild(E.span(k, ':', idval))
if k is not keys[-1]:
td.appendChild(document.createTextNode(', '))
def process_languages(field, fm, name, val): def process_languages(field, fm, name, val):
if val and val.length: if val and val.length:
@ -325,7 +326,7 @@ class BookDetailsPanel:
if not metadata.formats or not metadata.formats.length: if not metadata.formats or not metadata.formats.length:
row.style.display = 'none' row.style.display = 'none'
container.appendChild(row) container.appendChild(row)
md = E.div(style='max-width:500px; margin-bottom: 1ex') md = E.div(style='max-width:500px; margin-bottom: 2ex')
table = E.table(class_='metadata') table = E.table(class_='metadata')
container.appendChild(md) container.appendChild(md)
md.appendChild(table) md.appendChild(table)