From d6c761ec6cc6f597a3cc3d9f94e7e9e8fdb29909 Mon Sep 17 00:00:00 2001 From: celogeek <65178+celogeek@users.noreply.github.com> Date: Fri, 31 Mar 2023 09:07:39 +0200 Subject: [PATCH] add part information in title and series meta --- internal/epub/core.go | 13 ++++++++++++- internal/epub/templates/content.opf.tmpl | 6 +++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/internal/epub/core.go b/internal/epub/core.go index ebbdd8e..bcb1582 100644 --- a/internal/epub/core.go +++ b/internal/epub/core.go @@ -166,9 +166,20 @@ func (e *ePub) Write() error { } defer wz.Close() + title := e.Title + if totalParts > 1 { + title = fmt.Sprintf("%s [%d/%d]", title, i+1, totalParts) + } content := []zipContent{ {"META-INF/container.xml", containerTmpl}, - {"OEBPS/content.opf", e.render(contentTmpl, map[string]any{"Info": e, "Cover": part.Cover, "Images": part.Images})}, + {"OEBPS/content.opf", e.render(contentTmpl, map[string]any{ + "Info": e, + "Cover": part.Cover, + "Images": part.Images, + "Title": title, + "Part": i + 1, + "Total": totalParts, + })}, {"OEBPS/toc.ncx", e.render(tocTmpl, map[string]any{"Info": e})}, {"OEBPS/nav.xhtml", e.render(navTmpl, map[string]any{"Info": e})}, {"OEBPS/Text/style.css", styleTmpl}, diff --git a/internal/epub/templates/content.opf.tmpl b/internal/epub/templates/content.opf.tmpl index 074a819..54e5880 100644 --- a/internal/epub/templates/content.opf.tmpl +++ b/internal/epub/templates/content.opf.tmpl @@ -2,7 +2,7 @@ {{ $info := .Info }} - {{ $info.Title }} + {{ .Title }} en-US urn:uuid:{{ $info.UID }} {{ $info.Publisher }} @@ -18,6 +18,10 @@ {{ if eq $info.AddPanelView true }} +{{ end }} +{{ if gt .Total 1 }} + + {{ end }}