diff --git a/cps/about.py b/cps/about.py index 8d0a938f..630243f4 100644 --- a/cps/about.py +++ b/cps/about.py @@ -37,6 +37,7 @@ except ImportError: from flask_login.__about__ import __version__ as flask_loginVersion try: import unidecode + # _() necessary to make babel aware of string for translation unidecode_version = _(u'installed') except ImportError: unidecode_version = _(u'not installed') @@ -62,8 +63,8 @@ _VERSIONS = OrderedDict( iso639=isoLanguages.__version__, pytz=pytz.__version__, Unidecode = unidecode_version, - Flask_SimpleLDAP = _(u'installed') if bool(services.ldap) else _(u'not installed'), - Goodreads = _(u'installed') if bool(services.goodreads_support) else _(u'not installed'), + Flask_SimpleLDAP = u'installed' if bool(services.ldap) else u'not installed', + Goodreads = u'installed' if bool(services.goodreads_support) else u'not installed', ) _VERSIONS.update(uploader.get_versions()) diff --git a/cps/converter.py b/cps/converter.py index 32bc273f..d3482e5f 100644 --- a/cps/converter.py +++ b/cps/converter.py @@ -19,6 +19,7 @@ from __future__ import division, print_function, unicode_literals import os import re +from flask_babel import gettext as _ from . import config, logger from .subproc_wrapper import process_wait @@ -26,7 +27,8 @@ from .subproc_wrapper import process_wait log = logger.create() -_NOT_CONFIGURED = 'not configured' +# _() necessary to make babel aware of string for translation +_NOT_CONFIGURED = _('not configured') _NOT_INSTALLED = 'not installed' _EXECUTION_ERROR = 'Execution permissions missing' diff --git a/cps/epub.py b/cps/epub.py index d9129646..d315abf6 100644 --- a/cps/epub.py +++ b/cps/epub.py @@ -64,7 +64,12 @@ def get_epub_info(tmp_file_path, original_file_name, original_file_extension): for s in ['title', 'description', 'creator', 'language', 'subject']: tmp = p.xpath('dc:%s/text()' % s, namespaces=ns) if len(tmp) > 0: - epub_metadata[s] = p.xpath('dc:%s/text()' % s, namespaces=ns)[0] + if s == 'creator': + epub_metadata[s] = ' & '.join(p.xpath('dc:%s/text()' % s, namespaces=ns)) + elif s == 'subject': + epub_metadata[s] = ', '.join(p.xpath('dc:%s/text()' % s, namespaces=ns)) + else: + epub_metadata[s] = p.xpath('dc:%s/text()' % s, namespaces=ns)[0] else: epub_metadata[s] = "Unknown" @@ -109,18 +114,20 @@ def get_epub_info(tmp_file_path, original_file_name, original_file_extension): meta_cover = tree.xpath("/pkg:package/pkg:metadata/pkg:meta[@name='cover']/@content", namespaces=ns) if len(meta_cover) > 0: coversection = tree.xpath("/pkg:package/pkg:manifest/pkg:item[@id='"+meta_cover[0]+"']/@href", namespaces=ns) - if len(coversection) > 0: - filetype = coversection[0].rsplit('.', 1)[-1] - if filetype == "xhtml" or filetype == "html": # if cover is (x)html format - markup = epubZip.read(os.path.join(coverpath, coversection[0])) - markupTree = etree.fromstring(markup) - # no matter xhtml or html with no namespace - imgsrc = markupTree.xpath("//*[local-name() = 'img']/@src") - # imgsrc maybe startwith "../"" so fullpath join then relpath to cwd - filename = os.path.relpath(os.path.join(os.path.dirname(os.path.join(coverpath, coversection[0])), imgsrc[0])) - coverfile = extractCover(epubZip, filename, "", tmp_file_path) - else: - coverfile = extractCover(epubZip, coversection[0], coverpath, tmp_file_path) + else: + coversection = tree.xpath("/pkg:package/pkg:guide/pkg:reference/@href", namespaces=ns) + if len(coversection) > 0: + filetype = coversection[0].rsplit('.', 1)[-1] + if filetype == "xhtml" or filetype == "html": # if cover is (x)html format + markup = epubZip.read(os.path.join(coverpath, coversection[0])) + markupTree = etree.fromstring(markup) + # no matter xhtml or html with no namespace + imgsrc = markupTree.xpath("//*[local-name() = 'img']/@src") + # imgsrc maybe startwith "../"" so fullpath join then relpath to cwd + filename = os.path.relpath(os.path.join(os.path.dirname(os.path.join(coverpath, coversection[0])), imgsrc[0])) + coverfile = extractCover(epubZip, filename, "", tmp_file_path) + else: + coverfile = extractCover(epubZip, coversection[0], coverpath, tmp_file_path) if not epub_metadata['title']: title = original_file_name diff --git a/cps/templates/stats.html b/cps/templates/stats.html index 7f941ac9..1c4692e4 100644 --- a/cps/templates/stats.html +++ b/cps/templates/stats.html @@ -1,9 +1,9 @@ {% extends "layout.html" %} {% block body %}
{{instance}} powered by +
{{instance}} powered by Calibre-Web. -
+{{library}} | -{{version}} | +{{_(version)}} |
---|