model

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2014 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Storage *jsonStorage
)

Functions

func All added in v0.1.5

func All()

func CleanTokens

func CleanTokens()

clean all expired tokens in memory. do not write to json.

func CreateComment

func CreateComment(cid int, c *Comment)

func CreateFilePath

func CreateFilePath(dir string, f *File) string

func CreateReader

func CreateReader(c *Comment)

func CreateUser

func CreateUser(u *User) error

create new user.

func DefaultNavigators added in v0.2.0

func DefaultNavigators()

func GetCustomSettings

func GetCustomSettings() map[string]string

func GetNavigators added in v0.2.0

func GetNavigators() []*navItem

func GetSetting

func GetSetting(key string) string

func GetVersion added in v0.1.5

func GetVersion() *version

func Init

func Init(v int)

func LoadComments

func LoadComments()

func LoadContents

func LoadContents()

load all contents. generate indexes.

func LoadFiles

func LoadFiles()

func LoadMessages added in v0.2.0

func LoadMessages()

func LoadNavigators added in v0.2.0

func LoadNavigators()

func LoadReaders

func LoadReaders()

func LoadSettings

func LoadSettings()

func LoadTokens

func LoadTokens()

load all tokens from json.

func LoadUsers

func LoadUsers()

func RecycleComments added in v0.2.0

func RecycleComments()

func RecycleMessages added in v0.2.0

func RecycleMessages()

func RemoveComment

func RemoveComment(cid int, id int)

func RemoveContent

func RemoveContent(c *Content)

remove a content. not delete file, just change status to DELETE. it can't be loaded in memory from json.

func RemoveFile

func RemoveFile(id int)

func RemoveToken

func RemoveToken(v string)

remove a token by token value.

func RemoveUser

func RemoveUser(u *User)

remove a user.

func SaveComment

func SaveComment(c *Comment)

func SaveContent

func SaveContent(c *Content)

save changed content.

func SaveMessageRead added in v0.2.0

func SaveMessageRead(m *Message)

func SetMessageGenerator added in v0.2.0

func SetMessageGenerator(name string, fn func(v interface{}) string)

func SetNavigators added in v0.2.0

func SetNavigators(order []string, text []string, title []string, link []string)

func SetSetting

func SetSetting(key string, v string)

func SortNavigators added in v0.2.0

func SortNavigators()

func StartCommentsTimer added in v0.2.0

func StartCommentsTimer()

func StartContentsTimer

func StartContentsTimer()

func StartMessageTimer added in v0.2.0

func StartMessageTimer()

func SyncAll added in v0.2.0

func SyncAll()

func SyncContent

func SyncContent(c *Content)

write a content to json.

func SyncContents

func SyncContents()

write all contents to json.

func SyncFiles

func SyncFiles()

func SyncMessages added in v0.2.0

func SyncMessages()

func SyncNavigators added in v0.2.0

func SyncNavigators()

func SyncReaders

func SyncReaders()

func SyncSettings

func SyncSettings()

func SyncTokens

func SyncTokens()

write tokens to json. it calls CleanTokens before writing.

func SyncUsers

func SyncUsers()

write users to json.

func SyncVersion added in v0.1.5

func SyncVersion()

func UpdateCommentAdmin added in v0.2.0

func UpdateCommentAdmin(user *User)

Types

type Comment

type Comment struct {
	Id         int
	Author     string
	Email      string
	Url        string
	Avatar     string
	Content    string
	CreateTime int64
	Cid        int
	Pid        int
	Status     string
	Ip         string
	UserAgent  string
	IsAdmin    bool
}

func GetCommentById

func GetCommentById(id int) *Comment

func GetCommentList

func GetCommentList(page, size int) ([]*Comment, *utils.Pager)

func (*Comment) GetContent

func (c *Comment) GetContent() *Content

func (*Comment) GetReader

func (c *Comment) GetReader() *Reader

func (*Comment) IsRemovable added in v0.2.0

func (c *Comment) IsRemovable() bool

func (*Comment) IsValid

func (c *Comment) IsValid() bool

func (*Comment) ParentMd

func (c *Comment) ParentMd() string

