本文整理匯總了Golang中github.com/fuxiaohei/GoInk.Context.Render方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.Render方法的具體用法?Golang Context.Render怎麽用?Golang Context.Render使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/fuxiaohei/GoInk.Context
的用法示例。
在下文中一共展示了Context.Render方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: AdminProfile
func AdminProfile(context *GoInk.Context) {
uid, _ := strconv.Atoi(context.Cookie("token-user"))
user := model.GetUserById(uid)
if context.Method == "POST" {
data := context.Input()
if !user.ChangeEmail(data["email"]) {
Json(context, false).Set("msg", "郵箱與別的用戶重複").End()
return
}
user.Name = data["user"]
user.Email = data["email"]
user.Avatar = utils.Gravatar(user.Email, "180")
user.Url = data["url"]
user.Nick = data["nick"]
user.Bio = data["bio"]
Json(context, true).End()
go model.SyncUsers()
go model.UpdateCommentAdmin(user)
context.Do("profile_update", user)
return
}
context.Layout("admin/admin")
context.Render("admin/profile", map[string]interface{}{
"Title": "個性資料",
"User": user,
})
}
示例2: CmdBackup
func CmdBackup(context *GoInk.Context) {
if context.Method == "POST" {
file, e := cmd.DoBackup(context.App(), true)
if e != nil {
Json(context, false).Set("msg", e.Error()).End()
return
}
Json(context, true).Set("file", file).End()
context.Do("bakcup_success", file)
model.CreateMessage("backup", "[1]"+file)
return
}
if context.Method == "DELETE" {
file := context.String("file")
if file == "" {
Json(context, false).End()
return
}
cmd.RemoveBackupFile(file)
Json(context, true).End()
context.Do("backup_delete", file)
return
}
files, _ := cmd.GetBackupFiles()
context.Layout("admin/cmd")
context.Render("admin/cmd/backup", map[string]interface{}{
"Files": files,
"Title": "備份",
})
}
示例3: CmdMonitor
func CmdMonitor(ctx *GoInk.Context) {
ctx.Layout("admin/cmd")
ctx.Render("admin/cmd/monitor", map[string]interface{}{
"Title": "係統監控",
"M": cmd.ReadMemStats(),
})
}
示例4: AdminPlugin
func AdminPlugin(context *GoInk.Context) {
if context.Method == "POST" {
action := context.String("action")
if action == "" {
Json(context, false).End()
return
}
pln := context.String("plugin")
if action == "activate" {
plugin.Activate(pln)
plugin.Update(context.App())
Json(context, true).End()
context.Do("plugin_activated", pln)
return
}
if action == "deactivate" {
plugin.Deactivate(pln)
Json(context, true).End()
context.Do("plugin_deactivated", pln)
return
}
context.Status = 405
Json(context, false).End()
return
}
context.Layout("admin/admin")
context.Render("admin/plugin", map[string]interface{}{
"Title": "插件",
"Plugins": plugin.GetPlugins(),
})
}
示例5: CmdMessage
func CmdMessage(context *GoInk.Context) {
context.Layout("admin/cmd")
context.Render("admin/cmd/message", map[string]interface{}{
"Title": "消息",
"Messages": model.GetMessages(),
})
}
示例6: Login
func Login(context *GoInk.Context) {
if context.Method == "POST" {
data := context.Input()
user := model.GetUserByName(data["user"])
if user == nil {
Json(context, false).End()
return
}
if !user.CheckPassword(data["password"]) {
Json(context, false).End()
return
}
exp := 3600 * 24 * 3
expStr := strconv.Itoa(exp)
s := model.CreateToken(user, context, int64(exp))
context.Cookie("token-user", strconv.Itoa(s.UserId), expStr)
context.Cookie("token-value", s.Value, expStr)
Json(context, true).End()
return
}
if context.Cookie("token-value") != "" {
context.Redirect("/admin/")
return
}
context.Render("admin/login", nil)
}
示例7: ArticleWrite
func ArticleWrite(context *GoInk.Context) {
if context.Method == "POST" {
c := new(model.Content)
c.Id = 0
data := context.Input()
if !c.ChangeSlug(data["slug"]) {
Json(context, false).Set("msg", "固定鏈接重複").End()
return
}
c.Title = data["title"]
c.Text = data["content"]
c.Tags = strings.Split(strings.Replace(data["tag"], ",", ",", -1), ",")
c.IsComment = data["comment"] == "1"
c.IsLinked = false
c.AuthorId, _ = strconv.Atoi(context.Cookie("token-user"))
c.Template = "blog.html"
c.Status = data["status"]
c.Format = "markdown"
c.Hits = 1
var e error
c, e = model.CreateContent(c, "article")
if e != nil {
Json(context, false).Set("msg", e.Error()).End()
return
}
Json(context, true).Set("content", c).End()
context.Do("article_created", c)
//c.Type = "article"
return
}
context.Layout("admin/admin")
context.Render("admin/write_article", map[string]interface{}{
"Title": "撰寫文章",
})
}
示例8: AdminPage
func AdminPage(context *GoInk.Context) {
pages, pager := model.GetPageList(context.Int("page"), 10)
context.Layout("admin/admin")
context.Render("admin/pages", map[string]interface{}{
"Title": "頁麵",
"Pages": pages,
"Pager": pager,
})
}
示例9: AdminArticle
func AdminArticle(context *GoInk.Context) {
articles, pager := model.GetArticleList(context.Int("page"), 10)
context.Layout("admin/admin")
context.Render("admin/articles", map[string]interface{}{
"Title": "文章",
"Articles": articles,
"Pager": pager,
})
}
示例10: Admin
func Admin(context *GoInk.Context) {
uid, _ := strconv.Atoi(context.Cookie("token-user"))
user := model.GetUserById(uid)
context.Layout("admin/admin")
context.Render("admin/home", map[string]interface{}{
"Title": "控製台",
"Statis": model.NewStatis(),
"User": user,
"Messages": model.GetUnreadMessages(),
})
}
示例11: CmdLogs
func CmdLogs(context *GoInk.Context) {
if context.Method == "DELETE" {
cmd.RemoveLogFile(context.App(), context.String("file"))
Json(context, true).End()
return
}
context.Layout("admin/cmd")
context.Render("admin/cmd/log", map[string]interface{}{
"Title": "日誌",
"Logs": cmd.GetLogs(context.App()),
})
}
示例12: CmdReader
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": "讀者",
"Readers": model.GetReaders(),
})
}
示例13: AdminComments
func AdminComments(context *GoInk.Context) {
if context.Method == "DELETE" {
id := context.Int("id")
cmt := model.GetCommentById(id)
model.RemoveComment(cmt.Cid, id)
Json(context, true).End()
context.Do("comment_delete", id)
return
}
if context.Method == "PUT" {
id := context.Int("id")
cmt2 := model.GetCommentById(id)
cmt2.Status = "approved"
cmt2.GetReader().Active = true
model.SaveComment(cmt2)
Json(context, true).End()
context.Do("comment_change_status", cmt2)
return
}
if context.Method == "POST" {
// get required data
pid := context.Int("pid")
cid := model.GetCommentById(pid).Cid
uid, _ := strconv.Atoi(context.Cookie("token-user"))
user := model.GetUserById(uid)
co := new(model.Comment)
co.Author = user.Nick
co.Email = user.Email
co.Url = user.Url
co.Content = context.String("content")
co.Avatar = utils.Gravatar(co.Email, "50")
co.Pid = pid
co.Ip = context.Ip
co.UserAgent = context.UserAgent
co.IsAdmin = true
model.CreateComment(cid, co)
Json(context, true).Set("comment", co.ToJson()).End()
model.CreateMessage("comment", co)
context.Do("comment_reply", co)
return
}
page := context.IntOr("page", 1)
comments, pager := model.GetCommentList(page, 10)
context.Layout("admin/admin")
context.Render("admin/comments", map[string]interface{}{
"Title": "評論",
"Comments": comments,
"Pager": pager,
})
}
示例14: AdminFiles
func AdminFiles(context *GoInk.Context) {
if context.Method == "DELETE" {
id := context.Int("id")
model.RemoveFile(id)
Json(context, true).End()
context.Do("attach_delete", id)
return
}
files, pager := model.GetFileList(context.Int("page"), 10)
context.Layout("admin/admin")
context.Render("admin/files", map[string]interface{}{
"Title": "媒體文件",
"Files": files,
"Pager": pager,
})
}
示例15: AdminPassword
func AdminPassword(context *GoInk.Context) {
if context.Method == "POST" {
uid, _ := strconv.Atoi(context.Cookie("token-user"))
user := model.GetUserById(uid)
if !user.CheckPassword(context.String("old")) {
Json(context, false).Set("msg", "舊密碼錯誤").End()
return
}
user.ChangePassword(context.String("new"))
go model.SyncUsers()
Json(context, true).End()
context.Do("password_update", user)
return
}
context.Layout("admin/admin")
context.Render("admin/password", map[string]interface{}{
"Title": "修改密碼",
//"User":user,
})
}