remove panelview by default, add an option addpanelview

On kindle it's better to not add manually the panelview as it will
unlock several features:
- Animation
- Adjust to screen size
- Panel View
It means, you can still have a panel view, but it's handled by kindle
directly.
This commit is contained in:
Celogeek 2023-03-05 00:01:19 +01:00
parent 6f74f959fd
commit 393bba0266
Signed by: celogeek
GPG Key ID: E6B7BDCFC446233A
9 changed files with 120 additions and 80 deletions

View File

@ -76,6 +76,8 @@ The ePub include as a first page:
# go-comic-converter -h
Usage of go-comic-converter:
-addpanelview
Add an embeded panel view. On kindle you may not need this option as it is handled by the kindle.
-author string
Author of the epub (default "GO Comic Converter")
-auto

View File

@ -26,6 +26,7 @@ type ImageOptions struct {
NoBlankPage bool
Manga bool
HasCover bool
AddPanelView bool
Workers int
}
@ -198,6 +199,9 @@ 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
@ -215,13 +219,19 @@ func (e *ePub) Write() error {
}
for _, 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{
var content string
if e.AddPanelView {
content = e.render(textTmpl, map[string]any{
"Image": img,
"Manga": e.Manga,
}),
); err != nil {
})
} 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 {
return err
}

View File

@ -17,11 +17,17 @@ 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

View File

@ -24,7 +24,10 @@
<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="cover" href="Images/{{ .Cover.Id }}_p{{ .Cover.Part }}.jpg" media-type="image/jpeg" properties="cover-image"/>
<item id="css" href="Text/style.css" media-type="text/css"/>
<item id="style_css" href="Text/style.css" media-type="text/css"/>
{{ if eq $info.AddPanelView true }}
<item id="panelview_css" href="Text/panelview.css" media-type="text/css"/>
{{ end }}
<item id="page_part" href="Text/part.xhtml" media-type="application/xhtml+xml"/>
{{ range .Images }}
<item id="page_{{ .Id }}_p{{ .Part}}" href="Text/{{ .Id }}_p{{ .Part}}.xhtml" media-type="application/xhtml+xml"/>

View File

@ -0,0 +1,73 @@
#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;
}

View File

@ -6,78 +6,4 @@ body {
display: block;
margin: 0;
padding: 0;
}
#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;
}

View File

@ -4,6 +4,7 @@
<head>
<title>Page {{ .Image.Id }}_p{{ .Image.Part}}</title>
<link href="style.css" type="text/css" rel="stylesheet"/>
<link href="panelview.css" type="text/css" rel="stylesheet"/>
<meta name="viewport" content="width={{ .Image.Width }}, height={{ .Image.Height }}"/>
</head>
<body style="">

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>Page {{ .Image.Id }}_p{{ .Image.Part}}</title>
<link href="style.css" type="text/css" rel="stylesheet"/>
<meta name="viewport" content="width={{ .Image.Width }}, height={{ .Image.Height }}"/>
</head>
<body style="">
<div style="text-align:center;top:0.0%;">
<img width="{{ .Image.Width }}" height="{{ .Image.Height }}" src="../Images/{{ .Image.Id }}_p{{ .Image.Part}}.jpg"/>
</div>
</body>
</html>

View File

@ -72,6 +72,7 @@ type Option struct {
NoBlankPage bool
Manga bool
NoCover bool
AddPanelView bool
Workers int
LimitMb int
}
@ -108,6 +109,7 @@ Options:
NoBlankPage : %v
Manga : %v
HasCover : %v
AddPanelView : %v
LimitMb : %s
Workers : %d
`,
@ -125,6 +127,7 @@ Options:
o.NoBlankPage,
o.Manga,
!o.NoCover,
o.AddPanelView,
limitmb,
o.Workers,
)
@ -158,6 +161,7 @@ func main() {
flag.BoolVar(&opt.NoBlankPage, "noblankpage", false, "Remove blank pages")
flag.BoolVar(&opt.Manga, "manga", false, "Manga mode (right to left)")
flag.BoolVar(&opt.NoCover, "nocover", false, "Indicate if your comic doesn't have a cover. The first page will be used as a cover and include after the title.")
flag.BoolVar(&opt.AddPanelView, "addpanelview", false, "Add an embeded panel view. On kindle you may not need this option as it is handled by the kindle.")
flag.IntVar(&opt.LimitMb, "limitmb", 0, "Limit size of the ePub: Default nolimit (0), Minimum 20")
flag.IntVar(&opt.Workers, "workers", runtime.NumCPU(), "Number of workers")
flag.Usage = func() {
@ -266,6 +270,7 @@ func main() {
NoBlankPage: opt.NoBlankPage,
Manga: opt.Manga,
HasCover: !opt.NoCover,
AddPanelView: opt.AddPanelView,
Workers: opt.Workers,
},
}).Write(); err != nil {