forked from Ivasoft/opds-proxy
it mostly works
This commit is contained in:
21
html/html.go
21
html/html.go
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user