Documentation
¶
Index ¶
- func FileToParams(fpath string) map[string]string
- func T(page *Page, s string) string
- func ToASCII(str string) string
- func ToTime(s string) (time.Time, error)
- type Application
- func (app *Application) BinPath() string
- func (app *Application) Collection(ckey string) *Collection
- func (app *Application) CollectionCount() int
- func (app *Application) CollectionPages(ckey, csubkey string) PageList
- func (app *Application) FileToPage(fpath string) *Page
- func (app *Application) IsValidLang(lang string) bool
- func (app *Application) LoadContent()
- func (app *Application) NewPage(lang, label string) *Page
- func (app *Application) Page(slug string) *Page
- func (app *Application) PageCount() int
- func (app *Application) Print()
- func (app *Application) Search(pageSlug, sterm string) PageList
- type Collection
- type Page
- func (page *Page) AbsoluteURL() string
- func (page *Page) AppendContent(content []byte)
- func (page *Page) BlankParams()
- func (page *Page) Content() []byte
- func (page *Page) Get(key string) string
- func (page *Page) IsDir() bool
- func (page *Page) IsEqual(key, val string) bool
- func (page *Page) IsNegation(key string) bool
- func (page *Page) IsNo(key string) bool
- func (page *Page) IsSet(key string) bool
- func (page *Page) IsYes(key string) bool
- func (page *Page) MergeParams(moreParams map[string]string)
- func (page *Page) ModTime() time.Time
- func (page *Page) Paging(pNum, pSize, pLimit int)
- func (page *Page) Params() map[string]string
- func (page *Page) ParamsLen() int
- func (page *Page) PopulateParams(s string) string
- func (page *Page) Print()
- func (page *Page) PrintRow()
- func (page *Page) PrintTree(depth int)
- func (page *Page) ReloadContent() bool
- func (page *Page) RemoveParam(key string)
- func (page *Page) Search(sterm string) PageList
- func (page *Page) SearchByParam(key, val string) PageList
- func (page *Page) Set(key, val string)
- func (page *Page) SetContent(content []byte)
- func (page *Page) SetLang(lang string) string
- func (page *Page) SetValue(key string, val interface{})
- func (page *Page) Split(key, sep string) []string
- func (page *Page) Walk(fnCheck func(p *Page) bool) PageList
- func (page *Page) WalkTop(fn func(parent *Page))
- type PageList
- type PageMap
- type Server
- func (srv *Server) Render(w io.Writer, page *Page, templateID string)
- func (srv *Server) Run404(w http.ResponseWriter, r *http.Request)
- func (srv *Server) RunIndex(w http.ResponseWriter, r *http.Request)
- func (srv *Server) RunOne(w http.ResponseWriter, r *http.Request)
- func (srv *Server) Start() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FileToParams ¶
FileToParams - Read file contents and convert to map of params We do not check for error because we only want to get/or not file Importance order: 1. Content params 2. Filename params 3. (same depth) .defaults 4 -n. (up n depth) .subdefaults 5. .mango config file params
Types ¶
type Application ¶
type Application struct { // Absoluted domain path with scheme // https://example.loc Domain string // Absolute path to content (folders with .md files) ContentPath string // Absolute path to web accessible files PublicPath string // Page tree Pages PageList // URLTemplates - url templates for pages URLTemplates map[string]string // Link to server Server *Server // Run this func on content reload OnReload func(app *Application) // contains filtered or unexported fields }
Application - mango application
func NewApplication ¶
func NewApplication() (*Application, error)
NewApplication - create/init new application Must be executed only one time
func (*Application) Collection ¶
func (app *Application) Collection(ckey string) *Collection
Collection - get collection by ckey
func (*Application) CollectionCount ¶
func (app *Application) CollectionCount() int
CollectionCount - total count of collections
func (*Application) CollectionPages ¶
func (app *Application) CollectionPages(ckey, csubkey string) PageList
CollectionPages - shorthand to get collection subitems Avoiding errors. Without it need to use: app.Collection(ckey).Get(csubkey) But there could be no ckey collection and that results in go-lang error
func (*Application) FileToPage ¶
func (app *Application) FileToPage(fpath string) *Page
FileToPage for application
func (*Application) IsValidLang ¶
func (app *Application) IsValidLang(lang string) bool
IsValidLang - is given language is valid in App scope
func (*Application) LoadContent ¶
func (app *Application) LoadContent()
LoadContent - Load files to application Can be executed more than once times (on .reload file creation)
func (*Application) NewPage ¶
func (app *Application) NewPage(lang, label string) *Page
NewPage already linked to app
func (*Application) Page ¶
func (app *Application) Page(slug string) *Page
Page - get one page by given slug. Slug must be equal and is case-sensitive
func (*Application) PageCount ¶
func (app *Application) PageCount() int
PageCount - total count of pages
func (*Application) Search ¶
func (app *Application) Search(pageSlug, sterm string) PageList
Search pages from given top page
type Collection ¶
Collection is map of *Page
func (*Collection) Append ¶
func (c *Collection) Append(key string, page *Page)
Append new page to PageList under key
type Page ¶
type Page struct { sync.RWMutex // Link to application App *Application // Parent page Parent *Page // Sub-pages for this page Pages PageList // contains filtered or unexported fields }
Page - page with content and params + sub-pages
func (*Page) AbsoluteURL ¶
AbsoluteURL - page URL prefixed with domain
func (*Page) AppendContent ¶
AppendContent - append to content
func (*Page) BlankParams ¶
func (page *Page) BlankParams()
BlankParams - init/clear all params Or could be used to init page params map
func (*Page) IsNegation ¶
IsNegation - Similar to IsNo, bu check for more negation forms Negation values are: No Not None N/A 0 -1 "" (empty, not set)
func (*Page) MergeParams ¶
MergeParams - merge some more params
func (*Page) ModTime ¶
ModTime - Get mod time for page from params not reading actual file from filesystem
func (*Page) Paging ¶
Paging - slice page.Pages with paging logic and add params from paging to page params
func (*Page) PopulateParams ¶
PopulateParams - replace given string with templated params Use figure brackets "{}" as param placeholders /{Slug}.html with be replaced with actual page slug
func (*Page) ReloadContent ¶
ReloadContent file Content (only) TODO: reload params too? changing Slug is dangerous
func (*Page) RemoveParam ¶
RemoveParam - remove param by given key
func (*Page) Search ¶
Search - find all pages by given search term TODO: make correct search by params and content
func (*Page) SearchByParam ¶
SearchByParam - find all pages that search value is equal to page param
func (*Page) SetContent ¶
SetContent set content for page
func (*Page) SetLang ¶
SetLang - try to set page language If given lang is not valid, use default lang from App
type PageList ¶
type PageList []*Page
PageList is slice as []*Page
type PageMap ¶
PageMap is map of *Page
func (*PageMap) Add ¶
Add new *Page to local map Can't use only Slug, because PageMap can be used for many purposes
type Server ¶
type Server struct { Host string Port string App *Application Templates *template.Template Router *mux.Router FuncMap template.FuncMap // user can define its /* Middlewares: Middlewares["Page"] Middlewares["File"] To add multiple middlewares on one map key: srv.Middlewares["File"] = func(next http.Handler) http.Handler { return mwFirst(mwSecond(next)) } */ Middlewares map[string]func(next http.Handler) http.Handler }
Server - mango server for serving content from mango-structure data
func (*Server) Run404 ¶
func (srv *Server) Run404(w http.ResponseWriter, r *http.Request)
Run404 - handler 404
func (*Server) RunIndex ¶
func (srv *Server) RunIndex(w http.ResponseWriter, r *http.Request)
RunIndex - handler for first page