Added basic quote display

This commit is contained in:
Scott 2017-12-03 22:33:24 +01:00
parent d4d7294f4e
commit f9c6711e8e
5 changed files with 93 additions and 0 deletions

View File

@ -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)

39
pages/quote/quote.go Normal file
View File

@ -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))
}

15
pages/quote/quote.pixy Normal file
View File

@ -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")

16
pages/quotes/quotes.go Normal file
View File

@ -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))
}

17
pages/quotes/quotes.pixy Normal file
View File

@ -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