本文整理汇总了Golang中github.com/QLeelulu/goku.HttpContext.Render方法的典型用法代码示例。如果您正苦于以下问题:Golang HttpContext.Render方法的具体用法?Golang HttpContext.Render怎么用?Golang HttpContext.Render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/QLeelulu/goku.HttpContext
的用法示例。
在下文中一共展示了HttpContext.Render方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: user_Fans
// 查看粉丝
func user_Fans(ctx *goku.HttpContext) goku.ActionResulter {
userId, _ := strconv.ParseInt(ctx.RouteData.Params["id"], 10, 64)
var user *models.User
if userId > 0 {
user = models.User_GetById(userId)
} else {
if u, ok := ctx.Data["user"]; ok {
user = u.(*models.User)
ctx.ViewData["UserMenu"] = "um-fans"
}
}
if user == nil {
ctx.ViewData["errorMsg"] = "用户不存在"
return ctx.Render("error", nil)
}
page, pagesize := utils.PagerParams(ctx.Request)
followers, _ := models.UserFollow_Followers(user.Id, page, pagesize)
ctx.ViewData["Followers"] = models.User_ToVUsers(followers, ctx)
ctx.ViewData["HasMoreFollowers"] = len(followers) >= pagesize
return ctx.View(models.User_ToVUser(user, ctx))
}
示例2: discover_index
// 发现 首页
func discover_index(ctx *goku.HttpContext) goku.ActionResulter {
ot := ctx.Get("o")
if ot == "" {
ot = "hot"
}
dt, _ := strconv.Atoi(ctx.Get("dt"))
ctx.ViewData["Order"] = ot
links, _ := models.LinkForHome_GetByPage(ot, dt, 1, golink.PAGE_SIZE)
ctx.ViewData["Links"] = models.Link_ToVLink(links, ctx)
ctx.ViewData["TopTab"] = "discover"
ctx.ViewData["HasMoreLink"] = len(links) >= golink.PAGE_SIZE
return ctx.Render("/home/index", nil)
}
示例3: admin_links
func admin_links(ctx *goku.HttpContext) goku.ActionResulter {
page, pagesize := utils.PagerParams(ctx.Request)
links, total, err := models.Link_GetByPage(page, pagesize, "")
if err != nil {
ctx.ViewData["errorMsg"] = err.Error()
return ctx.Render("error", nil)
}
ctx.ViewData["LinkList"] = links
ctx.ViewData["TotalLinks"] = total
ctx.ViewData["Page"] = page
ctx.ViewData["Pagesize"] = pagesize
return ctx.View(nil)
}
示例4: admin_users
func admin_users(ctx *goku.HttpContext) goku.ActionResulter {
page, pagesize := utils.PagerParams(ctx.Request)
users, total, err := models.User_GetList(page, pagesize, "")
if err != nil {
ctx.ViewData["errorMsg"] = err.Error()
return ctx.Render("error", nil)
}
ctx.ViewData["UserList"] = users
ctx.ViewData["UserCount"] = total
ctx.ViewData["Page"] = page
ctx.ViewData["Pagesize"] = pagesize
return ctx.View(nil)
}
示例5: admin_comments
func admin_comments(ctx *goku.HttpContext) goku.ActionResulter {
page, pagesize := utils.PagerParams(ctx.Request)
comments, total, err := models.Comment_GetByPage(page, pagesize, "")
if err != nil {
ctx.ViewData["errorMsg"] = err.Error()
return ctx.Render("error", nil)
}
ctx.ViewData["CommentList"] = comments
ctx.ViewData["CommentCount"] = total
ctx.ViewData["Page"] = page
ctx.ViewData["Pagesize"] = pagesize
return ctx.View(nil)
}
示例6: admin_index
func admin_index(ctx *goku.HttpContext) goku.ActionResulter {
var db *goku.MysqlDB = models.GetDB()
defer db.Close()
linkCount, err := db.Count("link", "")
if err != nil {
ctx.ViewData["errorMsg"] = err.Error()
return ctx.Render("error", nil)
}
ctx.ViewData["linkCount"] = linkCount
userCount, err := db.Count("user", "")
if err != nil {
ctx.ViewData["errorMsg"] = err.Error()
return ctx.Render("error", nil)
}
ctx.ViewData["userCount"] = userCount
topicCount, err := db.Count("topic", "")
if err != nil {
ctx.ViewData["errorMsg"] = err.Error()
return ctx.Render("error", nil)
}
ctx.ViewData["topicCount"] = topicCount
commentCount, err := db.Count("comment", "")
if err != nil {
ctx.ViewData["errorMsg"] = err.Error()
return ctx.Render("error", nil)
}
ctx.ViewData["commentCount"] = commentCount
return ctx.View(nil)
}
示例7: admin_topics
func admin_topics(ctx *goku.HttpContext) goku.ActionResulter {
page, pagesize := utils.PagerParams(ctx.Request)
topics, total, err := models.Topic_GetByPage(page, pagesize, "")
if err != nil {
ctx.ViewData["errorMsg"] = err.Error()
return ctx.Render("error", nil)
}
ctx.ViewData["TopicList"] = topics
ctx.ViewData["TopicCount"] = total
ctx.ViewData["Page"] = page
ctx.ViewData["Pagesize"] = pagesize
ctx.ViewData["TabName"] = "topics"
return ctx.View(nil)
}
示例8: link_showWithComments
func link_showWithComments(ctx *goku.HttpContext, slinkId, scommentId string) goku.ActionResulter {
linkId, err1 := strconv.ParseInt(slinkId, 10, 64)
commentId, err2 := strconv.ParseInt(scommentId, 10, 64)
if err1 != nil || err2 != nil {
ctx.ViewData["errorMsg"] = "参数错误"
return ctx.Render("error", nil)
}
link, err := models.Link_GetById(linkId)
if err != nil {
ctx.ViewData["errorMsg"] = "服务器开小差了 >_<!!"
return ctx.Render("error", nil)
}
if link == nil {
ctx.ViewData["errorMsg"] = "内容不存在,去首页逛逛吧"
return ctx.Render("error", nil)
}
if link.Deleted() {
ctx.ViewData["errorMsg"] = "内容已被摧毁,去首页逛逛吧"
return ctx.Render("error", nil)
}
if !utils.IsSpider(ctx.Request.UserAgent()) {
// 更新链接的评论查看计数
models.Link_IncViewCount(link.Id, 1)
}
vlink := models.Link_ToVLink([]models.Link{*link}, ctx)
sortType := strings.ToLower(ctx.Get("cm_order")) //"hot":热门;"hotc":热议;"time":最新;"vote":得分;"ctvl":"争议"
if sortType == "" {
sortType = "hot"
}
var comments string
if commentId > 0 {
comments = models.GetPermalinkComment(linkId, commentId, sortType)
ctx.ViewData["SubLinkUrl"] = fmt.Sprintf("permacoment/%d/%d/", linkId, commentId)
} else {
comments = models.GetSortComments("", "/", int64(0), linkId, sortType, "", false) //models.Comment_SortForLink(link.Id, "hot")
ctx.ViewData["SubLinkUrl"] = linkId
}
ctx.ViewData["Comments"] = template.HTML(comments)
ctx.ViewData["SortType"] = sortType
ctx.ViewData["SortTypeName"] = ORDER_NAMES[sortType]
return ctx.Render("/link/show", vlink[0])
}
示例9: link_search
//link搜索界面
func link_search(ctx *goku.HttpContext) goku.ActionResulter {
ls := utils.LinkSearch{}
searchResult, err := ls.SearchLink(ctx.Get("term"), 1, golink.PAGE_SIZE)
if err == nil && searchResult.TimedOut == false && searchResult.HitResult.HitArray != nil && len(searchResult.HitResult.HitArray) > 0 {
links, _ := models.Link_GetByIdList(searchResult.HitResult.HitArray)
ctx.ViewData["Links"] = models.Link_ToVLink(links, ctx)
ctx.ViewData["HasMoreLink"] = len(links) >= golink.PAGE_SIZE
} else {
ctx.ViewData["Links"] = nil
ctx.ViewData["HasMoreLink"] = false
}
ctx.ViewData["Term"] = ctx.Get("term")
return ctx.Render("/link/search", nil)
}
示例10: discover_index
// 发现 首页
func discover_index(ctx *goku.HttpContext) goku.ActionResulter {
ot := ctx.Get("o")
if ot == "" {
ot = "hot"
}
dt, _ := strconv.Atoi(ctx.Get("dt"))
ctx.ViewData["Order"] = ot
links, _ := models.LinkForHome_GetByPage(ot, dt, 1, golink.PAGE_SIZE)
ctx.ViewData["Links"] = models.Link_ToVLink(links, ctx)
ctx.ViewData["TopTab"] = "discover"
ctx.ViewData["HasMoreLink"] = len(links) >= golink.PAGE_SIZE
// 最新链接的未读提醒
var userId, lastReadLinkId int64
unreadCookieName := "newestUnrLinkId"
u, ok := ctx.Data["user"]
if ok && u != nil {
user := u.(*models.User)
userId = user.Id
lastReadLinkId = user.LastReadLinkId
} else {
// 从Cook读取最后一次阅读的链接id
cLastReadLinkId, err := ctx.Request.Cookie(unreadCookieName)
if err == nil {
lastReadLinkId, _ = strconv.ParseInt(cLastReadLinkId.Value, 10, 64)
}
}
if ot == "hot" {
newestUnreadCount, _ := models.NewestLinkUnread_All(userId, lastReadLinkId)
ctx.ViewData["NewestUnreadCount"] = models.NewestLinkUnread_ToString(userId, newestUnreadCount)
} else if ot == "time" && links != nil && len(links) > 0 {
if userId > 0 {
models.NewestLinkUnread_UpdateForAll(userId, links[0].Id)
} else {
c := &http.Cookie{
Name: unreadCookieName,
Value: fmt.Sprintf("%d", links[0].Id),
Expires: time.Now().AddDate(0, 1, 0),
Path: "/",
HttpOnly: true,
}
ctx.SetCookie(c)
}
}
return ctx.Render("/home/index", nil)
}
示例11: checkUserStatus
// 检查用户的状态(禁言、封号等)
func checkUserStatus(user *models.User, ctx *goku.HttpContext) (ar goku.ActionResulter, err error) {
if user != nil && user.IsBaned() {
if ctx.Request.Method == "POST" {
if ctx.IsAjax() {
ar = ctx.Json(map[string]interface{}{
"success": false,
"needLogin": false,
"errors": "你已经被禁言。",
})
} else {
ctx.ViewData["errorMsg"] = "你已经被禁言"
ar = ctx.Render("error", nil)
}
}
}
return
}
示例12: comment_Inbox
/**
* 收到的评论
*/
func comment_Inbox(ctx *goku.HttpContext) goku.ActionResulter {
user := ctx.Data["user"].(*models.User)
page, pagesize := utils.PagerParams(ctx.Request)
comments, total, err := models.CommentForUser_GetByPage(user.Id, page, pagesize, "")
if err != nil {
ctx.ViewData["errorMsg"] = err.Error()
return ctx.Render("error", nil)
}
ctx.ViewData["CommentList"] = comments
ctx.ViewData["CommentCount"] = total
ctx.ViewData["Page"] = page
ctx.ViewData["Pagesize"] = pagesize
err = models.Remind_Reset(user.Id, models.REMIND_COMMENT)
if err != nil {
goku.Logger().Errorln("Reset用户提醒信息数出错:", err.Error())
}
return ctx.View(nil)
}
示例13: OnActionExecuting
func (raf *RequireAdminFilter) OnActionExecuting(ctx *goku.HttpContext) (ar goku.ActionResulter, err error) {
ar, err = raf.RequireLoginFilter.OnActionExecuting(ctx)
if ar != nil || err != nil {
return
}
user := ctx.Data["user"].(*models.User)
if !user.IsAdmin() {
if ctx.IsAjax() {
ar = ctx.Json(map[string]interface{}{
"success": false,
"needLogin": false,
"errors": "没有权限",
})
} else {
ctx.ViewData["errorMsg"] = "没有权限"
ar = ctx.Render("error", nil)
}
}
return
}
示例14: home_guideForNew
// 新用户引导
func home_guideForNew(ctx *goku.HttpContext) goku.ActionResulter {
pagesize := 30
users, totalUser, err := models.User_GetList(1, pagesize, "link_count desc")
if err != nil {
ctx.ViewData["errorMsg"] = err.Error()
return ctx.Render("error", nil)
}
topics, totalTopic, err := models.Topic_GetByPage(1, pagesize, "link_count desc")
if err != nil {
ctx.ViewData["errorMsg"] = err.Error()
return ctx.Render("error", nil)
}
ctx.ViewData["Users"] = models.User_ToVUsers(users, ctx)
ctx.ViewData["TotalUser"] = totalUser
ctx.ViewData["Topics"] = models.Topic_ToVTopics(topics, ctx)
ctx.ViewData["TotalTopics"] = totalTopic
return ctx.Render("guide", nil)
}