model

package
v0.0.0-...-14122a6 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2016 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FileCompiled means the file is from compiled data
	FileCompiled = "compiled"
	// FileStatic means it's copied from static directory
	FileStatic = "static"
	// FileMedia means it's copied from media directory
	FileMedia = "media"

	// OpCompiled means this file is after compiled
	OpCompiled = "compiled"
	// OpCopy mean the file is from copying operation
	OpCopy = "copy"
	// OpKeep means the file is keep, no operation
	OpKeep = "Keep"
	// OpRemove means the files is removed in this process
	OpRemove = "remove"
)
View Source
const (
	TreeIndex    = "index"
	TreePost     = "post"
	TreePage     = "page"
	TreeArchive  = "archive"
	TreePostList = "post-list"
	TreePostTag  = "post-tag"
	TreeTag      = "tag"
)

Variables

This section is empty.

Functions

func ShouldFormatExtension

func ShouldFormatExtension() map[FormatType]string

ShouldFormatExtension return all extensions of all formats

func ShouldMetaFiles

func ShouldMetaFiles() map[FormatType]string

ShouldMetaFiles return all filenames of meta file in all format

Types

type Analytics

type Analytics struct {
	Google string `toml:"google" ini:"google"`
	Baidu  string `toml:"baidu" ini:"baidu"`
}

Analytics save unique values for web analytics service

type Archive

type Archive struct {
	Year  int // each list by year
	Posts []*Post
}

Archive is archive set for posts

func NewArchive

func NewArchive(posts []*Post) []*Archive

NewArchive converts posts to archive

type Author

type Author struct {
	Name    string `toml:"name" ini:"name"`
	Nick    string `toml:"nick" ini:"nick"`
	Email   string `toml:"email" ini:"email"`
	URL     string `toml:"url" ini:"url"`
	Avatar  string `toml:"avatar" ini:"avatar"`
	Bio     string `toml:"bio" ini:"bio"`
	IsOwner bool   // must be the first author
}

Author is author item in meta file

type AuthorGroup

type AuthorGroup []*Author

AuthorGroup is collection of Authors

type Comment

type Comment struct {
	Disqus  string `toml:"disqus" ini:"disqus"`
	Duoshuo string `toml:"duoshuo" ini:"duoshuo"`
}

Comment save unique values for third-party comment systems

func (*Comment) IsOK

func (c *Comment) IsOK() bool

type File

type File struct {
	URL     string
	ModTime time.Time
	Size    int64
	Type    string
	Hash    string
	Op      string
}

File describe a generated or compiled or operated file

type Files

type Files struct {
	// contains filtered or unexported fields
}

Files record all relative files

func NewFiles

func NewFiles() *Files

NewFiles create files group

func (*Files) Add

func (fs *Files) Add(url string, size int64, modTime time.Time, t string, op string)

Add add file

func (*Files) All

func (fs *Files) All() map[string]*File

All return all files in Files

func (*Files) Exist

func (fs *Files) Exist(file string) bool

Exist check file existing in operated files

func (*Files) Get

func (fs *Files) Get(url string) *File

func (*Files) Print

func (fs *Files) Print()

Print print files

type FormatType

type FormatType int8

FormatType define type of front-matter format, meta file and language file

const (
	// FormatTOML mean toml format
	FormatTOML FormatType = 1
	// FormatINI mean ini format
	FormatINI FormatType = 2
)

type Meta

type Meta struct {
	Title    string `toml:"title" ini:"title"`
	Subtitle string `toml:"subtitle" ini:"subtitle"`
	Keyword  string `toml:"keyword" ini:"keyword"`
	Desc     string `toml:"desc" ini:"desc"`
	Domain   string `toml:"domain" ini:"domain"`
	Root     string `toml:"root" ini:"root"`
	Cover    string `toml:"cover" ini:"cover"`
	Language string `toml:"lang" ini:"lang"`
	Path     string `toml:"-" ini:"-"`
}

Meta is meta info of website

func (*Meta) DomainURL

func (m *Meta) DomainURL(link string) string

DomainURL return link with domain prefix

type MetaAll

type MetaAll struct {
	Meta        *Meta       `toml:"meta"`
	NavGroup    NavGroup    `toml:"nav"`
	AuthorGroup AuthorGroup `toml:"author"`
	Comment     *Comment    `toml:"comment"`
	Analytics   *Analytics  `toml:"analytics"`
}

MetaAll is all data struct in meta file

func NewMetaAll

func NewMetaAll(data []byte, format FormatType) (*MetaAll, error)

NewMetaAll parse bytes with correct FormatType

func (*MetaAll) Normalize

func (ma *MetaAll) Normalize() error

Normalize make meta all data correct, it fills blank fields to correct values

type Nav struct {
	Link        string `toml:"link" ini:"link"`
	Title       string `toml:"title" ini:"title"`
	OriginTitle string `toml:"-" ini:"-"`
	IsBlank     bool   `toml:"blank" ini:"blank"`
	Icon        string `toml:"icon" ini:"icon"`
	IconClass   string `toml:"icon" ini:"icon"` // deprecated, old icon field name
	Hover       string `toml:"hover" ini:"hover"`
	I18n        string `toml:"i18n" ini:"i18n"`
	IsRemote    bool   `toml:"-" ini:"-"`
}

Nav is item of navigation

func (n *Nav) Tr(i18n *helper.I18n) string

Tr print nav title with i18n helper

func (n *Nav) TrLink(i18n *helper.I18n) string

