Esempio n. 1
0
//printCSVRecent renders csv of caches which are written recently(are updated remotely).
func printCSVRecent(w http.ResponseWriter, r *http.Request) {
	g, err := new(w, r)
	if err != nil {
		log.Println(err)
		return
	}
	if !g.IsFriend() && !g.IsAdmin() {
		g.Print403()
		return
	}
	cl := thread.MakeRecentCachelist()
	g.renderCSV(cl)
}
Esempio n. 2
0
//makeSubjectCachelist returns thread.Caches in all thread.Cache and in recentlist sorted by recent stamp.
//if board is specified,  returns thread.Caches whose tagstr=board.
func (m *mchCGI) makeSubjectCachelist(board string) []*thread.Cache {
	result := thread.MakeRecentCachelist()
	if board == "" {
		return result
	}
	var result2 []*thread.Cache
	for _, c := range result {
		if user.Has(c.Datfile, board) {
			result2 = append(result2, c)
		}
	}
	return result2
}
Esempio n. 3
0
//printRecent renders cache in recentlist.
func printRecent(w http.ResponseWriter, r *http.Request) {
	g, err := new(w, r)
	if err != nil {
		log.Println(err)
		return
	}
	title := g.M["recent"]
	if g.Filter != "" {
		title = fmt.Sprintf("%s : %s", g.M["recent"], g.Filter)
	}
	g.Header(title, "", nil, true)
	fmt.Fprintf(g.WR, "<p>%s</p>", g.M["desc_recent"])
	cl := thread.MakeRecentCachelist()
	g.PrintIndexList(cl, "recent", true, false, g.Filter, g.Tag)
}
Esempio n. 4
0
//printRecentRSS renders rss of caches which are written recently(are updated remotely).
//including title,tags,last-modified.
func printRecentRSS(w http.ResponseWriter, r *http.Request) {
	g, err := new(w, r)
	if err != nil {
		log.Println(err)
		return
	}
	rsss := cgi.NewRSS("UTF-8", "", fmt.Sprintf("%s - %s", g.M["recent"], g.M["logo"]),
		"http://"+g.Host(), "",
		"http://"+g.Host()+cfg.GatewayURL+"/"+"recent_rss", g.M["description"], xslURL)
	cl := thread.MakeRecentCachelist()
	for _, ca := range cl {
		title := util.Escape(util.FileDecode(ca.Datfile))
		tags := suggest.Get(ca.Datfile, nil)
		tags = append(tags, user.GetByThread(ca.Datfile)...)
		rsss.Append(cfg.ThreadURL[1:]+"/"+util.StrEncode(title),
			title, "", "", html.EscapeString(title), tags.GetTagstrSlice(),
			ca.RecentStamp(), false)
	}
	g.WR.Header().Set("Content-Type", "text/xml; charset=UTF-8")
	if rsss.Len() != 0 {
		g.WR.Header().Set("Last-Modified", g.RFC822Time(rsss.Feeds[0].Date))
	}
	rsss.MakeRSS1(g.WR)
}