leo
f129606b8f
All checks were successful
continuous-integration/drone/push Build is passing
* add handlers for signin,singup,logout... * introduce ent ORM and add user schema * add live mode, devel mode to selectively turn on features via config/flags * add templates, handle embedding moar smarter: * live mode uses live folder structure, else embedded templates are used * start using tailwindcss to style stuff * add development goodies for hot-reloading (browser-sync - bs.js) * pimp-up config.dhall with actual custom config Type (enables remote schema and local values only as needed) * add justfile (alternative to makefile for process automation)
53 lines
877 B
Go
53 lines
877 B
Go
package app
|
|
|
|
import (
|
|
"fmt"
|
|
"io/fs"
|
|
"log"
|
|
"net/http"
|
|
"os"
|
|
)
|
|
|
|
func (a *App) getAssets(live bool) http.FileSystem {
|
|
if live {
|
|
log.Print("assets - live mode")
|
|
return http.FS(os.DirFS("static"))
|
|
}
|
|
|
|
log.Print("assets - embed mode")
|
|
|
|
fsys, err := fs.Sub(a.embeds.assets, "static")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
return http.FS(fsys)
|
|
}
|
|
|
|
// func (a *App) getTemplates(live bool) http.FileSystem {
|
|
func (a *App) getTemplates(live bool) fs.FS {
|
|
if live {
|
|
log.Print("tmpls - live mode")
|
|
// return http.FS(os.DirFS("../templates"))
|
|
entries, err := os.ReadDir("templates")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
for _, e := range entries {
|
|
fmt.Println(e.Name())
|
|
}
|
|
|
|
return os.DirFS("templates")
|
|
}
|
|
|
|
log.Print("tmpls - embed mode")
|
|
|
|
fsys, err := fs.Sub(a.embeds.templates, "templates")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
// return http.FS(fsys)
|
|
return fsys
|
|
}
|