Archived
1
0

fix boards.html

This commit is contained in:
Jeff Becker 2017-04-03 21:35:09 -04:00
parent 279ca91043
commit e8fa40c0ca
2 changed files with 36 additions and 42 deletions

View File

@ -99,7 +99,7 @@ func (self *nullHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return return
} }
if strings.HasPrefix(file, "boards.html") { if strings.HasPrefix(file, "boards.html") {
template.genFrontPage(10, self.prefix, self.name, ioutil.Discard, w, self.database) template.genBoardList(self.prefix, self.name, w, self.database)
return return
} }

View File

@ -441,9 +441,7 @@ func (self *templateEngine) genGraphs(prefix string, wr io.Writer, db Database)
} }
// generate front page and board list func (self *templateEngine) genBoardList(prefix, name string, wr io.Writer, db Database) {
func (self *templateEngine) genFrontPage(top_count int, prefix, frontend_name string, indexwr, boardswr io.Writer, db Database) {
/*
// the graph for the front page // the graph for the front page
var frontpage_graph boardPageRows var frontpage_graph boardPageRows
@ -463,21 +461,21 @@ func (self *templateEngine) genFrontPage(top_count int, prefix, frontend_name st
Board: group, Board: group,
}) })
} }
param := map[string]interface{}{
var posts_graph postsGraph "prefix": prefix,
"frontend": name,
posts := db.GetLastDaysPosts(10) }
if posts == nil { sort.Sort(frontpage_graph)
// wtf? param["graph"] = frontpage_graph
} else { _, err := io.WriteString(wr, self.renderTemplate("boardlist.mustache", param))
for _, entry := range posts { if err != nil {
posts_graph = append(posts_graph, postsGraphRow{ log.Println("error writing board list page", err)
day: entry.Time(),
Num: entry.Count(),
})
} }
} }
*/
// generate front page
func (self *templateEngine) genFrontPage(top_count int, prefix, frontend_name string, indexwr, boardswr io.Writer, db Database) {
models := db.GetLastPostedPostModels(prefix, 20) models := db.GetLastPostedPostModels(prefix, 20)
wr := indexwr wr := indexwr
@ -488,7 +486,7 @@ func (self *templateEngine) genFrontPage(top_count int, prefix, frontend_name st
/* /*
sort.Sort(posts_graph) sort.Sort(posts_graph)
param["postsgraph"] = self.renderTemplate("posts_graph.mustache", map[string]interface{}{"graph": posts_graph}) param["postsgraph"] = self.renderTemplate("posts_graph.mustache", map[string]interface{}{"graph": posts_graph})
sort.Sort(frontpage_graph)
if len(frontpage_graph) > top_count { if len(frontpage_graph) > top_count {
param["boardgraph"] = frontpage_graph[:top_count] param["boardgraph"] = frontpage_graph[:top_count]
} else { } else {
@ -507,11 +505,7 @@ func (self *templateEngine) genFrontPage(top_count int, prefix, frontend_name st
} }
/* /*
wr = boardswr wr = boardswr
param["graph"] = frontpage_graph
_, err = io.WriteString(wr, self.renderTemplate("boardlist.mustache", param))
if err != nil {
log.Println("error writing board list page", err)
}
*/ */
} }