mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
User Manual: Add nicer cover for EPUB User Manual
This commit is contained in:
parent
025cb0375f
commit
1e260bd0e3
@ -100,9 +100,8 @@ html_use_smartypants = True
|
|||||||
html_title = 'calibre User Manual'
|
html_title = 'calibre User Manual'
|
||||||
html_short_title = 'Start'
|
html_short_title = 'Start'
|
||||||
html_logo = 'resources/logo.png'
|
html_logo = 'resources/logo.png'
|
||||||
epub_titlepage = 'resources/titlepage.html'
|
|
||||||
epub_logo = 'resources/logo.png'
|
|
||||||
epub_author = 'Kovid Goyal'
|
epub_author = 'Kovid Goyal'
|
||||||
|
epub_cover = 'resources/epub_cover.jpg'
|
||||||
|
|
||||||
# Custom sidebar templates, maps document names to template names.
|
# Custom sidebar templates, maps document names to template names.
|
||||||
#html_sidebars = {}
|
#html_sidebars = {}
|
||||||
|
@ -304,9 +304,8 @@ def auto_member(dirname, arguments, options, content, lineno,
|
|||||||
return list(node)
|
return list(node)
|
||||||
|
|
||||||
def setup(app):
|
def setup(app):
|
||||||
app.add_config_value('epub_titlepage', None, False)
|
app.add_config_value('epub_cover', None, False)
|
||||||
app.add_config_value('epub_author', '', False)
|
app.add_config_value('epub_author', '', False)
|
||||||
app.add_config_value('epub_logo', None, False)
|
|
||||||
app.add_builder(CustomBuilder)
|
app.add_builder(CustomBuilder)
|
||||||
app.add_builder(CustomQtBuild)
|
app.add_builder(CustomQtBuild)
|
||||||
app.add_builder(EPUBHelpBuilder)
|
app.add_builder(EPUBHelpBuilder)
|
||||||
|
@ -50,6 +50,7 @@ OPF = '''\
|
|||||||
<dc:identifier opf:scheme="sphinx" id="sphinx_id">{uid}</dc:identifier>
|
<dc:identifier opf:scheme="sphinx" id="sphinx_id">{uid}</dc:identifier>
|
||||||
<dc:date>{date}</dc:date>
|
<dc:date>{date}</dc:date>
|
||||||
<meta name="calibre:publication_type" content="sphinx_manual" />
|
<meta name="calibre:publication_type" content="sphinx_manual" />
|
||||||
|
<meta name="cover" content="cover"/>
|
||||||
</metadata>
|
</metadata>
|
||||||
<manifest>
|
<manifest>
|
||||||
{manifest}
|
{manifest}
|
||||||
@ -71,6 +72,29 @@ CONTAINER='''\
|
|||||||
</rootfiles>
|
</rootfiles>
|
||||||
</container>
|
</container>
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
SVG_TEMPLATE = '''\
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
<meta name="calibre:cover" content="true" />
|
||||||
|
<title>Cover</title>
|
||||||
|
<style type="text/css" title="override_css">
|
||||||
|
@page {padding: 0pt; margin:0pt}
|
||||||
|
body { text-align: center; padding:0pt; margin: 0pt; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
width="100%%" height="100%%" viewBox="0 0 600 800"
|
||||||
|
preserveAspectRatio="none">
|
||||||
|
<image width="600" height="800" xlink:href="%s"/>
|
||||||
|
</svg>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
'''
|
||||||
|
|
||||||
class TOC(list):
|
class TOC(list):
|
||||||
|
|
||||||
def __init__(self, title=None, href=None):
|
def __init__(self, title=None, href=None):
|
||||||
@ -151,8 +175,6 @@ class EPUBHelpBuilder(StandaloneHTMLBuilder):
|
|||||||
spine = [' '*8+'<itemref idref=%s />'%quoteattr(x) for x in self.spine]
|
spine = [' '*8+'<itemref idref=%s />'%quoteattr(x) for x in self.spine]
|
||||||
spine = '\n'.join(spine)
|
spine = '\n'.join(spine)
|
||||||
guide = ''
|
guide = ''
|
||||||
if self.conf.epub_titlepage:
|
|
||||||
guide = ' '*8 + '<reference type="cover" href="_static/titlepage.html" />'
|
|
||||||
|
|
||||||
opf = OPF.format(title=escape(self.conf.html_title),
|
opf = OPF.format(title=escape(self.conf.html_title),
|
||||||
author=escape(self.conf.epub_author), uid=str(uuid.uuid4()),
|
author=escape(self.conf.epub_author), uid=str(uuid.uuid4()),
|
||||||
@ -162,18 +184,15 @@ class EPUBHelpBuilder(StandaloneHTMLBuilder):
|
|||||||
self.manifest['content.opf'] = ('application/oebps-package+xml', 'opf')
|
self.manifest['content.opf'] = ('application/oebps-package+xml', 'opf')
|
||||||
|
|
||||||
def create_titlepage(self):
|
def create_titlepage(self):
|
||||||
if self.conf.epub_titlepage:
|
self.cover_image_url = None
|
||||||
img = ''
|
if self.conf.epub_cover:
|
||||||
if self.conf.epub_logo:
|
img = '_static/'+os.path.basename(self.conf.epub_cover)
|
||||||
img = '_static/epub_logo'+os.path.splitext(self.conf.epub_logo)[1]
|
shutil.copyfile(self.conf.epub_cover, os.path.join(self.html_outdir,
|
||||||
shutil.copyfile(self.conf.epub_logo,
|
*img.split('/')))
|
||||||
os.path.join(self.html_outdir, *img.split('/')))
|
self.cover_image_url = img
|
||||||
raw = open(self.conf.epub_titlepage, 'rb').read()
|
tp = SVG_TEMPLATE%img.split('/')[-1]
|
||||||
raw = raw%dict(title=self.conf.html_title,
|
open(os.path.join(self.html_outdir, '_static', 'titlepage.html'),
|
||||||
version=self.conf.version,
|
'wb').write(tp)
|
||||||
img=img.split('/')[-1],
|
|
||||||
author=self.conf.epub_author)
|
|
||||||
open(os.path.join(self.html_outdir, '_static', 'titlepage.html'), 'wb').write(raw)
|
|
||||||
|
|
||||||
def generate_manifest(self):
|
def generate_manifest(self):
|
||||||
self.manifest = {}
|
self.manifest = {}
|
||||||
@ -190,8 +209,12 @@ class EPUBHelpBuilder(StandaloneHTMLBuilder):
|
|||||||
self.manifest[url] = 'application/octet-stream'
|
self.manifest[url] = 'application/octet-stream'
|
||||||
if self.manifest[url] == 'text/html':
|
if self.manifest[url] == 'text/html':
|
||||||
self.manifest[url] = 'application/xhtml+xml'
|
self.manifest[url] = 'application/xhtml+xml'
|
||||||
self.manifest[url] = (self.manifest[url], 'id'+str(id))
|
if self.cover_image_url and url.endswith(self.cover_image_url):
|
||||||
|
id_ = 'cover'
|
||||||
|
else:
|
||||||
|
id_ = 'id'+str(id)
|
||||||
id += 1
|
id += 1
|
||||||
|
self.manifest[url] = (self.manifest[url], id_)
|
||||||
|
|
||||||
def isdocnode(self, node):
|
def isdocnode(self, node):
|
||||||
if not isinstance(node, nodes.list_item):
|
if not isinstance(node, nodes.list_item):
|
||||||
@ -227,7 +250,7 @@ class EPUBHelpBuilder(StandaloneHTMLBuilder):
|
|||||||
open('toc.ncx', 'wb').write(ncx)
|
open('toc.ncx', 'wb').write(ncx)
|
||||||
self.manifest['toc.ncx'] = ('application/x-dtbncx+xml', 'ncx')
|
self.manifest['toc.ncx'] = ('application/x-dtbncx+xml', 'ncx')
|
||||||
self.spine.insert(0, self.manifest[self.conf.master_doc+'.html'][1])
|
self.spine.insert(0, self.manifest[self.conf.master_doc+'.html'][1])
|
||||||
if self.conf.epub_titlepage:
|
if self.conf.epub_cover:
|
||||||
self.spine.insert(0, self.manifest['_static/titlepage.html'][1])
|
self.spine.insert(0, self.manifest['_static/titlepage.html'][1])
|
||||||
|
|
||||||
def add_to_spine(self, href):
|
def add_to_spine(self, href):
|
||||||
|
@ -160,7 +160,7 @@ Alternative for the iPad
|
|||||||
As of |app| version 0.7.0, you can plugin your iPad into the computer using its charging cable, and |app| will detect it and show you a list of books on the iPad. You can then use the Send to device button to send books directly to iBooks on the iPad.
|
As of |app| version 0.7.0, you can plugin your iPad into the computer using its charging cable, and |app| will detect it and show you a list of books on the iPad. You can then use the Send to device button to send books directly to iBooks on the iPad.
|
||||||
|
|
||||||
This method only works on Windows XP and higher and OS X 10.5 and higher. Linux is not supported (iTunes is not available in linux) and OS X 10.4 is not supported. For more details, see
|
This method only works on Windows XP and higher and OS X 10.5 and higher. Linux is not supported (iTunes is not available in linux) and OS X 10.4 is not supported. For more details, see
|
||||||
`this forum post http://www.mobileread.com/forums/showpost.php?p=944079&postcount=1`_.
|
`this forum post <http://www.mobileread.com/forums/showpost.php?p=944079&postcount=1>`_.
|
||||||
|
|
||||||
How do I use |app| with my Android phone?
|
How do I use |app| with my Android phone?
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
BIN
src/calibre/manual/resources/epub_cover.jpg
Normal file
BIN
src/calibre/manual/resources/epub_cover.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 144 KiB |
@ -1,29 +0,0 @@
|
|||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
|
||||||
<head>
|
|
||||||
<title>%(title)s</title>
|
|
||||||
<style type="text/css">
|
|
||||||
body {
|
|
||||||
text-align: center;
|
|
||||||
vertical-align: center;
|
|
||||||
overflow: hidden;
|
|
||||||
font-size: 16pt;
|
|
||||||
}
|
|
||||||
.logo {
|
|
||||||
text-align:center;
|
|
||||||
font-size: 1pt;
|
|
||||||
overflow:hidden;
|
|
||||||
}
|
|
||||||
h1 { font-family: serif; }
|
|
||||||
h2, h4 { font-family: monospace; }
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>%(title)s</h1>
|
|
||||||
<h4 style="font-family:monospace">%(version)s</h4>
|
|
||||||
<div style="text-align:center">
|
|
||||||
<img class="logo" src="%(img)s" alt="calibre logo" />
|
|
||||||
</div>
|
|
||||||
<h2>%(author)s</h2>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user