150 lines
5.3 KiB
Go
Raw Normal View History

2016-11-09 11:32:19 +00:00
package main
import (
2016-11-09 13:11:49 +00:00
"github.com/aerogo/aero"
2017-06-16 23:12:28 +00:00
"github.com/aerogo/api"
"github.com/aerogo/session-store-aerospike"
2017-06-08 21:26:58 +00:00
"github.com/animenotifier/arn"
2017-06-16 23:32:47 +00:00
"github.com/animenotifier/notify.moe/auth"
"github.com/animenotifier/notify.moe/components/css"
2017-06-15 21:03:55 +00:00
"github.com/animenotifier/notify.moe/layout"
2017-06-16 23:12:28 +00:00
"github.com/animenotifier/notify.moe/middleware"
2017-06-18 15:16:40 +00:00
"github.com/animenotifier/notify.moe/pages/admin"
2016-11-19 14:54:31 +00:00
"github.com/animenotifier/notify.moe/pages/anime"
2017-06-19 20:16:01 +00:00
"github.com/animenotifier/notify.moe/pages/animelist"
2017-06-19 18:59:02 +00:00
"github.com/animenotifier/notify.moe/pages/animelistitem"
2017-07-01 12:03:10 +00:00
"github.com/animenotifier/notify.moe/pages/apiview"
2017-07-01 00:14:14 +00:00
"github.com/animenotifier/notify.moe/pages/best"
2017-07-13 06:23:20 +00:00
"github.com/animenotifier/notify.moe/pages/character"
2017-06-02 14:17:58 +00:00
"github.com/animenotifier/notify.moe/pages/dashboard"
2017-06-28 15:55:08 +00:00
"github.com/animenotifier/notify.moe/pages/editanime"
2017-07-08 19:11:03 +00:00
"github.com/animenotifier/notify.moe/pages/editor"
2017-06-24 19:07:45 +00:00
"github.com/animenotifier/notify.moe/pages/embed"
2017-06-30 23:16:25 +00:00
"github.com/animenotifier/notify.moe/pages/explore"
2016-11-19 14:54:31 +00:00
"github.com/animenotifier/notify.moe/pages/forum"
"github.com/animenotifier/notify.moe/pages/forums"
2017-07-03 17:33:52 +00:00
"github.com/animenotifier/notify.moe/pages/listimport"
"github.com/animenotifier/notify.moe/pages/listimport/listimportanilist"
2017-07-12 06:24:26 +00:00
"github.com/animenotifier/notify.moe/pages/listimport/listimportkitsu"
2017-07-07 23:18:21 +00:00
"github.com/animenotifier/notify.moe/pages/listimport/listimportmyanimelist"
2017-06-21 01:05:34 +00:00
"github.com/animenotifier/notify.moe/pages/login"
2017-06-27 10:39:41 +00:00
"github.com/animenotifier/notify.moe/pages/music"
2017-06-27 12:56:22 +00:00
"github.com/animenotifier/notify.moe/pages/newsoundtrack"
2017-06-27 02:15:52 +00:00
"github.com/animenotifier/notify.moe/pages/newthread"
"github.com/animenotifier/notify.moe/pages/posts"
2016-11-20 10:26:11 +00:00
"github.com/animenotifier/notify.moe/pages/profile"
"github.com/animenotifier/notify.moe/pages/search"
2017-06-18 15:16:40 +00:00
"github.com/animenotifier/notify.moe/pages/settings"
2017-07-07 00:07:34 +00:00
"github.com/animenotifier/notify.moe/pages/statistics"
2016-11-19 14:54:31 +00:00
"github.com/animenotifier/notify.moe/pages/threads"
2017-06-27 22:16:45 +00:00
"github.com/animenotifier/notify.moe/pages/tracks"
2017-06-20 12:16:23 +00:00
"github.com/animenotifier/notify.moe/pages/user"
2016-12-06 03:36:31 +00:00
"github.com/animenotifier/notify.moe/pages/users"
2017-06-20 09:13:56 +00:00
"github.com/animenotifier/notify.moe/pages/webdev"
2016-11-09 11:32:19 +00:00
)
var app = aero.New()
func main() {
2017-06-22 14:08:34 +00:00
// Configure and start
configure(app).Run()
}
func configure(app *aero.Application) *aero.Application {
2016-12-02 15:23:05 +00:00
// HTTPS
2016-12-06 03:36:31 +00:00
app.Security.Load("security/fullchain.pem", "security/privkey.pem")
2016-12-02 15:23:05 +00:00
2017-06-11 09:13:59 +00:00
// CSS
app.SetStyle(css.Bundle())
2017-06-11 09:13:59 +00:00
2017-06-17 20:19:26 +00:00
// Sessions
2017-06-27 18:01:24 +00:00
app.Sessions.Duration = 3600 * 24 * 7
app.Sessions.Store = aerospikestore.New(arn.DB, "Session", app.Sessions.Duration)
2017-06-08 21:26:58 +00:00
// Layout
2017-06-15 21:03:55 +00:00
app.Layout = layout.Render
2016-11-09 11:32:19 +00:00
// Ajax routes
2017-06-02 14:17:58 +00:00
app.Ajax("/", dashboard.Get)
2016-11-19 14:54:31 +00:00
app.Ajax("/anime/:id", anime.Get)
2017-06-28 15:55:08 +00:00
app.Ajax("/anime/:id/edit", editanime.Get)
2017-07-01 12:03:10 +00:00
app.Ajax("/api", apiview.Get)
2017-07-01 00:14:14 +00:00
app.Ajax("/best/anime", best.Get)
app.Ajax("/explore", explore.Get)
app.Ajax("/forum", forums.Get)
2016-11-19 14:54:31 +00:00
app.Ajax("/forum/:tag", forum.Get)
app.Ajax("/thread/:id", threads.Get)
app.Ajax("/post/:id", posts.Get)
2017-07-13 06:23:20 +00:00
app.Ajax("/track/:id", tracks.Get)
app.Ajax("/character/:id", character.Get)
2017-07-08 19:11:03 +00:00
app.Ajax("/new/thread", newthread.Get)
app.Ajax("/new/soundtrack", newsoundtrack.Get)
app.Ajax("/settings", settings.Get)
app.Ajax("/music", music.Get)
app.Ajax("/users", users.Get)
app.Ajax("/login", login.Get)
// User profiles
2017-06-20 12:16:23 +00:00
app.Ajax("/user", user.Get)
2016-11-20 10:26:11 +00:00
app.Ajax("/user/:nick", profile.Get)
2017-06-16 23:25:02 +00:00
app.Ajax("/user/:nick/threads", profile.GetThreadsByUser)
2017-06-22 14:21:26 +00:00
app.Ajax("/user/:nick/posts", profile.GetPostsByUser)
2017-06-27 18:12:08 +00:00
app.Ajax("/user/:nick/tracks", profile.GetSoundTracksByUser)
2017-07-13 00:32:36 +00:00
app.Ajax("/user/:nick/stats", profile.GetStatsByUser)
2017-06-19 20:16:01 +00:00
app.Ajax("/user/:nick/animelist", animelist.Get)
2017-07-05 14:52:24 +00:00
app.Ajax("/user/:nick/animelist/watching", animelist.FilterByStatus(arn.AnimeListStatusWatching))
app.Ajax("/user/:nick/animelist/completed", animelist.FilterByStatus(arn.AnimeListStatusCompleted))
app.Ajax("/user/:nick/animelist/planned", animelist.FilterByStatus(arn.AnimeListStatusPlanned))
app.Ajax("/user/:nick/animelist/hold", animelist.FilterByStatus(arn.AnimeListStatusHold))
app.Ajax("/user/:nick/animelist/dropped", animelist.FilterByStatus(arn.AnimeListStatusDropped))
app.Ajax("/user/:nick/animelist/anime/:id", animelistitem.Get)
2017-07-08 19:11:03 +00:00
// Search
app.Ajax("/search", search.Get)
app.Ajax("/search/:term", search.Get)
// Admin
app.Ajax("/admin", admin.Get)
app.Ajax("/editor", editor.Get)
app.Ajax("/statistics", statistics.Get)
app.Ajax("/statistics/anime", statistics.Anime)
app.Ajax("/webdev", webdev.Get)
// Import
2017-07-03 17:33:52 +00:00
app.Ajax("/import", listimport.Get)
2017-07-04 22:40:03 +00:00
app.Ajax("/import/anilist/animelist", listimportanilist.Preview)
app.Ajax("/import/anilist/animelist/finish", listimportanilist.Finish)
2017-07-07 23:18:21 +00:00
app.Ajax("/import/myanimelist/animelist", listimportmyanimelist.Preview)
app.Ajax("/import/myanimelist/animelist/finish", listimportmyanimelist.Finish)
2017-07-12 06:24:26 +00:00
app.Ajax("/import/kitsu/animelist", listimportkitsu.Preview)
app.Ajax("/import/kitsu/animelist/finish", listimportkitsu.Finish)
2017-07-08 19:11:03 +00:00
// Genres
2017-06-11 09:13:59 +00:00
// app.Ajax("/genres", genres.Get)
// app.Ajax("/genres/:name", genre.Get)
2017-06-06 14:59:04 +00:00
2017-07-08 19:11:03 +00:00
// Browser extension
app.Ajax("/extension/embed", embed.Get)
2017-06-16 23:12:28 +00:00
// Middleware
2017-06-16 23:25:02 +00:00
app.Use(middleware.Log())
app.Use(middleware.Session())
app.Use(middleware.UserInfo())
2017-06-12 19:11:20 +00:00
2017-06-16 23:12:28 +00:00
// API
api := api.New("/api/", arn.DB)
api.Install(app)
2017-06-12 19:11:20 +00:00
2017-06-16 23:12:28 +00:00
// Domain
2017-06-23 17:22:39 +00:00
if arn.IsDevelopment() {
2017-06-16 23:12:28 +00:00
app.Config.Domain = "beta.notify.moe"
2017-07-01 00:28:50 +00:00
} else {
arn.DB.SetScanPriority("high")
2017-06-16 23:12:28 +00:00
}
2017-06-03 23:17:00 +00:00
2017-06-15 17:56:09 +00:00
// Authentication
2017-06-16 23:32:47 +00:00
auth.Install(app)
2017-06-15 17:56:09 +00:00
2017-06-22 14:08:34 +00:00
return app
2016-11-09 11:32:19 +00:00
}