mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Metadata jacket: Allow customizing the jacket template to show the tags in alphabetical order
This commit is contained in:
parent
2faac51ceb
commit
8e2abc008f
@ -32,6 +32,8 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr class="cbj_tags">
|
<tr class="cbj_tags">
|
||||||
<td class="cbj_label">{tags_label}:</td>
|
<td class="cbj_label">{tags_label}:</td>
|
||||||
|
<!-- If you want the tags to be alphabetical, change {tags} to
|
||||||
|
{tags.alphabetical} -->
|
||||||
<td class="cbj_content">{tags}</td>
|
<td class="cbj_content">{tags}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
@ -18,6 +18,7 @@ from calibre.ebooks.BeautifulSoup import BeautifulSoup
|
|||||||
from calibre.ebooks.oeb.base import XPath, XHTML_NS, XHTML, xml2text, urldefrag
|
from calibre.ebooks.oeb.base import XPath, XHTML_NS, XHTML, xml2text, urldefrag
|
||||||
from calibre.library.comments import comments_to_html
|
from calibre.library.comments import comments_to_html
|
||||||
from calibre.utils.date import is_date_undefined
|
from calibre.utils.date import is_date_undefined
|
||||||
|
from calibre.utils.icu import sort_key
|
||||||
from calibre.ebooks.chardet import strip_encoding_declarations
|
from calibre.ebooks.chardet import strip_encoding_declarations
|
||||||
from calibre.ebooks.metadata import fmt_sidx
|
from calibre.ebooks.metadata import fmt_sidx
|
||||||
|
|
||||||
@ -155,6 +156,14 @@ class Series(unicode):
|
|||||||
s.roman = roman
|
s.roman = roman
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
class Tags(unicode):
|
||||||
|
|
||||||
|
def __new__(self, tags, output_profile):
|
||||||
|
tags = tags or ()
|
||||||
|
t = unicode.__new__(self, output_profile.tags_to_string(tags))
|
||||||
|
t.alphabetical = output_profile.tags_to_string(sorted(tags, key=sort_key))
|
||||||
|
return t
|
||||||
|
|
||||||
def render_jacket(mi, output_profile,
|
def render_jacket(mi, output_profile,
|
||||||
alt_title=_('Unknown'), alt_tags=[], alt_comments='',
|
alt_title=_('Unknown'), alt_tags=[], alt_comments='',
|
||||||
alt_publisher=(''), rescale_fonts=False):
|
alt_publisher=(''), rescale_fonts=False):
|
||||||
@ -183,11 +192,7 @@ def render_jacket(mi, output_profile,
|
|||||||
|
|
||||||
rating = get_rating(mi.rating, output_profile.ratings_char, output_profile.empty_ratings_char)
|
rating = get_rating(mi.rating, output_profile.ratings_char, output_profile.empty_ratings_char)
|
||||||
|
|
||||||
tags = mi.tags if mi.tags else alt_tags
|
tags = Tags((mi.tags if mi.tags else alt_tags), output_profile)
|
||||||
if tags:
|
|
||||||
tags = output_profile.tags_to_string(tags)
|
|
||||||
else:
|
|
||||||
tags = ''
|
|
||||||
|
|
||||||
comments = mi.comments if mi.comments else alt_comments
|
comments = mi.comments if mi.comments else alt_comments
|
||||||
comments = comments.strip()
|
comments = comments.strip()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user