Example #1
0
func Screen(c *middleware.Context) {
	id := c.ParamsInt64(":id")
	name, e := screen(id)
	if e != nil {
		color.Red("%s", e)
	}
	c.Redirect("/" + makePaths(name) + "/" + name)
}
Example #2
0
func Show(c *middleware.Context) {
	site, e := models.GetSite(c.ParamsInt64(":id"))
	if e != nil {
		color.Red("%s", e)
	}
	go models.SiteFetchNewFeed(site.Id)
	c.Data["site"] = site
	c.Data["Title"] = site.Title
	c.HTML(200, "catalog/show")
}
Example #3
0
func SetFeed(c *middleware.Context) {
	id := c.ParamsInt64(":id")
	val := c.Query("hf")
	hf := false
	if val == "1" {
		hf = true
	}
	e := models.SiteSetHasFeed(id, hf)
	if e != nil {
		c.Flash.Error(e.Error())
	}
	c.Redirect(c.URLFor("cat_item", ":id", c.Params(":id")))
}
Example #4
0
func FeedShow(c *middleware.Context) {
	sf, e := models.GetSiteFeedItem(c.ParamsInt64(":feedId"))
	if e != nil {
		color.Red("%s", e)
	}
	a, e := linkpreview.Articler.ParseArticle(sf.Source, []byte(sf.Body))
	if e != nil {
		color.Red("%s", e)
	}
	if !sf.Published.Equal(a.Published.In(time.Now().Location())) {
		sf.Published = a.Published.In(time.Now().Location())
		models.SaveSiteFeed(sf)
	}
	sf.Body = a.Text
	c.Data["feed"] = sf
	c.HTML(200, "catalog/feedshow")
}
Example #5
0
func Feed(c *middleware.Context) {
	sid := c.ParamsInt64(":id")
	p := c.ParamsInt(":p")
	if p < 1 {
		p = 1
	}
	feed, e := models.GetSiteFeed(sid, p)
	if e != nil {
		color.Red("%s", e)
	}

	cnt, e := models.SiteFeedCount(sid)
	if e != nil {
		color.Red("%s", e)
	}

	c.Data["feed"] = feed
	c.Data["paginater"] = paginater.New(int(cnt), 10, p, 5)
	c.Data["SiteId"] = sid
	c.HTML(200, "catalog/feed")
}