Applied new layout system

This commit is contained in:
Eduard Urbach 2019-06-03 12:20:17 +09:00
parent 36427a1501
commit 3268488b7b
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
26 changed files with 346 additions and 308 deletions

View File

@ -43,7 +43,7 @@ component FooBar
Your page needs to become available on the `/foobar` route. Let's add it to `pages/index.go`, inside `Configure`:
```go
l.Page("/foobar", foobar.Get)
page.Get(app, "/foobar", foobar.Get)
```
Your IDE should automatically insert the needed package import upon saving the file.

5
go.mod
View File

@ -5,12 +5,11 @@ go 1.12
require (
cloud.google.com/go v0.39.0 // indirect
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
github.com/aerogo/aero v1.3.5
github.com/aerogo/aero v1.3.8
github.com/aerogo/api v0.2.0
github.com/aerogo/crawler v0.2.5
github.com/aerogo/graphql v0.4.0
github.com/aerogo/http v1.0.6
github.com/aerogo/layout v0.3.1
github.com/aerogo/log v0.2.5
github.com/aerogo/manifest v0.1.4
github.com/aerogo/markdown v0.1.8
@ -19,7 +18,7 @@ require (
github.com/aerogo/sitemap v0.1.3
github.com/akyoto/cache v1.0.2
github.com/akyoto/color v1.8.5
github.com/akyoto/hash v0.3.5
github.com/akyoto/hash v0.4.0
github.com/akyoto/stringutils v0.2.1
github.com/animenotifier/anilist v0.2.3
github.com/animenotifier/arn v1.2.0

23
go.sum
View File

@ -11,10 +11,8 @@ github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUW
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/aerogo/aero v1.3.1 h1:P4XS4ePrJWSJwHLXKkX5YjFsoywhWuXf3dPIX5XVAW0=
github.com/aerogo/aero v1.3.1/go.mod h1:5rPhXo2DNMFQ7XhDsuZ3L7Zr6TH/349+WczUbrOUZvM=
github.com/aerogo/aero v1.3.3 h1:7pBFEirK/iUpCG4ts6ljL9bu1PXBbybSIZII3VETGSU=
github.com/aerogo/aero v1.3.3/go.mod h1:5rPhXo2DNMFQ7XhDsuZ3L7Zr6TH/349+WczUbrOUZvM=
github.com/aerogo/aero v1.3.5 h1:XTf9p+caxq9IYL7G4MOg9aGZBKpPq2RaS/BvaKMIeIE=
github.com/aerogo/aero v1.3.5/go.mod h1:5rPhXo2DNMFQ7XhDsuZ3L7Zr6TH/349+WczUbrOUZvM=
github.com/aerogo/aero v1.3.8 h1:bKYigLZx4NupGb2mu2I0KdvQH2Kq8rP7Xg1scrz10sQ=
github.com/aerogo/aero v1.3.8/go.mod h1:DZA+Yt0AevLyvNG7w1CyYoZZfoFMysABOOrFrgrQhHM=
github.com/aerogo/api v0.2.0 h1:mIc/y381e+Qc85eSc2cKPdpDDOmT0hlnEeCw2Dcf7no=
github.com/aerogo/api v0.2.0/go.mod h1:6objJn5XiKpYpywQUPrFjxZIXD4NVI2LwcBNYCEcS3Y=
github.com/aerogo/cluster v0.1.6 h1:9HYjJwo19uuh9thIc80T3caap9t9b4BXZ1iN8aztjlU=
@ -35,8 +33,6 @@ github.com/aerogo/http v1.0.3 h1:vf6A+Igme5OHQPaP3a00uPDS0oxsx3puMA23d1NsWDM=
github.com/aerogo/http v1.0.3/go.mod h1:B1igUmMLpE6KabMpc9reHCJJNUOJ2U/PR9s1fF3TpPQ=
github.com/aerogo/http v1.0.6 h1:+aswlcWlUxjVcokF8hUjNJmGIEZuhbFbHi8uSadEvtc=
github.com/aerogo/http v1.0.6/go.mod h1:LwJ7b+LjrHj60FhYQ586K3/O7aNGxkE2dy/exEkQ6rA=
github.com/aerogo/layout v0.3.1 h1:XLXYCU8vgifSZMIpM0m1Qk8UffyKg4KvhF/naHJI3mg=
github.com/aerogo/layout v0.3.1/go.mod h1:n+/yJdPnYWaNzBZccNiNn3WiRzoYgXYJPaowqhYftcM=
github.com/aerogo/linter-performance v1.0.3 h1:pYsmUd8jp6CVrFx+YNo9Gfdf222CKG2gCVjp8cljZNY=
github.com/aerogo/linter-performance v1.0.3/go.mod h1:po6XSSbSgR30lazzqSRGV++a2omxYr2qjqFvcvUCH40=
github.com/aerogo/log v0.2.5 h1:LGeElbLqyaD8r8Ls9HuG7tYF6YV4kP56IxJWl/b4cZQ=
@ -77,6 +73,8 @@ github.com/akyoto/go-matroska v0.1.1 h1:HgoCAkeWrGjYr0FZr3yCzAIkXuOGRiVil7Ul329l
github.com/akyoto/go-matroska v0.1.1/go.mod h1:x+GUVwyby6HN/MKKNP4BvGqP9VrHuEznfBf288gehek=
github.com/akyoto/hash v0.3.5 h1:5EJGHx6RfE9aHrEzWU3pfLGFUWMvPVqtsxt7mSON+mY=
github.com/akyoto/hash v0.3.5/go.mod h1:uPmnZyhBJIyLON8V9LNi0CcqtwYaH2RiKLFQg67fwq0=
github.com/akyoto/hash v0.4.0 h1:M9Q3E6cOAxbf7q3yu5SZZdbZxC4thndCkqJctxl1+zg=
github.com/akyoto/hash v0.4.0/go.mod h1:purxg2OohOWT7H0oLP0xQF1DG/EbazUbw7zomRUk8Y8=
github.com/akyoto/imageserver v0.3.6 h1:Sxcbgo45Lh7afcSmcU8OS49VYbqh4kE3DK0Lxuuxf74=
github.com/akyoto/imageserver v0.3.6/go.mod h1:9AuMUxIt5CPlTmJre4ETwWxRnThOkkE1EhavC8HX4U8=
github.com/akyoto/stringutils v0.2.0 h1:86gMW/31LO7zc8mGGWB4gLqyFzrNHMZYyj6ebSQbpH4=
@ -109,6 +107,7 @@ github.com/animenotifier/twist v0.2.3 h1:81esnkQaPKj9b7UIor3VTrziMt4nMNtcb2OoHZp
github.com/animenotifier/twist v0.2.3/go.mod h1:/D0ya3VliOavlgUQLpzJHq3YWZ1Gu3Mgq0NHYS9GOEg=
github.com/bwmarrin/discordgo v0.19.0 h1:kMED/DB0NR1QhRcalb85w0Cu3Ep2OrGAqZH1R5awQiY=
github.com/bwmarrin/discordgo v0.19.0/go.mod h1:O9S4p+ofTFwB02em7jkpkV8M3R0/PUVOwN61zSZ0r4Q=
github.com/campoy/embedmd v1.0.0/go.mod h1:oxyr9RCiSXg0M3VJ3ks0UGfp98BpSSGr0kpiX3MzVl8=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@ -116,6 +115,7 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dlespiau/covertool v0.0.0-20180314162135-b0c4c6d0583a/go.mod h1:/eQMcW3eA1bzKx23ZYI2H3tXPdJB5JWYTHzoUPBvQY4=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/frankban/quicktest v1.4.0 h1:rCSCih1FnSWJEel/eub9wclBSqpF2F/PuvxUWGWnbO8=
@ -179,6 +179,9 @@ github.com/minio/minio-go v6.0.14+incompatible h1:fnV+GD28LeqdN6vT2XdGKW8Qe/IfjJ
github.com/minio/minio-go v6.0.14+incompatible/go.mod h1:7guKYtitv8dktvNUGrhzmNlA5wrAABTQXCoesZdFQO8=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mmcloughlin/avo v0.0.0-20190318053554-7a0eb66183da/go.mod h1:lf5GMZxA5kz8dnCweJuER5Rmbx6dDu6qvw0fO3uYKK8=
github.com/mmcloughlin/avo v0.0.0-20190515040033-83fbad1a6b3c h1:5h3Y/BxvWNkTaLi716IIqjLFYfGmziT3hhBHEKRgH44=
github.com/mmcloughlin/avo v0.0.0-20190515040033-83fbad1a6b3c/go.mod h1:lf5GMZxA5kz8dnCweJuER5Rmbx6dDu6qvw0fO3uYKK8=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
@ -217,11 +220,15 @@ github.com/teris-io/shortid v0.0.0-20171029131806-771a37caa5cf h1:Z2X3Os7oRzpdJ7
github.com/teris-io/shortid v0.0.0-20171029131806-771a37caa5cf/go.mod h1:M8agBzgqHIhgj7wEn9/0hJUZcrvt9VY+Ln+S1I5Mha0=
github.com/ungerik/go-gravatar v0.0.0-20120802094239-6ab22628222a h1:TZyMbJbyPL+4/ndyXns8aNDrmUJn5a6aV8lj3qEM7fM=
github.com/ungerik/go-gravatar v0.0.0-20120802094239-6ab22628222a/go.mod h1:cmQAsXze586z5DHYfoVO9jZBampncP3iuhVgujPqdxk=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/ventu-io/go-shortid v0.0.0-20171029131806-771a37caa5cf h1:cgAKVljim9RJRcJNGjnBUajXj1FupBSdWwW4JaQG7vk=
github.com/ventu-io/go-shortid v0.0.0-20171029131806-771a37caa5cf/go.mod h1:6rZqAOk/eYX5FJyjQJ6Z3RBSN389IXX2ijwW4FcggaM=
github.com/xrash/smetrics v0.0.0-20170218160415-a3153f7040e9 h1:w8V9v0qVympSF6GjdjIyeqR7+EVhAF9CBQmkmW7Zw0w=
github.com/xrash/smetrics v0.0.0-20170218160415-a3153f7040e9/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
github.com/zeebo/xxh3 v0.0.0-20190402181837-148601fe83bd h1:0CwfhYjYmz+cyy8HCXOjPB6No7nLrwKm8nMrbypfSJk=
github.com/zeebo/xxh3 v0.0.0-20190402181837-148601fe83bd/go.mod h1:+RhiatAQMOV+Fp5BwtjGVpEUpW8jRsRxH556rHTRG+4=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
golang.org/x/arch v0.0.0-20181203225421-5a4828bb7045/go.mod h1:cYlCBUl1MsqxdiKgmc4uh7TxZfWSFLOGSRR090WDxt8=
golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529 h1:iMGN4xG0cnqj3t+zOM8wUB0BiPKHEwSxEZCvzcbZuvk=
@ -261,6 +268,7 @@ golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190316082340-a2f829d7f35f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190428183149-804c0c7841b5 h1:m0i9YywO9THhxmJvLEwKJDD/pD8ljCB+EaT/wYS41Is=
golang.org/x/sys v0.0.0-20190428183149-804c0c7841b5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@ -274,6 +282,8 @@ golang.org/x/sys v0.0.0-20190523142557-0e01d883c5c5 h1:sM3evRHxE/1RuMe1FYAL3j7C7
golang.org/x/sys v0.0.0-20190523142557-0e01d883c5c5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2 h1:T5DasATyLQfmbTpfEXx/IOL9vfjzW6up+ZDkmHvIf2s=
golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed h1:uPxWBzB3+mlnjy9W58qY1j/cjyFjutgw/Vhan2zLy/A=
golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2 h1:z99zHgr7hKfrUcX/KsoJk5FJfjTceCKIp96+biqP4To=
@ -282,6 +292,7 @@ golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190106171756-3ef68632349c/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=

View File

@ -1,38 +0,0 @@
package layout
import (
"sort"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/middleware"
"github.com/animenotifier/notify.moe/utils"
)
// Render layout.
func Render(ctx aero.Context, content string) string {
user := utils.GetUser(ctx)
customCtx := ctx.(*middleware.OpenGraphContext)
openGraph := customCtx.OpenGraph
// Make output order deterministic to profit from Aero caching.
// To do this, we need to create slices and sort the tags.
var meta []string
var tags []string
if openGraph != nil {
for name := range openGraph.Meta {
meta = append(meta, name)
}
sort.Strings(meta)
for name := range openGraph.Tags {
tags = append(tags, name)
}
sort.Strings(tags)
}
return components.Layout(ctx, user, openGraph, meta, tags, content)
}

View File

@ -46,6 +46,7 @@ func configure(app *aero.Application) *aero.Application {
// Middleware
app.Use(
middleware.OpenGraph,
middleware.Layout,
middleware.Log,
middleware.Session,
middleware.UserInfo,

51
middleware/Layout.go Normal file
View File

@ -0,0 +1,51 @@
package middleware
import (
"sort"
"strings"
"github.com/aerogo/aero"
"github.com/akyoto/stringutils/unsafe"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
)
// Layout middleware modifies the response body
// to be wrapped around the general layout.
func Layout(next aero.Handler) aero.Handler {
return func(ctx aero.Context) error {
if ctx.Request().Method() != "GET" || !strings.Contains(ctx.Request().Header("Accept"), "text/html") || strings.HasPrefix(ctx.Path(), "/_") || strings.HasPrefix(ctx.Path(), "/api/") || strings.HasPrefix(ctx.Path(), "/graphql") {
return next(ctx)
}
ctx.AddModifier(func(content []byte) []byte {
user := arn.GetUserFromContext(ctx)
customCtx := ctx.(*OpenGraphContext)
openGraph := customCtx.OpenGraph
// Make output order deterministic to profit from Aero caching.
// To do this, we need to create slices and sort the tags.
var meta []string
var tags []string
if openGraph != nil {
for name := range openGraph.Meta {
meta = append(meta, name)
}
sort.Strings(meta)
for name := range openGraph.Tags {
tags = append(tags, name)
}
sort.Strings(tags)
}
html := components.Layout(ctx, user, openGraph, meta, tags, unsafe.BytesToString(content))
return unsafe.StringToBytes(html)
})
return next(ctx)
}
}

View File

@ -2,8 +2,6 @@ package pages
import (
"github.com/aerogo/aero"
"github.com/aerogo/layout"
fullpage "github.com/animenotifier/notify.moe/layout"
"github.com/animenotifier/notify.moe/pages/index/amvroutes"
"github.com/animenotifier/notify.moe/pages/index/animeroutes"
"github.com/animenotifier/notify.moe/pages/index/apiroutes"
@ -26,32 +24,27 @@ import (
// Configure registers the page routes in the application.
func Configure(app *aero.Application) {
l := layout.New(app)
// Set render function for the layout
l.Render = fullpage.Render
// Register the routes
coreroutes.Register(l)
userroutes.Register(l)
characterroutes.Register(l)
exploreroutes.Register(l)
amvroutes.Register(l)
forumroutes.Register(l)
animeroutes.Register(l, app)
userlistroutes.Register(l)
quoteroutes.Register(l)
companyroutes.Register(l)
soundtrackroutes.Register(l)
grouproutes.Register(l)
searchroutes.Register(l)
importroutes.Register(l)
shoproutes.Register(l, app)
settingsroutes.Register(l)
staffroutes.Register(l)
apiroutes.Register(l, app)
coreroutes.Register(app)
userroutes.Register(app)
characterroutes.Register(app)
exploreroutes.Register(app)
amvroutes.Register(app)
forumroutes.Register(app)
animeroutes.Register(app)
userlistroutes.Register(app)
quoteroutes.Register(app)
companyroutes.Register(app)
soundtrackroutes.Register(app)
grouproutes.Register(app)
searchroutes.Register(app)
importroutes.Register(app)
shoproutes.Register(app)
settingsroutes.Register(app)
staffroutes.Register(app)
apiroutes.Register(app)
// Mixed
// l.Page("/database", database.Get)
// app.Get("/database", database.Get)
// app.Get("/api/select/:data-type/where/:field/is/:field-value", database.Select)
}

View File

@ -1,21 +1,22 @@
package amvroutes
import (
"github.com/aerogo/layout"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/pages/amv"
"github.com/animenotifier/notify.moe/pages/amvs"
"github.com/animenotifier/notify.moe/utils/page"
)
// Register registers the page routes.
func Register(l *layout.Layout) {
func Register(app *aero.Application) {
// AMV
l.Page("/amv/:id", amv.Get)
l.Page("/amv/:id/edit", amv.Edit)
l.Page("/amv/:id/history", amv.History)
page.Get(app, "/amv/:id", amv.Get)
page.Get(app, "/amv/:id/edit", amv.Edit)
page.Get(app, "/amv/:id/history", amv.History)
// AMVs
l.Page("/amvs", amvs.Latest)
l.Page("/amvs/from/:index", amvs.Latest)
l.Page("/amvs/best", amvs.Best)
l.Page("/amvs/best/from/:index", amvs.Best)
page.Get(app, "/amvs", amvs.Latest)
page.Get(app, "/amvs/from/:index", amvs.Latest)
page.Get(app, "/amvs/best", amvs.Best)
page.Get(app, "/amvs/best/from/:index", amvs.Best)
}

View File

@ -2,40 +2,40 @@ package animeroutes
import (
"github.com/aerogo/aero"
"github.com/aerogo/layout"
"github.com/animenotifier/notify.moe/pages/anime"
"github.com/animenotifier/notify.moe/pages/anime/editanime"
"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/utils/page"
)
// Register registers the page routes.
func Register(l *layout.Layout, app *aero.Application) {
func Register(app *aero.Application) {
// Anime
l.Page("/anime/:id", anime.Get)
l.Page("/anime/:id/episodes", anime.Episodes)
l.Page("/anime/:id/characters", anime.Characters)
l.Page("/anime/:id/tracks", anime.Tracks)
l.Page("/anime/:id/relations", anime.Relations)
l.Page("/anime/:id/comments", anime.Comments)
l.Page("/anime/:id/episode/:episode-number", episode.Get)
page.Get(app, "/anime/:id", anime.Get)
page.Get(app, "/anime/:id/episodes", anime.Episodes)
page.Get(app, "/anime/:id/characters", anime.Characters)
page.Get(app, "/anime/:id/tracks", anime.Tracks)
page.Get(app, "/anime/:id/relations", anime.Relations)
page.Get(app, "/anime/:id/comments", anime.Comments)
page.Get(app, "/anime/:id/episode/:episode-number", episode.Get)
app.Get("/anime/:id/episode/:episode-number/subtitles/:language", episode.Subtitles)
// Anime redirects
l.Page("/kitsu/anime/:id", anime.RedirectByMapping("kitsu/anime"))
l.Page("/mal/anime/:id", anime.RedirectByMapping("myanimelist/anime"))
l.Page("/anilist/anime/:id", anime.RedirectByMapping("anilist/anime"))
page.Get(app, "/kitsu/anime/:id", anime.RedirectByMapping("kitsu/anime"))
page.Get(app, "/mal/anime/:id", anime.RedirectByMapping("myanimelist/anime"))
page.Get(app, "/anilist/anime/:id", anime.RedirectByMapping("anilist/anime"))
// Edit anime
l.Page("/anime/:id/edit", editanime.Main)
l.Page("/anime/:id/edit/images", editanime.Images)
l.Page("/anime/:id/edit/characters", editanime.Characters)
l.Page("/anime/:id/edit/relations", editanime.Relations)
l.Page("/anime/:id/edit/episodes", editanime.Episodes)
l.Page("/anime/:id/edit/history", editanime.History)
page.Get(app, "/anime/:id/edit", editanime.Main)
page.Get(app, "/anime/:id/edit/images", editanime.Images)
page.Get(app, "/anime/:id/edit/characters", editanime.Characters)
page.Get(app, "/anime/:id/edit/relations", editanime.Relations)
page.Get(app, "/anime/:id/edit/episodes", editanime.Episodes)
page.Get(app, "/anime/:id/edit/history", editanime.History)
// Genres
l.Page("/genres", genres.Get)
l.Page("/genre/:name", genre.Get)
page.Get(app, "/genres", genres.Get)
page.Get(app, "/genre/:name", genre.Get)
}

View File

@ -3,13 +3,7 @@ package apiroutes
import (
"strings"
"github.com/animenotifier/notify.moe/pages/post"
"github.com/animenotifier/notify.moe/pages/sse"
"github.com/animenotifier/notify.moe/pages/thread"
"github.com/aerogo/aero"
"github.com/aerogo/layout"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/pages/animeimport"
"github.com/animenotifier/notify.moe/pages/apiview"
@ -19,17 +13,21 @@ import (
"github.com/animenotifier/notify.moe/pages/me"
"github.com/animenotifier/notify.moe/pages/notifications"
"github.com/animenotifier/notify.moe/pages/popular"
"github.com/animenotifier/notify.moe/pages/post"
"github.com/animenotifier/notify.moe/pages/soundtrack"
"github.com/animenotifier/notify.moe/pages/sse"
"github.com/animenotifier/notify.moe/pages/thread"
"github.com/animenotifier/notify.moe/pages/upload"
"github.com/animenotifier/notify.moe/utils/page"
)
// Register registers the page routes.
func Register(l *layout.Layout, app *aero.Application) {
func Register(app *aero.Application) {
// API pages
l.Page("/api", apiview.Get)
page.Get(app, "/api", apiview.Get)
for name := range arn.DB.Types() {
l.Page("/api/"+strings.ToLower(name), apidocs.ByType(name))
page.Get(app, "/api/"+strings.ToLower(name), apidocs.ByType(name))
}
// API

View File

@ -1,22 +1,23 @@
package characterroutes
import (
"github.com/aerogo/layout"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/pages/character"
"github.com/animenotifier/notify.moe/pages/characters"
"github.com/animenotifier/notify.moe/utils/page"
)
// Register registers the page routes.
func Register(l *layout.Layout) {
func Register(app *aero.Application) {
// Characters
l.Page("/characters", characters.Latest)
l.Page("/characters/from/:index", characters.Latest)
l.Page("/characters/best", characters.Best)
l.Page("/characters/best/from/:index", characters.Best)
page.Get(app, "/characters", characters.Latest)
page.Get(app, "/characters/from/:index", characters.Latest)
page.Get(app, "/characters/best", characters.Best)
page.Get(app, "/characters/best/from/:index", characters.Best)
// Character
l.Page("/character/:id", character.Get)
l.Page("/character/:id/edit", character.Edit)
l.Page("/character/:id/edit/images", character.EditImages)
l.Page("/character/:id/history", character.History)
page.Get(app, "/character/:id", character.Get)
page.Get(app, "/character/:id/edit", character.Edit)
page.Get(app, "/character/:id/edit/images", character.EditImages)
page.Get(app, "/character/:id/history", character.History)
}

View File

@ -1,18 +1,19 @@
package companyroutes
import (
"github.com/aerogo/layout"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/pages/companies"
"github.com/animenotifier/notify.moe/pages/company"
"github.com/animenotifier/notify.moe/utils/page"
)
// Register registers the page routes.
func Register(l *layout.Layout) {
func Register(app *aero.Application) {
// Companies
l.Page("/company/:id", company.Get)
l.Page("/company/:id/edit", company.Edit)
l.Page("/company/:id/history", company.History)
l.Page("/companies", companies.Popular)
l.Page("/companies/from/:index", companies.Popular)
l.Page("/companies/all", companies.All)
page.Get(app, "/company/:id", company.Get)
page.Get(app, "/company/:id/edit", company.Edit)
page.Get(app, "/company/:id/history", company.History)
page.Get(app, "/companies", companies.Popular)
page.Get(app, "/companies/from/:index", companies.Popular)
page.Get(app, "/companies/all", companies.All)
}

View File

@ -1,7 +1,7 @@
package coreroutes
import (
"github.com/aerogo/layout"
"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"
@ -10,35 +10,36 @@ import (
"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"
)
// Register registers the page routes.
func Register(l *layout.Layout) {
func Register(app *aero.Application) {
// Front page
l.Page("/", home.Get)
page.Get(app, "/", home.Get)
// Login
l.Page("/login", login.Get)
page.Get(app, "/login", login.Get)
// Welcome
l.Page("/welcome", welcome.Get)
page.Get(app, "/welcome", welcome.Get)
// Activity
l.Page("/activity", activity.Global)
l.Page("/activity/from/:index", activity.Global)
l.Page("/activity/followed", activity.Followed)
l.Page("/activity/followed/from/:index", activity.Followed)
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
l.Page("/calendar", calendar.Get)
page.Get(app, "/calendar", calendar.Get)
// Statistics
l.Page("/statistics", statistics.Get)
l.Page("/statistics/anime", statistics.Anime)
page.Get(app, "/statistics", statistics.Get)
page.Get(app, "/statistics/anime", statistics.Anime)
// Legal stuff
l.Page("/terms", terms.Get)
page.Get(app, "/terms", terms.Get)
// Browser extension
l.Page("/extension/embed", embed.Get)
page.Get(app, "/extension/embed", embed.Get)
}

View File

@ -1,18 +1,19 @@
package exploreroutes
import (
"github.com/aerogo/layout"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/pages/explore"
"github.com/animenotifier/notify.moe/pages/explore/explorecolor"
"github.com/animenotifier/notify.moe/pages/explore/halloffame"
"github.com/animenotifier/notify.moe/utils/page"
)
// Register registers the page routes.
func Register(l *layout.Layout) {
func Register(app *aero.Application) {
// Explore
l.Page("/explore", explore.Filter)
l.Page("/explore/anime/:year/:season/:status/:type", explore.Filter)
l.Page("/explore/color/:color/anime", explorecolor.AnimeByAverageColor)
l.Page("/explore/color/:color/anime/from/:index", explorecolor.AnimeByAverageColor)
l.Page("/halloffame", halloffame.Get)
page.Get(app, "/explore", explore.Filter)
page.Get(app, "/explore/anime/:year/:season/:status/:type", explore.Filter)
page.Get(app, "/explore/color/:color/anime", explorecolor.AnimeByAverageColor)
page.Get(app, "/explore/color/:color/anime/from/:index", explorecolor.AnimeByAverageColor)
page.Get(app, "/halloffame", halloffame.Get)
}

View File

@ -1,27 +1,28 @@
package forumroutes
import (
"github.com/aerogo/layout"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/pages/forum"
"github.com/animenotifier/notify.moe/pages/newthread"
"github.com/animenotifier/notify.moe/pages/post"
"github.com/animenotifier/notify.moe/pages/post/editpost"
"github.com/animenotifier/notify.moe/pages/thread"
"github.com/animenotifier/notify.moe/pages/thread/editthread"
"github.com/animenotifier/notify.moe/utils/page"
)
// Register registers the page routes.
func Register(l *layout.Layout) {
func Register(app *aero.Application) {
// Forum
l.Page("/forum", forum.Get)
l.Page("/forum/:tag", forum.Get)
page.Get(app, "/forum", forum.Get)
page.Get(app, "/forum/:tag", forum.Get)
// Thread
l.Page("/thread/:id", thread.Get)
l.Page("/thread/:id/edit", editthread.Get)
l.Page("/new/thread", newthread.Get)
page.Get(app, "/thread/:id", thread.Get)
page.Get(app, "/thread/:id/edit", editthread.Get)
page.Get(app, "/new/thread", newthread.Get)
// Post
l.Page("/post/:id", post.Get)
l.Page("/post/:id/edit", editpost.Get)
page.Get(app, "/post/:id", post.Get)
page.Get(app, "/post/:id/edit", editpost.Get)
}

View File

@ -1,24 +1,25 @@
package grouproutes
import (
"github.com/aerogo/layout"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/pages/group"
"github.com/animenotifier/notify.moe/pages/groups"
"github.com/animenotifier/notify.moe/utils/page"
)
// Register registers the page routes.
func Register(l *layout.Layout) {
func Register(app *aero.Application) {
// Groups
l.Page("/groups", groups.Latest)
l.Page("/groups/from/:index", groups.Latest)
l.Page("/groups/popular", groups.Popular)
l.Page("/groups/popular/from/:index", groups.Popular)
l.Page("/groups/joined", groups.Joined)
l.Page("/groups/joined/from/:index", groups.Joined)
l.Page("/group/:id", group.Feed)
l.Page("/group/:id/info", group.Info)
l.Page("/group/:id/members", group.Members)
l.Page("/group/:id/edit", group.Edit)
l.Page("/group/:id/edit/image", group.EditImage)
l.Page("/group/:id/history", group.History)
page.Get(app, "/groups", groups.Latest)
page.Get(app, "/groups/from/:index", groups.Latest)
page.Get(app, "/groups/popular", groups.Popular)
page.Get(app, "/groups/popular/from/:index", groups.Popular)
page.Get(app, "/groups/joined", groups.Joined)
page.Get(app, "/groups/joined/from/:index", groups.Joined)
page.Get(app, "/group/:id", group.Feed)
page.Get(app, "/group/:id/info", group.Info)
page.Get(app, "/group/:id/members", group.Members)
page.Get(app, "/group/:id/edit", group.Edit)
page.Get(app, "/group/:id/edit/image", group.EditImage)
page.Get(app, "/group/:id/history", group.History)
}

View File

@ -1,21 +1,22 @@
package importroutes
import (
"github.com/aerogo/layout"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/pages/listimport"
"github.com/animenotifier/notify.moe/pages/listimport/listimportanilist"
"github.com/animenotifier/notify.moe/pages/listimport/listimportkitsu"
"github.com/animenotifier/notify.moe/pages/listimport/listimportmyanimelist"
"github.com/animenotifier/notify.moe/utils/page"
)
// Register registers the page routes.
func Register(l *layout.Layout) {
func Register(app *aero.Application) {
// Import
l.Page("/import", listimport.Get)
l.Page("/import/anilist/animelist", listimportanilist.Preview)
l.Page("/import/anilist/animelist/finish", listimportanilist.Finish)
l.Page("/import/myanimelist/animelist", listimportmyanimelist.Preview)
l.Page("/import/myanimelist/animelist/finish", listimportmyanimelist.Finish)
l.Page("/import/kitsu/animelist", listimportkitsu.Preview)
l.Page("/import/kitsu/animelist/finish", listimportkitsu.Finish)
page.Get(app, "/import", listimport.Get)
page.Get(app, "/import/anilist/animelist", listimportanilist.Preview)
page.Get(app, "/import/anilist/animelist/finish", listimportanilist.Finish)
page.Get(app, "/import/myanimelist/animelist", listimportmyanimelist.Preview)
page.Get(app, "/import/myanimelist/animelist/finish", listimportmyanimelist.Finish)
page.Get(app, "/import/kitsu/animelist", listimportkitsu.Preview)
page.Get(app, "/import/kitsu/animelist/finish", listimportkitsu.Finish)
}

View File

@ -1,19 +1,20 @@
package quoteroutes
import (
"github.com/aerogo/layout"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/pages/quote"
"github.com/animenotifier/notify.moe/pages/quotes"
"github.com/animenotifier/notify.moe/utils/page"
)
// Register registers the page routes.
func Register(l *layout.Layout) {
func Register(app *aero.Application) {
// Quotes
l.Page("/quote/:id", quote.Get)
l.Page("/quote/:id/edit", quote.Edit)
l.Page("/quote/:id/history", quote.History)
l.Page("/quotes", quotes.Latest)
l.Page("/quotes/from/:index", quotes.Latest)
l.Page("/quotes/best", quotes.Best)
l.Page("/quotes/best/from/:index", quotes.Best)
page.Get(app, "/quote/:id", quote.Get)
page.Get(app, "/quote/:id/edit", quote.Edit)
page.Get(app, "/quote/:id/history", quote.History)
page.Get(app, "/quotes", quotes.Latest)
page.Get(app, "/quotes/from/:index", quotes.Latest)
page.Get(app, "/quotes/best", quotes.Best)
page.Get(app, "/quotes/best/from/:index", quotes.Best)
}

View File

@ -1,25 +1,26 @@
package searchroutes
import (
"github.com/aerogo/layout"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/pages/search"
"github.com/animenotifier/notify.moe/pages/search/multisearch"
"github.com/animenotifier/notify.moe/utils/page"
)
// Register registers the page routes.
func Register(l *layout.Layout) {
func Register(app *aero.Application) {
// Search
l.Page("/search/*term", search.Get)
l.Page("/empty-search", search.GetEmptySearch)
l.Page("/anime-search/*term", search.Anime)
l.Page("/character-search/*term", search.Characters)
l.Page("/posts-search/*term", search.Posts)
l.Page("/threads-search/*term", search.Threads)
l.Page("/soundtrack-search/*term", search.SoundTracks)
l.Page("/user-search/*term", search.Users)
l.Page("/amv-search/*term", search.AMVs)
l.Page("/company-search/*term", search.Companies)
page.Get(app, "/search/*term", search.Get)
page.Get(app, "/empty-search", search.GetEmptySearch)
page.Get(app, "/anime-search/*term", search.Anime)
page.Get(app, "/character-search/*term", search.Characters)
page.Get(app, "/posts-search/*term", search.Posts)
page.Get(app, "/threads-search/*term", search.Threads)
page.Get(app, "/soundtrack-search/*term", search.SoundTracks)
page.Get(app, "/user-search/*term", search.Users)
page.Get(app, "/amv-search/*term", search.AMVs)
page.Get(app, "/company-search/*term", search.Companies)
// Multi-search
l.Page("/multisearch/anime", multisearch.Anime)
page.Get(app, "/multisearch/anime", multisearch.Anime)
}

View File

@ -1,18 +1,19 @@
package settingsroutes
import (
"github.com/aerogo/layout"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/pages/settings"
"github.com/animenotifier/notify.moe/utils/page"
)
// Register registers the page routes.
func Register(l *layout.Layout) {
func Register(app *aero.Application) {
// Settings
l.Page("/settings", settings.Get(components.SettingsPersonal))
l.Page("/settings/accounts", settings.Get(components.SettingsAccounts))
l.Page("/settings/notifications", settings.Get(components.SettingsNotifications))
l.Page("/settings/info", settings.Get(components.SettingsInfo))
l.Page("/settings/style", settings.Get(components.SettingsStyle))
l.Page("/settings/extras", settings.Get(components.SettingsExtras))
page.Get(app, "/settings", settings.Get(components.SettingsPersonal))
page.Get(app, "/settings/accounts", settings.Get(components.SettingsAccounts))
page.Get(app, "/settings/notifications", settings.Get(components.SettingsNotifications))
page.Get(app, "/settings/info", settings.Get(components.SettingsInfo))
page.Get(app, "/settings/style", settings.Get(components.SettingsStyle))
page.Get(app, "/settings/extras", settings.Get(components.SettingsExtras))
}

View File

@ -2,26 +2,26 @@ package shoproutes
import (
"github.com/aerogo/aero"
"github.com/aerogo/layout"
"github.com/animenotifier/notify.moe/pages/charge"
"github.com/animenotifier/notify.moe/pages/inventory"
"github.com/animenotifier/notify.moe/pages/paypal"
"github.com/animenotifier/notify.moe/pages/shop"
"github.com/animenotifier/notify.moe/pages/support"
"github.com/animenotifier/notify.moe/utils/page"
)
// Register registers the page routes.
func Register(l *layout.Layout, app *aero.Application) {
func Register(app *aero.Application) {
// Shop
l.Page("/support", support.Get)
l.Page("/shop", shop.Get)
l.Page("/inventory", inventory.Get)
l.Page("/charge", charge.Get)
l.Page("/shop/history", shop.PurchaseHistory)
page.Get(app, "/support", support.Get)
page.Get(app, "/shop", shop.Get)
page.Get(app, "/inventory", inventory.Get)
page.Get(app, "/charge", charge.Get)
page.Get(app, "/shop/history", shop.PurchaseHistory)
// PayPal
l.Page("/paypal/success", paypal.Success)
l.Page("/paypal/cancel", paypal.Cancel)
page.Get(app, "/paypal/success", paypal.Success)
page.Get(app, "/paypal/cancel", paypal.Cancel)
// API: Create payment
app.Post("/api/paypal/payment/create", paypal.CreatePayment)

View File

@ -1,22 +1,23 @@
package soundtrackroutes
import (
"github.com/aerogo/layout"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/pages/soundtrack"
"github.com/animenotifier/notify.moe/pages/soundtracks"
"github.com/animenotifier/notify.moe/utils/page"
)
// Register registers the page routes.
func Register(l *layout.Layout) {
func Register(app *aero.Application) {
// Soundtracks
l.Page("/soundtracks", soundtracks.Latest)
l.Page("/soundtracks/from/:index", soundtracks.Latest)
l.Page("/soundtracks/best", soundtracks.Best)
l.Page("/soundtracks/best/from/:index", soundtracks.Best)
l.Page("/soundtracks/tag/:tag", soundtracks.FilterByTag)
l.Page("/soundtracks/tag/:tag/from/:index", soundtracks.FilterByTag)
l.Page("/soundtrack/:id", soundtrack.Get)
l.Page("/soundtrack/:id/lyrics", soundtrack.Lyrics)
l.Page("/soundtrack/:id/edit", soundtrack.Edit)
l.Page("/soundtrack/:id/history", soundtrack.History)
page.Get(app, "/soundtracks", soundtracks.Latest)
page.Get(app, "/soundtracks/from/:index", soundtracks.Latest)
page.Get(app, "/soundtracks/best", soundtracks.Best)
page.Get(app, "/soundtracks/best/from/:index", soundtracks.Best)
page.Get(app, "/soundtracks/tag/:tag", soundtracks.FilterByTag)
page.Get(app, "/soundtracks/tag/:tag/from/:index", soundtracks.FilterByTag)
page.Get(app, "/soundtrack/:id", soundtrack.Get)
page.Get(app, "/soundtrack/:id/lyrics", soundtrack.Lyrics)
page.Get(app, "/soundtrack/:id/edit", soundtrack.Edit)
page.Get(app, "/soundtrack/:id/history", soundtrack.History)
}

View File

@ -2,7 +2,6 @@ package staffroutes
import (
"github.com/aerogo/aero"
"github.com/aerogo/layout"
"github.com/animenotifier/notify.moe/pages/admin"
"github.com/animenotifier/notify.moe/pages/editlog"
"github.com/animenotifier/notify.moe/pages/editor"
@ -10,16 +9,17 @@ import (
"github.com/animenotifier/notify.moe/pages/editor/filtercompanies"
"github.com/animenotifier/notify.moe/pages/editor/filtersoundtracks"
"github.com/animenotifier/notify.moe/pages/editor/jobs"
"github.com/animenotifier/notify.moe/utils/page"
)
// Register registers the page routes.
func Register(l *layout.Layout) {
func Register(app *aero.Application) {
// Editor
l.Page("/editor", editor.Get)
page.Get(app, "/editor", editor.Get)
// Editor links can be filtered by year, status and type
editorFilterable := func(route string, handler func(ctx aero.Context) error) {
l.Page(route+"/:year/:season/:status/:type", handler)
page.Get(app, route+"/:year/:season/:status/:type", handler)
}
// Editor - Anime
@ -51,32 +51,32 @@ func Register(l *layout.Layout) {
editorFilterable("/editor/mal/diff/anime", editor.CompareMAL)
// Editor - Kitsu
l.Page("/editor/kitsu/new/anime", editor.NewKitsuAnime)
page.Get(app, "/editor/kitsu/new/anime", editor.NewKitsuAnime)
// Editor - Companies
l.Page("/editor/companies/description", filtercompanies.NoDescription)
page.Get(app, "/editor/companies/description", filtercompanies.NoDescription)
// Editor - Soundtracks
l.Page("/editor/soundtracks/links", filtersoundtracks.Links)
l.Page("/editor/soundtracks/lyrics/missing", filtersoundtracks.MissingLyrics)
l.Page("/editor/soundtracks/lyrics/unaligned", filtersoundtracks.UnalignedLyrics)
l.Page("/editor/soundtracks/tags", filtersoundtracks.Tags)
l.Page("/editor/soundtracks/file", filtersoundtracks.File)
page.Get(app, "/editor/soundtracks/links", filtersoundtracks.Links)
page.Get(app, "/editor/soundtracks/lyrics/missing", filtersoundtracks.MissingLyrics)
page.Get(app, "/editor/soundtracks/lyrics/unaligned", filtersoundtracks.UnalignedLyrics)
page.Get(app, "/editor/soundtracks/tags", filtersoundtracks.Tags)
page.Get(app, "/editor/soundtracks/file", filtersoundtracks.File)
// Editor - Jobs
l.Page("/editor/jobs", jobs.Overview)
page.Get(app, "/editor/jobs", jobs.Overview)
// Log
l.Page("/log", editlog.Get)
l.Page("/log/from/:index", editlog.Get)
l.Page("/user/:nick/log", editlog.Get)
l.Page("/user/:nick/log/from/:index", editlog.Get)
page.Get(app, "/log", editlog.Get)
page.Get(app, "/log/from/:index", editlog.Get)
page.Get(app, "/user/:nick/log", editlog.Get)
page.Get(app, "/user/:nick/log/from/:index", editlog.Get)
// Admin
l.Page("/admin", admin.Get)
l.Page("/admin/webdev", admin.WebDev)
l.Page("/admin/registrations", admin.UserRegistrations)
l.Page("/admin/errors/client", admin.ClientErrors)
l.Page("/admin/purchases", admin.PurchaseHistory)
l.Page("/admin/payments", admin.PaymentHistory)
page.Get(app, "/admin", admin.Get)
page.Get(app, "/admin/webdev", admin.WebDev)
page.Get(app, "/admin/registrations", admin.UserRegistrations)
page.Get(app, "/admin/errors/client", admin.ClientErrors)
page.Get(app, "/admin/purchases", admin.PurchaseHistory)
page.Get(app, "/admin/payments", admin.PaymentHistory)
}

View File

@ -1,21 +1,22 @@
package userlistroutes
import (
"github.com/aerogo/layout"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/pages/users"
"github.com/animenotifier/notify.moe/utils/page"
)
// Register registers the page routes.
func Register(l *layout.Layout) {
func Register(app *aero.Application) {
// User lists
l.Page("/users", users.Active)
l.Page("/users/map", users.Map)
l.Page("/users/noavatar", users.ActiveNoAvatar)
l.Page("/users/games/osu", users.Osu)
l.Page("/users/games/overwatch", users.Overwatch)
l.Page("/users/games/ffxiv", users.FFXIV)
l.Page("/users/staff", users.Staff)
l.Page("/users/pro", users.Pro)
l.Page("/users/editors", users.Editors)
l.Page("/users/country/:country", users.ByCountry)
page.Get(app, "/users", users.Active)
page.Get(app, "/users/map", users.Map)
page.Get(app, "/users/noavatar", users.ActiveNoAvatar)
page.Get(app, "/users/games/osu", users.Osu)
page.Get(app, "/users/games/overwatch", users.Overwatch)
page.Get(app, "/users/games/ffxiv", users.FFXIV)
page.Get(app, "/users/staff", users.Staff)
page.Get(app, "/users/pro", users.Pro)
page.Get(app, "/users/editors", users.Editors)
page.Get(app, "/users/country/:country", users.ByCountry)
}

View File

@ -1,7 +1,7 @@
package userroutes
import (
"github.com/aerogo/layout"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/pages/animelist"
"github.com/animenotifier/notify.moe/pages/animelistitem"
@ -12,56 +12,57 @@ import (
"github.com/animenotifier/notify.moe/pages/profile/profilecharacters"
"github.com/animenotifier/notify.moe/pages/recommended"
"github.com/animenotifier/notify.moe/pages/user"
"github.com/animenotifier/notify.moe/utils/page"
)
// Register registers the page routes.
func Register(l *layout.Layout) {
func Register(app *aero.Application) {
// User profiles
l.Page("/user", user.Get)
l.Page("/user/:nick", profile.Get)
l.Page("/user/:nick/characters/liked", profilecharacters.Liked)
// l.Page("/user/:nick/forum/threads", profile.GetThreadsByUser)
// l.Page("/user/:nick/forum/posts", profile.GetPostsByUser)
// l.Page("/user/:nick/soundtracks/added", profiletracks.Added)
// l.Page("/user/:nick/soundtracks/added/from/:index", profiletracks.Added)
// l.Page("/user/:nick/soundtracks/liked", profiletracks.Liked)
// l.Page("/user/:nick/soundtracks/liked/from/:index", profiletracks.Liked)
// l.Page("/user/:nick/quotes/added", profilequotes.Added)
// l.Page("/user/:nick/quotes/added/from/:index", profilequotes.Added)
// l.Page("/user/:nick/quotes/liked", profilequotes.Liked)
// l.Page("/user/:nick/quotes/liked/from/:index", profilequotes.Liked)
// l.Page("/user/:nick/stats", profile.GetStatsByUser)
// l.Page("/user/:nick/followers", profile.GetFollowers)
l.Page("/user/:nick/animelist/anime/:id", animelistitem.Get)
l.Page("/user/:nick/anime/recommended", recommended.Anime)
l.Page("/user/:nick/anime/sequels", explorerelations.Sequels)
l.Page("/user/:nick/notifications", notifications.ByUser)
l.Page("/user/:nick/edit", user.Edit)
page.Get(app, "/user", user.Get)
page.Get(app, "/user/:nick", profile.Get)
page.Get(app, "/user/:nick/characters/liked", profilecharacters.Liked)
// page.Get(app, "/user/:nick/forum/threads", profile.GetThreadsByUser)
// page.Get(app, "/user/:nick/forum/posts", profile.GetPostsByUser)
// page.Get(app, "/user/:nick/soundtracks/added", profiletracks.Added)
// page.Get(app, "/user/:nick/soundtracks/added/from/:index", profiletracks.Added)
// page.Get(app, "/user/:nick/soundtracks/liked", profiletracks.Liked)
// page.Get(app, "/user/:nick/soundtracks/liked/from/:index", profiletracks.Liked)
// page.Get(app, "/user/:nick/quotes/added", profilequotes.Added)
// page.Get(app, "/user/:nick/quotes/added/from/:index", profilequotes.Added)
// page.Get(app, "/user/:nick/quotes/liked", profilequotes.Liked)
// page.Get(app, "/user/:nick/quotes/liked/from/:index", profilequotes.Liked)
// page.Get(app, "/user/:nick/stats", profile.GetStatsByUser)
// page.Get(app, "/user/:nick/followers", profile.GetFollowers)
page.Get(app, "/user/:nick/animelist/anime/:id", animelistitem.Get)
page.Get(app, "/user/:nick/anime/recommended", recommended.Anime)
page.Get(app, "/user/:nick/anime/sequels", explorerelations.Sequels)
page.Get(app, "/user/:nick/notifications", notifications.ByUser)
page.Get(app, "/user/:nick/edit", user.Edit)
// Anime list
l.Page("/user/:nick/animelist/watching", animelist.FilterByStatus(arn.AnimeListStatusWatching))
l.Page("/user/:nick/animelist/completed", animelist.FilterByStatus(arn.AnimeListStatusCompleted))
l.Page("/user/:nick/animelist/planned", animelist.FilterByStatus(arn.AnimeListStatusPlanned))
l.Page("/user/:nick/animelist/hold", animelist.FilterByStatus(arn.AnimeListStatusHold))
l.Page("/user/:nick/animelist/dropped", animelist.FilterByStatus(arn.AnimeListStatusDropped))
page.Get(app, "/user/:nick/animelist/watching", animelist.FilterByStatus(arn.AnimeListStatusWatching))
page.Get(app, "/user/:nick/animelist/completed", animelist.FilterByStatus(arn.AnimeListStatusCompleted))
page.Get(app, "/user/:nick/animelist/planned", animelist.FilterByStatus(arn.AnimeListStatusPlanned))
page.Get(app, "/user/:nick/animelist/hold", animelist.FilterByStatus(arn.AnimeListStatusHold))
page.Get(app, "/user/:nick/animelist/dropped", animelist.FilterByStatus(arn.AnimeListStatusDropped))
l.Page("/user/:nick/animelist/watching/from/:index", animelist.FilterByStatus(arn.AnimeListStatusWatching))
l.Page("/user/:nick/animelist/completed/from/:index", animelist.FilterByStatus(arn.AnimeListStatusCompleted))
l.Page("/user/:nick/animelist/planned/from/:index", animelist.FilterByStatus(arn.AnimeListStatusPlanned))
l.Page("/user/:nick/animelist/hold/from/:index", animelist.FilterByStatus(arn.AnimeListStatusHold))
l.Page("/user/:nick/animelist/dropped/from/:index", animelist.FilterByStatus(arn.AnimeListStatusDropped))
page.Get(app, "/user/:nick/animelist/watching/from/:index", animelist.FilterByStatus(arn.AnimeListStatusWatching))
page.Get(app, "/user/:nick/animelist/completed/from/:index", animelist.FilterByStatus(arn.AnimeListStatusCompleted))
page.Get(app, "/user/:nick/animelist/planned/from/:index", animelist.FilterByStatus(arn.AnimeListStatusPlanned))
page.Get(app, "/user/:nick/animelist/hold/from/:index", animelist.FilterByStatus(arn.AnimeListStatusHold))
page.Get(app, "/user/:nick/animelist/dropped/from/:index", animelist.FilterByStatus(arn.AnimeListStatusDropped))
// Redirects
l.Page("/animelist/watching", animelist.Redirect)
l.Page("/animelist/completed", animelist.Redirect)
l.Page("/animelist/planned", animelist.Redirect)
l.Page("/animelist/hold", animelist.Redirect)
l.Page("/animelist/dropped", animelist.Redirect)
page.Get(app, "/animelist/watching", animelist.Redirect)
page.Get(app, "/animelist/completed", animelist.Redirect)
page.Get(app, "/animelist/planned", animelist.Redirect)
page.Get(app, "/animelist/hold", animelist.Redirect)
page.Get(app, "/animelist/dropped", animelist.Redirect)
// Compare
l.Page("/compare/animelist/:nick-1/:nick-2", compare.AnimeList)
page.Get(app, "/compare/animelist/:nick-1/:nick-2", compare.AnimeList)
// Notifications
l.Page("/notifications", notifications.ByUser)
l.Page("/notifications/all", notifications.All)
page.Get(app, "/notifications", notifications.ByUser)
page.Get(app, "/notifications/all", notifications.All)
}

9
utils/page/page.go Normal file
View File

@ -0,0 +1,9 @@
package page
import "github.com/aerogo/aero"
// Get registers a layout rendered route and a contents-only route.
func Get(app *aero.Application, route string, handler aero.Handler) {
app.Get(route, handler)
app.Get("/_"+route, handler)
}