Added sitemaps
This commit is contained in:
parent
54b08453dc
commit
567aff76f9
38
assets.go
38
assets.go
@ -4,6 +4,8 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
|
"github.com/aerogo/sitemap"
|
||||||
|
"github.com/animenotifier/arn"
|
||||||
"github.com/animenotifier/notify.moe/components/js"
|
"github.com/animenotifier/notify.moe/components/js"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -52,6 +54,42 @@ func configureAssets(app *aero.Application) {
|
|||||||
return ctx.File("videos" + ctx.Get("file"))
|
return ctx.File("videos" + ctx.Get("file"))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Anime sitemap
|
||||||
|
app.Get("/sitemap/anime.txt", func(ctx *aero.Context) string {
|
||||||
|
sitemap := sitemap.New()
|
||||||
|
prefix := "https://" + app.Config.Domain
|
||||||
|
|
||||||
|
for anime := range arn.StreamAnime() {
|
||||||
|
sitemap.Add(prefix + anime.Link())
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctx.Text(sitemap.Text())
|
||||||
|
})
|
||||||
|
|
||||||
|
// Character sitemap
|
||||||
|
app.Get("/sitemap/character.txt", func(ctx *aero.Context) string {
|
||||||
|
sitemap := sitemap.New()
|
||||||
|
prefix := "https://" + app.Config.Domain
|
||||||
|
|
||||||
|
for character := range arn.StreamCharacters() {
|
||||||
|
sitemap.Add(prefix + character.Link())
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctx.Text(sitemap.Text())
|
||||||
|
})
|
||||||
|
|
||||||
|
// User sitemap
|
||||||
|
app.Get("/sitemap/user.txt", func(ctx *aero.Context) string {
|
||||||
|
sitemap := sitemap.New()
|
||||||
|
prefix := "https://" + app.Config.Domain
|
||||||
|
|
||||||
|
for user := range arn.StreamUsers() {
|
||||||
|
sitemap.Add(prefix + user.Link())
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctx.Text(sitemap.Text())
|
||||||
|
})
|
||||||
|
|
||||||
// For benchmarks
|
// For benchmarks
|
||||||
app.Get("/hello", func(ctx *aero.Context) string {
|
app.Get("/hello", func(ctx *aero.Context) string {
|
||||||
return ctx.Text("Hello World")
|
return ctx.Text("Hello World")
|
||||||
|
@ -68,7 +68,7 @@ func logRequest(ctx *aero.Context, responseTime time.Duration) {
|
|||||||
|
|
||||||
// Notify us about long requests.
|
// Notify us about long requests.
|
||||||
// However ignore requests under /auth/ because those depend on 3rd party servers.
|
// However ignore requests under /auth/ because those depend on 3rd party servers.
|
||||||
if responseTime >= 200*time.Millisecond && !strings.HasPrefix(ctx.URI(), "/auth/") {
|
if responseTime >= 300*time.Millisecond && !strings.HasPrefix(ctx.URI(), "/auth/") {
|
||||||
err.Error("Long response time", ip, hostName, responseTimeString, ctx.StatusCode, ctx.URI())
|
err.Error("Long response time", ip, hostName, responseTimeString, ctx.StatusCode, ctx.URI())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user