it mostly works

This commit is contained in:
Evan Buss
2024-07-04 23:48:11 -04:00
parent 9daf7bf8b9
commit 7c63b06e05
11 changed files with 328 additions and 63 deletions

View File

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