From 30f4d20c6a9ad85dcfa022c959018c2b43d21b0b Mon Sep 17 00:00:00 2001 From: celogeek <65178+celogeek@users.noreply.github.com> Date: Tue, 27 Dec 2022 23:00:42 +0100 Subject: [PATCH] readjust cover --- internal/epub/core.go | 7 +------ internal/epub/templates/content.opf.tmpl | 4 +--- internal/epub/templates/nav.xhtml.tmpl | 4 ++-- internal/epub/templates/part.xhtml.tmpl | 4 +++- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/internal/epub/core.go b/internal/epub/core.go index 1e7203c..87e2a5c 100644 --- a/internal/epub/core.go +++ b/internal/epub/core.go @@ -301,18 +301,13 @@ func (e *EPub) Write() error { {"META-INF/container.xml", gohtml.Format(TEMPLATE_CONTAINER)}, {"OEBPS/content.opf", e.Render(TEMPLATE_CONTENT, 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, "Image": part.Images[0]})}, {"OEBPS/Text/style.css", TEMPLATE_STYLE}, {"OEBPS/Text/part.xhtml", e.Render(TEMPLATE_PART, map[string]any{ "Info": e, "Part": i + 1, "Total": totalParts, })}, - {"OEBPS/Text/cover.xhtml", e.Render(TEMPLATE_TEXT, map[string]any{ - "Id": "cover", - "Width": part.Cover.Width, - "Height": part.Cover.Height, - })}, {"OEBPS/Images/cover.jpg", part.Cover.Data}, } diff --git a/internal/epub/templates/content.opf.tmpl b/internal/epub/templates/content.opf.tmpl index d460f80..52ed07f 100644 --- a/internal/epub/templates/content.opf.tmpl +++ b/internal/epub/templates/content.opf.tmpl @@ -22,8 +22,7 @@ <manifest> <item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+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="img_cover" href="Images/cover.jpg" media-type="image/jpeg" properties="cover-image"/> +<item id="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 }} <item id="page_{{ .Id }}" href="Text/{{ .Id }}.xhtml" media-type="application/xhtml+xml"/> @@ -31,7 +30,6 @@ {{ end }} </manifest> <spine page-progression-direction="ltr" toc="ncx"> -<itemref idref="page_cover" linear="yes" properties="page-spread-left"/> <itemref idref="page_part" linear="yes" properties="page-spread-right"/> {{ range $idx, $ := .Images }} {{ if mod $idx 2 }} diff --git a/internal/epub/templates/nav.xhtml.tmpl b/internal/epub/templates/nav.xhtml.tmpl index 1c8a326..f485174 100644 --- a/internal/epub/templates/nav.xhtml.tmpl +++ b/internal/epub/templates/nav.xhtml.tmpl @@ -8,12 +8,12 @@ <body> <nav xmlns:epub="http://www.idpf.org/2007/ops" epub:type="toc" id="toc"> <ol> -<li><a href="Text/cover.xhtml">{{ .Info.Title }}</a></li> +<li><a href="Text/{{ .Image.Id }}.xhtml">{{ .Info.Title }}</a></li> </ol> </nav> <nav epub:type="page-list"> <ol> -<li><a href="Text/cover.xhtml">{{ .Info.Title }}</a></li> +<li><a href="Text/{{ .Image.Id }}.xhtml">{{ .Info.Title }}</a></li> </ol> </nav> </body> diff --git a/internal/epub/templates/part.xhtml.tmpl b/internal/epub/templates/part.xhtml.tmpl index 0ee8053..bb409c0 100644 --- a/internal/epub/templates/part.xhtml.tmpl +++ b/internal/epub/templates/part.xhtml.tmpl @@ -7,7 +7,8 @@ <meta name="viewport" content="width={{ .Info.ViewWidth }}, height={{ .Info.ViewHeight }}"/> </head> <body style=""> -<h1 style="text-align:center;top:0%;padding-top:50%;font-size:4em"> +<div style="text-align:center;top:0.0%;"> +<h1> <p> {{ .Info.Title }} </p> @@ -15,5 +16,6 @@ Part {{ .Part }} / {{ .Total }} </p> </h1> +</div> </body> </html> \ No newline at end of file