Example #1
0
// 加载更多link
func discover_loadMoreLink(ctx *goku.HttpContext) goku.ActionResulter {
	page, err := strconv.Atoi(ctx.Get("page"))
	success, hasmore := false, false
	errorMsgs, html := "", ""
	if err == nil && page > 1 {
		ot := ctx.Get("o")
		if ot == "" {
			ot = "hot"
		}
		dt, _ := strconv.Atoi(ctx.Get("dt"))
		links, _ := models.LinkForHome_GetByPage(ot, dt, page, golink.PAGE_SIZE)
		if links != nil && len(links) > 0 {
			ctx.ViewData["Links"] = models.Link_ToVLink(links, ctx)
			vr := ctx.RenderPartial("loadmorelink", nil)
			vr.Render(ctx, vr.Body)
			html = vr.Body.String()
			hasmore = len(links) >= golink.PAGE_SIZE
		}
		success = true
	} else {
		errorMsgs = "参数错误"
	}
	r := map[string]interface{}{
		"success": success,
		"errors":  errorMsgs,
		"html":    html,
		"hasmore": hasmore,
	}
	return ctx.Json(r)
}
Example #2
0
func favorite_loadMoreLink(ctx *goku.HttpContext) goku.ActionResulter {
	page, err := strconv.Atoi(ctx.Get("page"))
	success, hasmore := false, false
	errorMsgs, html := "", ""
	if err == nil && page > 1 {
		user := ctx.Data["user"].(*models.User)

		links := models.FavoriteLink_ByUser(user.Id, page, golink.PAGE_SIZE)
		if links != nil && len(links) > 0 {
			ctx.ViewData["Links"] = models.Link_ToVLink(links, ctx)
			vr := ctx.RenderPartial("loadmorelink", nil)
			vr.Render(ctx, vr.Body)
			html = vr.Body.String()
			hasmore = len(links) >= golink.PAGE_SIZE
		}
		success = true
	} else {
		errorMsgs = "参数错误"
	}
	r := map[string]interface{}{
		"success": success,
		"errors":  errorMsgs,
		"html":    html,
		"hasmore": hasmore,
	}
	return ctx.Json(r)
}
Example #3
0
// 加载更多的搜索link
func link_search_loadMore(ctx *goku.HttpContext) goku.ActionResulter {
	term, _ := url.QueryUnescape(ctx.Get("term"))
	page, err := strconv.Atoi(ctx.Get("page"))
	success, hasmore := false, false
	errorMsgs, html := "", ""
	if err == nil && page > 1 {
		ls := utils.LinkSearch{}
		searchResult, err := ls.SearchLink(term, page, golink.PAGE_SIZE)
		if err == nil && searchResult.TimedOut == false && searchResult.HitResult.HitArray != nil {
			if len(searchResult.HitResult.HitArray) > 0 {
				links, _ := models.Link_GetByIdList(searchResult.HitResult.HitArray)
				if links != nil && len(links) > 0 {
					ctx.ViewData["Links"] = models.Link_ToVLink(links, ctx)
					vr := ctx.RenderPartial("loadmorelink", nil)
					vr.Render(ctx, vr.Body)
					html = vr.Body.String()
					hasmore = len(links) >= golink.PAGE_SIZE
				}
			}
			success = true
		}
	} else {
		errorMsgs = "参数错误"
	}
	r := map[string]interface{}{
		"success": success,
		"errors":  errorMsgs,
		"html":    html,
		"hasmore": hasmore,
	}
	return ctx.Json(r)
}
Example #4
0
/**
 * 获取用户信息
 * 用于浮动层
 */
func actionPopupBoxInfo(ctx *goku.HttpContext) goku.ActionResulter {

	topicName := ctx.Get("t")
	topic, _ := models.Topic_GetByName(topicName)

	if topic != nil {
		return ctx.RenderPartial("pop-info", models.Topic_ToVTopic(topic, ctx))
	}
	return ctx.Html("")
}