2023-10-08 15:24:59 +01:00
|
|
|
package pages
|
|
|
|
|
|
|
|
import (
|
|
|
|
"embed"
|
|
|
|
_ "embed"
|
2023-10-08 16:43:27 +01:00
|
|
|
"github.com/1f349/overlapfs"
|
2023-10-08 15:24:59 +01:00
|
|
|
"html/template"
|
|
|
|
"os"
|
2023-10-08 16:43:27 +01:00
|
|
|
"path/filepath"
|
2023-10-08 15:24:59 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2023-10-08 16:43:27 +01:00
|
|
|
//go:embed *.go.html
|
2023-10-08 15:24:59 +01:00
|
|
|
flowPages embed.FS
|
2023-10-08 16:43:27 +01:00
|
|
|
FlowTemplates *template.Template
|
2023-10-08 15:24:59 +01:00
|
|
|
)
|
|
|
|
|
2023-10-08 16:43:27 +01:00
|
|
|
func LoadPages(wd string) error {
|
|
|
|
wwwDir := filepath.Join(wd, "www")
|
|
|
|
err := os.Mkdir(wwwDir, os.ModePerm)
|
|
|
|
if err != nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
wdFs := os.DirFS(wwwDir)
|
|
|
|
o := overlapfs.OverlapFS{A: flowPages, B: wdFs}
|
|
|
|
FlowTemplates, err = template.ParseFS(o, "*.go.html")
|
|
|
|
return err
|
2023-10-08 15:24:59 +01:00
|
|
|
}
|