blog, tags, archives

This commit is contained in:
life committed 2014-11-10 23:56:15 +08:00
1 parent 6555384e5c
commit d979a0c3e2
11 files changed
+233 -125

No files matched your search

+19 -17
View File
@@ -1,7 +1,7 @@
package info
import (
// "time"
"time"
)
// 仅仅为了博客的主题
@@ -22,24 +22,26 @@ type BlogInfoCustom struct {
type Post struct {
NoteId string
Title string
CreatedTime time.Time
UpdatedTime time.Time
PublicTime time.Time
Desc string
Abstract string
Content string
Tags []string
CommentNum int
ReadNum int
LikeNum int
IsMarkdown bool
}
// 归档
type ArchiveMonth struct {
Month int
Posts []*Post
}
type Archive struct {
Year int
Posts []map[string]interface{}
MonthAchives []ArchiveMonth
Posts []*Post
}
type TagsCounts []TagCount
type TagCount struct {
Tag string
Count int
}
func (this TagsCounts) Len() int {
return len(this)
}
func (this TagsCounts) Less(i, j int) bool {
return this[i].Count > this[j].Count
}
func (this TagsCounts) Swap(i, j int) {
this[i], this[j] = this[j], this[i]
}
+24 -1
View File
@@ -5,15 +5,38 @@ import (
)
// 这里主要是为了统计每个tag的note数目
// 暂时没用
/*
type TagNote struct {
TagId bson.ObjectId `bson:"_id,omitempty"` // 必须要设置bson:"_id" 不然mgo不会认为是主键
UserId bson.ObjectId `bson:"UserId"`
Tag string `Title` // 标题
NoteNum int `NoteNum` // note数目
}
*/
// 每个用户一条记录, 存储用户的所有tags
type Tag struct {
UserId bson.ObjectId `bson:"_id"`
Tags []string `Tags`
}
}
type TagCount struct {
TagCountId bson.ObjectId `bson:"_id,omitempty"`
UserId bson.ObjectId `UserId` // 谁的
Tag string `Tag`
IsBlog bool `IsBlog` // 是否是博客的tag统计
Count int `Count` // 统计数量
}
/*
type TagsCounts []TagCount
func (this TagsCounts) Len() int {
return len(this)
}
func (this TagsCounts) Less(i, j int) bool {
return this[i].Count > this[j].Count
}
func (this TagsCounts) Swap(i, j int) {
this[i], this[j] = this[j], this[i]
}
*/