62c53a6b4d
* Initial rough draft switch to sqlite. * Rewrote cache implemenation. * Provide typed tasks. * Task cleanup. * Use same db for tasks. * Provide task queue registration and service container injection. * Added optional delay to tasks. Pool buffers when encoding. * Added tests for the task client and runner. * Added handler examples for caching and tasks. * Cleanup and documentation. * Use make in workflow. * Updated documentation. * Updated documentation.
55 lines
1.3 KiB
Go
55 lines
1.3 KiB
Go
package templates
|
|
|
|
import (
|
|
"embed"
|
|
"io/fs"
|
|
"os"
|
|
"path"
|
|
"path/filepath"
|
|
"runtime"
|
|
)
|
|
|
|
type (
|
|
Layout string
|
|
Page string
|
|
)
|
|
|
|
const (
|
|
LayoutMain Layout = "main"
|
|
LayoutAuth Layout = "auth"
|
|
LayoutHTMX Layout = "htmx"
|
|
)
|
|
|
|
const (
|
|
PageAbout Page = "about"
|
|
PageCache Page = "cache"
|
|
PageContact Page = "contact"
|
|
PageError Page = "error"
|
|
PageForgotPassword Page = "forgot-password"
|
|
PageHome Page = "home"
|
|
PageLogin Page = "login"
|
|
PageRegister Page = "register"
|
|
PageResetPassword Page = "reset-password"
|
|
PageSearch Page = "search"
|
|
PageTask Page = "task"
|
|
)
|
|
|
|
//go:embed *
|
|
var templates embed.FS
|
|
|
|
// Get returns a file system containing all templates via embed.FS
|
|
func Get() embed.FS {
|
|
return templates
|
|
}
|
|
|
|
// GetOS returns a file system containing all templates which will load the files directly from the operating system.
|
|
// This should only be used for local development in order to facilitate live reloading.
|
|
func GetOS() fs.FS {
|
|
// Gets the complete templates directory path
|
|
// This is needed in case this is called from a package outside of main, such as within tests
|
|
_, b, _, _ := runtime.Caller(0)
|
|
d := path.Join(path.Dir(b))
|
|
p := filepath.Join(filepath.Dir(d), "templates")
|
|
return os.DirFS(p)
|
|
}
|