From f9c6711e8e9a9aacc7452795ddba47ae87a02dc7 Mon Sep 17 00:00:00 2001 From: Scott Date: Sun, 3 Dec 2017 22:33:24 +0100 Subject: [PATCH 01/10] =?UTF-8?q?=E2=9C=A8=20Added=20basic=20quote=20displ?= =?UTF-8?q?ay?= 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 From 9eb4d1a2340a9743beaf30224cda98f5538622db Mon Sep 17 00:00:00 2001 From: Scott Date: Mon, 4 Dec 2017 01:01:16 +0100 Subject: [PATCH 02/10] =?UTF-8?q?=F0=9F=92=84=20Enhance=20the=20display=20?= =?UTF-8?q?so=20we=20can=20add=20and=20edit=20a=20quote.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index.go | 1 + pages/quote/edit.go | 32 ++++++++++++++++++++++++++++++++ pages/quote/quote.pixy | 1 - pages/quote/quote.scarlet | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 pages/quote/edit.go create mode 100644 pages/quote/quote.scarlet diff --git a/pages/index.go b/pages/index.go index ec55c188..481ac3ed 100644 --- a/pages/index.go +++ b/pages/index.go @@ -108,6 +108,7 @@ func Configure(app *aero.Application) { 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/edit.go b/pages/quote/edit.go new file mode 100644 index 00000000..a741e1b9 --- /dev/null +++ b/pages/quote/edit.go @@ -0,0 +1,32 @@ +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" + "github.com/animenotifier/notify.moe/utils/editform" +) + +// Edit track. +func Edit(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) + } + + ctx.Data = &arn.OpenGraph{ + Tags: map[string]string{ + "og:title": quote.Description, + "og:url": "https://" + ctx.App.Config.Domain + quote.Link(), + "og:site_name": "notify.moe", + }, + } + + return ctx.HTML(components.QuoteTabs(quote, user) + editform.Render(quote, "Edit quote", user)) +} diff --git a/pages/quote/quote.pixy b/pages/quote/quote.pixy index 43187019..28923e78 100644 --- a/pages/quote/quote.pixy +++ b/pages/quote/quote.pixy @@ -1,4 +1,3 @@ -<<<<<<< HEAD component QuotePage(quote *arn.Quote, character *arn.Character, user *arn.User) QuoteTabs(quote, user) diff --git a/pages/quote/quote.scarlet b/pages/quote/quote.scarlet new file mode 100644 index 00000000..421788f7 --- /dev/null +++ b/pages/quote/quote.scarlet @@ -0,0 +1,36 @@ +.quote-page + vertical + +.quote-header + vertical + +.quote-sidebar + sidebar + +> 1250px + .quote-page + horizontal + + .quote-sidebar + sidebar-medium + +> 1400px + .quote-sidebar + sidebar-big + +.quote-name, +.quote-description + text-align left + +.quote-location + width 100% + height 300px + +.quote-character + horizontal-wrap + +.quote-character-item + anime-mini-item + +.quote-character-item-image + anime-mini-item-image \ No newline at end of file From c51cb4743bcd0880c045859d537d3a7b5b923b3d Mon Sep 17 00:00:00 2001 From: Scott Date: Wed, 17 Jan 2018 23:30:55 +0100 Subject: [PATCH 03/10] =?UTF-8?q?=E2=9C=A8=20Added=20the=20list=20of=20quo?= =?UTF-8?q?tes=20sorted=20by=20last=20and=20best=20with=20a=20correct=20de?= =?UTF-8?q?sign.=20The=20design=20has=20been=20verified=20to=20be=20respon?= =?UTF-8?q?sive=20and=20compatible=20with=20the=20dark=20theme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mixins/Quote.pixy | 23 +++++++++ pages/index.go | 5 +- pages/quote/edit.go | 4 ++ pages/quote/quote.go | 2 +- pages/quotes/best.go | 66 ++++++++++++++++++++++++++ pages/quotes/quotes.go | 58 +++++++++++++++++++++-- pages/quotes/quotes.pixy | 22 +++++++-- pages/quotes/quotes.scarlet | 87 +++++++++++++++++++++++++++++++++++ scripts/Actions/Theme.ts | 4 +- styles/include/config.scarlet | 4 ++ styles/include/dark.scarlet | 5 +- 11 files changed, 268 insertions(+), 12 deletions(-) create mode 100644 mixins/Quote.pixy create mode 100644 pages/quotes/best.go create mode 100644 pages/quotes/quotes.scarlet diff --git a/mixins/Quote.pixy b/mixins/Quote.pixy new file mode 100644 index 00000000..3b3e950f --- /dev/null +++ b/mixins/Quote.pixy @@ -0,0 +1,23 @@ +component Quote(quote *arn.Quote) + .quote.mountable(id=quote.ID) + QuoteContent(quote) + QuoteFooter(quote) + +component QuoteContent(quote *arn.Quote) + .quote-content + a.quotation.ajax(href="/quote/" + quote.ID) + blockquote + p + q= quote.Description + if quote.Character() != nil + footer.quote-character + span= "by" + a.ajax(href="/character/" + quote.Character().ID)= quote.Character().Name + CharacterSmall(quote.Character()) + +component QuoteFooter(quote *arn.Quote) + .quote-footer + span posted + span.utc-date(data-date=quote.Created) + span by + a.ajax(href=quote.Creator().Link())= quote.Creator().Nick + " " diff --git a/pages/index.go b/pages/index.go index 481ac3ed..c0daf691 100644 --- a/pages/index.go +++ b/pages/index.go @@ -107,7 +107,10 @@ func Configure(app *aero.Application) { // Quotes l.Page("/quote/:id", quote.Get) l.Page("/quote/:id/edit", quote.Edit) - l.Page("/quotes", quotes.Get) + l.Page("/quotes", quotes.Latest) + l.Page("/quotes/from/:index", quotes.LatestFrom) + l.Page("/quotes/best", quotes.Best) + l.Page("/quotes/best/from/:index", quotes.BestFrom) // Calendar l.Page("/calendar", calendar.Get) diff --git a/pages/quote/edit.go b/pages/quote/edit.go index a741e1b9..e7f72841 100644 --- a/pages/quote/edit.go +++ b/pages/quote/edit.go @@ -28,5 +28,9 @@ func Edit(ctx *aero.Context) string { }, } + if quote.Character() != nil { + ctx.Data.(*arn.OpenGraph).Tags["og:image"] = quote.Character().Image + } + return ctx.HTML(components.QuoteTabs(quote, user) + editform.Render(quote, "Edit quote", user)) } diff --git a/pages/quote/quote.go b/pages/quote/quote.go index 882d67fd..36090c86 100644 --- a/pages/quote/quote.go +++ b/pages/quote/quote.go @@ -19,7 +19,7 @@ func Get(ctx *aero.Context) string { return ctx.Error(http.StatusNotFound, "Quote not found", err) } - character, err := arn.GetCharacter(quote.Character) + character, err := arn.GetCharacter(quote.CharacterId) if err != nil { return ctx.Error(http.StatusNotFound, "Quote not found", err) } diff --git a/pages/quotes/best.go b/pages/quotes/best.go new file mode 100644 index 00000000..e86df8ea --- /dev/null +++ b/pages/quotes/best.go @@ -0,0 +1,66 @@ +package quotes + +import ( + "net/http" + "strconv" + + "github.com/aerogo/aero" + "github.com/animenotifier/arn" + "github.com/animenotifier/notify.moe/components" + "github.com/animenotifier/notify.moe/utils" +) + +// Best renders the quotes page ordered by the most favorites first. +func Best(ctx *aero.Context) string { + user := utils.GetUser(ctx) + + quotes := arn.FilterQuotes(func(track *arn.Quote) bool { + return !track.IsDraft && len(track.Description) > 0 + }) + + arn.SortQuotesPopularFirst(quotes) + + if len(quotes) > maxQuotes { + quotes = quotes[:maxQuotes] + } + + return ctx.HTML(components.Quotes(quotes, maxQuotes, user)) +} + +// BestFrom renders the quotes from the given index. +func BestFrom(ctx *aero.Context) string { + user := utils.GetUser(ctx) + index, err := ctx.GetInt("index") + + if err != nil { + return ctx.Error(http.StatusBadRequest, "Invalid start index", err) + } + + allQuotes := arn.FilterQuotes(func(track *arn.Quote) bool { + return !track.IsDraft && len(track.Description) > 0 + }) + + if index < 0 || index >= len(allQuotes) { + return ctx.Error(http.StatusBadRequest, "Invalid start index (maximum is "+strconv.Itoa(len(allQuotes))+")", nil) + } + + arn.SortQuotesPopularFirst(allQuotes) + + quotes := allQuotes[index:] + + if len(quotes) > maxQuotes { + quotes = quotes[:maxQuotes] + } + + nextIndex := index + maxQuotes + + if nextIndex >= len(allQuotes) { + // End of data - no more scrolling + ctx.Response().Header().Set("X-LoadMore-Index", "-1") + } else { + // Send the index for the next request + ctx.Response().Header().Set("X-LoadMore-Index", strconv.Itoa(nextIndex)) + } + + return ctx.HTML(components.QuotesScrollable(quotes, user)) +} diff --git a/pages/quotes/quotes.go b/pages/quotes/quotes.go index ce6e4ff4..35b13068 100644 --- a/pages/quotes/quotes.go +++ b/pages/quotes/quotes.go @@ -5,12 +5,62 @@ import ( "github.com/animenotifier/arn" "github.com/animenotifier/notify.moe/components" "github.com/animenotifier/notify.moe/utils" + "net/http" + "strconv" ) -// Get renders the quotes page. -func Get(ctx *aero.Context) string { +const maxQuotes = 12 + +// Latest renders the quotes page. +func Latest(ctx *aero.Context) string { user := utils.GetUser(ctx) - quotes := arn.AllQuotes() - return ctx.HTML(components.Quotes(quotes, user)) + quotes := arn.FilterQuotes(func(track *arn.Quote) bool { + return !track.IsDraft && len(track.Description) > 0 + }) + + arn.SortQuotesLatestFirst(quotes) + + if len(quotes) > maxQuotes { + quotes = quotes[:maxQuotes] + } + return ctx.HTML(components.Quotes(quotes, maxQuotes, user)) +} + +// LatestFrom renders the quotes from the given index. +func LatestFrom(ctx *aero.Context) string { + user := utils.GetUser(ctx) + index, err := ctx.GetInt("index") + + if err != nil { + return ctx.Error(http.StatusBadRequest, "Invalid start index", err) + } + + allQuotes := arn.FilterQuotes(func(track *arn.Quote) bool { + return !track.IsDraft && len(track.Description) > 0 + }) + + if index < 0 || index >= len(allQuotes) { + return ctx.Error(http.StatusBadRequest, "Invalid start index (maximum is "+strconv.Itoa(len(allQuotes))+")", nil) + } + + arn.SortQuotesLatestFirst(allQuotes) + + quotes := allQuotes[index:] + + if len(quotes) > maxQuotes { + quotes = quotes[:maxQuotes] + } + + nextIndex := index + maxQuotes + + if nextIndex >= len(allQuotes) { + // End of data - no more scrolling + ctx.Response().Header().Set("X-LoadMore-Index", "-1") + } else { + // Send the index for the next request + ctx.Response().Header().Set("X-LoadMore-Index", strconv.Itoa(nextIndex)) + } + + return ctx.HTML(components.QuotesScrollable(quotes, user)) } diff --git a/pages/quotes/quotes.pixy b/pages/quotes/quotes.pixy index 74f9cb56..7d947aa5 100644 --- a/pages/quotes/quotes.pixy +++ b/pages/quotes/quotes.pixy @@ -1,6 +1,8 @@ -component Quotes(quotes []*arn.Quote, user *arn.User) +component Quotes(quotes []*arn.Quote, quotesPerPage int, user *arn.User) h1.page-title Quotes + QuotesTabs + .corner-buttons if user != nil if user.DraftIndex().QuoteID == "" @@ -12,6 +14,18 @@ component Quotes(quotes []*arn.Quote, user *arn.User) Icon("pencil") span Edit draft - ul - each quote in quotes - li= quote.Description \ No newline at end of file + #load-more-target.quotes + QuotesScrollable(quotes, user) + + if len(quotes) == quotesPerPage + .buttons + LoadMore(quotesPerPage) + +component QuotesScrollable(quotes []*arn.Quote, user *arn.User) + each quote in quotes + Quote(quote) + +component QuotesTabs + .tabs + Tab("Latest", "quote-left", "/quotes") + Tab("Best", "heart", "/quotes/best") \ No newline at end of file diff --git a/pages/quotes/quotes.scarlet b/pages/quotes/quotes.scarlet new file mode 100644 index 00000000..99e99da8 --- /dev/null +++ b/pages/quotes/quotes.scarlet @@ -0,0 +1,87 @@ +.quotes + horizontal-wrap + justify-content space-around + +.quote + vertical + flex 1 + flex-basis 500px + padding 1rem + +.quote-content + vertical + border-radius 3px + border-left 5px solid quote-side-border-color + overflow hidden + box-shadow shadow-light + align-items stretch + align-content stretch + +.quote-character + horizontal + align-self flex-end + align-items baseline + justify-content space-around + padding 0 1em 1em 0 + + span + opacity 0.65 + + a + display inline + margin-left 0.5em + + +.quote-footer + text-align center + margin-bottom 1rem + margin-top 0.4rem + font-size 0.9em + + span + opacity 0.65 + +.quotation + height 100% + display flex + flex-grow 1 + align-items stretch + align-content stretch + +blockquote + flex-grow 1 + padding 1em + + p + line-height 2em + + q + quotes "\201C""\201D" + + :before + color quote-color + content open-quote + font-size 4em + line-height 0.1em + margin-right 0.25em + vertical-align -0.4em + + :after + color quote-color + content close-quote + font-size 4em + line-height 0.1em + margin-left 0.25em + vertical-align -0.4em + + +.character + display none !important + +> 800px + .character + margin 0.5em 0 0 0.5em !important + display block !important + + .quote-character a + display none \ No newline at end of file diff --git a/scripts/Actions/Theme.ts b/scripts/Actions/Theme.ts index 79ddd84d..851d967e 100644 --- a/scripts/Actions/Theme.ts +++ b/scripts/Actions/Theme.ts @@ -35,7 +35,9 @@ let dark = { "post-like-color": "var(--link-color)", "post-unlike-color": "var(--link-color)", - "post-permalink-color": "var(--link-color)" + "post-permalink-color": "var(--link-color)", + + "quote-color" : "var(--text-color)" } // Toggle theme diff --git a/styles/include/config.scarlet b/styles/include/config.scarlet index 21941f6d..0e8b60da 100644 --- a/styles/include/config.scarlet +++ b/styles/include/config.scarlet @@ -59,6 +59,10 @@ nav-link-hover-slide-color = main-color // nav-link-color = rgb(160, 160, 160) // nav-link-hover-color = rgb(80, 80, 80) +// Quote +quote-color = hsl(0, 0%, 45%) +quote-side-border-color = quote-color + // Forum post-like-color = green !important post-unlike-color = rgb(255, 32, 12) !important diff --git a/styles/include/dark.scarlet b/styles/include/dark.scarlet index b55c961d..a0207da9 100644 --- a/styles/include/dark.scarlet +++ b/styles/include/dark.scarlet @@ -34,4 +34,7 @@ // // Forum // post-like-color = link-color // post-unlike-color = link-color -// post-permalink-color = link-color \ No newline at end of file +// post-permalink-color = link-color + +// // Quote +// quote-color = text-color \ No newline at end of file From 9d41f4dc6e0fb91e61e5120cf79882c81823444d Mon Sep 17 00:00:00 2001 From: Scott Date: Thu, 25 Jan 2018 12:26:22 +0100 Subject: [PATCH 04/10] =?UTF-8?q?=E2=9C=A8=20Finished=20the=20design=20of?= =?UTF-8?q?=20the=20quote=20page=20and=20added=20the=20like=20action.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mixins/TabLikeQuote.pixy | 16 +++++++++++ pages/quote/quote.pixy | 57 ++++++++++++++++++++++++++++++++++----- pages/quote/quote.scarlet | 44 +++++++++++++++++++----------- 3 files changed, 96 insertions(+), 21 deletions(-) create mode 100644 mixins/TabLikeQuote.pixy diff --git a/mixins/TabLikeQuote.pixy b/mixins/TabLikeQuote.pixy new file mode 100644 index 00000000..0abd565b --- /dev/null +++ b/mixins/TabLikeQuote.pixy @@ -0,0 +1,16 @@ +// This should be made abstract for every Likeable so we avoid repeating ourselves but I'm unsure on +// how to do it +component TabLikeQuote(label string, icon string, quote *arn.Quote, user *arn.User) + if user == nil + .tab.action(aria-label=label, title="Login to like this quote") + Icon(icon) + span.tab-text= label + else + if quote.LikedBy(user.ID) + .tab.action(data-api="/api" + quote.Link(), data-action="unlike", data-trigger="click", aria-label=label, title="Click to unlike this quote") + Icon(icon) + span.tab-text= label + else + .tab.action(data-api="/api" + quote.Link(), data-action="like", data-trigger="click", aria-label=label, title="Click to like this quote") + Icon(icon + "-o") + span.tab-text= label diff --git a/pages/quote/quote.pixy b/pages/quote/quote.pixy index 28923e78..486e1198 100644 --- a/pages/quote/quote.pixy +++ b/pages/quote/quote.pixy @@ -1,14 +1,59 @@ 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) + .quote-full-page + + .quote-main-column + QuoteMainColumn(quote, user) + .quote-side-column + QuoteSideColumn(quote, user) + +component QuoteMainColumn(quote *arn.Quote, user *arn.User) + .widget-form + QuoteContent(quote) + + .footer.mountable + if quote.EditedBy != "" + span Edited + span.utc-date(data-date=quote.Edited) + span by + a.ajax(href=quote.EditedByUser().Link())= quote.EditedByUser().Nick + else + span Posted + span.utc-date(data-date=quote.Created) + span by + a.ajax(href=quote.Creator().Link())= quote.Creator().Nick + span . + +component QuoteSideColumn(quote *arn.Quote, user *arn.User) + QuoteInformation(quote, user) + +component QuoteInformation(quote *arn.Quote, user *arn.User) + section.quote-section.mountable + h3.quote-section-name Information + table.quote-info-table + if quote.Anime() != nil + tr.mountable(data-mountable-type="info") + td.quote-info-key Anime: + td.quote-info-value + QuoteAnime(quote.Anime(), user) + + if quote.Episode != 0 + tr.mountable(data-mountable-type="info") + td.quote-info-key Episode: + td.quote-info-value= quote.Episode + + if quote.Time != 0 + tr.mountable(data-mountable-type="info") + td.anime-info-key Time: + td.anime-info-value= strconv.Itoa(quote.Time) + " min" component QuoteTabs(quote *arn.Quote, user *arn.User) .tabs + TabLikeQuote(strconv.Itoa(len(quote.Likes)), "heart", quote, user) Tab("Quote", "building", quote.Link()) Tab("Edit", "pencil", quote.Link() + "/edit") + +component QuoteAnime(anime *arn.Anime, user *arn.User) + a.quote-anime-list-item.ajax(href=anime.Link(), title=anime.Title.ByUser(user)) + img.quote-anime-list-item-image.lazy(data-src=anime.Image("small"), data-webp="true", alt=anime.Title.ByUser(user)) \ No newline at end of file diff --git a/pages/quote/quote.scarlet b/pages/quote/quote.scarlet index 421788f7..a131d964 100644 --- a/pages/quote/quote.scarlet +++ b/pages/quote/quote.scarlet @@ -1,36 +1,50 @@ -.quote-page +quote-full-page vertical -.quote-header +.quote-main-column vertical + flex 1 -.quote-sidebar +.quote-side-column sidebar > 1250px - .quote-page + .quote-full-page horizontal - .quote-sidebar + .quote-side-column sidebar-medium > 1400px - .quote-sidebar + .quote-side-column sidebar-big -.quote-name, -.quote-description - text-align left +.quote-media + iframe + width 100% -.quote-location - width 100% - height 300px +.quote-info-table + margin 0 +// width 100% +// max-width 600px -.quote-character +.quote-info-value + text-align right + +.quote-section + margin-top 1rem + + :first-child + margin-top 0 !important + +.quote-section-name + font-weight bold + +.quote-anime-list horizontal-wrap -.quote-character-item +.quote-anime-list-item anime-mini-item -.quote-character-item-image +.quote-anime-list-item-image anime-mini-item-image \ No newline at end of file From 359a76dfa4844dfce1d5e3fcdd45282280adcdf3 Mon Sep 17 00:00:00 2001 From: Scott Date: Thu, 25 Jan 2018 15:29:52 +0100 Subject: [PATCH 05/10] =?UTF-8?q?=E2=9C=A8=20Added=20the=20quotes=20on=20a?= =?UTF-8?q?=20character=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/character/character.go | 9 +++++++- pages/character/character.pixy | 6 +++++- pages/character/character.scarlet | 10 +++++++++ tests.go | 36 +++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 2 deletions(-) diff --git a/pages/character/character.go b/pages/character/character.go index 9d6508ef..cc7100ea 100644 --- a/pages/character/character.go +++ b/pages/character/character.go @@ -36,6 +36,13 @@ func Get(ctx *aero.Context) string { return characterAnime[i].StartDate < characterAnime[j].StartDate }) + // Quotes + quotes := arn.FilterQuotes(func(quote *arn.Quote) bool { + return !quote.IsDraft && len(quote.Description) > 0 && quote.CharacterId == character.ID + }) + + arn.SortQuotesPopularFirst(quotes) + // Set OpenGraph attributes description := character.Description @@ -61,5 +68,5 @@ func Get(ctx *aero.Context) string { }, } - return ctx.HTML(components.CharacterDetails(character, characterAnime, user)) + return ctx.HTML(components.CharacterDetails(character, characterAnime, quotes, user)) } diff --git a/pages/character/character.pixy b/pages/character/character.pixy index 5dd50624..b2af09a1 100644 --- a/pages/character/character.pixy +++ b/pages/character/character.pixy @@ -1,4 +1,4 @@ -component CharacterDetails(character *arn.Character, characterAnime []*arn.Anime, user *arn.User) +component CharacterDetails(character *arn.Character, characterAnime []*arn.Anime, quotes []*arn.Quote, user *arn.User) .character-page .character-left-column .character-header @@ -15,6 +15,10 @@ component CharacterDetails(character *arn.Character, characterAnime []*arn.Anime each anime in characterAnime a.character-anime-item.ajax(href=anime.Link(), title=anime.Title.ByUser(user)) img.character-anime-item-image.lazy(data-src=anime.Image("small"), data-webp="true", alt=anime.Title.ByUser(user)) + h3 Quotes + .character-quotes + each quote in quotes + Quote(quote) if len(character.Attributes) > 0 .character-sidebar diff --git a/pages/character/character.scarlet b/pages/character/character.scarlet index 5926e034..c57d0588 100644 --- a/pages/character/character.scarlet +++ b/pages/character/character.scarlet @@ -41,6 +41,16 @@ .character-anime-item-image anime-mini-item-image +.character-quotes + horizontal-wrap + justify-content space-around + + .quote + flex-basis 400px !important + + footer + display none !important + > 1250px .character-page horizontal diff --git a/tests.go b/tests.go index 01464a23..0a137597 100644 --- a/tests.go +++ b/tests.go @@ -87,6 +87,30 @@ var routeTests = map[string][]string{ "/search/Dragon Ball", }, + "/quote/:id": []string{ + "/quote/-8I3JKykR", + }, + + "/quote/:id/edit": []string{ + "/quote/-8I3JKykR/edit", + }, + + "/quotes": []string{ + "/quotes", + }, + + "/quotes/best": []string{ + "/quotes/best", + }, + + "/quotes/from/:index": []string{ + "/quotes/from/2", + }, + + "/quotes/best/from/:index": []string{ + "/quotes/best/from/2", + }, + "/soundtrack/:id": []string{ "/soundtrack/h0ac8sKkg", }, @@ -95,10 +119,22 @@ var routeTests = map[string][]string{ "/soundtrack/h0ac8sKkg/edit", }, + "/soundtracks": []string{ + "/soundtracks", + }, + + "/soundtracks/best": []string{ + "/soundtracks/best", + }, + "/soundtracks/from/:index": []string{ "/soundtracks/from/12", }, + "/soundtracks/best/from/:index": []string{ + "/soundtracks/best/from/12", + }, + "/character/:id": []string{ "/character/6556", }, From e009c30b20ed68e7525dba8791a5ab0dba18e478 Mon Sep 17 00:00:00 2001 From: Scott Date: Thu, 25 Jan 2018 16:52:09 +0100 Subject: [PATCH 06/10] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20the=20InfiniteScro?= =?UTF-8?q?ller=20loading=20the=20last=20item=20infinitely?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/Actions/InfiniteScroller.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/Actions/InfiniteScroller.ts b/scripts/Actions/InfiniteScroller.ts index 591f630a..6bbaeb86 100644 --- a/scripts/Actions/InfiniteScroller.ts +++ b/scripts/Actions/InfiniteScroller.ts @@ -3,7 +3,7 @@ import { AnimeNotifier } from "../AnimeNotifier" // Load more export function loadMore(arn: AnimeNotifier, button: HTMLButtonElement) { // Prevent firing this event multiple times - if(arn.isLoading || button.disabled) { + if(arn.isLoading || button.disabled || button.classList.contains("hidden")) { return } From 7f10bee755b8fe616e40e017fb4fbbdacd6fb625 Mon Sep 17 00:00:00 2001 From: Scott Date: Fri, 26 Jan 2018 11:30:26 +0100 Subject: [PATCH 07/10] =?UTF-8?q?=F0=9F=90=9B=20Hide=20the=20Quotes=20titl?= =?UTF-8?q?e=20if=20there=20is=20no=20quotes=20in=20the=20character=20page?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/character/character.pixy | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pages/character/character.pixy b/pages/character/character.pixy index b2af09a1..53adfcda 100644 --- a/pages/character/character.pixy +++ b/pages/character/character.pixy @@ -15,10 +15,11 @@ component CharacterDetails(character *arn.Character, characterAnime []*arn.Anime each anime in characterAnime a.character-anime-item.ajax(href=anime.Link(), title=anime.Title.ByUser(user)) img.character-anime-item-image.lazy(data-src=anime.Image("small"), data-webp="true", alt=anime.Title.ByUser(user)) - h3 Quotes - .character-quotes - each quote in quotes - Quote(quote) + if len(quotes) >0 + h3 Quotes + .character-quotes + each quote in quotes + Quote(quote) if len(character.Attributes) > 0 .character-sidebar From 5ad259e57d49dfed40233aede81d00457e0adee5 Mon Sep 17 00:00:00 2001 From: Scott Date: Fri, 26 Jan 2018 11:31:24 +0100 Subject: [PATCH 08/10] =?UTF-8?q?=F0=9F=92=84=20Added=20a=20sidebar=20butt?= =?UTF-8?q?on=20tp=20access=20the=20quotes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layout/sidebar/sidebar.pixy | 1 + 1 file changed, 1 insertion(+) diff --git a/layout/sidebar/sidebar.pixy b/layout/sidebar/sidebar.pixy index 1c1a14cd..36fa518f 100644 --- a/layout/sidebar/sidebar.pixy +++ b/layout/sidebar/sidebar.pixy @@ -17,6 +17,7 @@ component Sidebar(user *arn.User) SidebarButton("Explore", "/explore", "th") SidebarButton("Calendar", "/calendar", "calendar") SidebarButton("Soundtracks", "/soundtracks", "headphones") + SidebarButton("Quotes", "/quotes", "quote-left") SidebarButton("Users", "/users", "globe") if user != nil From 9653da7ba030521db33b71f48b660bd93279abd1 Mon Sep 17 00:00:00 2001 From: Scott Date: Fri, 26 Jan 2018 11:31:50 +0100 Subject: [PATCH 09/10] =?UTF-8?q?=F0=9F=92=84=20Changed=20the=20quote=20ic?= =?UTF-8?q?on=20in=20the=20quote=20page.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/quote/quote.pixy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/quote/quote.pixy b/pages/quote/quote.pixy index 486e1198..9ffc5141 100644 --- a/pages/quote/quote.pixy +++ b/pages/quote/quote.pixy @@ -51,7 +51,7 @@ component QuoteInformation(quote *arn.Quote, user *arn.User) component QuoteTabs(quote *arn.Quote, user *arn.User) .tabs TabLikeQuote(strconv.Itoa(len(quote.Likes)), "heart", quote, user) - Tab("Quote", "building", quote.Link()) + Tab("Quote", "quote-left", quote.Link()) Tab("Edit", "pencil", quote.Link() + "/edit") component QuoteAnime(anime *arn.Anime, user *arn.User) From b234877a1238f7774c12a13e9cf6cbbd9cb6b834 Mon Sep 17 00:00:00 2001 From: Scott Date: Sat, 24 Feb 2018 13:11:12 +0100 Subject: [PATCH 10/10] =?UTF-8?q?=F0=9F=91=8C=20Applied=20review=20changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mixins/Quote.pixy | 4 ++-- pages/character/character.go | 2 +- pages/character/character.pixy | 3 ++- pages/character/character.scarlet | 8 ++++---- pages/quote/edit.go | 2 +- pages/quote/quote.go | 4 ++-- pages/quote/quote.pixy | 6 ++---- pages/quote/quote.scarlet | 2 -- 8 files changed, 14 insertions(+), 17 deletions(-) diff --git a/mixins/Quote.pixy b/mixins/Quote.pixy index 3b3e950f..4eca694f 100644 --- a/mixins/Quote.pixy +++ b/mixins/Quote.pixy @@ -5,14 +5,14 @@ component Quote(quote *arn.Quote) component QuoteContent(quote *arn.Quote) .quote-content - a.quotation.ajax(href="/quote/" + quote.ID) + a.quotation.ajax(href=quote.Link()) blockquote p q= quote.Description if quote.Character() != nil footer.quote-character span= "by" - a.ajax(href="/character/" + quote.Character().ID)= quote.Character().Name + a.ajax(href=quote.Character().Link())= quote.Character().Name CharacterSmall(quote.Character()) component QuoteFooter(quote *arn.Quote) diff --git a/pages/character/character.go b/pages/character/character.go index cc7100ea..2ed5ac1b 100644 --- a/pages/character/character.go +++ b/pages/character/character.go @@ -38,7 +38,7 @@ func Get(ctx *aero.Context) string { // Quotes quotes := arn.FilterQuotes(func(quote *arn.Quote) bool { - return !quote.IsDraft && len(quote.Description) > 0 && quote.CharacterId == character.ID + return !quote.IsDraft && len(quote.Description) > 0 && quote.CharacterID == character.ID }) arn.SortQuotesPopularFirst(quotes) diff --git a/pages/character/character.pixy b/pages/character/character.pixy index 53adfcda..ca598cdd 100644 --- a/pages/character/character.pixy +++ b/pages/character/character.pixy @@ -19,7 +19,8 @@ component CharacterDetails(character *arn.Character, characterAnime []*arn.Anime h3 Quotes .character-quotes each quote in quotes - Quote(quote) + .character-quote + Quote(quote) if len(character.Attributes) > 0 .character-sidebar diff --git a/pages/character/character.scarlet b/pages/character/character.scarlet index c57d0588..0da011c3 100644 --- a/pages/character/character.scarlet +++ b/pages/character/character.scarlet @@ -45,11 +45,11 @@ horizontal-wrap justify-content space-around - .quote - flex-basis 400px !important +.character-quote + flex-basis 400px - footer - display none !important + footer + display none > 1250px .character-page diff --git a/pages/quote/edit.go b/pages/quote/edit.go index e7f72841..ad1f521b 100644 --- a/pages/quote/edit.go +++ b/pages/quote/edit.go @@ -10,7 +10,7 @@ import ( "github.com/animenotifier/notify.moe/utils/editform" ) -// Edit track. +// Edit quote. func Edit(ctx *aero.Context) string { user := utils.GetUser(ctx) id := ctx.Get("id") diff --git a/pages/quote/quote.go b/pages/quote/quote.go index 36090c86..5e1dcd7a 100644 --- a/pages/quote/quote.go +++ b/pages/quote/quote.go @@ -9,7 +9,7 @@ import ( "github.com/animenotifier/notify.moe/utils" ) -// Get company. +// Get quote. func Get(ctx *aero.Context) string { user := utils.GetUser(ctx) id := ctx.Get("id") @@ -19,7 +19,7 @@ func Get(ctx *aero.Context) string { return ctx.Error(http.StatusNotFound, "Quote not found", err) } - character, err := arn.GetCharacter(quote.CharacterId) + character, err := arn.GetCharacter(quote.CharacterID) if err != nil { return ctx.Error(http.StatusNotFound, "Quote not found", err) } diff --git a/pages/quote/quote.pixy b/pages/quote/quote.pixy index 9ffc5141..913b4a1c 100644 --- a/pages/quote/quote.pixy +++ b/pages/quote/quote.pixy @@ -1,8 +1,6 @@ component QuotePage(quote *arn.Quote, character *arn.Character, user *arn.User) QuoteTabs(quote, user) - .quote-full-page - .quote-main-column QuoteMainColumn(quote, user) .quote-side-column @@ -38,10 +36,10 @@ component QuoteInformation(quote *arn.Quote, user *arn.User) td.quote-info-value QuoteAnime(quote.Anime(), user) - if quote.Episode != 0 + if quote.EpisodeNumber != 0 tr.mountable(data-mountable-type="info") td.quote-info-key Episode: - td.quote-info-value= quote.Episode + td.quote-info-value= quote.EpisodeNumber if quote.Time != 0 tr.mountable(data-mountable-type="info") diff --git a/pages/quote/quote.scarlet b/pages/quote/quote.scarlet index a131d964..d46ebe77 100644 --- a/pages/quote/quote.scarlet +++ b/pages/quote/quote.scarlet @@ -25,8 +25,6 @@ quote-full-page .quote-info-table margin 0 -// width 100% -// max-width 600px .quote-info-value text-align right