2016-11-09 20:32:19 +09:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2016-11-09 22:11:49 +09:00
|
|
|
"github.com/aerogo/aero"
|
2017-06-17 01:12:28 +02:00
|
|
|
"github.com/aerogo/api"
|
2017-06-08 23:26:58 +02:00
|
|
|
"github.com/animenotifier/arn"
|
2017-06-17 01:32:47 +02:00
|
|
|
"github.com/animenotifier/notify.moe/auth"
|
2016-11-13 01:40:16 +09:00
|
|
|
"github.com/animenotifier/notify.moe/components"
|
2017-06-15 23:03:55 +02:00
|
|
|
"github.com/animenotifier/notify.moe/layout"
|
2017-06-17 01:12:28 +02:00
|
|
|
"github.com/animenotifier/notify.moe/middleware"
|
2017-06-18 17:16:40 +02:00
|
|
|
"github.com/animenotifier/notify.moe/pages/admin"
|
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"
|
2017-06-19 22:16:01 +02:00
|
|
|
"github.com/animenotifier/notify.moe/pages/animelist"
|
2017-06-19 20:59:02 +02:00
|
|
|
"github.com/animenotifier/notify.moe/pages/animelistitem"
|
2017-06-02 16:17:58 +02:00
|
|
|
"github.com/animenotifier/notify.moe/pages/dashboard"
|
2016-11-19 23:54:31 +09:00
|
|
|
"github.com/animenotifier/notify.moe/pages/forum"
|
2016-11-20 03:02:33 +09:00
|
|
|
"github.com/animenotifier/notify.moe/pages/forums"
|
2017-06-21 03:05:34 +02:00
|
|
|
"github.com/animenotifier/notify.moe/pages/login"
|
2017-06-21 03:46:15 +02:00
|
|
|
"github.com/animenotifier/notify.moe/pages/popularanime"
|
2016-11-22 12:34:59 +09:00
|
|
|
"github.com/animenotifier/notify.moe/pages/posts"
|
2016-11-20 19:26:11 +09:00
|
|
|
"github.com/animenotifier/notify.moe/pages/profile"
|
2016-11-22 12:34:59 +09:00
|
|
|
"github.com/animenotifier/notify.moe/pages/search"
|
2017-06-18 17:16:40 +02:00
|
|
|
"github.com/animenotifier/notify.moe/pages/settings"
|
2016-11-19 23:54:31 +09:00
|
|
|
"github.com/animenotifier/notify.moe/pages/threads"
|
2017-06-20 14:16:23 +02:00
|
|
|
"github.com/animenotifier/notify.moe/pages/user"
|
2016-12-06 12:36:31 +09:00
|
|
|
"github.com/animenotifier/notify.moe/pages/users"
|
2017-06-20 11:13:56 +02:00
|
|
|
"github.com/animenotifier/notify.moe/pages/webdev"
|
2017-06-17 01:12:28 +02:00
|
|
|
"github.com/animenotifier/notify.moe/utils"
|
2016-11-09 20:32:19 +09:00
|
|
|
)
|
|
|
|
|
|
|
|
var app = aero.New()
|
|
|
|
|
|
|
|
func main() {
|
2017-06-22 16:08:34 +02:00
|
|
|
// Configure and start
|
|
|
|
configure(app).Run()
|
|
|
|
}
|
|
|
|
|
|
|
|
func configure(app *aero.Application) *aero.Application {
|
2016-12-03 00:23:05 +09:00
|
|
|
// HTTPS
|
2016-12-06 12:36:31 +09:00
|
|
|
app.Security.Load("security/fullchain.pem", "security/privkey.pem")
|
2016-12-03 00:23:05 +09:00
|
|
|
|
2017-06-11 11:13:59 +02:00
|
|
|
// CSS
|
|
|
|
app.SetStyle(components.CSS())
|
|
|
|
|
2017-06-17 22:19:26 +02:00
|
|
|
// Sessions
|
|
|
|
app.Sessions.Duration = 3600 * 24
|
|
|
|
app.Sessions.Store = arn.NewAerospikeStore("Session", app.Sessions.Duration)
|
2017-06-08 23:26:58 +02:00
|
|
|
|
2016-11-29 01:06:00 +09:00
|
|
|
// Layout
|
2017-06-15 23:03:55 +02:00
|
|
|
app.Layout = layout.Render
|
2016-11-09 20:32:19 +09:00
|
|
|
|
2016-11-29 01:06:00 +09:00
|
|
|
// Ajax routes
|
2017-06-02 16:17:58 +02:00
|
|
|
app.Ajax("/", dashboard.Get)
|
2017-06-21 00:00:40 +02:00
|
|
|
app.Ajax("/anime", popularanime.Get)
|
2016-11-19 23:54:31 +09:00
|
|
|
app.Ajax("/anime/:id", anime.Get)
|
2016-11-20 03:02:33 +09:00
|
|
|
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)
|
2016-11-22 12:34:59 +09:00
|
|
|
app.Ajax("/posts/:id", posts.Get)
|
2017-06-20 14:16:23 +02:00
|
|
|
app.Ajax("/user", user.Get)
|
2016-11-20 19:26:11 +09:00
|
|
|
app.Ajax("/user/:nick", profile.Get)
|
2017-06-17 01:25:02 +02:00
|
|
|
app.Ajax("/user/:nick/threads", profile.GetThreadsByUser)
|
2017-06-22 11:21:26 -03:00
|
|
|
app.Ajax("/user/:nick/posts", profile.GetPostsByUser)
|
2017-06-19 22:16:01 +02:00
|
|
|
app.Ajax("/user/:nick/animelist", animelist.Get)
|
2017-06-19 20:59:02 +02:00
|
|
|
app.Ajax("/user/:nick/animelist/:id", animelistitem.Get)
|
2017-06-18 17:16:40 +02:00
|
|
|
app.Ajax("/settings", settings.Get)
|
|
|
|
app.Ajax("/admin", admin.Get)
|
2017-06-20 22:54:45 +02:00
|
|
|
app.Ajax("/search/:term", search.Get)
|
2016-12-06 12:36:31 +09:00
|
|
|
app.Ajax("/users", users.Get)
|
2017-06-21 03:05:34 +02:00
|
|
|
app.Ajax("/login", login.Get)
|
2017-06-10 02:19:31 +02:00
|
|
|
app.Ajax("/airing", airing.Get)
|
2017-06-20 11:13:56 +02:00
|
|
|
app.Ajax("/webdev", webdev.Get)
|
2017-06-11 11:13:59 +02:00
|
|
|
// app.Ajax("/genres", genres.Get)
|
|
|
|
// app.Ajax("/genres/:name", genre.Get)
|
2017-06-06 16:59:04 +02:00
|
|
|
|
2017-06-17 01:12:28 +02:00
|
|
|
// Middleware
|
2017-06-17 01:25:02 +02:00
|
|
|
app.Use(middleware.Log())
|
|
|
|
app.Use(middleware.Session())
|
2017-06-22 20:51:11 +02:00
|
|
|
app.Use(middleware.UserInfo())
|
2017-06-12 21:11:20 +02:00
|
|
|
|
2017-06-17 01:12:28 +02:00
|
|
|
// API
|
|
|
|
api := api.New("/api/", arn.DB)
|
|
|
|
api.Install(app)
|
2017-06-12 21:11:20 +02:00
|
|
|
|
2017-06-17 01:12:28 +02:00
|
|
|
// Domain
|
|
|
|
if utils.IsDevelopment() {
|
|
|
|
app.Config.Domain = "beta.notify.moe"
|
|
|
|
}
|
2017-06-04 01:17:00 +02:00
|
|
|
|
2017-06-15 19:56:09 +02:00
|
|
|
// Authentication
|
2017-06-17 01:32:47 +02:00
|
|
|
auth.Install(app)
|
2017-06-15 19:56:09 +02:00
|
|
|
|
2017-06-22 16:08:34 +02:00
|
|
|
return app
|
2016-11-09 20:32:19 +09:00
|
|
|
}
|