From a871df28db2789d4c6667b3264500b6db82ca5e2 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sun, 19 Nov 2017 00:34:03 +0100 Subject: [PATCH] Started company editing UI --- pages/company/company.go | 9 +++++++++ pages/company/company.pixy | 7 ++++++- pages/company/edit.go | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 pages/company/edit.go diff --git a/pages/company/company.go b/pages/company/company.go index 4a51223a..1b1afb37 100644 --- a/pages/company/company.go +++ b/pages/company/company.go @@ -19,5 +19,14 @@ func Get(ctx *aero.Context) string { return ctx.Error(http.StatusNotFound, "Company not found", err) } + ctx.Data = &arn.OpenGraph{ + Tags: map[string]string{ + "og:title": company.Name.English, + "og:url": "https://" + ctx.App.Config.Domain + company.Link(), + "og:site_name": "notify.moe", + "og:image": company.Image, + }, + } + return ctx.HTML(components.CompanyPage(company, user)) } diff --git a/pages/company/company.pixy b/pages/company/company.pixy index 72146986..382edbde 100644 --- a/pages/company/company.pixy +++ b/pages/company/company.pixy @@ -1,2 +1,7 @@ component CompanyPage(company *arn.Company, user *arn.User) - h1= company.Name.English \ No newline at end of file + h1= company.Name.English + +component CompanyTabs(company *arn.Company, user *arn.User) + .tabs + Tab("Company", "building", company.Link()) + Tab("Edit", "pencil", company.Link() + "/edit") \ No newline at end of file diff --git a/pages/company/edit.go b/pages/company/edit.go new file mode 100644 index 00000000..44c9a38a --- /dev/null +++ b/pages/company/edit.go @@ -0,0 +1,33 @@ +package company + +import ( + "net/http" + + "github.com/aerogo/aero" + "github.com/animenotifier/arn" + "github.com/animenotifier/notify.moe/components" + "github.com/animenotifier/notify.moe/utils" + "github.com/animenotifier/notify.moe/utils/editform" +) + +// Edit track. +func Edit(ctx *aero.Context) string { + id := ctx.Get("id") + company, err := arn.GetCompany(id) + user := utils.GetUser(ctx) + + if err != nil { + return ctx.Error(http.StatusNotFound, "Company not found", err) + } + + ctx.Data = &arn.OpenGraph{ + Tags: map[string]string{ + "og:title": company.Name.English, + "og:url": "https://" + ctx.App.Config.Domain + company.Link(), + "og:site_name": "notify.moe", + "og:image": company.Image, + }, + } + + return ctx.HTML(components.CompanyTabs(company, user) + editform.Render(company, "Edit company", user)) +}