Documentation ¶
Index ¶
- Constants
- Variables
- func CreateNode(n *Node) (err error)
- func CreateReply(r *Reply) (err error)
- func CreateTopic(t *Topic) error
- func DeleteNode(n *Node) (err error)
- func FindTopicPages(channel string, nodeId, page, perPage int) (topics []*Topic, pageInfo Pagination)
- func GenerateAvatar(name string) error
- func GetRand() int
- func GetReplyCount() int
- func GetSearchPages(search string, page int, perPage int) (topics []*Topic, pageInfo Pagination)
- func GetSetting(key string) (out string)
- func GetTopicCount() (count int)
- func GetUserCount() int
- func Init()
- func InitNodeGroup()
- func InsertSetting(s Setting) error
- func NotifyMention(userId, actorId int32, notifyableType string, notifyableId int32) error
- func PushMessage(channel string, message interface{})
- func PushNotifyInfoToUser(userId int32, note Notification, isNew bool)
- func RepliesCountCached() (count int)
- func Subscribe(channel string, callback func(message interface{}))
- func TableName(name string) string
- func TopicsCountCached() (count int)
- func UpdateNode(n *Node) (err error)
- func UpdateReply(reply Reply) error
- func UpdateSetting(setting Setting) error
- func UpdateTopic(t *Topic) validation.Validation
- func UsersCountCached() (count int)
- type BaseModel
- type Followable
- type Node
- type NodeGroup
- type Notification
- func (n *Notification) IsMention() bool
- func (n *Notification) IsNotifyableReply() bool
- func (n *Notification) IsNotifyableTopic() bool
- func (n *Notification) IsReply() bool
- func (n *Notification) IsTopic() bool
- func (n *Notification) NotifyableTitle() string
- func (n *Notification) NotifyableURL() string
- func (n *Notification) Reply() (r Reply, err error)
- func (n *Notification) TableName() string
- func (n *Notification) Topic() (t Topic)
- type NotifyInfo
- type Pagination
- type Reply
- type Setting
- type Topic
- func (t *Topic) CheckMention()
- func (t *Topic) DeleteTopic() error
- func (t *Topic) FollowerIds() (ids []int32)
- func (t Topic) IsAwesome() bool
- func (t Topic) IsNoPoint() bool
- func (t Topic) IsNormal() bool
- func (t *Topic) NewRecord() bool
- func (t *Topic) TableName() string
- func (t Topic) URL() string
- func (t *Topic) UpdateLastReply(reply *Reply) (err error)
- func (t *Topic) UpdateRank(rank int) error
- type User
- func (u User) BeforeCreate() error
- func (u *User) ClearNotifications() error
- func (u User) EncodePassword(raw string) (md5Digest string)
- func (u User) GavatarURL(size string) string
- func (u User) IsAdmin() bool
- func (u User) IsStared(t Topic) bool
- func (u User) IsWatched(t Topic) bool
- func (u *User) NewRecord() bool
- func (u *User) NotificationsPage(page, perPage int) (notes []Notification, pageInfo Pagination)
- func (u User) NotifyChannelId() string
- func (u *User) ReadNotifications(notes []Notification) error
- func (u User) SameAs(obj interface{}) bool
- func (u User) Signin(login string, password string) (user User, v validation.Validation)
- func (u User) Signup(login string, email string, password string, passwordConfirm string) (user User, err error)
- func (u User) Star(t Topic) bool
- func (u *User) TableName() string
- func (u User) UnReadNotificationsCount() (count int32)
- func (u User) UnStar(t Topic) bool
- func (u User) UnWatch(t Topic) bool
- func (u User) UpdatePassword(oldPassword, newPassword, confirmPassword string) error
- func (u User) Watch(t Topic) bool
Constants ¶
View Source
const ( RankNoPoint = -1 RankNormal = 0 RankAwesome = 1 )
Variables ¶
View Source
var (
ADMIN_LOGINS = []string{"admin"}
)
View Source
var Cache cache.Cache
View Source
var (
PushCenter *pubsub.PubSub
)
Functions ¶
func CreateNode ¶
func CreateReply ¶
func CreateTopic ¶
func DeleteNode ¶
func FindTopicPages ¶
func FindTopicPages(channel string, nodeId, page, perPage int) (topics []*Topic, pageInfo Pagination)
func GenerateAvatar ¶
func GetReplyCount ¶
func GetReplyCount() int
func GetSearchPages ¶
func GetSearchPages(search string, page int, perPage int) (topics []*Topic, pageInfo Pagination)
func GetSetting ¶
func GetTopicCount ¶
func GetTopicCount() (count int)
func GetUserCount ¶
func GetUserCount() int
func InsertSetting ¶
func NotifyMention ¶
func PushMessage ¶
func PushMessage(channel string, message interface{})
func PushNotifyInfoToUser ¶
func PushNotifyInfoToUser(userId int32, note Notification, isNew bool)
func RepliesCountCached ¶
func RepliesCountCached() (count int)
func TopicsCountCached ¶
func TopicsCountCached() (count int)
func UpdateNode ¶
func UpdateReply ¶
func UpdateSetting ¶
func UpdateTopic ¶
func UpdateTopic(t *Topic) validation.Validation
func UsersCountCached ¶
func UsersCountCached() (count int)
Types ¶
type Followable ¶
type Followable struct { Id int32 `orm:"pk;auto"` FollowType string `orm:"size(20)"` TopicId int32 `` Topic *Topic `orm:"-"` UserId int32 `` User *User `orm:"-"` CreatedAt time.Time `orm:"type(datetime);auto_now_add"` UpdatedAt time.Time `orm:"type(datetime);auto_now"` }
func (*Followable) TableName ¶
func (f *Followable) TableName() string
type Node ¶
type Node struct { Id int32 `orm:"pk;auto"` Name string `orm:"unique"` Summary string `orm:"type(text)"` NodeGroup *NodeGroup `orm:"rel(fk)"` Sort int `orm:"default(0)"` CreatedAt time.Time `orm:"type(datetime);auto_now_add"` UpdatedAt time.Time `orm:"type(datetime);auto_now"` DeletedAt time.Time `orm:"type(datetime);null"` }
NodeGroupId int “
func FindAllNodes ¶
func FindAllNodes() (nodes []*Node)
func FindNodeBySort ¶
func GetNodeById ¶
type NodeGroup ¶
type Notification ¶
type Notification struct { Id int32 `` NotifyType string `` Read bool `orm:"default(false)"` User *User `orm:"rel(fk)"` Actor *User `orm:"rel(fk)"` NotifyableType string `` NotifyableId int32 `` CreatedAt time.Time `orm:"auto_now_add;type(datetime)"` UpdatedAt time.Time `orm:"auto_now;type(datetime)"` }
func (*Notification) IsMention ¶
func (n *Notification) IsMention() bool
func (*Notification) IsNotifyableReply ¶
func (n *Notification) IsNotifyableReply() bool
func (*Notification) IsNotifyableTopic ¶
func (n *Notification) IsNotifyableTopic() bool
func (*Notification) IsReply ¶
func (n *Notification) IsReply() bool
func (*Notification) IsTopic ¶
func (n *Notification) IsTopic() bool
func (*Notification) NotifyableTitle ¶
func (n *Notification) NotifyableTitle() string
func (*Notification) NotifyableURL ¶
func (n *Notification) NotifyableURL() string
func (*Notification) Reply ¶
func (n *Notification) Reply() (r Reply, err error)
func (*Notification) TableName ¶
func (n *Notification) TableName() string
func (*Notification) Topic ¶
func (n *Notification) Topic() (t Topic)
type NotifyInfo ¶
type Pagination ¶
type Pagination struct { Query orm.QuerySeter TotalEntites int PerPage int Path string Page int TotalPages int }
func (*Pagination) Paginate ¶
func (p *Pagination) Paginate(page int) orm.QuerySeter
type Reply ¶
type Reply struct { Id int32 `orm:"pk;auto"` User *User `orm:"rel(fk)"` Topic *Topic `orm:"rel(fk)"` Body string `orm:"type:text;"` IsDeleted bool `` CreatedAt time.Time `orm:"auto_now_add;type(datetime)"` UpdatedAt time.Time `orm:"type(datetime);auto_now"` }
func GetReplyById ¶
func (*Reply) AfterCreate ¶
func (*Reply) BeforeCreate ¶
func (*Reply) BeforeDelete ¶
func (*Reply) CheckMention ¶
func (r *Reply) CheckMention()
func (*Reply) NotifyReply ¶
type Setting ¶
func FindSettingByKey ¶
func GetSettings ¶
func (*Setting) RewriteCache ¶
func (s *Setting) RewriteCache()
type Topic ¶
type Topic struct { Id int32 `orm:"pk;auto"` User *User `orm:"rel(fk)"` Node *Node `orm:"rel(fk)"` Title string `` Body string `orm:"type(text)"` Replies []*Reply `orm:"reverse(many)"` RepliesCount int32 `orm:"default(0)"` LastActiveMark int64 `orm:"default(0)"` LastRepliedAt time.Time `orm:"type(datetime);null"` LastReplyId int32 `` LastReplyUser *User `orm:"-"` LastReplyUserLogin string `` StarsCount int32 `orm:"default(0)"` WatchesCount int32 `orm:"default(0)"` Rank int32 `orm:"default(0)"` CreatedAt time.Time `orm:"type(datetime);auto_now_add"` UpdatedAt time.Time `orm:"type(datetime);auto_now"` DeletedAt time.Time `orm:"type(datetime);null"` }
func GetTopicById ¶
func GetTopicByUserId ¶
func (*Topic) CheckMention ¶
func (t *Topic) CheckMention()
func (*Topic) DeleteTopic ¶
func (*Topic) FollowerIds ¶
func (*Topic) UpdateLastReply ¶
func (*Topic) UpdateRank ¶
type User ¶
type User struct { Id int32 `orm:"pk;auto"` Login string `orm:"size(100)" valid:"Required;MaxSize(100)"` Password string `orm:"size(100)" valid:"Required;MaxSize(100)"` Email string `orm:"size(100)" valid:"Email;MaxSize(100)"` Avatar string `orm:"size(100)"` GitHub string `orm:"size(100)"` Twitter string `orm:"size(100)"` HomePage string `orm:"size(100)"` Tagline string `orm:"size(100)"` Description string `orm:"size(250)"` Location string `orm:"size(200)"` Topics []*Topic `orm:"-"` Replies []*Reply `orm:"-"` CreatedAt time.Time `orm:"type(datetime);auto_now_add"` UpdatedAt time.Time `orm:"type(datetime);auto_now"` DeletedAt time.Time `orm:"type(datetime);null"` }
func FindUserByLogin ¶
func GetUserById ¶
func UpdateUserProfile ¶
func (User) BeforeCreate ¶
func (*User) ClearNotifications ¶
func (User) EncodePassword ¶
func (*User) NotificationsPage ¶
func (u *User) NotificationsPage(page, perPage int) (notes []Notification, pageInfo Pagination)
func (User) NotifyChannelId ¶
func (*User) ReadNotifications ¶
func (u *User) ReadNotifications(notes []Notification) error
func (User) Signin ¶
func (u User) Signin(login string, password string) (user User, v validation.Validation)
func (User) UnReadNotificationsCount ¶
func (User) UpdatePassword ¶
Click to show internal directories.
Click to hide internal directories.