Documentation
¶
Index ¶
- Constants
- func EngineDir() string
- func GlobTemplates(pattern string) ([]string, error)
- func GlobTemplatesIn(theme, pattern string) ([]string, error)
- func ModuleStaticFS(module string) fs.FS
- func ModuleTemplatesGlob(pattern string) ([]string, error)
- func ModuleTemplatesGlobIn(name, pattern string) ([]string, error)
- func ModulesDir() string
- func PreviewTheme(ctx context.Context) (string, bool)
- func PrivateFilesDir() string
- func PrivateStore() filestore.Store
- func PublicFilesDir() string
- func PublicFilesRel() string
- func PublicFilesURL() string
- func PublicStore() filestore.Store
- func PublicStoreURL() string
- func ReadTemplate(p string) ([]byte, error)
- func ResolveTemplate(rel string) (string, error)
- func ResolveTemplateIn(theme, rel string) (string, error)
- func SetBaseThemes(f func(name string) string)
- func SetEngineDir(dir string)
- func SetModuleAssets(assets map[string]fs.FS, embedded bool)
- func SetPrivateFiles(dir string)
- func SetPrivateStore(s filestore.Store)
- func SetPublicFiles(dir, url string)
- func SetPublicStore(s filestore.Store, url string)
- func SetTheme(name string)
- func SetThemesDir(dir string)
- func StaticDir() string
- func TemplateExists(p string) bool
- func TemplatesDir() (string, error)
- func Theme() string
- func ThemeChain(name string) []string
- func ThemeDir(name string) string
- func ThemeFor(ctx context.Context) string
- func ThemeStaticDir(name string) string
- func ThemeTemplatesDirOf(name string) string
- func ThemeTemplatesDirsOf(name string) []string
- func ThemeTranslationsDirsOf(name string) []string
- func ThemeWithStatic(name, rel string) string
- func ThemesDir() (string, error)
- func ThemesDirs() []string
- func ThemesLockFile() (string, error)
- func WithTheme(ctx context.Context, name string) context.Context
Constants ¶
const ( DefaultPublicFilesDir = "./web/uploads" DefaultPublicFilesURL = "/uploads/" )
Public files (uploads, image style derivatives): the directory on disk and the URL path it is served at - config files.public_dir / files.public_url. Content stores the files' URLs, so a site keeps its URL path once it has content.
const DefaultPrivateFilesDir = "./private"
DefaultPrivateFilesDir - the private files directory without a config.
const MaxThemeChain = 8
MaxThemeChain - the deepest chain of base themes followed, the theme itself included; a deeper one doesn't load (themes.LoadInfoFor).
const PrivateFilesURL = "/files/private/"
PrivateFilesURL - the URL path the site serves the private files at, after checking the viewer may see a content item a file is attached to: PrivateFilesURL + its key.
Variables ¶
This section is empty.
Functions ¶
func EngineDir ¶
func EngineDir() string
EngineDir - the engine directory SetEngineDir set ("" - none).
func GlobTemplates ¶
GlobTemplates - files matching pattern (relative to the templates root) from the engine, the modules and the active theme: a theme file replaces the engine's or a module's with the same relative path (a module's never replaces the engine's); theme-only files come last.
func GlobTemplatesIn ¶
GlobTemplatesIn - GlobTemplates with theme name's files and its base themes' (ThemeChain): a theme's file replaces its base's, both the engine's.
func ModuleStaticFS ¶
ModuleStaticFS - a module's static files (nil when it has none), from its source directory or its embedded files (moduleSources); a missing minified file (the pages link <name>.min.css and .min.js) is its unminified one - a module from outside the engine may ship no minified copies.
func ModuleTemplatesGlob ¶
ModuleTemplatesGlob - ModuleTemplatesGlobIn the active theme.
func ModuleTemplatesGlobIn ¶
ModuleTemplatesGlobIn - the modules' templates matching pattern (relative to a module's templates directory), each the copy of theme name's chain (the theme, then its base themes, ThemeTemplatesDirsOf) when one has it: e.g. every module's "blocks/*.html" partials, parsed with every page - a previewed theme's and a subtheme's overrides too.
func ModulesDir ¶
func ModulesDir() string
ModulesDir - internal/modules from the current directory (the project root, or a cmd/* or package directory two levels down, as tests run); "" when missing.
func PreviewTheme ¶
PreviewTheme - the theme WithTheme gave ctx, if any.
func PrivateStore ¶
PrivateStore - the store of the private files: the one set, else the directory PrivateFilesDir on disk.
func PublicFilesDir ¶
func PublicFilesDir() string
PublicFilesDir - the public files directory on disk.
func PublicFilesRel ¶
func PublicFilesRel() string
PublicFilesRel - the URL path without its leading slash ("uploads/"), as stored in some relative values.
func PublicFilesURL ¶
func PublicFilesURL() string
PublicFilesURL - the URL path of the public files directory, with the leading and trailing slash (e.g. "/uploads/").
func PublicStore ¶
PublicStore - the store of the public files: the one set, else the directory PublicFilesDir on disk. Keys are paths relative to PublicFilesURL.
func PublicStoreURL ¶
func PublicStoreURL() string
PublicStoreURL - the address (ending in "/") the public files' store serves them at itself, e.g. a bucket's CDN: the site redirects its files' addresses (PublicFilesURL + key) there. "" - the site serves them.
func ReadTemplate ¶
ReadTemplate - a template file's contents: from disk, or from a module's embedded files for an "embed:…" path.
func ResolveTemplate ¶
ResolveTemplate - the absolute path of a template given relative to the templates root: the active theme's copy when it has one, else the engine's, else a module's (moduleSources: its file on disk, or an "embed:…" path of its embedded files - ReadTemplate reads either).
func ResolveTemplateIn ¶
ResolveTemplateIn - ResolveTemplate with theme name's copy: its own, else its base themes' (ThemeChain).
func SetBaseThemes ¶
SetBaseThemes - how a theme's base theme is found.
func SetEngineDir ¶
func SetEngineDir(dir string)
SetEngineDir sets the engine directory ("" - the working directory).
func SetModuleAssets ¶
SetModuleAssets sets the modules' embedded files by name (at startup): with embedded - the only ones used (a site runs the binary's own); without, a module's source directory on disk comes first (local development), its embedded files where it has none.
func SetPrivateFiles ¶
func SetPrivateFiles(dir string)
SetPrivateFiles sets the private files directory (config files.private_dir; "" - the default): files the application serves only after a permission check, never from the web directory.
func SetPrivateStore ¶
SetPrivateStore sets the store the private files are kept in; called once at startup from the config (nil - the directory PrivateFilesDir).
func SetPublicFiles ¶
func SetPublicFiles(dir, url string)
SetPublicFiles sets the public files directory and URL path; called once at startup from the config. Empty values keep the defaults; the URL path gets its leading and trailing slashes.
func SetPublicStore ¶
SetPublicStore sets the store the public files are kept in and the address it serves them at itself ("" - the site serves them); called once at startup from the config (nil - the directory PublicFilesDir).
func SetTheme ¶
func SetTheme(name string)
SetTheme sets the active theme; called once at startup from the config.
func SetThemesDir ¶
func SetThemesDir(dir string)
SetThemesDir points ThemesDir at dir ("" - back to themes/ beside web/): the tests' own themes (testdata/themes), which the engine's tests use rather than a site's theme.
func StaticDir ¶
func StaticDir() string
StaticDir - the engine's static files, served at /static/: the engine directory's web/static, else the working directory's.
func TemplateExists ¶
TemplateExists - whether a template path (ResolveTemplate's) is a file.
func TemplatesDir ¶
TemplatesDir returns the path to the engine's templates: the engine directory's web/templates (SetEngineDir), else web/templates relative to the current working directory - the project root or a cmd/* layout (e.g. running from cmd/app).
func ThemeChain ¶
ThemeChain - theme name and its base themes, the theme first (a subtheme, its base, the base's base…; empty - the engine's templates). A loop or a chain deeper than MaxThemeChain stops there.
func ThemeDir ¶
ThemeDir - theme name's directory (<themes>/<name>, the first of ThemesDirs having it), "" for none, a missing one or a name that isn't a directory's.
func ThemeStaticDir ¶
ThemeStaticDir - theme name's static directory (served at /static/themes/<name>/), "" for none or a missing one.
func ThemeTemplatesDirOf ¶
ThemeTemplatesDirOf - theme name's templates directory, "" for none or a missing one.
func ThemeTemplatesDirsOf ¶
ThemeTemplatesDirsOf - the templates directories of theme name's chain (ThemeChain) that exist, the theme's first.
func ThemeTranslationsDirsOf ¶
ThemeTranslationsDirsOf - the translations directories of theme name's chain (ThemeChain) that exist, the theme's first.
func ThemeWithStatic ¶
ThemeWithStatic - the first theme of name's chain with the static file rel (under its static/), name itself when none has it.
func ThemesDir ¶
ThemesDir - the directory of the themes, themes/ beside web/ (the project's or the installation's root), or the one SetThemesDir set. With an engine directory (SetEngineDir) the themes are the site's own: themes/ in its working directory.
func ThemesDirs ¶
func ThemesDirs() []string
ThemesDirs - where themes are looked for, first first: ThemesDir and, with an engine directory (SetEngineDir), the themes it ships (its themes/), which every site sharing it has; a site's own theme of the same name comes first.
func ThemesLockFile ¶
ThemesLockFile - the record of the themes installed from their repositories (app theme add): themes/themes.lock, deployed with them.
Types ¶
This section is empty.