diff --git a/common/pages.go b/common/pages.go index d3706d0e..47b04f64 100644 --- a/common/pages.go +++ b/common/pages.go @@ -100,11 +100,17 @@ type TopicPage struct { LastPage int } +type TopicListSort struct { + SortBy string // lastupdate, mostviewed, mostviewedtoday, mostviewedthisweek, mostviewedthismonth + Ascending bool +} + type TopicListPage struct { *Header TopicList []*TopicsRow ForumList []Forum DefaultForum int + Sort TopicListSort Paginator } diff --git a/common/template_init.go b/common/template_init.go index e08ad184..3292e851 100644 --- a/common/template_init.go +++ b/common/template_init.go @@ -237,7 +237,7 @@ func CompileTemplates() error { var topicsList []*TopicsRow topicsList = append(topicsList, &TopicsRow{1, "topic-title", "Topic Title", "The topic content.", 1, false, false, now, now, "Date", user3.ID, 1, "", "127.0.0.1", 1, 0, 1, "classname", "", &user2, "", 0, &user3, "General", "/forum/general.2"}) header2.Title = "Topic List" - topicListPage := TopicListPage{header, topicsList, forumList, Config.DefaultForum, Paginator{[]int{1}, 1, 1}} + topicListPage := TopicListPage{header, topicsList, forumList, Config.DefaultForum, TopicListSort{"lastupdated", false}, Paginator{[]int{1}, 1, 1}} topicListTmpl, err := c.Compile("topics.html", "templates/", "common.TopicListPage", topicListPage, varList) if err != nil { return err diff --git a/routes/topic_list.go b/routes/topic_list.go index 1f5a53e1..862a40e1 100644 --- a/routes/topic_list.go +++ b/routes/topic_list.go @@ -44,7 +44,7 @@ func TopicList(w http.ResponseWriter, r *http.Request, user common.User) common. return common.NotFound(w, r, header) } - pi := common.TopicListPage{header, topicList, forumList, common.Config.DefaultForum, paginator} + pi := common.TopicListPage{header, topicList, forumList, common.Config.DefaultForum, common.TopicListSort{"lastupdated", false}, paginator} if common.RunPreRenderHook("pre_render_topic_list", w, r, &user, &pi) { return nil } diff --git a/templates/topics.html b/templates/topics.html index dbd6a13c..cf8b5a01 100644 --- a/templates/topics.html +++ b/templates/topics.html @@ -12,7 +12,8 @@
- {{else}}{{end}} + + {{else}}{{end}} {{end}}