Made /api page

This commit is contained in:
Eduard Urbach 2017-07-01 14:03:10 +02:00
parent 715686ddee
commit 6e41c08e60
5 changed files with 41 additions and 26 deletions

View File

@ -12,6 +12,7 @@ import (
"github.com/animenotifier/notify.moe/pages/anime" "github.com/animenotifier/notify.moe/pages/anime"
"github.com/animenotifier/notify.moe/pages/animelist" "github.com/animenotifier/notify.moe/pages/animelist"
"github.com/animenotifier/notify.moe/pages/animelistitem" "github.com/animenotifier/notify.moe/pages/animelistitem"
"github.com/animenotifier/notify.moe/pages/apiview"
"github.com/animenotifier/notify.moe/pages/best" "github.com/animenotifier/notify.moe/pages/best"
"github.com/animenotifier/notify.moe/pages/dashboard" "github.com/animenotifier/notify.moe/pages/dashboard"
"github.com/animenotifier/notify.moe/pages/editanime" "github.com/animenotifier/notify.moe/pages/editanime"
@ -59,6 +60,7 @@ func configure(app *aero.Application) *aero.Application {
app.Ajax("/", dashboard.Get) app.Ajax("/", dashboard.Get)
app.Ajax("/anime/:id", anime.Get) app.Ajax("/anime/:id", anime.Get)
app.Ajax("/anime/:id/edit", editanime.Get) app.Ajax("/anime/:id/edit", editanime.Get)
app.Ajax("/api", apiview.Get)
app.Ajax("/best/anime", best.Get) app.Ajax("/best/anime", best.Get)
app.Ajax("/explore", explore.Get) app.Ajax("/explore", explore.Get)
app.Ajax("/forum", forums.Get) app.Ajax("/forum", forums.Get)

View File

@ -1,10 +1,7 @@
package admin package admin
import ( import (
"sort"
"github.com/aerogo/aero" "github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components" "github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils" "github.com/animenotifier/notify.moe/utils"
) )
@ -17,13 +14,5 @@ func Get(ctx *aero.Context) string {
return ctx.Redirect("/") return ctx.Redirect("/")
} }
types := []string{} return ctx.HTML(components.Admin(user))
for typeName := range arn.DB.Types() {
types = append(types, typeName)
}
sort.Strings(types)
return ctx.HTML(components.Admin(user, types))
} }

View File

@ -1,4 +1,4 @@
component Admin(user *arn.User, types []string) component Admin(user *arn.User)
h2.page-title Admin Panel h2.page-title Admin Panel
h3 Server h3 Server
@ -16,16 +16,4 @@ component Admin(user *arn.User, types []string)
td= runtime.NumGoroutine() td= runtime.NumGoroutine()
tr tr
td Go version: td Go version:
td= runtime.Version() td= runtime.Version()
h3 Types
table
//- thead
//- tr
//- th Table
tbody
each typeName in types
tr
td= typeName
td
a(href="/api/" + strings.ToLower(typeName) + "/")= "/api/" + strings.ToLower(typeName) + "/"

22
pages/apiview/api.go Normal file
View File

@ -0,0 +1,22 @@
package apiview
import (
"sort"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
)
// Get api page.
func Get(ctx *aero.Context) string {
types := []string{}
for typeName := range arn.DB.Types() {
types = append(types, typeName)
}
sort.Strings(types)
return ctx.HTML(components.API(types))
}

14
pages/apiview/api.pixy Normal file
View File

@ -0,0 +1,14 @@
component API(types []string)
h2.page-title API
h3 Types
table
//- thead
//- tr
//- th Table
tbody
each typeName in types
tr
td= typeName
td
a(href="/api/" + strings.ToLower(typeName) + "/")= "/api/" + strings.ToLower(typeName) + "/"