From 1f9e4cab475c2ca74dbbaddfa9941a3ee6127c11 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Mon, 2 Sep 2019 08:19:10 +0900 Subject: [PATCH] Better routes splitting --- pages/database/download.go | 10 +++++++++ pages/index.go | 2 ++ pages/index/activityroutes/activityroutes.go | 15 +++++++++++++ pages/index/animeroutes/animeroutes.go | 9 ++++++++ pages/index/apiroutes/apiroutes.go | 3 ++- pages/index/coreroutes/coreroutes.go | 23 -------------------- 6 files changed, 38 insertions(+), 24 deletions(-) create mode 100644 pages/database/download.go create mode 100644 pages/index/activityroutes/activityroutes.go diff --git a/pages/database/download.go b/pages/database/download.go new file mode 100644 index 00000000..1b2caf4f --- /dev/null +++ b/pages/database/download.go @@ -0,0 +1,10 @@ +package database + +import ( + "github.com/aerogo/aero" +) + +// Download downloads a snapshot of a database collection. +func Download(ctx aero.Context) error { + return nil +} diff --git a/pages/index.go b/pages/index.go index 37c6a282..074e697e 100644 --- a/pages/index.go +++ b/pages/index.go @@ -4,6 +4,7 @@ import ( "strings" "github.com/aerogo/aero" + "github.com/animenotifier/notify.moe/pages/index/activityroutes" "github.com/animenotifier/notify.moe/pages/index/amvroutes" "github.com/animenotifier/notify.moe/pages/index/animeroutes" "github.com/animenotifier/notify.moe/pages/index/apiroutes" @@ -31,6 +32,7 @@ func Configure(app *aero.Application) { userroutes.Register(app) characterroutes.Register(app) exploreroutes.Register(app) + activityroutes.Register(app) amvroutes.Register(app) forumroutes.Register(app) animeroutes.Register(app) diff --git a/pages/index/activityroutes/activityroutes.go b/pages/index/activityroutes/activityroutes.go new file mode 100644 index 00000000..5718f314 --- /dev/null +++ b/pages/index/activityroutes/activityroutes.go @@ -0,0 +1,15 @@ +package activityroutes + +import ( + "github.com/aerogo/aero" + "github.com/animenotifier/notify.moe/pages/activity" + "github.com/animenotifier/notify.moe/utils/page" +) + +// Register registers the page routes. +func Register(app *aero.Application) { + page.Get(app, "/activity", activity.Global) + page.Get(app, "/activity/from/:index", activity.Global) + page.Get(app, "/activity/followed", activity.Followed) + page.Get(app, "/activity/followed/from/:index", activity.Followed) +} diff --git a/pages/index/animeroutes/animeroutes.go b/pages/index/animeroutes/animeroutes.go index 20d657e3..a3ea6e9a 100644 --- a/pages/index/animeroutes/animeroutes.go +++ b/pages/index/animeroutes/animeroutes.go @@ -4,9 +4,11 @@ import ( "github.com/aerogo/aero" "github.com/animenotifier/notify.moe/pages/anime" "github.com/animenotifier/notify.moe/pages/anime/editanime" + "github.com/animenotifier/notify.moe/pages/calendar" "github.com/animenotifier/notify.moe/pages/episode" "github.com/animenotifier/notify.moe/pages/genre" "github.com/animenotifier/notify.moe/pages/genres" + "github.com/animenotifier/notify.moe/pages/statistics" "github.com/animenotifier/notify.moe/utils/page" ) @@ -38,4 +40,11 @@ func Register(app *aero.Application) { // Genres page.Get(app, "/genres", genres.Get) page.Get(app, "/genre/:name", genre.Get) + + // Calendar + page.Get(app, "/calendar", calendar.Get) + + // Statistics + page.Get(app, "/statistics", statistics.Get) + page.Get(app, "/statistics/anime", statistics.Anime) } diff --git a/pages/index/apiroutes/apiroutes.go b/pages/index/apiroutes/apiroutes.go index 530ca496..42f16173 100644 --- a/pages/index/apiroutes/apiroutes.go +++ b/pages/index/apiroutes/apiroutes.go @@ -52,8 +52,9 @@ func Register(app *aero.Application) { // Post app.Get("/api/post/:id/reply/ui", post.ReplyUI) - // Post + // Types app.Get("/api/types", database.Types) + app.Get("/api/types/:type/all", database.Download) // SoundTrack app.Post("/api/soundtrack/:id/download", soundtrack.Download) diff --git a/pages/index/coreroutes/coreroutes.go b/pages/index/coreroutes/coreroutes.go index 7e111225..756a5635 100644 --- a/pages/index/coreroutes/coreroutes.go +++ b/pages/index/coreroutes/coreroutes.go @@ -2,12 +2,9 @@ package coreroutes import ( "github.com/aerogo/aero" - "github.com/animenotifier/notify.moe/pages/activity" - "github.com/animenotifier/notify.moe/pages/calendar" "github.com/animenotifier/notify.moe/pages/embed" "github.com/animenotifier/notify.moe/pages/home" "github.com/animenotifier/notify.moe/pages/login" - "github.com/animenotifier/notify.moe/pages/statistics" "github.com/animenotifier/notify.moe/pages/terms" "github.com/animenotifier/notify.moe/pages/welcome" "github.com/animenotifier/notify.moe/utils/page" @@ -15,29 +12,9 @@ import ( // Register registers the page routes. func Register(app *aero.Application) { - // Front page page.Get(app, "/", home.Get) - - // Login page.Get(app, "/login", login.Get) - - // Welcome page.Get(app, "/welcome", welcome.Get) - - // Activity - page.Get(app, "/activity", activity.Global) - page.Get(app, "/activity/from/:index", activity.Global) - page.Get(app, "/activity/followed", activity.Followed) - page.Get(app, "/activity/followed/from/:index", activity.Followed) - - // Calendar - page.Get(app, "/calendar", calendar.Get) - - // Statistics - page.Get(app, "/statistics", statistics.Get) - page.Get(app, "/statistics/anime", statistics.Anime) - - // Legal stuff page.Get(app, "/terms", terms.Get) // Browser extension