From 6e41c08e601730fa92b2db85cf88df7542e1645a Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sat, 1 Jul 2017 14:03:10 +0200 Subject: [PATCH] Made /api page --- main.go | 2 ++ pages/admin/admin.go | 13 +------------ pages/admin/admin.pixy | 16 ++-------------- pages/apiview/api.go | 22 ++++++++++++++++++++++ pages/apiview/api.pixy | 14 ++++++++++++++ 5 files changed, 41 insertions(+), 26 deletions(-) create mode 100644 pages/apiview/api.go create mode 100644 pages/apiview/api.pixy diff --git a/main.go b/main.go index d82885fb..d519efce 100644 --- a/main.go +++ b/main.go @@ -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) diff --git a/pages/admin/admin.go b/pages/admin/admin.go index df83aa5b..9ef619e3 100644 --- a/pages/admin/admin.go +++ b/pages/admin/admin.go @@ -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)) } diff --git a/pages/admin/admin.pixy b/pages/admin/admin.pixy index 2fd92953..5790361d 100644 --- a/pages/admin/admin.pixy +++ b/pages/admin/admin.pixy @@ -1,4 +1,4 @@ -component Admin(user *arn.User, types []string) +component Admin(user *arn.User) h2.page-title Admin Panel h3 Server @@ -16,16 +16,4 @@ component Admin(user *arn.User, types []string) td= runtime.NumGoroutine() 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) + "/" \ No newline at end of file + td= runtime.Version() \ No newline at end of file diff --git a/pages/apiview/api.go b/pages/apiview/api.go new file mode 100644 index 00000000..31213c6e --- /dev/null +++ b/pages/apiview/api.go @@ -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)) +} diff --git a/pages/apiview/api.pixy b/pages/apiview/api.pixy new file mode 100644 index 00000000..daf887a8 --- /dev/null +++ b/pages/apiview/api.pixy @@ -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) + "/" \ No newline at end of file