fix: kavita 无法正确加载字体

This commit is contained in:
2025-07-17 14:03:10 +08:00
parent ca3fdf8980
commit 75745b9431
13 changed files with 70 additions and 193 deletions

View File

@@ -4,7 +4,7 @@ templ ContainerXML() {
@templ.Raw(`<?xml version='1.0' encoding='utf-8'?>`)
<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0">
<rootfiles>
<rootfile full-path="OEBPS/content.opf" media-type="application/oebps-package+xml"></rootfile>
<rootfile full-path="content.opf" media-type="application/oebps-package+xml"></rootfile>
</rootfiles>
</container>
}

View File

@@ -33,7 +33,7 @@ func ContainerXML() templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<container xmlns=\"urn:oasis:names:tc:opendocument:xmlns:container\" version=\"1.0\"><rootfiles><rootfile full-path=\"OEBPS/content.opf\" media-type=\"application/oebps-package+xml\"></rootfile></rootfiles></container>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<container xmlns=\"urn:oasis:names:tc:opendocument:xmlns:container\" version=\"1.0\"><rootfiles><rootfile full-path=\"content.opf\" media-type=\"application/oebps-package+xml\"></rootfile></rootfiles></container>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}

View File

@@ -8,7 +8,7 @@ templ ContentXHTML(content *model.Chapter) {
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="zh-CN">
<head>
<title>{ content.Title }</title>
@templ.Raw(`<link href="../Styles/style.css" rel="stylesheet" type="text/css"/>`)
@templ.Raw(`<link href="../../style.css" rel="stylesheet" type="text/css"/>`)
</head>
<body>
<div class="chapter">

View File

@@ -52,7 +52,7 @@ func ContentXHTML(content *model.Chapter) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templ.Raw(`<link href="../Styles/style.css" rel="stylesheet" type="text/css"/>`).Render(ctx, templ_7745c5c3_Buffer)
templ_7745c5c3_Err = templ.Raw(`<link href="../../style.css" rel="stylesheet" type="text/css"/>`).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}

View File

@@ -0,0 +1,37 @@
package template
templ CoverXHTML(coverPath string) {
@templ.Raw(`
<?xml version='1.0' encoding='utf-8'?>`)
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="zh-CN">
<head>
<title>Cover</title>
</head>
<style type="text/css">
@page {
padding: 0pt;
margin: 0pt
}
body {
text-align: center;
padding: 0pt;
margin: 0pt;
}
</style>
<body>
<div>
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
version="1.1"
width="100%"
height="100%"
viewBox="0 0 400 581"
preserveAspectRatio="none"
>
<image width="400" height="581" xlink:href={ coverPath }></image>
</svg>
</div>
</body>
</html>
}

View File

@@ -8,9 +8,7 @@ package template
import "github.com/a-h/templ"
import templruntime "github.com/a-h/templ/runtime"
import "bilinovel-downloader/model"
func TocNCX(title string, head *model.TocNCXHead, navMap *model.NavMap) templ.Component {
func CoverXHTML(coverPath string) templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
@@ -31,54 +29,25 @@ func TocNCX(title string, head *model.TocNCXHead, navMap *model.NavMap) templ.Co
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Err = templ.Raw(`<?xml version='1.0' encoding='utf-8'?>`).Render(ctx, templ_7745c5c3_Buffer)
templ_7745c5c3_Err = templ.Raw(`
<?xml version='1.0' encoding='utf-8'?>`).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templ.Raw(`<!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN" "http://www.daisy.org/z3986/2005/ncx-2005-1.dtd">`).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<ncx xmlns=\"http://www.daisy.org/z3986/2005/ncx/\" version=\"2005-1\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if head != nil {
head, err := head.Marshal()
if err == nil {
templ_7745c5c3_Err = templ.Raw(head).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<docTitle><text>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:epub=\"http://www.idpf.org/2007/ops\" xml:lang=\"zh-CN\"><head><title>Cover</title></head><style type=\"text/css\">\n\t\t@page {\n\t\t\tpadding: 0pt;\n\t\t\tmargin: 0pt\n\t\t}\n\t\tbody {\n\t\t\ttext-align: center;\n\t\t\tpadding: 0pt;\n\t\t\tmargin: 0pt;\n\t\t}\n\t\t</style><body><div><svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" version=\"1.1\" width=\"100%\" height=\"100%\" viewBox=\"0 0 400 581\" preserveAspectRatio=\"none\"><image width=\"400\" height=\"581\" xlink:href=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(title)
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(coverPath)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `template/toc.ncx.templ`, Line: 16, Col: 16}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `template/cover.xhtml.templ`, Line: 32, Col: 59}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "</text></docTitle> ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if navMap != nil {
navMap, err := navMap.Marshal()
if err == nil {
templ_7745c5c3_Err = templ.Raw(navMap).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "</ncx>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "\"></image></svg></div></body></html>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}

View File

@@ -1,25 +0,0 @@
package template
import "bilinovel-downloader/model"
templ TocNCX(title string, head *model.TocNCXHead, navMap *model.NavMap) {
@templ.Raw(`<?xml version='1.0' encoding='utf-8'?>`)
@templ.Raw(`<!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN" "http://www.daisy.org/z3986/2005/ncx-2005-1.dtd">`)
<ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">
if head != nil {
{{ head, err := head.Marshal() }}
if err == nil {
@templ.Raw(head)
}
}
<docTitle>
<text>{ title }</text>
</docTitle>
if navMap != nil {
{{ navMap, err := navMap.Marshal() }}
if err == nil {
@templ.Raw(navMap)
}
}
</ncx>
}