add part text

This commit is contained in:
Celogeek 2022-12-27 20:10:41 +01:00
parent ba7291eb65
commit 6444eb65a3
Signed by: celogeek
GPG Key ID: E6B7BDCFC446233A
4 changed files with 22 additions and 2 deletions

View File

@ -307,6 +307,7 @@ func (e *EPub) Write() error {
{"OEBPS/toc.ncx", e.Render(TEMPLATE_TOC, map[string]any{"Info": e, "Images": part.Images})}, {"OEBPS/toc.ncx", e.Render(TEMPLATE_TOC, map[string]any{"Info": e, "Images": part.Images})},
{"OEBPS/nav.xhtml", e.Render(TEMPLATE_NAV, map[string]any{"Info": e, "Images": part.Images})}, {"OEBPS/nav.xhtml", e.Render(TEMPLATE_NAV, map[string]any{"Info": e, "Images": part.Images})},
{"OEBPS/Text/style.css", TEMPLATE_STYLE}, {"OEBPS/Text/style.css", TEMPLATE_STYLE},
{"OEBPS/Text/part.xhtml", e.Render(TEMPLATE_PART, map[string]any{"Info": e, "Part": part})},
{"OEBPS/Text/cover.xhtml", e.Render(TEMPLATE_TEXT, map[string]any{ {"OEBPS/Text/cover.xhtml", e.Render(TEMPLATE_TEXT, map[string]any{
"Id": "cover", "Id": "cover",
"Width": part.Cover.Width, "Width": part.Cover.Width,

View File

@ -20,5 +20,8 @@ var TEMPLATE_NAV string
//go:embed "templates/style.css.tmpl" //go:embed "templates/style.css.tmpl"
var TEMPLATE_STYLE string var TEMPLATE_STYLE string
//go:embed "templates/part.xhtml.tmpl"
var TEMPLATE_PART string
//go:embed "templates/text.xhtml.tmpl" //go:embed "templates/text.xhtml.tmpl"
var TEMPLATE_TEXT string var TEMPLATE_TEXT string

View File

@ -24,6 +24,7 @@
<item id="nav" href="nav.xhtml" properties="nav" media-type="application/xhtml+xml"/> <item id="nav" href="nav.xhtml" properties="nav" media-type="application/xhtml+xml"/>
<item id="page_cover" href="Text/cover.xhtml" media-type="application/xhtml+xml"/> <item id="page_cover" href="Text/cover.xhtml" media-type="application/xhtml+xml"/>
<item id="img_cover" href="Images/cover.jpg" media-type="image/jpeg" properties="cover-image"/> <item id="img_cover" href="Images/cover.jpg" media-type="image/jpeg" properties="cover-image"/>
<item id="page_part" href="Text/part.xhtml" media-type="application/xhtml+xml"/>
{{ range .Images }} {{ range .Images }}
<item id="page_{{ .Id }}" href="Text/{{ .Id }}.xhtml" media-type="application/xhtml+xml"/> <item id="page_{{ .Id }}" href="Text/{{ .Id }}.xhtml" media-type="application/xhtml+xml"/>
<item id="img_{{ .Id }}" href="Images/{{ .Id }}.jpg" media-type="image/jpeg"/> <item id="img_{{ .Id }}" href="Images/{{ .Id }}.jpg" media-type="image/jpeg"/>
@ -31,11 +32,12 @@
</manifest> </manifest>
<spine page-progression-direction="ltr" toc="ncx"> <spine page-progression-direction="ltr" toc="ncx">
<itemref idref="page_cover" linear="yes" properties="page-spread-left"/> <itemref idref="page_cover" linear="yes" properties="page-spread-left"/>
<itemref idref="page_part" linear="yes" properties="page-spread-right"/>
{{ range $idx, $ := .Images }} {{ range $idx, $ := .Images }}
{{ if mod $idx 2 }} {{ if mod $idx 2 }}
<itemref idref="page_{{ $.Id }}" linear="yes" properties="page-spread-right"/>
{{ else }}
<itemref idref="page_{{ $.Id }}" linear="yes" properties="page-spread-left"/> <itemref idref="page_{{ $.Id }}" linear="yes" properties="page-spread-left"/>
{{ else }}
<itemref idref="page_{{ $.Id }}" linear="yes" properties="page-spread-right"/>
{{ end }} {{ end }}
{{ end }} {{ end }}
</spine> </spine>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
<head>
<title>Part {{ .Part.Idx }}</title>
<link href="style.css" type="text/css" rel="stylesheet"/>
<meta name="viewport" content="width={{ .Info.ViewWidth }}, height={{ .Info.ViewHeight }}"/>
</head>
<body style="">
<h1 style="text-align:center;top:50%;">
Part {{ .Part.Idx }}
</h1>
</body>
</html>