2022-05-24 18:30:14 +04:00
|
|
|
package web
|
|
|
|
|
|
|
|
import (
|
|
|
|
"embed"
|
2022-05-24 19:42:47 +04:00
|
|
|
"io/fs"
|
2022-05-24 18:30:14 +04:00
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
2022-06-13 18:47:27 +04:00
|
|
|
// To install a Jade compiler: go install github.com/Joker/jade/cmd/jade@latest
|
2023-08-06 03:35:32 +04:00
|
|
|
//go:generate $GOPATH/bin/jade -pkg=web -writer templates/index.pug
|
2022-06-13 18:39:30 +04:00
|
|
|
|
2022-05-24 18:30:14 +04:00
|
|
|
//go:embed assets
|
|
|
|
var assetsDir embed.FS
|
|
|
|
|
|
|
|
func Assets() http.FileSystem {
|
2022-05-24 19:42:47 +04:00
|
|
|
f, _ := fs.Sub(assetsDir, "assets")
|
|
|
|
return http.FS(f)
|
2022-05-24 18:30:14 +04:00
|
|
|
}
|
|
|
|
|
2024-04-20 18:54:05 +04:00
|
|
|
func AssetsGetFile(path string) []byte {
|
|
|
|
data, err := assetsDir.ReadFile("assets/" + path)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return data
|
2022-05-24 18:30:14 +04:00
|
|
|
}
|