func (*Comment) ToJson

func (c *Comment) ToJson() map[string]interface{}

type Content

type Content struct {
	Id    int
	Title string
	Slug  string
	Text  string
	//Category   string
	Tags []string

	CreateTime int64
	EditTime   int64
	UpdateTime int64

	IsComment bool
	IsLinked  bool

	AuthorId int

	Template string

	Type   string
	Status string
	Format string

	Comments []*Comment
	Hits     int
}

func CreateContent

func CreateContent(c *Content, t string) (*Content, error)

create new content.

func GetArticleList

func GetArticleList(page, size int) ([]*Content, *utils.Pager)

get articles list.

func GetContentById

func GetContentById(id int) *Content

get a content by given id.

func GetContentBySlug

func GetContentBySlug(slug string) *Content

get a content by given slug.

func GetPageList

func GetPageList(page, size int) ([]*Content, *utils.Pager)

get pages list.

func GetPublishArticleList added in v0.2.0

func GetPublishArticleList(page, size int) ([]*Content, *utils.Pager)

func (*Content) ChangeSlug

func (cnt *Content) ChangeSlug(slug string) bool

change slug and check unique.

func (*Content) CommentNum

func (cnt *Content) CommentNum() int

get content comments number.

func (*Content) Content

func (cnt *Content) Content() string

get content text.

func (cnt *Content) Link() string

get content link.

func (*Content) Summary

func (cnt *Content) Summary() string

get content summary.

func (*Content) TagString

func (cnt *Content) TagString() string

get content tags in a string.

func (*Content) User

func (cnt *Content) User() *User

get content author user.

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

func CreateFile(f *File) *File

func GetFileList

func GetFileList(page, size int) ([]*File, *utils.Pager)

type Message added in v0.2.0

type Message struct {
	Id         int
	Type       string
	CreateTime int64
	Data       string
	IsRead     bool
}

func CreateMessage added in v0.2.0

func CreateMessage(tp string, data interface{}) *Message

func GetMessage added in v0.2.0

func GetMessage(id int) *Message

func GetMessages added in v0.2.0

func GetMessages() []*Message

func GetTypedMessages added in v0.2.0

func GetTypedMessages(tp string, unread bool) []*Message

func GetUnreadMessages added in v0.2.0

func GetUnreadMessages() []*Message

type Reader

type Reader struct {
	Author   string
	Email    string
	Url      string
	Active   bool
	Comments int
	Rank     int
}

func (*Reader) Dec

func (r *Reader) Dec()

func (*Reader) Inc

func (r *Reader) Inc()

type Statis added in v0.1.5

type Statis struct {
	Comments int
	Articles int
	Pages    int
	Files    int
	Version  int
}

func NewStatis added in v0.1.5

func NewStatis() *Statis

type Token

type Token struct {
	Value      string
	UserId     int
	CreateTime int64
	ExpireTime int64
}

func CreateToken

func CreateToken(u *User, context *GoInk.Context, expire int64) *Token

create new token from user and context.

func GetTokenByValue

func GetTokenByValue(v string) *Token

get token by token value.

func GetTokensByUser

func GetTokensByUser(u *User) []*Token

get tokens of given user.

func (*Token) IsValid

func (t *Token) IsValid() bool

check token is valid or expired.

type User

type User struct {
	Id            int
	Name          string
	Password      string
	Nick          string
	Email         string
	Avatar        string
	Url           string
	Bio           string
	CreateTime    int64
	LastLoginTime int64
	Role          string
}

func GetUserByEmail

func GetUserByEmail(email string) *User

get a user by given email.

func GetUserById

func GetUserById(id int) *User

get a user by given id.

func GetUserByName

func GetUserByName(name string) *User

get a user by given name.

func GetUsersByRole

func GetUsersByRole(role string) []*User

get users of given role.

func (*User) ChangeEmail

func (u *User) ChangeEmail(email string) bool

change user email. check unique.

func (*User) ChangePassword

func (u *User) ChangePassword(pwd string)

change user password.

func (*User) CheckPassword

func (u *User) CheckPassword(pwd string) bool

check user password.

Jump to

Keyboard shortcuts

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