当前位置: 首页>>代码示例>>Golang>>正文


Golang HttpContext.View方法代码示例

本文整理汇总了Golang中github.com/QLeelulu/goku.HttpContext.View方法的典型用法代码示例。如果您正苦于以下问题:Golang HttpContext.View方法的具体用法?Golang HttpContext.View怎么用?Golang HttpContext.View使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/QLeelulu/goku.HttpContext的用法示例。


在下文中一共展示了HttpContext.View方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: home_index

func home_index(ctx *goku.HttpContext) goku.ActionResulter {
	u, ok := ctx.Data["user"]
	if !ok || u == nil {
		return ctx.Redirect("/discover")
	}
	user := u.(*models.User)
	if user.FriendCount+user.FtopicCount < 1 {
		return home_guideForNew(ctx)
	}
	ot := ctx.Get("o")
	if ot == "" {
		ot = "hot"
	}
	ctx.ViewData["Order"] = ot
	links, _ := models.Link_ForUser(user.Id, ot, 1, golink.PAGE_SIZE) //models.Link_GetByPage(1, 20)
	ctx.ViewData["Links"] = models.Link_ToVLink(links, ctx)
	ctx.ViewData["HasMoreLink"] = len(links) >= golink.PAGE_SIZE

	// 最新链接的未读提醒
	if ot == "hot" {
		newestUnreadCount, _ := models.NewestLinkUnread_Friends(user.Id, user.LastReadFriendLinkId)
		ctx.ViewData["NewestUnreadCount"] = models.NewestLinkUnread_ToString(user.Id, newestUnreadCount)
	} else if ot == "time" && links != nil && len(links) > 0 {
		models.NewestLinkUnread_UpdateForUser(user.Id, links[0].Id)
	}

	return ctx.View(nil)
}
开发者ID:yonglehou,项目名称:ohlala,代码行数:28,代码来源:home.go

示例2: 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))

}
开发者ID:venliong,项目名称:ohlala,代码行数:27,代码来源:user.go

示例3: 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)
}
开发者ID:yonglehou,项目名称:ohlala,代码行数:34,代码来源:index.go

示例4: link_submit

/**
 * 提交一个链接并保存到数据库
 */
func link_submit(ctx *goku.HttpContext) goku.ActionResulter {

	f := forms.CreateLinkSubmitForm()
	f.FillByRequest(ctx.Request)

	var resubmit bool
	if ctx.Get("resubmit") == "true" {
		resubmit = true
	}
	user := ctx.Data["user"].(*models.User)
	success, linkId, errorMsgs, _ := models.Link_SaveForm(f, user.Id, resubmit)

	if success {
		go addLinkForSearch(0, f.CleanValues(), linkId, user.Name) //contextType:0: url, 1:文本   TODO:

		return ctx.Redirect(fmt.Sprintf("/link/%d", linkId))
	} else if linkId > 0 {
		return ctx.Redirect(fmt.Sprintf("/link/%d?already_submitted=true", linkId))
	} else {
		ctx.ViewData["Errors"] = errorMsgs
		ctx.ViewData["Values"] = f.Values()
	}
	return ctx.View(nil)

}
开发者ID:hippasus,项目名称:ohlala,代码行数:28,代码来源:link.go

示例5: 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)
}
开发者ID:polaris1119,项目名称:ohlala,代码行数:13,代码来源:link.go

示例6: 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)
}
开发者ID:polaris1119,项目名称:ohlala,代码行数:13,代码来源:user.go

示例7: 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)
}
开发者ID:polaris1119,项目名称:ohlala,代码行数:13,代码来源:comment.go

示例8: 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)
}
开发者ID:cloudcache,项目名称:ohlala,代码行数:14,代码来源:topic.go

示例9: home_index

func home_index(ctx *goku.HttpContext) goku.ActionResulter {
	u, ok := ctx.Data["user"]
	if !ok || u == nil {
		return ctx.Redirect("/discover")
	}
	user := u.(*models.User)
	ot := ctx.Get("o")
	if ot == "" {
		ot = "hot"
	}
	ctx.ViewData["Order"] = ot
	links, _ := models.Link_ForUser(user.Id, ot, 1, golink.PAGE_SIZE) //models.Link_GetByPage(1, 20)
	ctx.ViewData["Links"] = models.Link_ToVLink(links, ctx)
	ctx.ViewData["HasMoreLink"] = len(links) >= golink.PAGE_SIZE
	return ctx.View(nil)
}
开发者ID:t7er,项目名称:ohlala,代码行数:16,代码来源:home.go

示例10: link_submit

/**
 * 提交一个链接并保存到数据库
 */
func link_submit(ctx *goku.HttpContext) goku.ActionResulter {

	f := forms.CreateLinkSubmitForm()
	f.FillByRequest(ctx.Request)

	success, linkId, errorMsgs := models.Link_SaveForm(f, (ctx.Data["user"].(*models.User)).Id)

	if success {
		return ctx.Redirect(fmt.Sprintf("/link/%d", linkId))
	} else {
		ctx.ViewData["Errors"] = errorMsgs
		ctx.ViewData["Values"] = f.Values()
	}
	return ctx.View(nil)

}
开发者ID:arowser,项目名称:ohlala,代码行数:19,代码来源:link.go

示例11: 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)
}
开发者ID:t7er,项目名称:ohlala,代码行数:21,代码来源:comment.go

示例12: link_submit

/**
 * 提交一个链接并保存到数据库
 */
func link_submit(ctx *goku.HttpContext) goku.ActionResulter {

	f := forms.CreateLinkSubmitForm()
	f.FillByRequest(ctx.Request)

	var resubmit bool
	if ctx.Get("resubmit") == "true" {
		resubmit = true
	}

	success, linkId, errorMsgs := models.Link_SaveForm(f, (ctx.Data["user"].(*models.User)).Id, resubmit)

	if success {
		return ctx.Redirect(fmt.Sprintf("/link/%d", linkId))
	} else if linkId > 0 {
		return ctx.Redirect(fmt.Sprintf("/link/%d?already_submitted=true", linkId))
	} else {
		ctx.ViewData["Errors"] = errorMsgs
		ctx.ViewData["Values"] = f.Values()
	}
	return ctx.View(nil)

}
开发者ID:kicool,项目名称:ohlala,代码行数:26,代码来源:link.go

示例13: home_partner

func home_partner(ctx *goku.HttpContext) goku.ActionResulter {
	return ctx.View(nil)
}
开发者ID:t7er,项目名称:ohlala,代码行数:3,代码来源:home.go

示例14: home_contact

func home_contact(ctx *goku.HttpContext) goku.ActionResulter {
	return ctx.View(nil)
}
开发者ID:t7er,项目名称:ohlala,代码行数:3,代码来源:home.go

示例15: home_disclaimer

func home_disclaimer(ctx *goku.HttpContext) goku.ActionResulter {
	return ctx.View(nil)
}
开发者ID:t7er,项目名称:ohlala,代码行数:3,代码来源:home.go


注:本文中的github.com/QLeelulu/goku.HttpContext.View方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。