本文整理汇总了Golang中github.com/QLeelulu/ohlala/golink/models.Link_ToVLink函数的典型用法代码示例。如果您正苦于以下问题:Golang Link_ToVLink函数的具体用法?Golang Link_ToVLink怎么用?Golang Link_ToVLink使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Link_ToVLink函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: discover_loadMoreLink
// 加载更多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)
}
开发者ID:yonglehou,项目名称:ohlala,代码行数:31,代码来源:discover.go
示例2: favorite_loadMoreLink
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)
}
开发者ID:yonglehou,项目名称:ohlala,代码行数:27,代码来源:favorite.go
示例3: 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
示例4: link_search_loadMore
// 加载更多的搜索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)
}
开发者ID:hippasus,项目名称:ohlala,代码行数:33,代码来源:link.go
示例5: discover_index
// 发现 首页
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"
ctx.ViewData["HasMoreLink"] = len(links) >= golink.PAGE_SIZE
return ctx.Render("/home/index", nil)
}
开发者ID:hippasus,项目名称:ohlala,代码行数:14,代码来源:discover.go
示例6: link_showWithComments
func link_showWithComments(ctx *goku.HttpContext, slinkId, scommentId string) goku.ActionResulter {
linkId, err1 := strconv.ParseInt(slinkId, 10, 64)
commentId, err2 := strconv.ParseInt(scommentId, 10, 64)
if err1 != nil || err2 != nil {
ctx.ViewData["errorMsg"] = "参数错误"
return ctx.Render("error", nil)
}
link, err := models.Link_GetById(linkId)
if err != nil {
ctx.ViewData["errorMsg"] = "服务器开小差了 >_<!!"
return ctx.Render("error", nil)
}
if link == nil {
ctx.ViewData["errorMsg"] = "内容不存在,去首页逛逛吧"
return ctx.Render("error", nil)
}
if link.Deleted() {
ctx.ViewData["errorMsg"] = "内容已被摧毁,去首页逛逛吧"
return ctx.Render("error", nil)
}
if !utils.IsSpider(ctx.Request.UserAgent()) {
// 更新链接的评论查看计数
models.Link_IncViewCount(link.Id, 1)
}
vlink := models.Link_ToVLink([]models.Link{*link}, ctx)
sortType := strings.ToLower(ctx.Get("cm_order")) //"hot":热门;"hotc":热议;"time":最新;"vote":得分;"ctvl":"争议"
if sortType == "" {
sortType = "hot"
}
var comments string
if commentId > 0 {
comments = models.GetPermalinkComment(linkId, commentId, sortType)
ctx.ViewData["SubLinkUrl"] = fmt.Sprintf("permacoment/%d/%d/", linkId, commentId)
} else {
comments = models.GetSortComments("", "/", int64(0), linkId, sortType, "", false) //models.Comment_SortForLink(link.Id, "hot")
ctx.ViewData["SubLinkUrl"] = linkId
}
ctx.ViewData["Comments"] = template.HTML(comments)
ctx.ViewData["SortType"] = sortType
ctx.ViewData["SortTypeName"] = ORDER_NAMES[sortType]
return ctx.Render("/link/show", vlink[0])
}
开发者ID:kicool,项目名称:ohlala,代码行数:49,代码来源:link.go
示例7: link_search
//link搜索界面
func link_search(ctx *goku.HttpContext) goku.ActionResulter {
ls := utils.LinkSearch{}
searchResult, err := ls.SearchLink(ctx.Get("term"), 1, golink.PAGE_SIZE)
if err == nil && searchResult.TimedOut == false && searchResult.HitResult.HitArray != nil && len(searchResult.HitResult.HitArray) > 0 {
links, _ := models.Link_GetByIdList(searchResult.HitResult.HitArray)
ctx.ViewData["Links"] = models.Link_ToVLink(links, ctx)
ctx.ViewData["HasMoreLink"] = len(links) >= golink.PAGE_SIZE
} else {
ctx.ViewData["Links"] = nil
ctx.ViewData["HasMoreLink"] = false
}
ctx.ViewData["Term"] = ctx.Get("term")
return ctx.Render("/link/search", nil)
}
开发者ID:hippasus,项目名称:ohlala,代码行数:16,代码来源:link.go
示例8: 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
示例9: discover_index
// 发现 首页
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"
ctx.ViewData["HasMoreLink"] = len(links) >= golink.PAGE_SIZE
// 最新链接的未读提醒
var userId, lastReadLinkId int64
unreadCookieName := "newestUnrLinkId"
u, ok := ctx.Data["user"]
if ok && u != nil {
user := u.(*models.User)
userId = user.Id
lastReadLinkId = user.LastReadLinkId
} else {
// 从Cook读取最后一次阅读的链接id
cLastReadLinkId, err := ctx.Request.Cookie(unreadCookieName)
if err == nil {
lastReadLinkId, _ = strconv.ParseInt(cLastReadLinkId.Value, 10, 64)
}
}
if ot == "hot" {
newestUnreadCount, _ := models.NewestLinkUnread_All(userId, lastReadLinkId)
ctx.ViewData["NewestUnreadCount"] = models.NewestLinkUnread_ToString(userId, newestUnreadCount)
} else if ot == "time" && links != nil && len(links) > 0 {
if userId > 0 {
models.NewestLinkUnread_UpdateForAll(userId, links[0].Id)
} else {
c := &http.Cookie{
Name: unreadCookieName,
Value: fmt.Sprintf("%d", links[0].Id),
Expires: time.Now().AddDate(0, 1, 0),
Path: "/",
HttpOnly: true,
}
ctx.SetCookie(c)
}
}
return ctx.Render("/home/index", nil)
}
开发者ID:yonglehou,项目名称:ohlala,代码行数:48,代码来源:discover.go
示例10:
return ctx.Render("error", nil)
}
sort := ctx.Get("o") //排序方式
t := ctx.Get("t") //时间范围
ctx.ViewData["Order"] = golink.ORDER_TYPE_HOT
if _, ok := golink.ORDER_TYPE_MAP[sort]; ok {
ctx.ViewData["Order"] = sort
}
page, pagesize := utils.PagerParams(ctx.Request)
links, _ := models.Link_ForTopic(topic.Id, page, pagesize, sort, t)
followers, _ := models.Topic_GetFollowers(topic.Id, 1, 24)
ctx.ViewData["Links"] = models.Link_ToVLink(links, ctx)
ctx.ViewData["HasMoreLink"] = len(links) >= golink.PAGE_SIZE
ctx.ViewData["Followers"] = followers
return ctx.View(models.Topic_ToVTopic(topic, ctx))
}). //Filters(filters.NewRequireLoginFilter()). // 暂时不需要登陆吧
/**
* 关注话题
*/
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 {
开发者ID:yonglehou,项目名称:ohlala,代码行数:31,代码来源:topic.go
注:本文中的github.com/QLeelulu/ohlala/golink/models.Link_ToVLink函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论