commit inicial
This commit is contained in:
commit
92b0a902ca
20 changed files with 2464 additions and 0 deletions
60
views/reader.go
Normal file
60
views/reader.go
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
package view
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"goreader/gallery"
|
||||
"strconv"
|
||||
|
||||
"github.com/silva-guimaraes/gtag"
|
||||
)
|
||||
|
||||
//go:embed static/panzoom.min.js
|
||||
var panzoom string
|
||||
|
||||
func Reader(g gallery.Gallery, page string) *gtag.Tag {
|
||||
images := g.Images()
|
||||
html := gtag.Doc()
|
||||
head := html.Head()
|
||||
{
|
||||
head.Tag("title").Text("leitor")
|
||||
head.Tag("style").Asis(styles)
|
||||
head.Asis("<!-- panzoom -->")
|
||||
head.Tag("script").Asis(panzoom)
|
||||
}
|
||||
body := html.Body().Id("reader")
|
||||
{
|
||||
nav := body.Tag("nav")
|
||||
{
|
||||
controls := nav.Div().Id("controls")
|
||||
{
|
||||
controls.Tag("button").Id("start-button").Text("start")
|
||||
controls.Tag("button").Id("previous-button").Text("previous")
|
||||
controls.Tag("button").Id("next-button").Text("next")
|
||||
controls.Tag("button").Id("end-button").Text("end")
|
||||
}
|
||||
nav.VoidTag("hr")
|
||||
pageCounter := nav.P().Style("block: inline;")
|
||||
{
|
||||
pageCounter.Tag("span").Id("page-counter").Text(page)
|
||||
pageCounter.Text("/")
|
||||
pageCounter.Text(strconv.Itoa(len(images)))
|
||||
}
|
||||
}
|
||||
cont := body.Div().Id("pages-container").SetAttr("data-page", page)
|
||||
{
|
||||
for i := range images {
|
||||
img := gtag.NewVoid("img").
|
||||
Class("page hidden").
|
||||
SetAttr("loading", "lazy").
|
||||
SetAttr("src", fmt.Sprintf("/page/%s/%d", g.Uuid(), i+1)).
|
||||
SetAttr("onclick", "pageNav(event);")
|
||||
cont.Append(img)
|
||||
}
|
||||
}
|
||||
body.Tag("a").Class("navigate").Id("left").SetAttr("href", "javascript:void(0)")
|
||||
body.Tag("a").Class("navigate").Id("right").SetAttr("href", "javascript:void(0)")
|
||||
body.Tag("script").Asis(readerJavascript)
|
||||
}
|
||||
return html
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue