24 lines
521 B
Go
Raw Normal View History

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