Documentation
¶
Index ¶
- Variables
- func All()
- func ChangeTimerFunc(name string, ticker int, fn func())
- func CleanTokens()
- func CreateComment(cid int, c *Comment)
- func CreateFilePath(dir string, f *File) string
- func CreateReader(c *Comment)
- func CreateUser(u *User) error
- func DefaultNavigators()
- func DelTimerFunc(name string)
- func GetCustomSettings() map[string]string
- func GetNavigators() []*navItem
- func GetSetting(key string) string
- func GetTimerFuncs() map[string]int
- func GetVersion() *version
- func Init(v int)
- func LoadComments()
- func LoadContents()
- func LoadFiles()
- func LoadMessages()
- func LoadNavigators()
- func LoadReaders()
- func LoadSettings()
- func LoadTokens()
- func LoadUsers()
- func RecycleComments()
- func RecycleMessages()
- func RemoveComment(cid int, id int)
- func RemoveContent(c *Content)
- func RemoveFile(id int)
- func RemoveReader(email string)
- func RemoveToken(v string)
- func RemoveUser(u *User)
- func SaveComment(c *Comment)
- func SaveContent(c *Content)
- func SaveMessageRead(m *Message)
- func SetMessageGenerator(name string, fn func(v interface{}) string)
- func SetNavigators(order []string, text []string, title []string, link []string)
- func SetSetting(key string, v string)
- func SetTimerFunc(name string, ticker int, fn func())
- func SortNavigators()
- func StartModelTimer()
- func SyncAll()
- func SyncContent(c *Content)
- func SyncContents()
- func SyncFiles()
- func SyncIndexes()
- func SyncMessages()
- func SyncNavigators()
- func SyncReaders()
- func SyncSettings()
- func SyncTokens()
- func SyncUsers()
- func SyncVersion()
- func UpdateCommentAdmin(user *User)
- type Comment
- type Content
- func CreateContent(c *Content, t string) (*Content, error)
- func GetArticleList(page, size int) ([]*Content, *utils.Pager)
- func GetContentById(id int) *Content
- func GetContentBySlug(slug string) *Content
- func GetPageList(page, size int) ([]*Content, *utils.Pager)
- func GetPopularArticleList(size int) []*Content
- func GetPublishArticleList(page, size int) ([]*Content, *utils.Pager)
- func GetTaggedArticleList(tag string, page, size int) ([]*Content, *utils.Pager)
- func (cnt *Content) ChangeSlug(slug string) bool
- func (cnt *Content) CommentNum() int
- func (cnt *Content) Content() string
- func (cnt *Content) GetTags() []*Tag
- func (cnt *Content) Link() string
- func (cnt *Content) Summary() string
- func (cnt *Content) TagString() string
- func (cnt *Content) User() *User
- type File
- type Message
- type Reader
- type Statis
- type Tag
- type Token
- type User
Constants ¶
This section is empty.
Variables ¶
var ( // global data storage instance Storage *jsonStorage // global tmp data storage instance. Temp data are generated for special usages, will not backup. TmpStorage *jsonStorage )
Functions ¶
func All ¶ added in v0.1.5
func All()
All loads all data from storage to memory. Start timers for content, comment and message.
func ChangeTimerFunc ¶ added in v0.2.5
ChangeTimerFunc can change timer func by given name. If the func of name is none, do not change anything, print error message.
func CreateComment ¶
CreateComment creates a comment and links it to the cid content.
func CreateFilePath ¶
func DefaultNavigators ¶ added in v0.2.0
func DefaultNavigators()
func GetCustomSettings ¶
func GetNavigators ¶ added in v0.2.0
func GetNavigators() []*navItem
func GetSetting ¶
func GetTimerFuncs ¶ added in v0.2.5
GetTimerFuncs returns registered timer func with its name and ticker int.
func GetVersion ¶ added in v0.1.5
func GetVersion() *version
func Init ¶
func Init(v int)
Init does model initialization. If first run, write default data. v means app.Version number. It's needed for version data.
func LoadMessages ¶ added in v0.2.0
func LoadMessages()
func LoadNavigators ¶ added in v0.2.0
func LoadNavigators()
func LoadSettings ¶
func LoadSettings()
func RecycleComments ¶ added in v0.2.0
func RecycleComments()
RecycleComments cleans removable comments.
func RecycleMessages ¶ added in v0.2.0
func RecycleMessages()
func RemoveComment ¶
RemoveComment removes a comment by id and updates content iten by cid.
func RemoveContent ¶
func RemoveContent(c *Content)
RemoveContent removes a content. Not delete file really, just change status to DELETE. This content can't be loaded in memory from storage json.
func RemoveFile ¶
func RemoveFile(id int)
func RemoveReader ¶ added in v0.2.5
func RemoveReader(email string)
RemoveReader removes a reader by his email.
func SaveComment ¶
func SaveComment(c *Comment)
SaveComment saves a comment and related updates content and reader data.
func SaveContent ¶
func SaveContent(c *Content)
SaveContent saves changed content. It will re-generate related indexes.
func SaveMessageRead ¶ added in v0.2.0
func SaveMessageRead(m *Message)
func SetMessageGenerator ¶ added in v0.2.0
func SetNavigators ¶ added in v0.2.0
func SetSetting ¶
func SetTimerFunc ¶ added in v0.2.5
SetTimerFunc adds timer func for time ticker. Ticker means step time, after ticker size step passed, do function. Name is unique name of func.If set same name func, use the last one.
func SortNavigators ¶ added in v0.2.0
func SortNavigators()
func StartModelTimer ¶ added in v0.2.5
func StartModelTimer()
StartModelTimer adds models' timer and starts time ticker. The default step is 10 min once.
func SyncAll ¶ added in v0.2.0
func SyncAll()
SyncAll writes all current memory data to storage files.
func SyncIndexes ¶ added in v0.2.5
func SyncIndexes()
func SyncMessages ¶ added in v0.2.0
func SyncMessages()
func SyncNavigators ¶ added in v0.2.0
func SyncNavigators()
func SyncSettings ¶
func SyncSettings()
func SyncVersion ¶ added in v0.1.5
func SyncVersion()
func UpdateCommentAdmin ¶ added in v0.2.0
func UpdateCommentAdmin(user *User)
UpdateCommentAdmin updates comment author data if admin user data updated. It only updates admin comments.
Types ¶
type Comment ¶
type Comment struct { Id int Author string Email string Url string Avatar string Content string CreateTime int64 // Content id Cid int // Parent Comment id Pid int Status string Ip string UserAgent string // Is comment of admin IsAdmin bool }
Comment struct defines a comment item data.
func GetCommentList ¶
GetCommentList returns a comments list and pager. This list scans all comments no matter its status.
func GetCommentRecentList ¶ added in v0.2.5
GetCommentRecentList returns a comments list of recent comments. Recent comments are approved and no parent and not admin comment. It's ordered by comment id desc.
func (*Comment) GetContent ¶
GetContent returns the content item of this comment.
func (*Comment) IsRemovable ¶ added in v0.2.0
IsRemovable returns whether this comment can remove. If content or parent comment of this comment is removed, return true.
func (*Comment) IsValid ¶
IsValid returns whether this comment is valid to show. If this comment is not approved or its parent is missing, return false.
type Content ¶
type Content struct { Id int Title string Slug string Text string //Category string Tags []string CreateTime int64 EditTime int64 UpdateTime int64 // IsComment opens or closes comment IsComment bool // IsLinked makes pager link as top level link /link.html IsLinked bool AuthorId int // Template makes pager use own template file Template string Type string Status string // Format defines the content text format type. Now only support markdown. Format string Comments []*Comment Hits int // contains filtered or unexported fields }
Content instance, defines content data items.
func CreateContent ¶
CreateContent creates new content. t means content type, article or page.
func GetArticleList ¶
GetArticleList gets articles list and pager no matter article status.
func GetContentById ¶
GetContentById gets a content by given id.
func GetContentBySlug ¶
GetContentBySlug gets a content by given slug.
func GetPageList ¶
GetPageList gets pages list and pager no matter page status. In common cases, no need to get a list or pagers for public page.
func GetPopularArticleList ¶ added in v0.2.5
GetPopularArticleList returns popular articles list. Popular articles are ordered by comment number.
func GetPublishArticleList ¶ added in v0.2.0
GetPublishArticleList gets published article list and pager.
func GetTaggedArticleList ¶ added in v0.2.5
GetTaggedArticleList returns tagged articles list. These articles contains same one tag.
func (*Content) ChangeSlug ¶
ChangeSlug changes content's slug. It checks whether this slug is unique.
func (*Content) CommentNum ¶
CommentNum returns content comments number. If comment are checking or, its parent are lost, do not count it.
func (*Content) Content ¶
Content returns whole content text. If enable go-markdown, return markdown-rendered content.
func (*Content) Link ¶
Link returns content link as {type}/{id}/{slug}.html. If content isn't published, return "#". If content is page and top linked, return {slug}.html as top level link.
func (*Content) Summary ¶
Summary returns content summary. Summary text means the part before page-break <!--more-->. It can be go-markdown rendered.
type File ¶
type File struct { Id int Name string UploadTime int64 Url string ContentType string Author int IsUsed bool Size int64 Type string Hits int }
func CreateFile ¶
type Message ¶ added in v0.2.0
func CreateMessage ¶ added in v0.2.0
func GetMessage ¶ added in v0.2.0
func GetMessages ¶ added in v0.2.0
func GetMessages() []*Message
func GetTypedMessages ¶ added in v0.2.0
func GetUnreadMessages ¶ added in v0.2.0
func GetUnreadMessages() []*Message
type Reader ¶
Comment Reader struct. Saving comment reader for visiting wall usage or other statics.
func GetReaders ¶ added in v0.2.5
func GetReaders() []*Reader
GetReaders returns slice of all readers
type Token ¶
func CreateToken ¶
create new token from user and context.