Moved string constants to module level.

This commit is contained in:
Roland Meister 2010-01-12 22:09:02 +01:00
parent a880aa8f70
commit 46047b60bf

View File

@ -23,6 +23,9 @@ from sphinx.builders.html import StandaloneHTMLBuilder
# (Fragment) templates from which the metainfo files content.opf, toc.ncx, # (Fragment) templates from which the metainfo files content.opf, toc.ncx,
# mimetype, and META-INF/container.xml are created. # mimetype, and META-INF/container.xml are created.
# This template section also defines strings that are embedded in the html
# output but that may be customized by (re-)setting module attributes,
# e.g. from conf.py.
_mimetype_template = 'application/epub+zip' # no EOL! _mimetype_template = 'application/epub+zip' # no EOL!
@ -99,6 +102,10 @@ _spine_template = u'''\
_toctree_template = u'toctree-l%d' _toctree_template = u'toctree-l%d'
_link_target_template = u' [%(uri)s]'
_css_link_target_class = u'link-target'
_media_types = { _media_types = {
'.html': 'application/xhtml+xml', '.html': 'application/xhtml+xml',
'.css': 'text/css', '.css': 'text/css',
@ -128,11 +135,12 @@ class VisibleLinksTransform(Transform):
uri = ref.get('refuri', '') uri = ref.get('refuri', '')
if ( uri.startswith('http:') or uri.startswith('https:') or \ if ( uri.startswith('http:') or uri.startswith('https:') or \
uri.startswith('ftp:') ) and uri not in ref.astext(): uri.startswith('ftp:') ) and uri not in ref.astext():
uri = ' [%s]' % uri uri = _link_target_template % {'uri': uri}
idx = ref.parent.index(ref) + 1 if uri:
link = nodes.inline(uri, uri) idx = ref.parent.index(ref) + 1
link['classes'].append('link-target') link = nodes.inline(uri, uri)
ref.parent.insert(idx, link) link['classes'].append(_css_link_target_class)
ref.parent.insert(idx, link)
# The epub publisher # The epub publisher