This commit is contained in:
Evan Buss
2024-07-04 14:39:25 -04:00
parent 5276d9fc1e
commit 9daf7bf8b9
7 changed files with 115 additions and 0 deletions

11
html/feed.html Normal file
View File

@@ -0,0 +1,11 @@
{{define "content"}}
{{range .Feed.Links}}
{{template "link" .}}
<a href="{{.Href}}">{{.Title}}</a>
{{end}}
{{range .Feed.Entries}}
{{$link := index .Links 0}}
<a href="{{$link.Href}}">{{.Title}}</a>
{{end}}
{{end}}

27
html/html.go Normal file
View File

@@ -0,0 +1,27 @@
package html
import (
"html/template"
"io"
"github.com/opds-community/libopds2-go/opds1"
)
var (
feed = parse("feed.html")
)
func parse(file string) *template.Template {
return template.Must(template.New("layout.html").ParseFiles("html/layout.html", "html/" + file))
}
type FeedParams struct {
Feed *opds1.Feed
}
func Feed(w io.Writer, p FeedParams, partial string) error {
if (partial == "" ) {
partial = "layout.html"
}
return feed.ExecuteTemplate(w, partial, p)
}

11
html/layout.html Normal file
View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{block "title" .}}Kobo OPDS Proxy{{end}}</title>
<link rel="stylesheet" href="./static/style.css">
</head>
<body>
{{block "content" .}}{{end}}
</body>
</html>