Book jacket generation: Add ability to customize the book jacket template and add custom columns into the jacket. Fixes #889912 ([Enhancement] Add metadata from custom columns to jacket)

This commit is contained in:
Kovid Goyal 2011-11-15 09:59:22 +05:30
parent 6bed672533
commit 1d23886c12
2 changed files with 16 additions and 0 deletions

View File

@ -36,6 +36,14 @@
<div class="cbj_footer">{footer}</div> <div class="cbj_footer">{footer}</div>
</div> </div>
<hr class="cbj_kindle_banner_hr" /> <hr class="cbj_kindle_banner_hr" />
<!--
In addition you can add code to show the values of custom columns here.
The value is available as _column_name and the title as _column_name_label.
For example, if you have a custom column with label #genre, you can add it to
this template with:
<div>{_genre_label}: {_genre}</div>
-->
<div class="cbj_comments">{comments}</div> <div class="cbj_comments">{comments}</div>
</body> </body>
</html> </html>

View File

@ -171,6 +171,14 @@ def render_jacket(mi, output_profile,
comments=comments, comments=comments,
footer='' footer=''
) )
for key in mi.custom_field_keys():
try:
display_name, val = mi.format_field_extended(key)[:2]
key = key.replace('#', '_')
args[key] = val
args[key+'_label'] = display_name
except:
pass
generated_html = P('jacket/template.xhtml', generated_html = P('jacket/template.xhtml',
data=True).decode('utf-8').format(**args) data=True).decode('utf-8').format(**args)