diff --git a/README.md b/README.md index 713c584..92309be 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,6 @@ Options: NoBlankPage : false Manga : true HasCover : true - AddPanelView : false LimitMb : 200 Mb StripFirstDirectoryFromToc: true SortPathMode : path=alphanum, file=alpha @@ -162,7 +161,6 @@ Options: NoBlankPage : false Manga : true HasCover : true - AddPanelView : false LimitMb : 200 Mb StripFirstDirectoryFromToc: true SortPathMode : path=alphanum, file=alphanum @@ -210,7 +208,6 @@ Options: NoBlankPage : false Manga : false HasCover : true - AddPanelView : false LimitMb : nolimit StripFirstDirectoryFromToc: false SortPathMode : path=alphanum, file=alpha @@ -233,7 +230,6 @@ Options: NoBlankPage : false Manga : true HasCover : true - AddPanelView : false LimitMb : 200 Mb StripFirstDirectoryFromToc: false SortPathMode : path=alphanum, file=alpha @@ -258,7 +254,6 @@ Options: NoBlankPage : false Manga : false HasCover : true - AddPanelView : false LimitMb : 200 Mb StripFirstDirectoryFromToc: false SortPathMode : path=alphanum, file=alpha @@ -284,7 +279,6 @@ Options: NoBlankPage : false Manga : false HasCover : true - AddPanelView : false LimitMb : nolimit Reset default to ~/.go-comic-converter.yaml @@ -360,8 +354,6 @@ Config: Manga mode (right to left) -hascover (default true) Has cover. Indicate if your comic have a cover. The first page will be used as a cover and include after the title. - -addpanelview - Add an embeded panel view. On kindle you may not need this option as it is handled by the kindle. -limitmb int Limit size of the ePub: Default nolimit (0), Minimum 20 -strip diff --git a/internal/converter/core.go b/internal/converter/core.go index 0a01c78..1e758d0 100644 --- a/internal/converter/core.go +++ b/internal/converter/core.go @@ -95,7 +95,6 @@ func (c *Converter) InitParse() { c.AddBoolParam(&c.Options.NoBlankPage, "noblankpage", c.Options.NoBlankPage, "Remove blank pages") c.AddBoolParam(&c.Options.Manga, "manga", c.Options.Manga, "Manga mode (right to left)") c.AddBoolParam(&c.Options.HasCover, "hascover", c.Options.HasCover, "Has cover. Indicate if your comic have a cover. The first page will be used as a cover and include after the title.") - c.AddBoolParam(&c.Options.AddPanelView, "addpanelview", c.Options.AddPanelView, "Add an embeded panel view. On kindle you may not need this option as it is handled by the kindle.") c.AddIntParam(&c.Options.LimitMb, "limitmb", c.Options.LimitMb, "Limit size of the ePub: Default nolimit (0), Minimum 20") c.AddBoolParam(&c.Options.StripFirstDirectoryFromToc, "strip", c.Options.StripFirstDirectoryFromToc, "Strip first directory from the TOC if only 1") c.AddIntParam(&c.Options.SortPathMode, "sort", c.Options.SortPathMode, "Sort path mode\n0 = alpha for path and file\n1 = alphanum for path and alpha for file\n2 = alphanum for path and file") diff --git a/internal/converter/options/core.go b/internal/converter/options/core.go index bf45a4f..2e372b9 100644 --- a/internal/converter/options/core.go +++ b/internal/converter/options/core.go @@ -31,7 +31,6 @@ type Options struct { NoBlankPage bool `yaml:"no_blank_page"` Manga bool `yaml:"manga"` HasCover bool `yaml:"has_cover"` - AddPanelView bool `yaml:"add_panel_view"` LimitMb int `yaml:"limit_mb"` StripFirstDirectoryFromToc bool `yaml:"strip_first_directory_from_toc"` SortPathMode int `yaml:"sort_path_mode"` @@ -61,7 +60,6 @@ func New() *Options { NoBlankPage: false, Manga: false, HasCover: true, - AddPanelView: false, LimitMb: 0, StripFirstDirectoryFromToc: false, SortPathMode: 1, @@ -150,7 +148,6 @@ func (o *Options) ShowDefault() string { NoBlankPage : %v Manga : %v HasCover : %v - AddPanelView : %v LimitMb : %s StripFirstDirectoryFromToc: %v SortPathMode : %s`, @@ -164,7 +161,6 @@ func (o *Options) ShowDefault() string { o.NoBlankPage, o.Manga, o.HasCover, - o.AddPanelView, limitmb, o.StripFirstDirectoryFromToc, sortpathmode, diff --git a/internal/epub/core.go b/internal/epub/core.go index da0ff2c..d8e9eae 100644 --- a/internal/epub/core.go +++ b/internal/epub/core.go @@ -27,7 +27,6 @@ type ImageOptions struct { NoBlankPage bool Manga bool HasCover bool - AddPanelView bool Workers int } @@ -298,9 +297,6 @@ func (e *ePub) Write() error { "Total": totalParts, })}, } - if e.AddPanelView { - content = append(content, zipContent{"OEBPS/Text/panelview.css", panelViewTmpl}) - } if err = wz.WriteMagic(); err != nil { return err @@ -317,24 +313,21 @@ func (e *ePub) Write() error { wz.WriteImage(part.Cover.Data) } - for _, img := range part.Images { - var content string - if e.AddPanelView { - content = e.render(textTmpl, map[string]any{ - "Image": img, - "Manga": e.Manga, - }) - } else { - content = e.render(textNoPanelTmpl, map[string]any{ - "Image": img, - }) - } - - if err := wz.WriteFile(fmt.Sprintf("OEBPS/Text/%d_p%d.xhtml", img.Id, img.Part), content); err != nil { + for i, img := range part.Images { + if err := wz.WriteFile(fmt.Sprintf("OEBPS/Text/%d_p%d.xhtml", img.Id, img.Part), e.render(textTmpl, map[string]any{ + "Info": e, + "Image": img, + "Top": fmt.Sprintf("%d", (e.ViewHeight-img.Height)/2), + })); err != nil { return err } - if img.NeedSpace { + if err := wz.WriteImage(img.Data); err != nil { + return err + } + + // Double Page or Last Image + if img.DoublePage || (i+1 == len(part.Images)) { if err := wz.WriteFile( fmt.Sprintf("OEBPS/Text/%d_sp.xhtml", img.Id), e.render(blankTmpl, map[string]any{ @@ -345,10 +338,6 @@ func (e *ePub) Write() error { return err } } - - if err := wz.WriteImage(img.Data); err != nil { - return err - } } bar.Add(1) } diff --git a/internal/epub/templates.go b/internal/epub/templates.go index ad5f61d..f0dea83 100644 --- a/internal/epub/templates.go +++ b/internal/epub/templates.go @@ -17,17 +17,11 @@ var navTmpl string //go:embed "templates/style.css.tmpl" var styleTmpl string -//go:embed "templates/panelview.css.tmpl" -var panelViewTmpl string - //go:embed "templates/part.xhtml.tmpl" var partTmpl string //go:embed "templates/text.xhtml.tmpl" var textTmpl string -//go:embed "templates/textnopanel.xhtml.tmpl" -var textNoPanelTmpl string - //go:embed "templates/blank.xhtml.tmpl" var blankTmpl string diff --git a/internal/epub/templates/panelview.css.tmpl b/internal/epub/templates/panelview.css.tmpl deleted file mode 100644 index 88d9feb..0000000 --- a/internal/epub/templates/panelview.css.tmpl +++ /dev/null @@ -1,103 +0,0 @@ -a.app-amzn-magnify { - display: inline-block; - width: 100%; - height: 100%; -} - -#PV { - position: absolute; - width: 100%; - height: 100%; - top: 0; - left: 0; -} - -#PV-T { - top: 0; - width: 100%; - height: 50%; -} - -#PV-B { - bottom: 0; - width: 100%; - height: 50%; -} - -#PV-L { - left: 0; - width: 49.5%; - height: 100%; - float: left; -} - -#PV-R { - right: 0; - width: 49.5%; - height: 100%; - float: right; -} - -#PV-TL { - top: 0; - left: 0; - width: 49.5%; - height: 50%; - float: left; -} - -#PV-TR { - top: 0; - right: 0; - width: 49.5%; - height: 50%; - float: right; -} - -#PV-BL { - bottom: 0; - left: 0; - width: 49.5%; - height: 50%; - float: left; -} - -#PV-BR { - bottom: 0; - right: 0; - width: 49.5%; - height: 50%; - float: right; -} - -.PV-P { - width: 100%; - height: 100%; - top: 0; - position: absolute; - display: none; -} - -div#PV-TL-P img { - position: absolute; - left: 0; - top: 0; -} - -div#PV-TR-P img { - position: absolute; - right: 0; - top: 0; -} - -div#PV-BL-P img { - position: absolute; - left: 0; - bottom: 0; -} - -div#PV-BR-P img { - position: absolute; - right: 0; - bottom: 0; -} \ No newline at end of file diff --git a/internal/epub/templates/text.xhtml.tmpl b/internal/epub/templates/text.xhtml.tmpl index d92b6f6..f22efeb 100644 --- a/internal/epub/templates/text.xhtml.tmpl +++ b/internal/epub/templates/text.xhtml.tmpl @@ -4,38 +4,11 @@ Page {{ .Image.Id }}_p{{ .Image.Part}} - - + -
+
-
-
- -
-
- -
-
- -
-
- -
-
-
- -
-
- -
-
- -
-
- -
\ No newline at end of file diff --git a/internal/epub/templates/textnopanel.xhtml.tmpl b/internal/epub/templates/textnopanel.xhtml.tmpl deleted file mode 100644 index 0350f5a..0000000 --- a/internal/epub/templates/textnopanel.xhtml.tmpl +++ /dev/null @@ -1,14 +0,0 @@ - - - - - Page {{ .Image.Id }}_p{{ .Image.Part}} - - - - -
- -
- - \ No newline at end of file diff --git a/main.go b/main.go index 51c6b0f..116227b 100644 --- a/main.go +++ b/main.go @@ -113,7 +113,6 @@ $ go install github.com/celogeek/go-comic-converter/v%d@%s NoBlankPage: cmd.Options.NoBlankPage, Manga: cmd.Options.Manga, HasCover: cmd.Options.HasCover, - AddPanelView: cmd.Options.AddPanelView, Workers: cmd.Options.Workers, }, }).Write(); err != nil {