Skip to content

Commit

Permalink
finish cmd reader page
Browse files Browse the repository at this point in the history
  • Loading branch information
fuxiaohei committed Feb 25, 2014
1 parent 81e4a91 commit 354410b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/handler/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ func CmdTheme(ctx *GoInk.Context) {
}

func CmdReader(ctx *GoInk.Context) {
if ctx.Method == "POST" {
email := ctx.String("email")
model.RemoveReader(email)
Json(ctx, true).End()
return
}
ctx.Layout("admin/cmd")
ctx.Render("admin/cmd/reader", map[string]interface{}{
"Title": "读者",
Expand Down
16 changes: 16 additions & 0 deletions app/model/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,28 @@ func UpdateCommentAdmin(user *User) {

// RecycleComments cleans removable comments.
func RecycleComments() {
readerTmp := make(map[string][]int)
for _, co := range comments {
if co.IsRemovable() {
removeOneComment(co.Cid, co.Id)
continue
}
r := co.GetReader()
if r == nil {
continue
}
if _, ok := readerTmp[r.Email]; !ok {
readerTmp[r.Email] = make([]int, 0)
}
readerTmp[r.Email] = append(readerTmp[r.Email], co.Id)
}
for _, r := range readers {
if _, ok := readerTmp[r.Email]; ok {
r.Comments = len(readerTmp[r.Email])
}
}
SyncContents()
SyncReaders()
}

func startCommentsTimer() {
Expand Down

0 comments on commit 354410b

Please sign in to comment.