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

View File

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

View File

@ -1,4 +1,4 @@
component Admin(user *arn.User, types []string)
component Admin(user *arn.User)
h2.page-title Admin Panel
h3 Server
@ -17,15 +17,3 @@ component Admin(user *arn.User, types []string)
tr
td Go 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) + "/"