Documentation ¶
Index ¶
- Constants
- Variables
- func FlushFiles(modDir string, files []File) error
- func GoFormat(path string) (string, error)
- func IsTTY() bool
- func ScanSitemap(sitePkg GoPackage) (pages []string, err error)
- func TimeoutScanln() (string, error)
- func TryReadModFile() (module string, baseDir string)
- func ValidatePageLocation(pageDir string, scaffold fs.FS) error
- func ValidatePageName(name string) error
- func ValidateScaffoldLocation(siteDir string, scaffold fs.FS) error
- type Entry
- type File
- func PageScaffold(sitePkg GoPackage, name string, scaffold fs.FS, starter fs.FS, ...) (files []File, err error)
- func PagesScaffold(sitePkg GoPackage, pages []string, scaffold fs.FS) (file File, err error)
- func RoutesScaffold(sitePkg GoPackage, pageName string, entries []Entry, routes []Route, ...) (files []File, err error)
- func SiteScaffold(pkg GoPackage, scaffold fs.FS) (files []File, err error)
- func StarterScaffold(dir string, scaffold, starter fs.FS) (files []File, err error)
- type GoModule
- type GoPackage
- type HTMLTemplate
- type HandleBlock
- type Handler
- type Route
- type TemplateBlock
- type TemplateSubView
Constants ¶
const ( FOLDER_PERMS = 0755 FILE_PERMS = 0644 )
Variables ¶
var (
PageNameRegex = regexp.MustCompile(`^[a-z][a-z]+$`)
)
Functions ¶
func FlushFiles ¶
FlushFiles will write files out to a temp directory and move those files to into the go package
func ScanSitemap ¶
ScanSitemap will scan the site page package and list pages
func TimeoutScanln ¶
TimeoutScanln will wait for at most 10 seconds for a line of input from the user
func TryReadModFile ¶
TryReadModFile will attempt to load the root module path from a go.mod file it will return empty string otherwise
func ValidatePageLocation ¶
ValidatePagePackage will check that a page can be installed at a given location.
If the target directory is not empty, this will scan for conflicts against the scaffold
func ValidatePageName ¶
ValidatePageName will check if a page name is permitted to be the name of a site page
func ValidateScaffoldLocation ¶
ValidateScaffoldPackage will check that a relative go package path is available for a site scaffold to to be installed and return the go import path and directory for the new scaffold site.
Note that '.' will attempt to install the site in the root directory of the current go module
If the target directory is not empty, this will scan for conflicts against the scaffold
Types ¶
type Entry ¶
type Entry struct { Type string // "SubView" "DefaultSubView" "Spacer" Assignment string Extends string Block string Template string Handler string Comment string }
Entry for the routes.go file
type File ¶
File description and contents that will later be flushed to disk
func PageScaffold ¶
func PageScaffold(sitePkg GoPackage, name string, scaffold fs.FS, starter fs.FS, withResources bool) (files []File, err error)
PageScaffold will assemble files for adding a new page to the site scaffold
func PagesScaffold ¶
PagesFile creates a new pages.go file by scanning the target scaffold site for directories inside the ./page sub-package
func RoutesScaffold ¶
func RoutesScaffold( sitePkg GoPackage, pageName string, entries []Entry, routes []Route, templates []HTMLTemplate, handlers []Handler, scaffold fs.FS, hasResources bool, ) (files []File, err error)
RoutesScaffold will generate all files for the good routes command
func SiteScaffold ¶
SiteScaffold will return a list of files that need to be created
func StarterScaffold ¶
StarterScaffold will output a copy of the raw starter template files
type GoModule ¶
GoModule represents a golang project level module
func GoListModule ¶
GoListModule will get the Go module information for the import path provied
type GoPackage ¶
type GoPackage struct { Dir string `json:"Dir"` ImportPath string `json:"ImportPath"` Module GoModule `json:"Module"` }
GoPackage represents a package within a go module
func GoListPackage ¶
GoListPackage will get the Go module information for the go path provied
func ParseSitePackage ¶
ParseSitePackage will normalize a relative path from a valid Go module and return a golang package import path and directory path relative to the module dir
func SiteFromPagePackage ¶
SiteFromPagePackage will construct a site go package given one that refers to a page in that site
type HTMLTemplate ¶
type HTMLTemplate struct { Filepath string Path string Blocks []TemplateBlock Block string Merge string Fragment bool Partial bool Page bool Name string }
HTMLTemplate is data for a page template document
type HandleBlock ¶
HandleBlock is the details of sub-views which should be delegated to in the handler
type Handler ¶
type Handler struct { Ref string Block string Method string Doc string Identifier string Blocks []HandleBlock }
Handler is data for a handler function which should be created
type Route ¶
type Route struct { Method string Path string Includes []string Reference string PageOnly bool FragmentOnly bool }
Route is a path mapped to a view definition
type TemplateBlock ¶
type TemplateBlock struct { FieldName string Name string Views []TemplateSubView }