diff --git a/resources/templates/html_export_default_index.tmpl b/resources/templates/html_export_default_index.tmpl index c751cb4da5..6184099bd4 100644 --- a/resources/templates/html_export_default_index.tmpl +++ b/resources/templates/html_export_default_index.tmpl @@ -7,17 +7,18 @@ -${for item_name in meta.items:}$ - ${for item in meta[item_name]:}$ - ${if namespace(item.term) == DC11_NS:}$ - - ${:endif}$ - ${:endfor}$ +${for item in meta:}$ + ${:endfor}$ +${for title in meta.titles():}$ +

${print title}$

+${:endfor}$ + +${print ', '.join(meta.creators())}$

Table of contents

${toc}$ diff --git a/src/calibre/ebooks/html/meta.py b/src/calibre/ebooks/html/meta.py new file mode 100644 index 0000000000..c0fd75b4f4 --- /dev/null +++ b/src/calibre/ebooks/html/meta.py @@ -0,0 +1,36 @@ +from __future__ import with_statement +__license__ = 'GPL 3' +__copyright__ = '2010, Fabian Grassl ' +__docformat__ = 'restructuredtext en' + +import os, re + +from os.path import dirname, abspath, relpath, exists, basename + +from calibre.ebooks.oeb.base import element, namespace, barename, DC11_NS + +class EasyMeta(object): + + def __init__(self, meta): + self.meta = meta + + def __iter__(self): + meta = self.meta + for item_name in meta.items: + for item in meta[item_name]: + if namespace(item.term) == DC11_NS: + yield { 'name': barename(item.term), 'value': item.value } + + def __len__(self): + count = 0 + for item in self: + count = count+1 + return count + + def titles(self): + for item in self.meta['title']: + yield item.value + + def creators(self): + for item in self.meta['creator']: + yield item.value diff --git a/src/calibre/ebooks/html/output.py b/src/calibre/ebooks/html/output.py index 6f9eaac643..df45854d78 100644 --- a/src/calibre/ebooks/html/output.py +++ b/src/calibre/ebooks/html/output.py @@ -1,6 +1,6 @@ from __future__ import with_statement __license__ = 'GPL 3' -__copyright__ = '2009, Kovid Goyal ' +__copyright__ = '2010, Fabian Grassl ' __docformat__ = 'restructuredtext en' import os, re @@ -16,6 +16,8 @@ from calibre import CurrentDir from urllib import unquote +from calibre.ebooks.html.meta import EasyMeta + class HTMLOutput(OutputFormatPlugin): name = 'HTML Output' @@ -66,7 +68,7 @@ class HTMLOutput(OutputFormatPlugin): html_toc = self.generate_html_toc(oeb_book, output_file, output_dir) templite = Templite(P('templates/html_export_default_index.tmpl', data=True)) print oeb_book.metadata.items - t = templite.render(toc=html_toc, meta=oeb_book.metadata, namespace=lambda x:namespace(x), barename=lambda x:barename(x), DC11_NS=DC11_NS) + t = templite.render(toc=html_toc, meta=EasyMeta(oeb_book.metadata)) f.write(t) with CurrentDir(output_dir):