forked from Ivasoft/opds-proxy
it mostly works
This commit is contained in:
@@ -1,11 +1,22 @@
|
||||
{{define "content"}}
|
||||
{{range .Feed.Links}}
|
||||
{{template "link" .}}
|
||||
<a href="{{.Href}}">{{.Title}}</a>
|
||||
{{end}}
|
||||
<ul>
|
||||
{{range .Feed.Links}}
|
||||
<li><a href="{{.Href}}" rel="{{.Rel}}">{{.Title}}{{.Rel}}</a></li>
|
||||
{{end}}
|
||||
|
||||
{{range .Feed.Entries}}
|
||||
{{$link := index .Links 0}}
|
||||
<a href="{{$link.Href}}">{{.Title}}</a>
|
||||
{{end}}
|
||||
{{range .Feed.Entries}}
|
||||
<li class="link">
|
||||
{{$title := .Title}}
|
||||
{{range .Links}}
|
||||
{{if .IsImage "image/thumbnail"}}
|
||||
<img src="/acquisition{{.Href}}" alt="{{$title}}" height="40">
|
||||
{{else if .IsDownload}}
|
||||
<a href="/acquisition{{.Href}}" download>{{$title}}</a>
|
||||
{{else if .IsNavigation }}
|
||||
<a href="{{.Href}}">{{$title}}</a>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
{{end}}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -3,9 +3,11 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{{block "title" .}}Kobo OPDS Proxy{{end}}</title>
|
||||
<link rel="stylesheet" href="./static/style.css">
|
||||
<link rel="stylesheet" href="/static/style.css">
|
||||
</head>
|
||||
<body>
|
||||
{{block "content" .}}{{end}}
|
||||
<main id="container">
|
||||
{{block "content" .}}{{end}}
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
40
html/static/style.css
Normal file
40
html/static/style.css
Normal file
@@ -0,0 +1,40 @@
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
|
||||
font-family: sans-serif;
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
#container {
|
||||
border: 1px solid rgba(0, 0, 0, 0.5);
|
||||
min-width: 1200px;
|
||||
}
|
||||
|
||||
#container > ul {
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
#container > ul > li {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0.5rem 1rem;
|
||||
}
|
||||
|
||||
#container > ul > li:not(:last-child) {
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
body {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: black;
|
||||
}
|
||||
Reference in New Issue
Block a user