EPUB writer: Removed need for separate epub-coverpage template.

The standard epub-page template is now used.
This commit is contained in:
John MacFarlane 2012-11-04 20:53:27 -08:00
parent 7f5e2af1fb
commit a7b8351d43
4 changed files with 7 additions and 15 deletions

3
README
View file

@ -661,8 +661,7 @@ by putting a file `templates/default.FORMAT` in the user data
directory (see `--data-dir`, above). *Exceptions:* For `odt` output,
customize the `default.opendocument` template. For `pdf` output,
customize the `default.latex` template. For `epub` and `epub3` output,
customize the `epub-page.html`, `epub-coverimage.html`, and
`epub-titlepage.html` templates.
customize the `epub-page.html`, and `epub-titlepage.html` templates.
Templates may contain *variables*. Variable names are sequences of
alphanumerics, `-`, and `_`, starting with a letter. A variable name

View file

@ -50,7 +50,6 @@ Data-Files:
templates/default.dzslides, templates/default.asciidoc,
templates/default.textile, templates/default.org,
templates/epub-titlepage.html, templates/epub-page.html,
templates/epub-coverimage.html,
-- data for ODT writer
reference.odt,
-- data for docx writer

View file

@ -74,12 +74,15 @@ writeEPUB :: EPUBVersion
writeEPUB version opts doc@(Pandoc meta _) = do
let epub3 = version == EPUB3
epochtime <- floor `fmap` getPOSIXTime
pageTemplate <- readDataFile (writerUserDataDir opts)
$ "templates" </> "epub-page" <.> "html"
let mkEntry path content = toEntry path epochtime content
let vars = ("epub3", if epub3 then "true" else "false")
: ("css", "stylesheet.css")
: writerVariables opts
let opts' = opts{ writerEmailObfuscation = NoObfuscation
, writerStandalone = True
, writerTemplate = pageTemplate
, writerSectionDivs = True
, writerHtml5 = epub3
, writerTableOfContents = False -- we always have one in epub
@ -95,23 +98,14 @@ writeEPUB version opts doc@(Pandoc meta _) = do
titlePageTemplate <- readDataFile (writerUserDataDir opts')
$ "templates" </> "epub-titlepage" <.> "html"
coverImageTemplate <- readDataFile (writerUserDataDir opts')
$ "templates" </> "epub-coverimage" <.> "html"
pageTemplate <- readDataFile (writerUserDataDir opts')
$ "templates" </> "epub-page" <.> "html"
-- cover page
(cpgEntry, cpicEntry) <-
case mbCoverImage of
Nothing -> return ([],[])
Just img -> do
let coverImage = "cover-image" ++ takeExtension img
let cpContent = fromStringLazy $ writeHtmlString
opts'{writerTemplate = coverImageTemplate,
writerHtml5 = epub3,
writerVariables = ("coverimage",coverImage):vars}
(Pandoc meta [])
let cpContent = renderHtml $ writeHtml opts'
(Pandoc meta [RawBlock "html" $ "<div id=\"cover-image\">\n<img src=\"" ++ coverImage ++ " alt=\"cover image\" />\n</div"])
imgContent <- B.readFile img
return ( [mkEntry "cover.xhtml" cpContent]
, [mkEntry coverImage imgContent] )

@ -1 +1 @@
Subproject commit 9fae8b31dd1fc3667993a35b7db6b252b85c840d
Subproject commit cd898b1d2febb88686054e4a63690b8c7891ae03