func (self *MainHandler) Get() { page, _ := self.GetInt("page") curtab, _ := self.GetInt("tab") cid, _ := self.GetInt(":cid") limit := 25 home := "false" if cid == 0 { home = "true" } self.Data["home"] = home self.Data["curcate"] = cid self.Data["curtab"] = curtab topics_rcs := len(models.GetAllTopicByCid(cid, 0, 0, 0, "hotness")) topics_pages, topics_pageout, topics_beginnum, topics_endnum, offset := helper.Pages(topics_rcs, int(page), limit) self.Data["topics_latest"] = models.GetAllTopicByCid(cid, offset, limit, 0, "id") self.Data["topics_hotness"] = models.GetAllTopicByCid(cid, offset, limit, 0, "hotness") self.Data["topics_views"] = models.GetAllTopicByCid(cid, offset, limit, 0, "views") self.Data["topics_reply_count"] = models.GetAllTopicByCid(cid, offset, limit, 0, "reply_count") self.Data["topics_pagesbar_tab1"] = helper.Pagesbar("tab=1&", topics_rcs, topics_pages, topics_pageout, topics_beginnum, topics_endnum, 1) self.Data["topics_pagesbar_tab2"] = helper.Pagesbar("tab=2&", topics_rcs, topics_pages, topics_pageout, topics_beginnum, topics_endnum, 1) self.Data["topics_pagesbar_tab3"] = helper.Pagesbar("tab=3&", topics_rcs, topics_pages, topics_pageout, topics_beginnum, topics_endnum, 1) self.Data["topics_pagesbar_tab4"] = helper.Pagesbar("tab=4&", topics_rcs, topics_pages, topics_pageout, topics_beginnum, topics_endnum, 1) nodes_rcs := len(models.GetAllNodeByCid(cid, 0, 0, 0, "hotness")) nodes_pages, nodes_pageout, nodes_beginnum, nodes_endnum, offset := helper.Pages(nodes_rcs, int(page), limit) self.Data["nodes_latest"] = models.GetAllNodeByCid(cid, offset, limit, 0, "id") self.Data["nodes_hotness"] = models.GetAllNodeByCid(cid, offset, limit, 0, "hotness") self.Data["nodes_pagesbar_tab5"] = helper.Pagesbar("tab=5&", nodes_rcs, nodes_pages, nodes_pageout, nodes_beginnum, nodes_endnum, 1) self.Data["nodes_pagesbar_tab6"] = helper.Pagesbar("tab=6&", nodes_rcs, nodes_pages, nodes_pageout, nodes_beginnum, nodes_endnum, 1) self.Layout = "layout.html" self.TplNames = "index.html" //self.Render() }
func (self *SearchHandler) Get() { if keyword := self.GetString("keyword"); keyword != "" { page, _ := self.GetInt("page") limit := 25 rcs := len(*models.SearchTopic(keyword, 0, 0, "id")) pages, pageout, beginnum, endnum, offset := helper.Pages(rcs, int(page), limit) self.Data["search_hotness"] = models.SearchTopic(keyword, offset, limit, "hotness") keywordz := "keyword=" + keyword + "&" self.Data["pagesbar"] = helper.Pagesbar(keywordz, rcs, pages, pageout, beginnum, endnum, 1) } self.TplNames = "search.html" self.Layout = "layout.html" self.Render() }
func (self *NodeHandler) Get() { page, _ := self.GetInt("page") nid, _ := self.GetInt(":nid") nid_handler := models.GetNode(nid) nid_handler.Views = nid_handler.Views + 1 models.UpdateNode(nid, nid_handler) limit := 25 rcs := len(models.GetAllTopicByNid(nid, 0, 0, 0, "hotness")) pages, pageout, beginnum, endnum, offset := helper.Pages(rcs, int(page), limit) self.Data["pagesbar"] = helper.Pagesbar("", rcs, pages, pageout, beginnum, endnum, 1) self.Data["nodeid"] = nid self.Data["topics_hotness"] = models.GetAllTopicByNid(nid, offset, limit, 0, "hotness") self.Data["topics_latest"] = models.GetAllTopicByNid(nid, offset, limit, 0, "id") self.TplNames = "node.html" self.Layout = "layout.html" if nid != 0 { self.Render() /* if sess_userrole, _ := self.GetSession("userrole").(int64); sess_userrole == -1000 { self.Render() } else { nid_path := strconv.Itoa(int(nid_handler.Pid)) + "/" + strconv.Itoa(int(nid_handler.Id)) + "/" nid_name := "index.html" rs, _ := self.RenderString() helper.Writefile("./archives/"+nid_path, nid_name, rs) self.Redirect("/archives/"+nid_path+nid_name, 301) }*/ } else { self.Redirect("/", 302) } }