diff --git a/main.go b/main.go index 61be8ff7..84ca0351 100644 --- a/main.go +++ b/main.go @@ -45,7 +45,7 @@ func main() { app.Ajax("/threads/:id", threads.Get) app.Ajax("/posts/:id", posts.Get) app.Ajax("/user/:nick", profile.Get) - app.Ajax("/user/:nick/threads", threads.GetByUser) + app.Ajax("/user/:nick/threads", profile.GetThreadsByUser) app.Ajax("/users", users.Get) app.Ajax("/airing", airing.Get) app.Ajax("/awards", awards.Get) @@ -53,8 +53,8 @@ func main() { // app.Ajax("/genres/:name", genre.Get) // Middleware - app.Use(middleware.RequestLog()) - app.Use(middleware.SaveSession()) + app.Use(middleware.Log()) + app.Use(middleware.Session()) // API api := api.New("/api/", arn.DB) diff --git a/middleware/request-log.go b/middleware/Log.go similarity index 92% rename from middleware/request-log.go rename to middleware/Log.go index c0072593..35f529ec 100644 --- a/middleware/request-log.go +++ b/middleware/Log.go @@ -11,8 +11,8 @@ import ( "github.com/aerogo/log" ) -// RequestLog logs every request into logs/request.log. -func RequestLog() aero.Middleware { +// Log middleware logs every request into logs/request.log. +func Log() aero.Middleware { err := log.NewLog() err.AddOutput(log.File("logs/error.log")) err.AddOutput(os.Stderr) diff --git a/middleware/save-session.go b/middleware/Session.go similarity index 74% rename from middleware/save-session.go rename to middleware/Session.go index 57f51705..b3838916 100644 --- a/middleware/save-session.go +++ b/middleware/Session.go @@ -2,8 +2,8 @@ package middleware import "github.com/aerogo/aero" -// SaveSession saves an existing session if it has been modified. -func SaveSession() aero.Middleware { +// Session middleware saves an existing session if it has been modified. +func Session() aero.Middleware { return func(ctx *aero.Context, next func()) { // Handle the request first next() diff --git a/pages/anime/anime.go b/pages/anime/anime.go index bcd2c4ec..f1389b38 100644 --- a/pages/anime/anime.go +++ b/pages/anime/anime.go @@ -6,7 +6,7 @@ import ( "github.com/animenotifier/notify.moe/components" ) -// Get ... +// Get anime page. func Get(ctx *aero.Context) string { id := ctx.Get("id") anime, err := arn.GetAnime(id) diff --git a/pages/dashboard/dashboard.go b/pages/dashboard/dashboard.go index af50fee9..97cc72fe 100644 --- a/pages/dashboard/dashboard.go +++ b/pages/dashboard/dashboard.go @@ -10,7 +10,7 @@ import ( const maxPosts = 5 -// Get ... +// Get dashboard. func Get(ctx *aero.Context) string { user := utils.GetUser(ctx) diff --git a/pages/forum/forum.go b/pages/forum/forum.go index 45c2c059..33b7ba6a 100644 --- a/pages/forum/forum.go +++ b/pages/forum/forum.go @@ -8,7 +8,7 @@ import ( const threadsPerPage = 20 -// Get ... +// Get forum category. func Get(ctx *aero.Context) string { tag := ctx.Get("tag") threads, _ := arn.GetThreadsByTag(tag) diff --git a/pages/forums/forums.go b/pages/forums/forums.go index 8ebdc72d..be137ffe 100644 --- a/pages/forums/forums.go +++ b/pages/forums/forums.go @@ -5,7 +5,7 @@ import ( "github.com/animenotifier/notify.moe/pages/forum" ) -// Get ... +// Get forums page. func Get(ctx *aero.Context) string { return forum.Get(ctx) } diff --git a/pages/posts/posts.go b/pages/posts/posts.go index 28b88db4..de0e45bd 100644 --- a/pages/posts/posts.go +++ b/pages/posts/posts.go @@ -6,7 +6,7 @@ import ( "github.com/animenotifier/notify.moe/components" ) -// Get ... +// Get post. func Get(ctx *aero.Context) string { id := ctx.Get("id") post, err := arn.GetPost(id) diff --git a/pages/profile/profile.go b/pages/profile/profile.go index 0ff355fa..47f6ff19 100644 --- a/pages/profile/profile.go +++ b/pages/profile/profile.go @@ -9,7 +9,7 @@ import ( const maxPosts = 5 -// Get ... +// Get user profile page. func Get(ctx *aero.Context) string { nick := ctx.Get("nick") viewUser, err := arn.GetUserByNick(nick) diff --git a/pages/threads/threadsByUser.go b/pages/profile/threads.go similarity index 74% rename from pages/threads/threadsByUser.go rename to pages/profile/threads.go index 7fe5b5f1..29cdd457 100644 --- a/pages/threads/threadsByUser.go +++ b/pages/profile/threads.go @@ -1,4 +1,4 @@ -package threads +package profile import ( "net/http" @@ -8,8 +8,8 @@ import ( "github.com/animenotifier/notify.moe/components" ) -// GetByUser ... -func GetByUser(ctx *aero.Context) string { +// GetThreadsByUser shows all forum threads of a particular user. +func GetThreadsByUser(ctx *aero.Context) string { nick := ctx.Get("nick") user, err := arn.GetUserByNick(nick) diff --git a/pages/search/search.go b/pages/search/search.go index f9a15766..8091fc4c 100644 --- a/pages/search/search.go +++ b/pages/search/search.go @@ -4,7 +4,7 @@ import ( "github.com/aerogo/aero" ) -// Get ... +// Get search page. func Get(ctx *aero.Context) string { // titleCount := 0 // animeCount := 0 diff --git a/pages/threads/threads.go b/pages/threads/threads.go index 912e4612..c2c112dd 100644 --- a/pages/threads/threads.go +++ b/pages/threads/threads.go @@ -6,7 +6,7 @@ import ( "github.com/animenotifier/notify.moe/components" ) -// Get ... +// Get thread. func Get(ctx *aero.Context) string { id := ctx.Get("id") thread, err := arn.GetThread(id)