mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
d13c4c2b94
commit
e925b0b301
@ -62,6 +62,7 @@ def mi_to_html(mi, field_list=None, default_author_link=None, use_roman_numbers=
|
||||
row = u'<td class="title">%s</td><td class="value">%s</td>'
|
||||
p = prepare_string_for_xml
|
||||
a = partial(prepare_string_for_xml, attribute=True)
|
||||
book_id = getattr(mi, 'id', 0)
|
||||
|
||||
for field in (field for field, display in field_list if display):
|
||||
try:
|
||||
@ -119,7 +120,7 @@ def mi_to_html(mi, field_list=None, default_author_link=None, use_roman_numbers=
|
||||
path = force_unicode(mi.path, filesystem_encoding)
|
||||
scheme = u'devpath' if isdevice else u'path'
|
||||
url = prepare_string_for_xml(path if isdevice else
|
||||
unicode(mi.id), True)
|
||||
unicode(book_id), True)
|
||||
pathstr = _('Click to open')
|
||||
extra = ''
|
||||
if isdevice:
|
||||
@ -141,13 +142,13 @@ def mi_to_html(mi, field_list=None, default_author_link=None, use_roman_numbers=
|
||||
bpath = '/'.join((os.path.basename(h), t))
|
||||
data = ({
|
||||
'fmt':x, 'path':a(path or ''), 'fname':a(mi.format_files.get(x, '')),
|
||||
'ext':x.lower(), 'id':mi.id, 'bpath':bpath,
|
||||
'ext':x.lower(), 'id':book_id, 'bpath':bpath,
|
||||
} for x in mi.formats)
|
||||
fmts = [u'<a data-full-path="{path}/{fname}.{ext}" title="{bpath}/{fname}.{ext}" href="format:{id}:{fmt}">{fmt}</a>'.format(**x) for x in data]
|
||||
ans.append((field, row % (name, u', '.join(fmts))))
|
||||
elif field == 'identifiers':
|
||||
urls = urls_from_identifiers(mi.identifiers)
|
||||
links = [u'<a href="%s" title="%s:%s" data-item="%s">%s</a>' % (a(url), a(id_typ), a(id_val), a(item_data(field, id_typ, mi.id)), p(namel))
|
||||
links = [u'<a href="%s" title="%s:%s" data-item="%s">%s</a>' % (a(url), a(id_typ), a(id_val), a(item_data(field, id_typ, book_id)), p(namel))
|
||||
for namel, id_typ, id_val, url in urls]
|
||||
links = u', '.join(links)
|
||||
if links:
|
||||
@ -186,7 +187,7 @@ def mi_to_html(mi, field_list=None, default_author_link=None, use_roman_numbers=
|
||||
continue
|
||||
val = '<a href="%s" title="%s" data-item="%s">%s</a>' % (
|
||||
search_href('publisher', mi.publisher), _('Click to see books with {0}: {1}').format(metadata['name'], a(mi.publisher)),
|
||||
a(item_data('publisher', mi.publisher, mi.id)), p(mi.publisher))
|
||||
a(item_data('publisher', mi.publisher, book_id)), p(mi.publisher))
|
||||
ans.append((field, row % (name, val)))
|
||||
else:
|
||||
val = mi.format_field(field)[-1]
|
||||
@ -207,7 +208,7 @@ def mi_to_html(mi, field_list=None, default_author_link=None, use_roman_numbers=
|
||||
'<span class="%(cls)s">%(series)s</span></a>') % dict(
|
||||
sidx=fmt_sidx(sidx, use_roman=use_roman_numbers), cls="series_name",
|
||||
series=p(series), href=search_href(st, series),
|
||||
data=a(item_data(field, series, mi.id)),
|
||||
data=a(item_data(field, series, book_id)),
|
||||
tt=p(_('Click to see books in this series')))
|
||||
elif metadata['datatype'] == 'datetime':
|
||||
aval = getattr(mi, field)
|
||||
@ -222,7 +223,8 @@ def mi_to_html(mi, field_list=None, default_author_link=None, use_roman_numbers=
|
||||
if field == 'tags':
|
||||
all_vals = sorted(all_vals, key=sort_key)
|
||||
links = ['<a href="%s" title="%s" data-item="%s">%s</a>' % (
|
||||
search_href(st, x), _('Click to see books with {0}: {1}').format(metadata['name'], a(x)), a(item_data(field, x, mi.id)), p(x))
|
||||
search_href(st, x), _('Click to see books with {0}: {1}').format(
|
||||
metadata['name'], a(x)), a(item_data(field, x, book_id)), p(x))
|
||||
for x in all_vals]
|
||||
val = metadata['is_multiple']['list_to_ui'].join(links)
|
||||
elif metadata['datatype'] == 'enumeration':
|
||||
@ -232,7 +234,7 @@ def mi_to_html(mi, field_list=None, default_author_link=None, use_roman_numbers=
|
||||
st = field
|
||||
val = '<a href="%s" title="%s" data-item="%s">%s</a>' % (
|
||||
search_href(st, val), a(_('Click to see books with {0}: {1}').format(metadata['name'], val)),
|
||||
a(item_data(field, val, mi.id)), p(val))
|
||||
a(item_data(field, val, book_id)), p(val))
|
||||
|
||||
ans.append((field, row % (name, val)))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user