本文整理匯總了Golang中github.com/fuxiaohei/GoInk.Context.Param方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.Param方法的具體用法?Golang Context.Param怎麽用?Golang Context.Param使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/fuxiaohei/GoInk.Context
的用法示例。
在下文中一共展示了Context.Param方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Comment
func Comment(context *GoInk.Context) {
cid, _ := strconv.Atoi(context.Param("id"))
if cid < 1 {
Json(context, false).End()
return
}
if model.GetContentById(cid) == nil {
Json(context, false).End()
return
}
data := context.Input()
msg := validateComment(data)
if msg != "" {
Json(context, false).Set("msg", msg).End()
return
}
co := new(model.Comment)
co.Author = data["user"]
co.Email = data["email"]
co.Url = data["url"]
co.Content = data["content"]
co.Avatar = utils.Gravatar(co.Email, "50")
co.Pid, _ = strconv.Atoi(data["pid"])
co.Ip = context.Ip
co.UserAgent = context.UserAgent
co.IsAdmin = false
model.CreateComment(cid, co)
Json(context, true).Set("comment", co.ToJson()).End()
model.CreateMessage("comment", co)
context.Do("comment_created", co)
}
示例2: Home
func Home(context *GoInk.Context) {
context.Layout("home")
page, _ := strconv.Atoi(context.Param("page"))
articles, pager := model.GetPublishArticleList(page, getArticleListSize())
data := map[string]interface{}{
"Articles": articles,
"Pager": pager,
"SidebarHtml": SidebarHtml(context),
}
if page > 1 {
data["Title"] = "第 " + strconv.Itoa(page) + " 頁"
}
Theme(context).Layout("home").Render("index", data)
}
示例3: TopPage
func TopPage(context *GoInk.Context) {
slug := context.Param("slug")
page := model.GetContentBySlug(slug)
if page == nil || page.Status != "publish" {
context.Redirect("/")
return
}
if page.IsLinked && page.Type == "page" {
Theme(context).Layout("home").Render("page", map[string]interface{}{
"Title": page.Title,
"Page": page,
})
page.Hits++
return
}
context.Redirect("/")
}
示例4: TagArticles
func TagArticles(ctx *GoInk.Context) {
ctx.Layout("home")
page, _ := strconv.Atoi(ctx.Param("page"))
tag, _ := url.QueryUnescape(ctx.Param("tag"))
size := getArticleListSize()
articles, pager := model.GetTaggedArticleList(tag, page, getArticleListSize())
// fix dotted tag
if len(articles) < 1 && strings.Contains(tag, "-") {
articles, pager = model.GetTaggedArticleList(strings.Replace(tag, "-", ".", -1), page, size)
}
Theme(ctx).Layout("home").Render("index", map[string]interface{}{
"Articles": articles,
"Pager": pager,
"SidebarHtml": SidebarHtml(ctx),
"Tag": tag,
"Title": tag,
})
}
示例5: Article
func Article(context *GoInk.Context) {
id, _ := strconv.Atoi(context.Param("id"))
slug := context.Param("slug")
article := model.GetContentById(id)
if article == nil {
context.Redirect("/")
return
}
if article.Slug != slug || article.Type != "article" {
context.Redirect("/")
return
}
article.Hits++
Theme(context).Layout("home").Render("article", map[string]interface{}{
"Title": article.Title,
"Article": article,
"CommentHtml": CommentHtml(context, article),
})
}
示例6: PageEdit
func PageEdit(context *GoInk.Context) {
id, _ := strconv.Atoi(context.Param("id"))
c := model.GetContentById(id)
if c == nil {
context.Redirect("/admin/pages/")
return
}
if context.Method == "DELETE" {
model.RemoveContent(c)
Json(context, true).End()
return
}
if context.Method == "POST" {
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 = data["link"] == "1"
//c.AuthorId, _ = strconv.Atoi(context.Cookie("token-user"))
//c.Template = "blog.html"
c.Status = data["status"]
//c.Format = "markdown"
model.SaveContent(c)
Json(context, true).Set("content", c).End()
context.Do("page_modified", c)
//c.Type = "article"
return
}
context.Layout("admin/admin")
context.Render("admin/edit_page", map[string]interface{}{
"Title": "編輯文章",
"Page": c,
})
}
示例7: PluginSetting
func PluginSetting(context *GoInk.Context) {
key := context.Param("plugin_key")
if key == "" {
context.Redirect("/admin/plugins/")
return
}
p := plugin.GetPluginByKey(key)
if p == nil {
context.Redirect("/admin/plugins/")
return
}
if context.Method == "POST" {
p.SetSetting(context.Input())
Json(context, true).End()
context.Do("plugin_setting_saved", p)
return
}
context.Layout("admin/admin")
context.Render("admin/plugin_setting", map[string]interface{}{
"Title": "插件 - " + p.Name(),
"Form": p.Form(),
})
}