Exemplo n.º 1
0
	"strconv"
	"time"
)

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"
Exemplo n.º 2
0
		if ctx.RouteData.Params["id"] != f.Values()["link_id"] {
			errorMsgs = "参数错误"
		} else {
			var errors []string
			success, errors = models.Comment_SaveForm(f, (ctx.Data["user"].(*models.User)).Id)
			if errors != nil {
				errorMsgs = strings.Join(errors, "\n")
			}
		}
		r := map[string]interface{}{
			"success": success,
			"errors":  errorMsgs,
		}
		return ctx.Json(r)

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

	/**
	 * 删除评论
	 */
	Post("ajax-del", link_ajaxDel).Filters(filters.NewRequireLoginFilter(), filters.NewAjaxFilter())

//

// 删除link
func link_ajaxDel(ctx *goku.HttpContext) goku.ActionResulter {
	var errs string
	var ok = false

	linkId, err := strconv.ParseInt(ctx.RouteData.Params["id"], 10, 64)
	if err == nil {
Exemplo n.º 3
0
)

var _ = goku.Controller("link").
	/**
	 * 查看某评论
	 */
	Get("permacoment", link_permacoment).
	/**
	 * 查看一个链接的评论
	 */
	Get("show", link_show).

	/**
	 * 删除link
	 */
	Post("ajax-del", link_ajaxDel).Filters(filters.NewRequireLoginFilter(), filters.NewAjaxFilter()).

	/**
	 * 提交一个链接并保存到数据库
	 */
	Post("submit", link_submit).Filters(filters.NewRequireLoginFilter()).

	/**
	 * 提交评论并保存到数据库
	 */
	Post("ajax-comment", link_ajax_comment).Filters(filters.NewRequireLoginFilter(), filters.NewAjaxFilter()).

	/**
	 * 提交评论并保存到数据库
	 */
	Post("inc-click", link_incClick).Filters(filters.NewAjaxFilter()).
Exemplo n.º 4
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,
Exemplo n.º 5
0
Arquivo: home.go Projeto: t7er/ohlala
)

var _ = goku.Controller("home").
	// index
	Get("index", home_index).
	// 关于
	Get("about", home_about).
	// 免责声明
	Get("disclaimer", home_disclaimer).
	// 合作伙伴
	Get("partner", home_partner).
	// 联系信息
	Get("contact", home_contact).
	// load more
	Get("loadmorelink", home_loadMoreLink).
	Filters(filters.NewRequireLoginFilter(), filters.NewAjaxFilter())

//

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)