From f9c6711e8e9a9aacc7452795ddba47ae87a02dc7 Mon Sep 17 00:00:00 2001 From: Scott Date: Sun, 3 Dec 2017 22:33:24 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Added=20basic=20quote=20display?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index.go | 6 ++++++ pages/quote/quote.go | 39 +++++++++++++++++++++++++++++++++++++++ pages/quote/quote.pixy | 15 +++++++++++++++ pages/quotes/quotes.go | 16 ++++++++++++++++ pages/quotes/quotes.pixy | 17 +++++++++++++++++ 5 files changed, 93 insertions(+) create mode 100644 pages/quote/quote.go create mode 100644 pages/quote/quote.pixy create mode 100644 pages/quotes/quotes.go create mode 100644 pages/quotes/quotes.pixy diff --git a/pages/index.go b/pages/index.go index ad7db770..ec55c188 100644 --- a/pages/index.go +++ b/pages/index.go @@ -43,6 +43,8 @@ import ( "github.com/animenotifier/notify.moe/pages/posts" "github.com/animenotifier/notify.moe/pages/profile" "github.com/animenotifier/notify.moe/pages/recommended" + "github.com/animenotifier/notify.moe/pages/quote" + "github.com/animenotifier/notify.moe/pages/quotes" "github.com/animenotifier/notify.moe/pages/search" "github.com/animenotifier/notify.moe/pages/settings" "github.com/animenotifier/notify.moe/pages/shop" @@ -102,6 +104,10 @@ func Configure(app *aero.Application) { // Characters l.Page("/character/:id", character.Get) + // Quotes + l.Page("/quote/:id", quote.Get) + l.Page("/quote/:id/edit", quote.Edit) + l.Page("/quotes", quotes.Get) // Calendar l.Page("/calendar", calendar.Get) diff --git a/pages/quote/quote.go b/pages/quote/quote.go new file mode 100644 index 00000000..882d67fd --- /dev/null +++ b/pages/quote/quote.go @@ -0,0 +1,39 @@ +package quote + +import ( + "net/http" + + "github.com/aerogo/aero" + "github.com/animenotifier/arn" + "github.com/animenotifier/notify.moe/components" + "github.com/animenotifier/notify.moe/utils" +) + +// Get company. +func Get(ctx *aero.Context) string { + user := utils.GetUser(ctx) + id := ctx.Get("id") + quote, err := arn.GetQuote(id) + + if err != nil { + return ctx.Error(http.StatusNotFound, "Quote not found", err) + } + + character, err := arn.GetCharacter(quote.Character) + if err != nil { + return ctx.Error(http.StatusNotFound, "Quote not found", err) + } + + openGraph := &arn.OpenGraph{ + Tags: map[string]string{ + "og:title": quote.Description, + "og:description": quote.Description, + "og:url": "https://" + ctx.App.Config.Domain + quote.Link(), + "og:site_name": "notify.moe", + "og:type": "article", + }, + } + + ctx.Data = openGraph + return ctx.HTML(components.QuotePage(quote, character, user)) +} diff --git a/pages/quote/quote.pixy b/pages/quote/quote.pixy new file mode 100644 index 00000000..43187019 --- /dev/null +++ b/pages/quote/quote.pixy @@ -0,0 +1,15 @@ +<<<<<<< HEAD +component QuotePage(quote *arn.Quote, character *arn.Character, user *arn.User) + QuoteTabs(quote, user) + + .quote-page + .quote-header + h1.quote-name.mountable= quote.Description + h3.mountable Characters + .quote-character.mountable + Character(character) + +component QuoteTabs(quote *arn.Quote, user *arn.User) + .tabs + Tab("Quote", "building", quote.Link()) + Tab("Edit", "pencil", quote.Link() + "/edit") diff --git a/pages/quotes/quotes.go b/pages/quotes/quotes.go new file mode 100644 index 00000000..ce6e4ff4 --- /dev/null +++ b/pages/quotes/quotes.go @@ -0,0 +1,16 @@ +package quotes + +import ( + "github.com/aerogo/aero" + "github.com/animenotifier/arn" + "github.com/animenotifier/notify.moe/components" + "github.com/animenotifier/notify.moe/utils" +) + +// Get renders the quotes page. +func Get(ctx *aero.Context) string { + user := utils.GetUser(ctx) + + quotes := arn.AllQuotes() + return ctx.HTML(components.Quotes(quotes, user)) +} diff --git a/pages/quotes/quotes.pixy b/pages/quotes/quotes.pixy new file mode 100644 index 00000000..74f9cb56 --- /dev/null +++ b/pages/quotes/quotes.pixy @@ -0,0 +1,17 @@ +component Quotes(quotes []*arn.Quote, user *arn.User) + h1.page-title Quotes + + .corner-buttons + if user != nil + if user.DraftIndex().QuoteID == "" + button.action(data-action="newObject", data-trigger="click", data-type="quote") + Icon("plus") + span Add quote + else + a.button.ajax(href="/quote/" + user.DraftIndex().QuoteID + "/edit") + Icon("pencil") + span Edit draft + + ul + each quote in quotes + li= quote.Description \ No newline at end of file