예제 #1
0
파일: home.go 프로젝트: yonglehou/ohlala
// 新用户引导
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)
}
예제 #2
0
파일: topic.go 프로젝트: yonglehou/ohlala
	"time"
)

/**
 * Controller: topic
 */
var _ = goku.Controller("topic").

	/**
	 * 话题列表页
	 */
	Get("index", func(ctx *goku.HttpContext) goku.ActionResulter {

		topics, _ := models.Topic_GetTops(1, 30)
		ctx.ViewData["TopTab"] = "topic"
		return ctx.View(models.Topic_ToVTopics(topics, ctx))

	}).

	/**
	 * 查看话题信息页
	 */
	Get("show", func(ctx *goku.HttpContext) goku.ActionResulter {

		ctx.ViewData["TopTab"] = "topic"
		topicName, _ := ctx.RouteData.Params["name"]
		topic, _ := models.Topic_GetByName(topicName)

		if topic == nil {
			ctx.ViewData["errorMsg"] = "话题不存在"
			return ctx.Render("error", nil)