models

package
v0.0.0-...-c336e2e Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2017 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrorFrontMetaParseFail means front-meta is parsed fail
	ErrorFrontMetaParseFail = errors.New("front-meta parse fail")
	// ErrorContentTimeLayoutFail means time string in content is parsed fail
	ErrorContentTimeLayoutFail = errors.New("content time parse fail")
)

Functions

func Markdown

func Markdown(raw []byte) []byte

Markdown converts markdown bytes to html bytes

func NewPostTags

func NewPostTags(posts []*Post, size int) (map[string]string, map[string][]*PostList)

NewPostTags build post tags and post lists of tag

func SizeOfPostLists

func SizeOfPostLists(lists []*PostList) int

SizeOfPostLists get all posts count from post lists

Types

type Analytics

type Analytics struct {
	Google  string `toml:"google"`
	Baidu   string `toml:"baidu"`
	Tencent string `toml:"tencent"`
	Cnzz    string `toml:"cnzz"`
}

Analytics is setting of third-party website analytics tool

type Archive

type Archive struct {
	Year  int
	Posts []*Post
}

Archive is list of archive by year

func NewArchives

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

NewArchives return archives list with posts

type Author

type Author struct {
	Name  string `toml:"name"`
	Nick  string `toml:"nick"`
	Email string `toml:"email"`
	URL   string `toml:"url"`
}

Author is author item

type Comment

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

Comment is setting of third-party comment system

type Content

type Content struct {
	Meta         *MetaData
	Posts        []*Post
	Lists        []*PostList
	Tags         map[string]string
	PostTagLists map[string][]*PostList
	Archives     []*Archive
	Pages        []*Page
	Theme        *theme.Theme
	DstFiles     map[string]bool
}

Content is all data collection

func NewContent

func NewContent() *Content

NewContent return new content object with proper default values

type MetaData

type MetaData struct {
	Meta      *MetaInfo `toml:"meta"`
	Nav       NavList   `toml:"nav"`
	Authors   []Author  `toml:"author"`
	Comment   Comment   `toml:"comment"`
	Analytics Analytics `toml:"analytics"`
	// contains filtered or unexported fields
}

MetaData is metadata from meta file

func ReadMetadata

func ReadMetadata(data []byte) (*MetaData, error)

ReadMetadata read metadata from bytes metadata's src file is blank

func ReadMetadataFile

func ReadMetadataFile(file string) (*MetaData, error)

ReadMetadataFile read metadata from file metadata's src file is set

func (*MetaData) FindAuthor

func (md *MetaData) FindAuthor(name string) *Author

FindAuthor find author by name of nickname if not found, return first author

type MetaInfo

type MetaInfo struct {
	Title    string `toml:"title"`
	Subtitle string `toml:"subtitle"`
	Keyword  string `toml:"keyword"`
	Desc     string `toml:"desc"`
	Root     string `toml:"root"`
	Lang     string `toml:"lang"`
	// contains filtered or unexported fields
}

MetaInfo is basic info from metadata to describe the website

func (*MetaInfo) Base

func (minfo *MetaInfo) Base() string

Base return base path of the root url use for subdirectory url

type Nav struct {
	Link    string `toml:"link"`
	Title   string `toml:"title"`
	Hover   string `toml:"hover"`
	I18n    string `toml:"i18n"`
	IsBlank bool   `toml:"is_blank"`
	Icon    string `toml:"icon"`
}

Nav is an item for a navigator link

type NavList []Nav

NavList is list of Nav items

type Page

type Page struct {
	Title      string `toml:"title"`
	Desc       string `toml:"desc"`
	Date       string `toml:"date"`
	UpdateDate string `toml:"update_date"`
	AuthorName string `toml:"author"`
	IsDraft    bool   `toml:"draft"`
	Hover      string `toml:"hover"`
	I18n       string `toml:"i18n"`
	Template   string `toml:"template"`
	// contains filtered or unexported fields
}

Page define common web page

func NewPageFromFile

