-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from fuxiaohei/develop
release v0.1
- Loading branch information
Showing
65 changed files
with
1,576 additions
and
2,367 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package handler | ||
|
||
import ( | ||
"github.com/fuxiaohei/GoInk/Core" | ||
"strconv" | ||
"github.com/fuxiaohei/GoBlog/app/model" | ||
"github.com/fuxiaohei/GoBlog/app/utils" | ||
"strings" | ||
) | ||
|
||
func AdminComment(context *Core.Context) interface{} { | ||
page := 1 | ||
if context.Param(2) == "page" { | ||
page, _ = strconv.Atoi(context.Param(3)) | ||
if page < 1 { | ||
page = 1 | ||
} | ||
} | ||
comments, pager := model.CommentM.GetPaged(page, 8, false) | ||
context.Render("admin:admin/comment.html", map[string]interface{}{ | ||
"Title": "评论", | ||
"IsComment": true, | ||
"Comments":comments, | ||
"Pager":pager, | ||
}) | ||
return nil | ||
} | ||
|
||
func AdminCommentStatusPost(context *Core.Context) interface {} { | ||
status := context.String("status") | ||
id := context.Int("id") | ||
if len(status) < 1 || id < 1 { | ||
context.Json(map[string]interface {}{ | ||
"res":false, | ||
"msg":"审核失败", | ||
}) | ||
return nil | ||
} | ||
model.CommentM.ChangeCommentStatus(id, status) | ||
model.ArticleM.CountComments() | ||
context.Json(map[string]interface {}{ | ||
"res":true, | ||
}) | ||
return nil | ||
} | ||
|
||
func AdminCommentReplyPost(context *Core.Context) interface {} { | ||
pid := context.Int("pid") | ||
pComment := model.CommentM.GetCommentById(pid) | ||
if pComment == nil { | ||
context.Json(map[string]interface {}{ | ||
"res":false, | ||
"msg":"回复失败", | ||
}) | ||
return nil | ||
} | ||
uid, _ := strconv.Atoi(context.Cookie("admin-user")) | ||
user := model.UserM.GetUserById(uid) | ||
data := context.Input() | ||
c := new(model.Comment) | ||
c.Author = user.Display | ||
c.Email = user.Email | ||
c.Site = user.Site | ||
c.Content = strings.Replace(data["content"], "\n", "<br/>", -1) | ||
c.ContentId = pComment.ContentId | ||
c.Pid = pid | ||
c.Avatar = utils.Gravatar(c.Email, "50") | ||
c.UserId = user.Id | ||
c.IsAdmin = true | ||
c = model.CommentM.CreateComment(c) | ||
context.Json(map[string]interface {}{ | ||
"res":true, | ||
"comment":c, | ||
}) | ||
return nil | ||
} | ||
|
||
func AdminCommentDeletePost(context *Core.Context) interface {} { | ||
id := context.Int("id") | ||
if id < 1 { | ||
context.Json(map[string]interface {}{ | ||
"res":false, | ||
"msg":"删除", | ||
}) | ||
return nil | ||
} | ||
model.CommentM.DeleteComment(id) | ||
model.ArticleM.CountComments() | ||
context.Json(map[string]interface {}{ | ||
"res":true, | ||
}) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package handler | ||
|
||
import ( | ||
"github.com/fuxiaohei/GoInk/Core" | ||
"github.com/fuxiaohei/GoBlog/app/model" | ||
) | ||
|
||
func AdminSetting(context *Core.Context) interface {} { | ||
context.Render("admin:admin/setting.html", map[string]interface {}{ | ||
"Title":"配置", | ||
"IsSetting":true, | ||
}) | ||
return nil | ||
} | ||
|
||
func AdminSettingPost(context *Core.Context) interface {} { | ||
data := context.Input() | ||
settingsMap := make([]map[string]string, len(data)) | ||
i := 0 | ||
for key, v := range data { | ||
settingsMap[i] = map[string]string{ | ||
"key":key, | ||
"value":v, | ||
} | ||
i++ | ||
} | ||
model.SettingM.SaveSetting(settingsMap...) | ||
context.Json(map[string]interface {}{ | ||
"res":true, | ||
}) | ||
return nil | ||
} | ||
|
Oops, something went wrong.