paths

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
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.

View Source
const DefaultPrivateFilesDir = "./private"

DefaultPrivateFilesDir - the private files directory without a config.

View Source
const MaxThemeChain = 8

MaxThemeChain - the deepest chain of base themes followed, the theme itself included; a deeper one doesn't load (themes.LoadInfoFor).

View Source
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

func GlobTemplates(pattern string) ([]string, error)

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

func GlobTemplatesIn(theme, pattern string) ([]string, error)

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

func ModuleStaticFS(module string) fs.FS

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

func ModuleTemplatesGlob(pattern string) ([]string, error)

ModuleTemplatesGlob - ModuleTemplatesGlobIn the active theme.

func ModuleTemplatesGlobIn

func ModuleTemplatesGlobIn(name, pattern string) ([]string, error)

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

func PreviewTheme(ctx context.Context) (string, bool)

PreviewTheme - the theme WithTheme gave ctx, if any.

func PrivateFilesDir

func PrivateFilesDir() string

PrivateFilesDir - the private files directory.

func PrivateStore

func PrivateStore() filestore.Store

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

func PublicStore() filestore.Store

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

func ReadTemplate(p string) ([]byte, error)

ReadTemplate - a template file's contents: from disk, or from a module's embedded files for an "embed:…" path.

func ResolveTemplate

func ResolveTemplate(rel string) (string, error)

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

func ResolveTemplateIn(theme, rel string) (string, error)

ResolveTemplateIn - ResolveTemplate with theme name's copy: its own, else its base themes' (ThemeChain).

func SetBaseThemes

func SetBaseThemes(f func(name string) string)

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

func SetModuleAssets(assets map[string]fs.FS, embedded bool)

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

func SetPrivateStore(s filestore.Store)

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

func SetPublicStore(s filestore.Store, url string)

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

func TemplateExists(p string) bool

TemplateExists - whether a template path (ResolveTemplate's) is a file.

func TemplatesDir

func TemplatesDir() (string, error)

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 Theme

func Theme() string

Theme - the active theme's name ("" - none).

func ThemeChain

func ThemeChain(name string) []string

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

func ThemeDir(name string) string

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 ThemeFor

func ThemeFor(ctx context.Context) string

ThemeFor - the theme ctx renders in: its preview theme, else the active one.

func ThemeStaticDir

func ThemeStaticDir(name string) string

ThemeStaticDir - theme name's static directory (served at /static/themes/<name>/), "" for none or a missing one.

func ThemeTemplatesDirOf

func ThemeTemplatesDirOf(name string) string

ThemeTemplatesDirOf - theme name's templates directory, "" for none or a missing one.

func ThemeTemplatesDirsOf

func ThemeTemplatesDirsOf(name string) []string

ThemeTemplatesDirsOf - the templates directories of theme name's chain (ThemeChain) that exist, the theme's first.

func ThemeTranslationsDirsOf

func ThemeTranslationsDirsOf(name string) []string

ThemeTranslationsDirsOf - the translations directories of theme name's chain (ThemeChain) that exist, the theme's first.

func ThemeWithStatic

func ThemeWithStatic(name, rel string) string

ThemeWithStatic - the first theme of name's chain with the static file rel (under its static/), name itself when none has it.

func ThemesDir

func ThemesDir() (string, error)

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

func ThemesLockFile() (string, error)

ThemesLockFile - the record of the themes installed from their repositories (app theme add): themes/themes.lock, deployed with them.

func WithTheme

func WithTheme(ctx context.Context, name string) context.Context

WithTheme - ctx rendering in theme name instead of the active one (a theme's preview); "" - the engine's own templates.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL