Ejemplo n.º 1
0
func Submit(c *middleware.Context) {
	if c.Req.Method == "POST" {
		submitPost(c)
		return
	}
	c.HTML(200, "catalog/submit")
}
Ejemplo n.º 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")
}
Ejemplo n.º 3
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")
}
Ejemplo n.º 4
0
func AllFeed(c *middleware.Context) {
	p := c.ParamsInt(":p")
	if p < 1 {
		p = 1
	}
	feed, e := models.GetFeed(p)
	if e != nil {
		color.Red("%s", e)
	}

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

	c.Data["feed"] = feed
	c.Data["paginater"] = paginater.New(int(cnt), 10, p, 5)
	c.HTML(200, "catalog/feed")
}
Ejemplo n.º 5
0
func Index(c *middleware.Context) {
	var (
		p = c.ParamsInt(":p")
	)
	sites, e := models.SiteList(p)
	if e != nil {
		color.Red("%s", e)
	}

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

	c.Data["sites"] = sites
	c.Data["sites_count"] = cnt
	c.Data["paginater"] = paginater.New(int(cnt), 10, p, 5)
	c.HTML(200, "catalog/index")
}
Ejemplo n.º 6
0
func submitPost(c *middleware.Context) {

	s, e := models.NewSite(c.Query("link"), c.Query("title"))
	if e != nil {
		c.Flash.Error(e.Error(), true)
		if c.QueryInt("ajax") == 1 {
			c.JSON(200, e.Error())
			return
		}
		c.HTML(200, "catalog/submit")
		return
	}

	c.Flash.Success(fmt.Sprintf("%d  добавлен", s.Id), true)
	if c.QueryInt("ajax") == 1 {
		c.JSON(200, fmt.Sprintf("%d  добавлен", s.Id))
		return
	}
	c.HTML(200, "catalog/submit")
}
Ejemplo n.º 7
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")
}
Ejemplo n.º 8
0
func Home(c *middleware.Context) {
	c.HTML(200, "home")
}