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-02-07 02:45:40 +04:00
|
|
|
//go:generate $GOPATH/bin/jade -pkg=web -stdbuf -stdlib -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
|
|
|
}
|
|
|
|
|
|
|
|
func AssetsGetFile(path string) ([]byte, error) {
|
2022-05-24 19:42:47 +04:00
|
|
|
return assetsDir.ReadFile("assets/" + path)
|
2022-05-24 18:30:14 +04:00
|
|
|
}
|