Esempio n. 1
0
//printCSVChanges renders csv of caches which changes recently and are in disk(validstamp is newer).
func printCSVChanges(w http.ResponseWriter, r *http.Request) {
	g, err := new(w, r)
	if err != nil {
		log.Println(err)
		return
	}
	all := thread.AllCaches()
	sort.Sort(sort.Reverse(thread.NewSortByStamp(all, false)))
	g.renderCSV(all)
}
Esempio n. 2
0
//PrintTitle renders list of newer thread in the disk for the top page
func PrintTitle(w http.ResponseWriter, r *http.Request) {
	g, err := new(w, r)
	if err != nil {
		log.Println(err)
		return
	}
	if r.FormValue("cmd") != "" {
		g.jumpNewFile()
		return
	}
	all := thread.AllCaches()
	sort.Sort(sort.Reverse(thread.NewSortByStamp(all, false)))
	outputCachelist := make([]*thread.Cache, 0, thread.Len())
	for _, ca := range all {
		if time.Now().Unix() <= ca.Stamp()+cfg.TopRecentRange {
			outputCachelist = append(outputCachelist, ca)
		}
	}

	g.Header(g.M["logo"]+" - "+g.M["description"], "", nil, false)
	s := struct {
		Target        string
		Taglist       tag.Slice
		MchURL        string
		MchCategories []*mchCategory
		Types         string
		NoList        bool
		cgi.ListItem
		cgi.Defaults
	}{
		"changes",
		user.Get(),
		g.mchURL(""),
		g.mchCategories(),
		"thread",
		len(outputCachelist) == 0,
		*cgi.NewListItem(outputCachelist, false, "changes", false, g.Filter, g.Tag),
		*g.Defaults(),
	}
	cgi.RenderTemplate("top", s, g.WR)
	g.PrintNewElementForm()
	g.Footer(nil)
}
Esempio n. 3
0
//printIndex renders threads in disk.
//id doChange threads are sorted by velocity.
func (g *gatewayCGI) printIndex(doChange bool) {
	str := "index"
	title := g.M[str]
	if doChange {
		str = "change"
		title = g.M["changes"]
	}

	if g.Filter != "" {
		title = fmt.Sprintf("%s : %s", g.M["string"], g.Filter)
	}
	g.Header(title, "", nil, true)
	fmt.Fprintf(g.WR, "<p>%s</p>", g.M["desc_"+str])
	cl := thread.AllCaches()
	if doChange {
		sort.Sort(sort.Reverse(thread.NewSortByStamp(cl, false)))
	} else {
		sort.Sort(sort.Reverse(thread.NewSortByVelocity(cl)))
	}
	g.PrintIndexList(cl, str, true, false, g.Filter, g.Tag)
}