24 lines
530 B
Go
Raw Normal View History

2016-11-19 14:54:31 +00:00
package forum
import (
"github.com/aerogo/aero"
2019-06-03 09:32:43 +00:00
"github.com/animenotifier/notify.moe/arn"
2016-11-19 14:54:31 +00:00
"github.com/animenotifier/notify.moe/components"
)
2017-06-20 14:19:43 +00:00
// ThreadsPerPage indicates how many threads are shown on one page.
const ThreadsPerPage = 20
2016-11-19 14:54:31 +00:00
2017-06-16 23:25:02 +00:00
// Get forum category.
2019-06-01 04:55:49 +00:00
func Get(ctx aero.Context) error {
2016-11-19 14:54:31 +00:00
tag := ctx.Get("tag")
2017-10-27 07:11:56 +00:00
threads := arn.GetThreadsByTag(tag)
2016-12-06 03:36:31 +00:00
arn.SortThreads(threads)
2016-11-19 14:54:31 +00:00
2017-06-20 14:19:43 +00:00
if len(threads) > ThreadsPerPage {
threads = threads[:ThreadsPerPage]
2016-11-19 14:54:31 +00:00
}
2017-06-20 14:19:43 +00:00
return ctx.HTML(components.Forum(tag, threads, ThreadsPerPage))
2016-11-19 14:54:31 +00:00
}