//mchCategories returns slice of mchCategory whose tags are in tag.txt. func (g *gatewayCGI) mchCategories() []*mchCategory { var categories []*mchCategory if !cfg.Enable2ch { return categories } for _, t := range user.Get() { tag := t.Tagstr catURL := g.mchURL(tag) categories = append(categories, &mchCategory{ catURL, tag, }) } return categories }
//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) }
//PrintIndexList renders index_list.txt which renders threads in cachelist. func (c *CGI) PrintIndexList(cl []*thread.Cache, target string, footer bool, searchNewFile bool, filter, tagg string) { s := struct { Target string Filter string Tag string Taglist tag.Slice NoList bool Defaults ListItem }{ target, filter, tagg, user.Get(), len(cl) == 0, *c.Defaults(), *NewListItem(cl, true, target, searchNewFile, filter, tagg), } RenderTemplate("index_list", s, c.WR) if footer { c.PrintNewElementForm() c.Footer(nil) } }