Documentation ¶
Index ¶
- Constants
- Variables
- func All(path, activeTheme string) ([]*domain.ThemeConfig, error)
- func Fetch(path string) *domain.ThemeConfig
- func Find(path string) (*domain.ThemeConfig, error)
- func FindScreenshot(path string) (string, error)
- func Get() *domain.ThemeConfig
- func Init(path string) *domain.ThemeConfig
- func Set(config domain.ThemeConfig)
Constants ¶
const ( // The default screenshot name within the theme's // directory. ScreenshotName = "screenshot" // The url of the screenshot. ScreenshotURL = "/themes/" )
const (
// The default configuration file name within the theme.
FileName = "config.yml"
)
Variables ¶
var ( // DefaultTheme is Global configuration for the theme, // sets defaults to ensure that there are no // empty values within the themes config // to prevent any errors. DefaultTheme = domain.ThemeConfig{ Theme: domain.Theme{}, Resources: nil, AssetsPath: "assets", FileExtension: ".cms", TemplateDir: "templates", LayoutDir: "layouts", Admin: domain.AdminConfig{ Path: "/admin", InactiveSessionTime: 60, }, Media: domain.MediaConfig{ UploadPath: "/uploads", AllowedFileTypes: []string{ "image/png", "image/jpeg", "image/gif", "image/webp", "image/bmp", "image/svg+xml", "video/mpeg", "video/mp4", "video/webm", "application/pdf", "application/msword", }, }, Editor: domain.Editor{ Modules: []string{ "blockquote", "code_block", "code_block_highlight", "hardbreak", "h1", "h2", "h3", "h4", "h5", "h6", "paragraph", "hr", "ul", "ol", "bold", "code", "italic", "link", "strike", "underline", "history", "search", "trailing_node", "color", }, Options: map[string]interface{}{ "palette": []string{ "#4D4D4D", "#999999", "#FFFFFF", "#F44E3B", "#FE9200", "#FCDC00", "#DBDF00", "#A4DD00", "#68CCCA", "#73D8FF", "#AEA1FF", "#FDA1FF", "#333333", "#808080", "#CCCCCC", "#D33115", "#E27300", "#FCC400", "#B0BC00", "#68BC00", "#16A5A5", "#009CE0", "#7B64FF", "#FA28FF", "#000000", "#666666", "#B3B3B3", "#9F0500", "#C45100", "#FB9E00", "#808900", "#194D33", "#0C797D", "#0062B1", "#653294", "#AB149E", }, }, }, } )
var ( // ErrNoThemes is returned by All when no themes // have been found by looping over the theme's // directory. ErrNoThemes = errors.New("no page templates found") )
var ( // ScreenshotExtensions is the allowed extensions // that the function will scan for. ScreenshotExtensions = []string{ ".png", ".svg", ".jpg", ".jpeg", } )
Functions ¶
func All ¶
func All(path, activeTheme string) ([]*domain.ThemeConfig, error)
All
Returns a slice of domain.ThemeConfig's by reading the path. If the file is a directory, it will be skipped until a config file has been found.
Returns errors.NOTFOUND if no themes were found. Returns errors.INTERNAL if the theme path is invalid.
func Fetch ¶
func Fetch(path string) *domain.ThemeConfig
Fetch
Get"s the themes configuration from the themes path
Logs errors.INTERNAL if the unmarshalling was unsuccessful and returns the DefaultTheme variable.
func Find ¶
func Find(path string) (*domain.ThemeConfig, error)
Find
Looks up for theme configuration file by the given path and default file name.
Returns errors.INTERNAL if the unmarshalling was unsuccessful and returns the DefaultTheme variable.
func FindScreenshot ¶
FindScreenshot
Ranges over the allowed screenshot extensions and checks for a match, if the screenshot has been found, a url will be returned.
Returns errors.NOTFOUND if no screenshot was found.
func Init ¶
func Init(path string) *domain.ThemeConfig
Init
Fetches and returns the theme configuration once.
func Set ¶
func Set(config domain.ThemeConfig)
Set
Sets the cfg variable to a new theme configuration when a theme has been set by the user.
Types ¶
This section is empty.