mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-05-25 08:12:36 +02:00
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:
parent
6f74f959fd
commit
393bba0266
@ -76,6 +76,8 @@ The ePub include as a first page:
|
|||||||
# go-comic-converter -h
|
# go-comic-converter -h
|
||||||
|
|
||||||
Usage of go-comic-converter:
|
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 string
|
||||||
Author of the epub (default "GO Comic Converter")
|
Author of the epub (default "GO Comic Converter")
|
||||||
-auto
|
-auto
|
||||||
|
@ -26,6 +26,7 @@ type ImageOptions struct {
|
|||||||
NoBlankPage bool
|
NoBlankPage bool
|
||||||
Manga bool
|
Manga bool
|
||||||
HasCover bool
|
HasCover bool
|
||||||
|
AddPanelView bool
|
||||||
Workers int
|
Workers int
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,6 +199,9 @@ func (e *ePub) Write() error {
|
|||||||
"Total": totalParts,
|
"Total": totalParts,
|
||||||
})},
|
})},
|
||||||
}
|
}
|
||||||
|
if e.AddPanelView {
|
||||||
|
content = append(content, zipContent{"OEBPS/Text/panelview.css", panelViewTmpl})
|
||||||
|
}
|
||||||
|
|
||||||
if err = wz.WriteMagic(); err != nil {
|
if err = wz.WriteMagic(); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -215,13 +219,19 @@ func (e *ePub) Write() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, img := range part.Images {
|
for _, img := range part.Images {
|
||||||
if err := wz.WriteFile(
|
var content string
|
||||||
fmt.Sprintf("OEBPS/Text/%d_p%d.xhtml", img.Id, img.Part),
|
if e.AddPanelView {
|
||||||
e.render(textTmpl, map[string]any{
|
content = e.render(textTmpl, map[string]any{
|
||||||
"Image": img,
|
"Image": img,
|
||||||
"Manga": e.Manga,
|
"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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,11 +17,17 @@ var navTmpl string
|
|||||||
//go:embed "templates/style.css.tmpl"
|
//go:embed "templates/style.css.tmpl"
|
||||||
var styleTmpl string
|
var styleTmpl string
|
||||||
|
|
||||||
|
//go:embed "templates/panelview.css.tmpl"
|
||||||
|
var panelViewTmpl string
|
||||||
|
|
||||||
//go:embed "templates/part.xhtml.tmpl"
|
//go:embed "templates/part.xhtml.tmpl"
|
||||||
var partTmpl string
|
var partTmpl string
|
||||||
|
|
||||||
//go:embed "templates/text.xhtml.tmpl"
|
//go:embed "templates/text.xhtml.tmpl"
|
||||||
var textTmpl string
|
var textTmpl string
|
||||||
|
|
||||||
|
//go:embed "templates/textnopanel.xhtml.tmpl"
|
||||||
|
var textNoPanelTmpl string
|
||||||
|
|
||||||
//go:embed "templates/blank.xhtml.tmpl"
|
//go:embed "templates/blank.xhtml.tmpl"
|
||||||
var blankTmpl string
|
var blankTmpl string
|
||||||
|
@ -24,7 +24,10 @@
|
|||||||
<item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml"/>
|
<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="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="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"/>
|
<item id="page_part" href="Text/part.xhtml" media-type="application/xhtml+xml"/>
|
||||||
{{ range .Images }}
|
{{ range .Images }}
|
||||||
<item id="page_{{ .Id }}_p{{ .Part}}" href="Text/{{ .Id }}_p{{ .Part}}.xhtml" media-type="application/xhtml+xml"/>
|
<item id="page_{{ .Id }}_p{{ .Part}}" href="Text/{{ .Id }}_p{{ .Part}}.xhtml" media-type="application/xhtml+xml"/>
|
||||||
|
73
internal/epub/templates/panelview.css.tmpl
Normal file
73
internal/epub/templates/panelview.css.tmpl
Normal 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;
|
||||||
|
}
|
@ -7,77 +7,3 @@ body {
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 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;
|
|
||||||
}
|
|
@ -4,6 +4,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<title>Page {{ .Image.Id }}_p{{ .Image.Part}}</title>
|
<title>Page {{ .Image.Id }}_p{{ .Image.Part}}</title>
|
||||||
<link href="style.css" type="text/css" rel="stylesheet"/>
|
<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 }}"/>
|
<meta name="viewport" content="width={{ .Image.Width }}, height={{ .Image.Height }}"/>
|
||||||
</head>
|
</head>
|
||||||
<body style="">
|
<body style="">
|
||||||
|
14
internal/epub/templates/textnopanel.xhtml.tmpl
Normal file
14
internal/epub/templates/textnopanel.xhtml.tmpl
Normal 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>
|
5
main.go
5
main.go
@ -72,6 +72,7 @@ type Option struct {
|
|||||||
NoBlankPage bool
|
NoBlankPage bool
|
||||||
Manga bool
|
Manga bool
|
||||||
NoCover bool
|
NoCover bool
|
||||||
|
AddPanelView bool
|
||||||
Workers int
|
Workers int
|
||||||
LimitMb int
|
LimitMb int
|
||||||
}
|
}
|
||||||
@ -108,6 +109,7 @@ Options:
|
|||||||
NoBlankPage : %v
|
NoBlankPage : %v
|
||||||
Manga : %v
|
Manga : %v
|
||||||
HasCover : %v
|
HasCover : %v
|
||||||
|
AddPanelView : %v
|
||||||
LimitMb : %s
|
LimitMb : %s
|
||||||
Workers : %d
|
Workers : %d
|
||||||
`,
|
`,
|
||||||
@ -125,6 +127,7 @@ Options:
|
|||||||
o.NoBlankPage,
|
o.NoBlankPage,
|
||||||
o.Manga,
|
o.Manga,
|
||||||
!o.NoCover,
|
!o.NoCover,
|
||||||
|
o.AddPanelView,
|
||||||
limitmb,
|
limitmb,
|
||||||
o.Workers,
|
o.Workers,
|
||||||
)
|
)
|
||||||
@ -158,6 +161,7 @@ func main() {
|
|||||||
flag.BoolVar(&opt.NoBlankPage, "noblankpage", false, "Remove blank pages")
|
flag.BoolVar(&opt.NoBlankPage, "noblankpage", false, "Remove blank pages")
|
||||||
flag.BoolVar(&opt.Manga, "manga", false, "Manga mode (right to left)")
|
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.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.LimitMb, "limitmb", 0, "Limit size of the ePub: Default nolimit (0), Minimum 20")
|
||||||
flag.IntVar(&opt.Workers, "workers", runtime.NumCPU(), "Number of workers")
|
flag.IntVar(&opt.Workers, "workers", runtime.NumCPU(), "Number of workers")
|
||||||
flag.Usage = func() {
|
flag.Usage = func() {
|
||||||
@ -266,6 +270,7 @@ func main() {
|
|||||||
NoBlankPage: opt.NoBlankPage,
|
NoBlankPage: opt.NoBlankPage,
|
||||||
Manga: opt.Manga,
|
Manga: opt.Manga,
|
||||||
HasCover: !opt.NoCover,
|
HasCover: !opt.NoCover,
|
||||||
|
AddPanelView: opt.AddPanelView,
|
||||||
Workers: opt.Workers,
|
Workers: opt.Workers,
|
||||||
},
|
},
|
||||||
}).Write(); err != nil {
|
}).Write(); err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user