mirror of
https://github.com/Theodor-Springmann-Stiftung/lenz-web.git
synced 2026-03-21 05:45:32 +00:00
Better inital
This commit is contained in:
114
app/app.go
114
app/app.go
@@ -1,27 +1,121 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"html/template"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
gitpkg "github.com/Theodor-Springmann-Stiftung/lenz-web/git"
|
||||
"github.com/Theodor-Springmann-Stiftung/lenz-web/git"
|
||||
"github.com/Theodor-Springmann-Stiftung/lenz-web/xmlmodels"
|
||||
)
|
||||
|
||||
type App struct {
|
||||
mu sync.Mutex
|
||||
lib atomic.Pointer[xmlmodels.Library]
|
||||
mu sync.Mutex
|
||||
lib atomic.Pointer[xmlmodels.Library]
|
||||
repo atomic.Pointer[git.Repo]
|
||||
tmpl *template.Template
|
||||
routes []Route
|
||||
err error
|
||||
}
|
||||
|
||||
func New() *App {
|
||||
return &App{}
|
||||
func New(cfg Config) (*App, error) {
|
||||
a := &App{}
|
||||
if err := a.init(cfg); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
func (a *App) Library() *xmlmodels.Library {
|
||||
return a.lib.Load()
|
||||
}
|
||||
|
||||
func (a *App) RefreshLibrary(dir string, commit *gitpkg.Commit) (*xmlmodels.Library, error) {
|
||||
func (a *App) Repo() *git.Repo {
|
||||
return a.repo.Load()
|
||||
}
|
||||
|
||||
func (a *App) Templates() *template.Template {
|
||||
return a.tmpl
|
||||
}
|
||||
|
||||
func (a *App) Routes() []Route {
|
||||
a.mu.Lock()
|
||||
defer a.mu.Unlock()
|
||||
|
||||
ret := make([]Route, len(a.routes))
|
||||
copy(ret, a.routes)
|
||||
return ret
|
||||
}
|
||||
|
||||
func (a *App) RenderPath(path string) ([]byte, error) {
|
||||
a.mu.Lock()
|
||||
var route *Route
|
||||
for i := range a.routes {
|
||||
if a.routes[i].Path == path {
|
||||
r := a.routes[i]
|
||||
route = &r
|
||||
break
|
||||
}
|
||||
}
|
||||
a.mu.Unlock()
|
||||
|
||||
if route == nil || route.page == nil {
|
||||
return nil, fmt.Errorf("no route for path: %s", path)
|
||||
}
|
||||
|
||||
model, err := route.page.Model(a, *route)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return route.page.Render(a, *route, model)
|
||||
}
|
||||
|
||||
func (a *App) init(cfg Config) error {
|
||||
a.mu.Lock()
|
||||
defer a.mu.Unlock()
|
||||
|
||||
path := filepath.Join(cfg.BaseDIR, cfg.GITPath)
|
||||
|
||||
repo, err := git.OpenOrClone(path, cfg.GitURL, cfg.GitBranch)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := repo.Pull(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
latest, err := repo.Latest()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
lib, err := xmlmodels.Parse(repo.Path, latest)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tmpl, err := parseTemplates()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
a.repo.Store(repo)
|
||||
a.lib.Store(lib)
|
||||
a.tmpl = tmpl
|
||||
|
||||
routes, err := discoverPages(a)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
a.routes = routes
|
||||
a.err = nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) RefreshLibrary(dir string, commit *git.Commit) (*xmlmodels.Library, error) {
|
||||
a.mu.Lock()
|
||||
defer a.mu.Unlock()
|
||||
|
||||
@@ -31,5 +125,13 @@ func (a *App) RefreshLibrary(dir string, commit *gitpkg.Commit) (*xmlmodels.Libr
|
||||
}
|
||||
|
||||
a.lib.Store(lib)
|
||||
|
||||
routes, err := discoverPages(a)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
a.routes = routes
|
||||
a.err = nil
|
||||
return lib, nil
|
||||
}
|
||||
|
||||
55
app/helpers.go
Normal file
55
app/helpers.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"io/fs"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/Theodor-Springmann-Stiftung/lenz-web/templates"
|
||||
)
|
||||
|
||||
func (a *App) Error() error {
|
||||
a.mu.Lock()
|
||||
defer a.mu.Unlock()
|
||||
return a.err
|
||||
}
|
||||
|
||||
func discoverPages(app *App) ([]Route, error) {
|
||||
var routes []Route
|
||||
for _, page := range RegisteredPages() {
|
||||
discovered, err := page.Discover(app)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i := range discovered {
|
||||
discovered[i].page = page
|
||||
}
|
||||
routes = append(routes, discovered...)
|
||||
}
|
||||
return routes, nil
|
||||
}
|
||||
|
||||
func parseTemplates() (*template.Template, error) {
|
||||
paths := make([]string, 0, 16)
|
||||
|
||||
err := fs.WalkDir(templates.FS, ".", func(path string, d fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if d.IsDir() {
|
||||
return nil
|
||||
}
|
||||
|
||||
switch strings.ToLower(filepath.Ext(path)) {
|
||||
case ".tmpl", ".html", ".gohtml":
|
||||
paths = append(paths, path)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return template.New("root").ParseFS(templates.FS, paths...)
|
||||
}
|
||||
40
app/pages.go
Normal file
40
app/pages.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package app
|
||||
|
||||
import "sync"
|
||||
|
||||
type Route struct {
|
||||
Path string
|
||||
Kind string
|
||||
ID string
|
||||
page Page
|
||||
}
|
||||
|
||||
type Page interface {
|
||||
Discover(app *App) ([]Route, error)
|
||||
Model(app *App, route Route) (map[string]any, error)
|
||||
Render(app *App, route Route, model map[string]any) ([]byte, error)
|
||||
}
|
||||
|
||||
var (
|
||||
pagesMu sync.RWMutex
|
||||
pages []Page
|
||||
)
|
||||
|
||||
func RegisterPage(page Page) {
|
||||
if page == nil {
|
||||
panic("cannot register nil page")
|
||||
}
|
||||
|
||||
pagesMu.Lock()
|
||||
defer pagesMu.Unlock()
|
||||
pages = append(pages, page)
|
||||
}
|
||||
|
||||
func RegisteredPages() []Page {
|
||||
pagesMu.RLock()
|
||||
defer pagesMu.RUnlock()
|
||||
|
||||
ret := make([]Page, len(pages))
|
||||
copy(ret, pages)
|
||||
return ret
|
||||
}
|
||||
7
go.mod
7
go.mod
@@ -5,6 +5,7 @@ go 1.25.7
|
||||
require (
|
||||
github.com/go-git/go-git/v5 v5.16.5
|
||||
github.com/kelseyhightower/envconfig v1.4.0
|
||||
github.com/labstack/echo/v5 v5.0.4
|
||||
)
|
||||
|
||||
require (
|
||||
@@ -23,8 +24,8 @@ require (
|
||||
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
|
||||
github.com/skeema/knownhosts v1.3.1 // indirect
|
||||
github.com/xanzy/ssh-agent v0.3.3 // indirect
|
||||
golang.org/x/crypto v0.45.0 // indirect
|
||||
golang.org/x/net v0.47.0 // indirect
|
||||
golang.org/x/sys v0.38.0 // indirect
|
||||
golang.org/x/crypto v0.47.0 // indirect
|
||||
golang.org/x/net v0.49.0 // indirect
|
||||
golang.org/x/sys v0.40.0 // indirect
|
||||
gopkg.in/warnings.v0 v0.1.2 // indirect
|
||||
)
|
||||
|
||||
26
go.sum
26
go.sum
@@ -47,6 +47,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/labstack/echo/v5 v5.0.4 h1:ll3I/O8BifjMztj9dD1vx/peZQv8cR2CTUdQK6QxGGc=
|
||||
github.com/labstack/echo/v5 v5.0.4/go.mod h1:SyvlSdObGjRXeQfCCXW/sybkZdOOQZBmpKF0bvALaeo=
|
||||
github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k=
|
||||
github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY=
|
||||
github.com/pjbgf/sha1cd v0.3.2 h1:a9wb0bp1oC2TGwStyn0Umc/IGKQnEgF0vVaZ8QF8eo4=
|
||||
@@ -65,32 +67,32 @@ github.com/skeema/knownhosts v1.3.1/go.mod h1:r7KTdC8l4uxWRyK2TpQZ/1o5HaSzh06ePQ
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
|
||||
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
|
||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
|
||||
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
|
||||
golang.org/x/crypto v0.47.0 h1:V6e3FRj+n4dbpw86FJ8Fv7XVOql7TEwpHapKoMJ/GO8=
|
||||
golang.org/x/crypto v0.47.0/go.mod h1:ff3Y9VzzKbwSSEzWqJsJVBnWmRwRSHt/6Op5n9bQc4A=
|
||||
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8=
|
||||
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
|
||||
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
|
||||
golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o=
|
||||
golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
|
||||
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
|
||||
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU=
|
||||
golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254=
|
||||
golang.org/x/term v0.39.0 h1:RclSuaJf32jOqZz74CkPA9qFuVTX7vhLlpfj/IGWlqY=
|
||||
golang.org/x/term v0.39.0/go.mod h1:yxzUCTP/U+FzoxfdKmLaA0RV1WgE0VY7hXBwKtY/4ww=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
|
||||
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
|
||||
golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE=
|
||||
golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
|
||||
36
lenz.go
36
lenz.go
@@ -1,11 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
"log/slog"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/Theodor-Springmann-Stiftung/lenz-web/app"
|
||||
"github.com/Theodor-Springmann-Stiftung/lenz-web/git"
|
||||
_ "github.com/Theodor-Springmann-Stiftung/lenz-web/pages"
|
||||
"github.com/Theodor-Springmann-Stiftung/lenz-web/templates"
|
||||
"github.com/labstack/echo/v5"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -18,23 +20,39 @@ func main() {
|
||||
slog.SetLogLoggerLevel(slog.LevelDebug)
|
||||
}
|
||||
|
||||
dir := filepath.Join(cfg.BaseDIR, cfg.GITPath)
|
||||
repo, err := git.OpenOrClone(dir, cfg.GitURL, cfg.GitBranch)
|
||||
application, err := app.New(cfg)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
println("Repo opened: " + repo.String())
|
||||
|
||||
latest, err := repo.Latest()
|
||||
e := echo.New()
|
||||
publicFS, err := fs.Sub(templates.PublicFS, "public")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
e.StaticFS("/public", publicFS)
|
||||
|
||||
println("Commit" + latest.String())
|
||||
for _, route := range application.Routes() {
|
||||
routePath := route.Path
|
||||
e.GET(routePath, func(c *echo.Context) error {
|
||||
out, err := application.RenderPath(routePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return c.HTMLBlob(200, out)
|
||||
})
|
||||
}
|
||||
|
||||
addr := cfg.Address + ":" + cfg.Port
|
||||
if err := e.Start(addr); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func GetConfig() (app.Config, error) {
|
||||
cp := app.NewConfigProvider([]string{"config.dev.json", "config.json"})
|
||||
return *cp.Config, cp.Read()
|
||||
if err := cp.Read(); err != nil {
|
||||
return app.Config{}, err
|
||||
}
|
||||
return *cp.Config, nil
|
||||
}
|
||||
|
||||
33
pages/home.go
Normal file
33
pages/home.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package pages
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/Theodor-Springmann-Stiftung/lenz-web/app"
|
||||
)
|
||||
|
||||
type HomePage struct{}
|
||||
|
||||
func init() {
|
||||
app.RegisterPage(HomePage{})
|
||||
}
|
||||
|
||||
func (p HomePage) Discover(a *app.App) ([]app.Route, error) {
|
||||
return []app.Route{
|
||||
{Path: "/", Kind: "page", ID: "home"},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (p HomePage) Model(a *app.App, route app.Route) (map[string]any, error) {
|
||||
return map[string]any{
|
||||
"Message": "Template system is working.",
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (p HomePage) Render(a *app.App, route app.Route, model map[string]any) ([]byte, error) {
|
||||
var buf bytes.Buffer
|
||||
if err := a.Templates().ExecuteTemplate(&buf, "home", model); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
2
templates/.gitignore
vendored
Normal file
2
templates/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
node_modules/
|
||||
public/*.map
|
||||
1
templates/components/placeholder.tmpl
Normal file
1
templates/components/placeholder.tmpl
Normal file
@@ -0,0 +1 @@
|
||||
{{/* placeholder */}}
|
||||
22
templates/embed.go
Normal file
22
templates/embed.go
Normal file
@@ -0,0 +1,22 @@
|
||||
//go:build !dev
|
||||
|
||||
package templates
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"io/fs"
|
||||
)
|
||||
|
||||
// FS contains all template files.
|
||||
//
|
||||
//go:embed layouts pages components
|
||||
var rawFS embed.FS
|
||||
|
||||
var FS fs.FS = rawFS
|
||||
|
||||
// PublicFS contains static assets (js, css, images, ...).
|
||||
//
|
||||
//go:embed public
|
||||
var rawPublicFS embed.FS
|
||||
|
||||
var PublicFS fs.FS = rawPublicFS
|
||||
29
templates/embed_dev.go
Normal file
29
templates/embed_dev.go
Normal file
@@ -0,0 +1,29 @@
|
||||
//go:build dev
|
||||
|
||||
package templates
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
var (
|
||||
FS fs.FS
|
||||
PublicFS fs.FS
|
||||
)
|
||||
|
||||
// INFO: We use the currrent embeds file path to create the FS.
|
||||
// This is used in builds tagged with dev only, to serve files from the FS.
|
||||
func init() {
|
||||
_, file, _, ok := runtime.Caller(0)
|
||||
if !ok {
|
||||
log.Fatal("cannot resolve templates path from runtime.Caller")
|
||||
}
|
||||
|
||||
base := filepath.Dir(file)
|
||||
FS = os.DirFS(base)
|
||||
PublicFS = os.DirFS(base)
|
||||
}
|
||||
13
templates/layouts/layout.gohtml
Normal file
13
templates/layouts/layout.gohtml
Normal file
@@ -0,0 +1,13 @@
|
||||
{{ define "layout" }}
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>{{ block "title" . }}Default{{ end }}</title>
|
||||
</head>
|
||||
<body>
|
||||
{{ block "body" . }}{{ end }}
|
||||
</body>
|
||||
</html>
|
||||
{{ end }}
|
||||
1
templates/layouts/placeholder.tmpl
Normal file
1
templates/layouts/placeholder.tmpl
Normal file
@@ -0,0 +1 @@
|
||||
{{/* placeholder */}}
|
||||
1453
templates/package-lock.json
generated
Normal file
1453
templates/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
22
templates/package.json
Normal file
22
templates/package.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "lenz-templates",
|
||||
"version": "1.0.0",
|
||||
"description": "Templates for the JMR Lenz briefausgabe",
|
||||
"license": "MIT",
|
||||
"author": "",
|
||||
"type": "commonjs",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"bundle": "npm run js_prod && npm run css_prod",
|
||||
"js_prod": "esbuild ./src/index.js --bundle --minify --outfile=./public/index.js",
|
||||
"js": "esbuild ./src/index.js --bundle --sourcemap --outfile=./public/index.js",
|
||||
"css_prod": "tailwindcss -i ./src/style.css -o ./public/style.css --minify",
|
||||
"css": "tailwindcss -i ./src/style.css -o ./public/style.css",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tailwindcss/cli": "^4.1.18",
|
||||
"esbuild": "^0.27.3",
|
||||
"tailwindcss": "^4.1.18"
|
||||
}
|
||||
}
|
||||
8
templates/pages/home.gohtml
Normal file
8
templates/pages/home.gohtml
Normal file
@@ -0,0 +1,8 @@
|
||||
{{ define "home" }}{{ template "layout" . }}{{ end }}
|
||||
|
||||
{{ define "title" }}Home{{ end }}
|
||||
|
||||
{{ define "body" }}
|
||||
<h1>Home</h1>
|
||||
<p>{{ .Message }}</p>
|
||||
{{ end }}
|
||||
1
templates/pages/placeholder.tmpl
Normal file
1
templates/pages/placeholder.tmpl
Normal file
@@ -0,0 +1 @@
|
||||
{{/* placeholder */}}
|
||||
1
templates/public/index.js
Normal file
1
templates/public/index.js
Normal file
@@ -0,0 +1 @@
|
||||
(()=>{var c=(b,a)=>()=>(a||b((a={exports:{}}).exports,a),a.exports);var d=c(()=>{});d();})();
|
||||
13
templates/public/main.js
Normal file
13
templates/public/main.js
Normal file
@@ -0,0 +1,13 @@
|
||||
(() => {
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __commonJS = (cb, mod) => function __require() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
|
||||
// src/main.js
|
||||
var require_main = __commonJS({
|
||||
"src/main.js"() {
|
||||
}
|
||||
});
|
||||
require_main();
|
||||
})();
|
||||
2
templates/public/style.css
Normal file
2
templates/public/style.css
Normal file
@@ -0,0 +1,2 @@
|
||||
/*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com */
|
||||
@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.static{position:static}}
|
||||
0
templates/src/index.js
Normal file
0
templates/src/index.js
Normal file
1
templates/src/style.css
Normal file
1
templates/src/style.css
Normal file
@@ -0,0 +1 @@
|
||||
@import "tailwindcss";
|
||||
Reference in New Issue
Block a user