2016-11-09 11:32:19 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
2016-11-23 09:07:02 +00:00
|
|
|
"runtime"
|
2016-11-09 11:32:19 +00:00
|
|
|
|
2016-11-09 13:11:49 +00:00
|
|
|
"github.com/aerogo/aero"
|
2016-11-12 16:40:16 +00:00
|
|
|
"github.com/animenotifier/notify.moe/components"
|
2016-11-23 03:44:28 +00:00
|
|
|
"github.com/animenotifier/notify.moe/pages/airing"
|
2016-11-19 14:54:31 +00:00
|
|
|
"github.com/animenotifier/notify.moe/pages/anime"
|
|
|
|
"github.com/animenotifier/notify.moe/pages/dashboard"
|
|
|
|
"github.com/animenotifier/notify.moe/pages/forum"
|
2016-11-19 18:02:33 +00:00
|
|
|
"github.com/animenotifier/notify.moe/pages/forums"
|
2016-11-19 14:54:31 +00:00
|
|
|
"github.com/animenotifier/notify.moe/pages/genre"
|
|
|
|
"github.com/animenotifier/notify.moe/pages/genres"
|
2016-11-22 03:34:59 +00:00
|
|
|
"github.com/animenotifier/notify.moe/pages/posts"
|
2016-11-20 10:26:11 +00:00
|
|
|
"github.com/animenotifier/notify.moe/pages/profile"
|
2016-11-22 03:34:59 +00:00
|
|
|
"github.com/animenotifier/notify.moe/pages/search"
|
2016-11-19 14:54:31 +00:00
|
|
|
"github.com/animenotifier/notify.moe/pages/threads"
|
2016-11-09 11:32:19 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var app = aero.New()
|
|
|
|
|
|
|
|
func main() {
|
2016-11-27 14:28:22 +00:00
|
|
|
app.SetStyle(components.CSS())
|
2016-11-09 11:32:19 +00:00
|
|
|
|
2016-11-23 14:21:24 +00:00
|
|
|
// app.Sessions = sessions.New(sessions.Config{
|
|
|
|
// Cookie: "sid",
|
|
|
|
// Expires: time.Duration(30) * time.Second,
|
|
|
|
// GcDuration: time.Duration(30) * time.Second,
|
|
|
|
// DecodeCookie: false,
|
|
|
|
// DisableSubdomainPersistence: false,
|
|
|
|
// })
|
|
|
|
|
2016-11-27 14:28:22 +00:00
|
|
|
// user, _ := arn.GetUserByNick("Akyoto")
|
|
|
|
// user.CoverImage.URL = "https://www.pixelstalk.net/wp-content/uploads/2016/10/Hanyijie-sky-scenery-ship-anime-art-1920x1080.jpg"
|
|
|
|
// user.CoverImage.Position.X = "50%"
|
|
|
|
// user.CoverImage.Position.Y = "0%"
|
|
|
|
// user.Save()
|
2016-11-20 10:26:11 +00:00
|
|
|
|
2016-11-09 11:32:19 +00:00
|
|
|
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
|
|
|
|
})
|
|
|
|
|
2016-11-12 16:40:16 +00:00
|
|
|
app.Get("/hello", func(ctx *aero.Context) string {
|
2016-11-23 09:07:02 +00:00
|
|
|
return ctx.Text("Hello World")
|
|
|
|
})
|
|
|
|
|
|
|
|
app.Get("/gc", func(ctx *aero.Context) string {
|
|
|
|
runtime.GC()
|
|
|
|
return ctx.Text("Ran garbage collector")
|
2016-11-12 16:40:16 +00:00
|
|
|
})
|
|
|
|
|
2016-11-09 11:32:19 +00:00
|
|
|
app.Layout = func(ctx *aero.Context, content string) string {
|
2016-11-12 16:40:16 +00:00
|
|
|
return components.Layout(content)
|
2016-11-09 11:32:19 +00:00
|
|
|
}
|
|
|
|
|
2016-11-19 14:54:31 +00:00
|
|
|
app.Ajax("/", dashboard.Get)
|
2016-11-22 03:34:59 +00:00
|
|
|
app.Ajax("/anime", search.Get)
|
2016-11-19 14:54:31 +00:00
|
|
|
app.Ajax("/anime/:id", anime.Get)
|
|
|
|
app.Ajax("/genres", genres.Get)
|
|
|
|
app.Ajax("/genres/:name", genre.Get)
|
2016-11-19 18:02:33 +00:00
|
|
|
app.Ajax("/forum", forums.Get)
|
2016-11-19 14:54:31 +00:00
|
|
|
app.Ajax("/forum/:tag", forum.Get)
|
|
|
|
app.Ajax("/threads/:id", threads.Get)
|
2016-11-22 03:34:59 +00:00
|
|
|
app.Ajax("/posts/:id", posts.Get)
|
2016-11-20 10:26:11 +00:00
|
|
|
app.Ajax("/user/:nick", profile.Get)
|
2016-11-23 03:44:28 +00:00
|
|
|
app.Ajax("/airing", airing.Get)
|
2016-11-19 14:54:31 +00:00
|
|
|
|
2016-11-27 14:28:22 +00:00
|
|
|
app.Ajax("/test", func(ctx *aero.Context) string {
|
|
|
|
return ctx.HTML(components.Test("Hello World"))
|
|
|
|
})
|
|
|
|
|
2016-11-09 11:32:19 +00:00
|
|
|
app.Run()
|
|
|
|
}
|