func NewPageFromFile(file, rel string) (*Page, error)

NewPageFromFile read page object from file

func (*Page) Author

func (p *Page) Author() *Author

Author return page's author

func (*Page) Content

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

Content return page content bytes

func (*Page) ContentHTML

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

ContentHTML return page content bytes as template.HTML

func (*Page) Created

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

Created return create time of page

func (*Page) FromFile

func (p *Page) FromFile() string

FromFile return source code file of the post

func (*Page) SetAuthor

func (p *Page) SetAuthor(author *Author)

SetAuthor set author object to the page

func (*Page) ToFile

func (p *Page) ToFile() string

ToFile return destination webpage file path

func (*Page) URL

func (p *Page) URL() string

URL return visit link of the page

func (*Page) Updated

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

Updated return update time of page if not set, same time to Created()

type Pager

type Pager struct {
	Begin   int
	End     int
	Prev    int
	Next    int
	Current int
	Pages   int
	All     int
	// contains filtered or unexported fields
}

Pager contains pagination data when on a page number

func (*Pager) Items

func (pg *Pager) Items() []*PagerItem

Items returns each page item in this pager

func (*Pager) NextURL

func (pg *Pager) NextURL() string

NextURL returns next url

func (*Pager) PrevURL

func (pg *Pager) PrevURL() string

PrevURL returns prev url

func (*Pager) SetLayout

func (pg *Pager) SetLayout(layout string)

SetLayout sets pager layout string, use to print url

func (*Pager) URL

func (pg *Pager) URL() string

URL returns page current url

type PagerCursor

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

PagerCursor creates Pager with each page number

func NewPagerCursor

func NewPagerCursor(size, all int) *PagerCursor

NewPagerCursor with size and all count

func (*PagerCursor) Page

func (pg *PagerCursor) Page(i int) *Pager

Page creates Pager on a page number

func (*PagerCursor) Pages

func (pg *PagerCursor) Pages() []*Pager

Pages return all pages from cursor

type PagerItem

type PagerItem struct {
	Page int
	Link string
}

PagerItem is one item of one page

type Post

type Post struct {
	Title      string   `toml:"title"`
	Slug       string   `toml:"slug"`
	Desc       string   `toml:"desc"`
	Date       string   `toml:"date"`
	UpdateDate string   `toml:"update_date"`
	AuthorName string   `toml:"author"`
	TagList    []string `toml:"tags"`
	IsDraft    bool     `toml:"draft"`
	// contains filtered or unexported fields
}

Post define blog post

func NewPostFromFile

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

NewPostFromFile read post from file

func (*Post) Author

func (p *Post) Author() *Author

Author return post's author

func (*Post) Brief

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

Brief return brief content bytes

func (*Post) BriefHTML

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

BriefHTML return brief content as template.HTML

func (*Post) Content

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

Content return post content bytes

func (*Post) ContentHTML

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

ContentHTML return post content bytes as template.HTML

func (*Post) Created

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

Created return create time of post

func (*Post) FromFile

func (p *Post) FromFile() string

FromFile return source code file of the post

func (*Post) SetAuthor

func (p *Post) SetAuthor(author *Author)

SetAuthor set author object to the post

func (*Post) Tags

func (p *Post) Tags() map[string]*PostTag

Tags return tags of the post

func (*Post) ToFile

func (p *Post) ToFile() string

ToFile return destination webpage file path

func (*Post) URL

func (p *Post) URL() string

URL return visit link of the post same to ToFile()

func (*Post) Updated

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

Updated return update time of post if not set, same time to Updated()

type PostList

type PostList struct {
	Tag   string
	Posts []*Post
	Pager *Pager
}

PostList is list of posts

func NewPostLists

func NewPostLists(posts []*Post, size int, tag string) []*PostList

NewPostLists build lists of posts with size

type PostTag

type PostTag struct {
	Name string
	URL  string
}

PostTag is tag of a post

Jump to

Keyboard shortcuts

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