TrLink print nav link with i18n prefix

type NavGroup []*Nav

NavGroup is group if items of navigation

func (ng NavGroup) FixURL(prefix string)

FixURL fix url path of all navigation items

type Page

type Page struct {
	Title      string                 `toml:"title" ini:"title"`
	Slug       string                 `toml:"slug" ini:"slug"`
	Desc       string                 `toml:"desc" ini:"desc"`
	Date       string                 `toml:"date" ini:"date"`
	Update     string                 `toml:"update_date" ini:"update_date"`
	AuthorName string                 `toml:"author" ini:"author"`
	NavHover   string                 `toml:"hover" ini:"hover"`
	Template   string                 `toml:"template" ini:"template"`
	Lang       string                 `toml:"lang" ini:"lang"`
	Bytes      []byte                 `toml:"-"`
	Meta       map[string]interface{} `toml:"meta" ini:"-"`
	Sort       int                    `toml:"sort" ini:"sort"`
	Author     *Author                `toml:"-" ini:"-"`
	// contains filtered or unexported fields
}

Page contain all fields of a page content

func NewPageOfMarkdown

func NewPageOfMarkdown(file, slug string) (*Page, error)

NewPageOfMarkdown create new page from markdown file

func (*Page) Content

func (p *Page) Content() []byte

Content is page's content bytes

func (*Page) ContentHTML

func (p *Page) ContentHTML() template.HTML

ContentHTML is page's content html

func (*Page) Created

func (p *Page) Created() time.Time

Created get create time

func (*Page) FixPlaceholder

func (p *Page) FixPlaceholder(hr *strings.Replacer)

FixPlaceholder fix @placeholder in post values

func (*Page) FixURL

func (p *Page) FixURL(prefix string)

FixURL fix path when assemble posts

func (*Page) TreeURL

func (p *Page) TreeURL() string

TreeURL is tree url of node

func (*Page) URL

func (p *Page) URL() string

URL is page's url

func (*Page) Updated

func (p *Page) Updated() time.Time

Updated get update time

type Pages

type Pages []*Page

Pages means pages list

func (Pages) BySlug

func (p Pages) BySlug(slug string) *Page

BySlug return a page by slug string

type Post

type Post struct {
	Title      string   `toml:"title" ini:"title"`
	Slug       string   `toml:"slug" ini:"slug"`
	Desc       string   `toml:"desc" ini:"desc"`
	Date       string   `toml:"date" ini:"date"`
	Update     string   `toml:"update_date" ini:"update_date"`
	AuthorName string   `toml:"author" ini:"author"`
	Thumb      string   `toml:"thumb" ini:"thumb"`
	TagString  []string `toml:"tags" ini:"-"`
	Tags       []*Tag   `toml:"-" ini:"-"`
	Author     *Author  `toml:"-" ini:"-"`

	Bytes []byte `toml:"-"`
	// contains filtered or unexported fields
}

Post contain all fields of a post content

func NewPostOfMarkdown

func NewPostOfMarkdown(file string) (*Post, error)

NewPostOfMarkdown create new post from markdown file

func (*Post) Brief

func (p *Post) Brief() []byte

Brief get brief content bytes

func (*Post) BriefHTML

func (p *Post) BriefHTML() template.HTML

BriefHTML get brief html content

func (*Post) Content

func (p *Post) Content() []byte

Content get html content bytes

func (*Post) ContentHTML

func (p *Post) ContentHTML() template.HTML

ContentHTML get html content

func (*Post) Created

func (p *Post) Created() time.Time

Created get create time

func (*Post) FixPlaceholder

func (p *Post) FixPlaceholder(r, hr *strings.Replacer)

FixPlaceholder fix @placeholder in post values

func (*Post) FixURL

func (p *Post) FixURL(prefix string)

FixURL fix path when assemble posts

func (*Post) Preview

func (p *Post) Preview() []byte

Preview get brief html content deprecated

func (*Post) PreviewHTML

func (p *Post) PreviewHTML() template.HTML

PreviewHTML get brief html content deprecated

func (*Post) TreeURL

func (p *Post) TreeURL() string

TreeURL get tree path of the post, use to create *Tree

func (*Post) URL

func (p *Post) URL() string

URL get url of the post

func (*Post) Updated

func (p *Post) Updated() time.Time

Updated get update time

type Posts

type Posts []*Post

Posts are posts list

func (Posts) Len

func (p Posts) Len() int

implement sort.Sort interface

func (Posts) Less

func (p Posts) Less(i, j int) bool

func (Posts) Range

func (p Posts) Range(i, j int) []*Post

Range get ranged[i:j] posts from list

func (Posts) Swap

func (p Posts) Swap(i, j int)

func (Posts) TopN

func (p Posts) TopN(i int) []*Post

TopN get top N posts from list

type Tag

type Tag struct {
	Name string
	URL  string
}

Tag is tag struct of post

func NewTag

func NewTag(name string) *Tag

NewTag returns new Tag with name and proper url

type Tree

type Tree struct {
	Link string
	I18n string
	Type string
	Sort int
	// contains filtered or unexported fields
}

func NewTree

func NewTree() *Tree

func (*Tree) Add

func (t *Tree) Add(link, linkType string, s int)

func (*Tree) Children

func (t *Tree) Children(link ...string) []*Tree

func (*Tree) Print

func (t *Tree) Print(prefix string)

func (*Tree) SubTree

func (t *Tree) SubTree(link string) *Tree

Jump to

Keyboard shortcuts

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