Cleanup
This commit is contained in:
parent
a9f88db566
commit
88614d412b
6
main.go
6
main.go
@ -45,7 +45,7 @@ func main() {
|
|||||||
app.Ajax("/threads/:id", threads.Get)
|
app.Ajax("/threads/:id", threads.Get)
|
||||||
app.Ajax("/posts/:id", posts.Get)
|
app.Ajax("/posts/:id", posts.Get)
|
||||||
app.Ajax("/user/:nick", profile.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("/users", users.Get)
|
||||||
app.Ajax("/airing", airing.Get)
|
app.Ajax("/airing", airing.Get)
|
||||||
app.Ajax("/awards", awards.Get)
|
app.Ajax("/awards", awards.Get)
|
||||||
@ -53,8 +53,8 @@ func main() {
|
|||||||
// app.Ajax("/genres/:name", genre.Get)
|
// app.Ajax("/genres/:name", genre.Get)
|
||||||
|
|
||||||
// Middleware
|
// Middleware
|
||||||
app.Use(middleware.RequestLog())
|
app.Use(middleware.Log())
|
||||||
app.Use(middleware.SaveSession())
|
app.Use(middleware.Session())
|
||||||
|
|
||||||
// API
|
// API
|
||||||
api := api.New("/api/", arn.DB)
|
api := api.New("/api/", arn.DB)
|
||||||
|
@ -11,8 +11,8 @@ import (
|
|||||||
"github.com/aerogo/log"
|
"github.com/aerogo/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RequestLog logs every request into logs/request.log.
|
// Log middleware logs every request into logs/request.log.
|
||||||
func RequestLog() aero.Middleware {
|
func Log() aero.Middleware {
|
||||||
err := log.NewLog()
|
err := log.NewLog()
|
||||||
err.AddOutput(log.File("logs/error.log"))
|
err.AddOutput(log.File("logs/error.log"))
|
||||||
err.AddOutput(os.Stderr)
|
err.AddOutput(os.Stderr)
|
@ -2,8 +2,8 @@ package middleware
|
|||||||
|
|
||||||
import "github.com/aerogo/aero"
|
import "github.com/aerogo/aero"
|
||||||
|
|
||||||
// SaveSession saves an existing session if it has been modified.
|
// Session middleware saves an existing session if it has been modified.
|
||||||
func SaveSession() aero.Middleware {
|
func Session() aero.Middleware {
|
||||||
return func(ctx *aero.Context, next func()) {
|
return func(ctx *aero.Context, next func()) {
|
||||||
// Handle the request first
|
// Handle the request first
|
||||||
next()
|
next()
|
@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get ...
|
// Get anime page.
|
||||||
func Get(ctx *aero.Context) string {
|
func Get(ctx *aero.Context) string {
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
anime, err := arn.GetAnime(id)
|
anime, err := arn.GetAnime(id)
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
|
|
||||||
const maxPosts = 5
|
const maxPosts = 5
|
||||||
|
|
||||||
// Get ...
|
// Get dashboard.
|
||||||
func Get(ctx *aero.Context) string {
|
func Get(ctx *aero.Context) string {
|
||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
const threadsPerPage = 20
|
const threadsPerPage = 20
|
||||||
|
|
||||||
// Get ...
|
// Get forum category.
|
||||||
func Get(ctx *aero.Context) string {
|
func Get(ctx *aero.Context) string {
|
||||||
tag := ctx.Get("tag")
|
tag := ctx.Get("tag")
|
||||||
threads, _ := arn.GetThreadsByTag(tag)
|
threads, _ := arn.GetThreadsByTag(tag)
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/pages/forum"
|
"github.com/animenotifier/notify.moe/pages/forum"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get ...
|
// Get forums page.
|
||||||
func Get(ctx *aero.Context) string {
|
func Get(ctx *aero.Context) string {
|
||||||
return forum.Get(ctx)
|
return forum.Get(ctx)
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get ...
|
// Get post.
|
||||||
func Get(ctx *aero.Context) string {
|
func Get(ctx *aero.Context) string {
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
post, err := arn.GetPost(id)
|
post, err := arn.GetPost(id)
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
const maxPosts = 5
|
const maxPosts = 5
|
||||||
|
|
||||||
// Get ...
|
// Get user profile page.
|
||||||
func Get(ctx *aero.Context) string {
|
func Get(ctx *aero.Context) string {
|
||||||
nick := ctx.Get("nick")
|
nick := ctx.Get("nick")
|
||||||
viewUser, err := arn.GetUserByNick(nick)
|
viewUser, err := arn.GetUserByNick(nick)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package threads
|
package profile
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -8,8 +8,8 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetByUser ...
|
// GetThreadsByUser shows all forum threads of a particular user.
|
||||||
func GetByUser(ctx *aero.Context) string {
|
func GetThreadsByUser(ctx *aero.Context) string {
|
||||||
nick := ctx.Get("nick")
|
nick := ctx.Get("nick")
|
||||||
user, err := arn.GetUserByNick(nick)
|
user, err := arn.GetUserByNick(nick)
|
||||||
|
|
@ -4,7 +4,7 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get ...
|
// Get search page.
|
||||||
func Get(ctx *aero.Context) string {
|
func Get(ctx *aero.Context) string {
|
||||||
// titleCount := 0
|
// titleCount := 0
|
||||||
// animeCount := 0
|
// animeCount := 0
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get ...
|
// Get thread.
|
||||||
func Get(ctx *aero.Context) string {
|
func Get(ctx *aero.Context) string {
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
thread, err := arn.GetThread(id)
|
thread, err := arn.GetThread(id)
|
||||||
|
Loading…
Reference in New Issue
Block a user