Documentation ¶
Index ¶
- Constants
- func CategoryName(name string) string
- func CategoryNameNE(name string) string
- func InjectPageOpt(page *Page, opt *PageOpt) error
- func MakeDir(dir, name string)
- func ModelName(name string) string
- func PageName(name string) string
- func PageNameExt(name, ext string) string
- func PageNameLink(name string) string
- func PageNameNE(name string) string
- func ScaleString(name string, retina []int) string
- func UniqueFilesInDir(dir string, extensions []string, thisDirOnly bool) ([]string, error)
- type AttributedObject
- type HTML
- type List
- type Map
- func (scope Map) Get(key string) (interface{}, error)
- func (scope Map) GetBlock(key string) (block, error)
- func (scope Map) GetBool(key string) (bool, error)
- func (scope Map) GetObj(key string) (AttributedObject, error)
- func (scope Map) GetStr(key string) (string, error)
- func (m *Map) Keys() []string
- func (m *Map) Map() map[string]interface{}
- func (m *Map) OrderedKeys() []string
- func (scope Map) Set(key string, value interface{}) error
- func (b Map) String() string
- type Page
- func (p *Page) Author() string
- func (p *Page) CSS() string
- func (p *Page) CacheExists() bool
- func (p *Page) CacheModified() time.Time
- func (p *Page) CachePath() string
- func (p *Page) Categories() []string
- func (p *Page) Created() time.Time
- func (p *Page) Draft() bool
- func (p *Page) Exists() bool
- func (p *Page) FmtTitle() HTML
- func (p *Page) Generated() bool
- func (scope Page) Get(key string) (interface{}, error)
- func (scope Page) GetBlock(key string) (block, error)
- func (scope Page) GetBool(key string) (bool, error)
- func (scope Page) GetObj(key string) (AttributedObject, error)
- func (scope Page) GetStr(key string) (string, error)
- func (p *Page) HTML() HTML
- func (p *Page) Info() PageInfo
- func (p *Page) IsSymlink() bool
- func (p *Page) Modified() time.Time
- func (p *Page) Name() string
- func (p *Page) NameNE() string
- func (p *Page) OSName() string
- func (p *Page) OSNameNE() string
- func (p *Page) Parse() error
- func (p *Page) Path() string
- func (p *Page) Prefix() string
- func (p *Page) Redirect() string
- func (p *Page) RelName() string
- func (p *Page) RelNameNE() string
- func (p *Page) RelPath() string
- func (p *Page) SearchPath() string
- func (scope Page) Set(key string, value interface{}) error
- func (p *Page) Title() string
- func (p *Page) TitleOrName() string
- type PageInfo
- type PageOpt
- type PageOptCategory
- type PageOptDir
- type PageOptExternal
- type PageOptExternalType
- type PageOptHost
- type PageOptImage
- type PageOptLink
- type PageOptLinkFunction
- type PageOptNavigation
- type PageOptPage
- type PageOptRoot
- type PageOptSearch
Constants ¶
const ( // PageOptExternalTypeQuiki is the external type for quiki sites. PageOptExternalTypeQuiki PageOptExternalType = "quiki" // PageOptExternalTypeMediaWiki is the external type for MediaWiki sites. PageOptExternalTypeMediaWiki = "mediawiki" // PageOptExternalTypeNone is an external type that can be used for websites that // perform no normalization of page targets beyond normal URI escaping. PageOptExternalTypeNone = "none" )
Variables ¶
This section is empty.
Functions ¶
func CategoryName ¶
CategoryName returns a clean category name.
func CategoryNameNE ¶
CategoryNameNE returns a clean category with No Extension.
func InjectPageOpt ¶
InjectPageOpt extracts page options found in the specified page and injects them into the provided PageOpt pointer.
func PageNameExt ¶
PageNameExt returns a clean page name with the provided extension.
func PageNameLink ¶
PageNameLink returns a clean page name without the extension.
func PageNameNE ¶
PageNameNE returns a clean page name with No Extension.
func ScaleString ¶
ScaleString returns a string of scaled image names for use in srcset.
func UniqueFilesInDir ¶
UniqueFilesInDir recursively scans a directory for files matching the requested extensions, resolves symlinks, and returns a list of unique files. That is, if more than one link resolves to the same thing (as is the case for quiki page redirects), there is only one occurrence in the output.
Types ¶
type AttributedObject ¶
type AttributedObject interface { // getters Get(key string) (interface{}, error) GetBool(key string) (bool, error) GetStr(key string) (string, error) GetBlock(key string) (block, error) GetObj(key string) (AttributedObject, error) // setters Set(key string, value interface{}) error // contains filtered or unexported methods }
An AttributedObject is any object on which you can set and retrieve attributes.
For example, a Page is an attributed object since it contains variables. Likewise, a Map is an attributed object because it has named properties.
type HTML ¶
type HTML string
HTML encapsulates a string to indicate that it is preformatted HTML. It lets quiki's parsers know not to attempt to format it any further.
type List ¶
type List struct {
// contains filtered or unexported fields
}
List represents a list of items. It is a quiki data type as well as the base of many block types.
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map represents a Key-value dictionary. It is a quiki data type as well as the base of many block types.
func NewMap ¶
func NewMap(mb block) *Map
NewMap creates a new map, given the main block of the page it is to be associated with.
func (Map) Get ¶
Get fetches a a value regardless of type.
The key may be segmented to indicate properties of each object (e.g. person.name).
If attempting to read a property of an object that does not support properties, such as a string, Get returns an error.
If the key is valid but nothing exists at it, Get returns (nil, nil).
func (Map) GetObj ¶
func (scope Map) GetObj(key string) (AttributedObject, error)
GetObj is like Get except it always returns an AttributedObject.
func (Map) GetStr ¶
GetStr is like Get except it always returns a string.
If the value is HTML, it is converted to a string.
func (*Map) OrderedKeys ¶
OrderedKeys returns a string of map keys in the order provided in the source. Keys that were set internally (and not from quiki source code) are omitted.
type Page ¶
type Page struct { Source string // source content FilePath string // Path to the .page file VarsOnly bool // True if Parse() should only extract variables Opt *PageOpt // page options Images map[string][][]int // references to images Models map[string]bool // references to models PageLinks map[string][]int // references to other pages Wiki interface{} // only available during Parse() and HTML() // contains filtered or unexported fields }
Page represents a single page or article, generally associated with a .page file. It provides the most basic public interface to parsing with the wikifier engine.
func NewPagePath ¶
NewPagePath creates a page given its filepath and relative name.
func NewPageSource ¶
NewPageSource creates a page given some source code.
func (*Page) CacheExists ¶
CacheExists is true if the page cache file exists.
func (*Page) CacheModified ¶
CacheModified returns the page cache file time.
func (*Page) Categories ¶
Categories returns a list of categories the page belongs to.
func (*Page) Generated ¶
Generated returns true if the page was auto-generated from some other source content.
func (Page) Get ¶
Get fetches a a value regardless of type.
The key may be segmented to indicate properties of each object (e.g. person.name).
If attempting to read a property of an object that does not support properties, such as a string, Get returns an error.
If the key is valid but nothing exists at it, Get returns (nil, nil).
func (Page) GetObj ¶
func (scope Page) GetObj(key string) (AttributedObject, error)
GetObj is like Get except it always returns an AttributedObject.
func (Page) GetStr ¶
GetStr is like Get except it always returns a string.
If the value is HTML, it is converted to a string.
func (*Page) HTML ¶
HTML generates and returns the HTML code for the page. The page must be parsed with Parse before attempting this method.
func (*Page) IsSymlink ¶
IsSymlink returns true if the page is a symbolic link to another file within the page directory. If it is symlinked to somewhere outside the page directory, it is treated as a normal page rather than a redirect.
func (*Page) Name ¶
Name returns the resolved page name with extension.
This DOES take symbolic links into account. and DOES include the page prefix if applicable. Any prefix will have forward slashes regardless of OS.
func (*Page) OSName ¶
OSName is like Name, except it uses the native path separator. It should be used for file operations only.
func (*Page) OSNameNE ¶
OSNameNE is like NameNE, except it uses the native path separator. It should be used for file operations only.
func (*Page) Parse ¶
Parse opens the page file and attempts to parse it, returning any errors encountered.
func (*Page) Path ¶
Path returns the absolute path to the page as resolved. If the path does not resolve, returns an empty string.
func (*Page) Prefix ¶
Prefix returns the page prefix.
For example, for a page named a/b.page, this is a. For a page named a.page, this is an empty string.
func (*Page) Redirect ¶
Redirect returns the location to which the page redirects, if any. This may be a relative or absolute URL, suitable for use in a Location header.
func (*Page) RelName ¶
RelName returns the unresolved page filename, with or without extension. This does NOT take symbolic links into account. It is not guaranteed to exist.
func (*Page) RelNameNE ¶
RelNameNE returns the unresolved page name with No Extension, relative to the page directory option. This does NOT take symbolic links into account. It is not guaranteed to exist.
func (*Page) RelPath ¶
RelPath returns the unresolved file path to the page. It may be a relative or absolute path. It is not guaranteed to exist.
func (*Page) SearchPath ¶
SearchPath returns the absolute path to the page search text file.
func (Page) Set ¶
Set sets a value at the given key.
The key may be segmented to indicate properties of each object (e.g. person.name).
If attempting to write to a property of an object that does not support properties, such as a string, Set returns an error.
func (*Page) TitleOrName ¶
TitleOrName returns the result of Title if available, otherwise that of Name.
type PageInfo ¶
type PageInfo struct { Path string `json:"omit"` // absolute filepath File string `json:"file,omitempty"` // name with extension, always with forward slashes Created *time.Time `json:"created,omitempty"` // creation time Modified *time.Time `json:"modified,omitempty"` // modify time Draft bool `json:"draft,omitempty"` // true if page is marked as draft Generated bool `json:"generated,omitempty"` // true if page was generated from another source Redirect string `json:"redirect,omitempty"` // path page is to redirect to FmtTitle HTML `json:"fmt_title,omitempty"` // title with formatting tags Title string `json:"title,omitempty"` // title without tags Author string `json:"author,omitempty"` // author's name }
PageInfo represents metadata associated with a page.
type PageOpt ¶
type PageOpt struct { Name string // wiki name Logo string // logo filename, relative to image dir MainPage string // name of main page ErrorPage string // name of error page Template string // name of template MainRedirect bool // redirect on main page rather than serve root Page PageOptPage Host PageOptHost Dir PageOptDir Root PageOptRoot Image PageOptImage Category PageOptCategory Search PageOptSearch Link PageOptLink External map[string]PageOptExternal }
PageOpt describes wiki/website options to a Page.
type PageOptCategory ¶
type PageOptCategory struct {
PerPage int
}
PageOptCategory describes wiki category options.
type PageOptDir ¶
type PageOptDir struct { Wiki string // path to wiki root directory Image string // path to image directory Category string // path to category directory Page string // path to page directory Model string // path to model directory Markdown string // path to markdown directory Cache string // path to cache directory }
PageOptDir describes actual filepaths to wiki resources.
type PageOptExternal ¶
type PageOptExternal struct { Name string // long name (e.g. Wikipedia) Root string // wiki page root (no trailing slash) Type PageOptExternalType // wiki type }
PageOptExternal describes an external wiki that we can use for link targets.
type PageOptHost ¶
type PageOptHost struct {
Wiki string // HTTP host for the wiki
}
PageOptHost describes HTTP hosts for a wiki.
type PageOptImage ¶
type PageOptImage struct { Retina []int SizeMethod string Calc func(file string, width, height int, page *Page) (w, h int) Sizer func(file string, width, height int, page *Page) (path string) }
PageOptImage describes wiki imaging options.
type PageOptLink ¶
type PageOptLink struct { ParseInternal PageOptLinkFunction // internal page links ParseExternal PageOptLinkFunction // external wiki page links ParseCategory PageOptLinkFunction // category links }
PageOptLink describes functions to assist with link targets.
type PageOptLinkFunction ¶
A PageOptLinkFunction sanitizes a link target.
type PageOptNavigation ¶
type PageOptNavigation struct {}
PageOptNavigation represents an ordered navigation item.
type PageOptPage ¶
type PageOptPage struct { EnableTitle bool // enable page title headings EnableCache bool // enable page caching }
PageOptPage describes option relating to a page.
type PageOptRoot ¶
type PageOptRoot struct { Wiki string // wiki root path Image string // image root path Category string // category root path Page string // page root path File string // file index path }
PageOptRoot describes HTTP paths to wiki resources.
type PageOptSearch ¶
type PageOptSearch struct {
Enable bool
}
PageOptSearch describes wiki search options.
Source Files ¶
- block-clear.go
- block-code.go
- block-fmt.go
- block-history.go
- block-html.go
- block-image.go
- block-infobox.go
- block-invisible.go
- block-list.go
- block-main.go
- block-manager.go
- block-map.go
- block-meta.go
- block-model.go
- block-p.go
- block-quote.go
- block-sec.go
- block-style.go
- block-toc.go
- block-unknown.go
- block.go
- element.go
- elements.go
- formatter.go
- page-css.go
- page-opt.go
- page.go
- parser-brace-escape.go
- parser-catch.go
- parser-variable.go
- parser.go
- utils.go
- variable.go