70 lines
1.8 KiB
Go
Raw Normal View History

2016-11-09 20:32:19 +09:00
package main
import (
"io/ioutil"
2016-11-09 22:11:49 +09:00
"github.com/aerogo/aero"
2016-11-13 01:40:16 +09:00
"github.com/animenotifier/notify.moe/components"
2016-11-23 12:44:28 +09:00
"github.com/animenotifier/notify.moe/pages/airing"
2016-11-19 23:54:31 +09:00
"github.com/animenotifier/notify.moe/pages/anime"
"github.com/animenotifier/notify.moe/pages/dashboard"
"github.com/animenotifier/notify.moe/pages/forum"
"github.com/animenotifier/notify.moe/pages/forums"
2016-11-19 23:54:31 +09:00
"github.com/animenotifier/notify.moe/pages/genre"
"github.com/animenotifier/notify.moe/pages/genres"
"github.com/animenotifier/notify.moe/pages/posts"
2016-11-20 19:26:11 +09:00
"github.com/animenotifier/notify.moe/pages/profile"
"github.com/animenotifier/notify.moe/pages/search"
2016-11-19 23:54:31 +09:00
"github.com/animenotifier/notify.moe/pages/threads"
2016-11-09 20:32:19 +09:00
)
var app = aero.New()
func main() {
// CSS
app.SetStyle(components.CSS())
2016-11-09 20:32:19 +09:00
2016-12-03 00:23:05 +09:00
// HTTPS
app.Security.Certificate, _ = ioutil.ReadFile("security/fullchain.pem")
app.Security.Key, _ = ioutil.ReadFile("security/privkey.pem")
// Layout
2016-11-09 20:32:19 +09:00
app.Layout = func(ctx *aero.Context, content string) string {
2016-11-13 01:40:16 +09:00
return components.Layout(content)
2016-11-09 20:32:19 +09:00
}
// Ajax routes
2016-11-19 23:54:31 +09:00
app.Ajax("/", dashboard.Get)
app.Ajax("/anime", search.Get)
2016-11-19 23:54:31 +09:00
app.Ajax("/anime/:id", anime.Get)
app.Ajax("/genres", genres.Get)
app.Ajax("/genres/:name", genre.Get)
app.Ajax("/forum", forums.Get)
2016-11-19 23:54:31 +09:00
app.Ajax("/forum/:tag", forum.Get)
app.Ajax("/threads/:id", threads.Get)
app.Ajax("/posts/:id", posts.Get)
2016-11-20 19:26:11 +09:00
app.Ajax("/user/:nick", profile.Get)
2016-11-23 12:44:28 +09:00
app.Ajax("/airing", airing.Get)
2016-11-19 23:54:31 +09:00
app.Ajax("/test", func(ctx *aero.Context) string {
return ctx.HTML(components.Test("Hello World"))
})
// Scripts
scripts, _ := ioutil.ReadFile("temp/scripts.js")
js := string(scripts)
app.Get("/scripts.js", func(ctx *aero.Context) string {
ctx.SetHeader("Content-Type", "application/javascript")
return js
})
// For testing
app.Get("/hello", func(ctx *aero.Context) string {
return ctx.Text("Hello World")
})
// Let's go
2016-11-09 20:32:19 +09:00
app.Run()
}