예제 #1
0
//printRSS reneders rss including newer records.
func printRSS(w http.ResponseWriter, r *http.Request) {
	g, err := new(w, r)
	if err != nil {
		log.Println(err)
		return
	}
	rsss := cgi.NewRSS("UTF-8", "", g.M["logo"], "http://"+g.Host(), "",
		"http://"+g.Host()+cfg.GatewayURL+"/"+"rss", g.M["description"], xslURL)
	for _, ca := range thread.AllCaches() {
		g.appendRSS(rsss, ca)
	}
	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)
}
예제 #2
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)
}