Esempio n. 1
0
	 */
	Post("follow", func(ctx *goku.HttpContext) goku.ActionResulter {

		topicId, _ := strconv.ParseInt(ctx.RouteData.Params["id"], 10, 64)
		ok, err := models.Topic_Follow(ctx.Data["user"].(*models.User).Id, topicId)
		var errs string
		if err != nil {
			errs = err.Error()
		}
		r := map[string]interface{}{
			"success": ok,
			"errors":  errs,
		}
		return ctx.Json(r)

	}).Filters(filters.NewRequireLoginFilter(), filters.NewAjaxFilter()).

	/**
	 * 取消关注话题
	 */
	Post("unfollow", func(ctx *goku.HttpContext) goku.ActionResulter {

		topicId, _ := strconv.ParseInt(ctx.RouteData.Params["id"], 10, 64)
		ok, err := models.Topic_UnFollow(ctx.Data["user"].(*models.User).Id, topicId)
		var errs string
		if err != nil {
			errs = err.Error()
		}
		r := map[string]interface{}{
			"success": ok,
			"errors":  errs,
Esempio n. 2
0
	"github.com/philsong/ohlala/golink/models"
	"strconv"
)

var _ = goku.Controller("discover").

	/**
	 * 未登陆用户首页
	 */
	Get("index", discover_index).

	/**
	 * 未登陆用户首页
	 */
	Get("loadmorelink", discover_loadMoreLink).
	Filters(filters.NewAjaxFilter())

// END Controller & Action
//

// 发现 首页
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"