예제 #1
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")
}
예제 #2
0
func screen(siteId int64) (string, error) {
	site, e := models.GetSite(siteId)
	if e != nil {
		return "", e
	}

	rdr, e := shot.Shot(site.Domain)
	if e != nil {
		return "", e
	}

	name := uuid.NewV4().String()

	//.fmt.Fprintf(w, "%v", handler.Header)
	e = os.MkdirAll("data/uploads/"+makePaths(name), 0777)
	if e != nil {
		return "", e
	}
	f, e := os.OpenFile("data/uploads/"+makePaths(name)+"/"+name, os.O_WRONLY|os.O_CREATE, 0777)
	if e != nil {
		return "", e
	}
	defer f.Close()
	_, e = io.Copy(f, rdr)
	if e != nil {
		return "", e
	}

	fp := filepath.Join("/", makePaths(name), "/", name)
	site.PreviewUrl = fp
	e = models.SaveSite(site)
	if e != nil {
		return "", e
	}
	return fp, nil
}