From 3d62ab830502c8cb296dfe1536553e83babb536c Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Mon, 26 Jun 2017 19:03:48 +0200 Subject: [PATCH] Style changes --- pages/dashboard/dashboard.go | 10 +++++----- pages/threads/threads.pixy | 7 ++++++- scripts/AnimeNotifier.ts | 30 +++++++++++++++++++++++++++++- scripts/actions.ts | 31 +++++++------------------------ 4 files changed, 47 insertions(+), 31 deletions(-) diff --git a/pages/dashboard/dashboard.go b/pages/dashboard/dashboard.go index 8aa9b386..6246dee2 100644 --- a/pages/dashboard/dashboard.go +++ b/pages/dashboard/dashboard.go @@ -12,6 +12,7 @@ import ( const maxPosts = 5 const maxFollowing = 5 +// Get the dashboard or the frontpage when logged out. func Get(ctx *aero.Context) string { user := utils.GetUser(ctx) @@ -19,16 +20,17 @@ func Get(ctx *aero.Context) string { return frontpage.Get(ctx) } - return Dashboard(ctx) + return dashboard(ctx) } -// Get dashboard. -func Dashboard(ctx *aero.Context) string { +// Render the dashboard. +func dashboard(ctx *aero.Context) string { var posts []*arn.Post var err error var followIDList []string var userList interface{} var followingList []*arn.User + user := utils.GetUser(ctx) flow.Parallel(func() { @@ -38,7 +40,6 @@ func Dashboard(ctx *aero.Context) string { if len(posts) > maxPosts { posts = posts[:maxPosts] } - }, func() { followIDList = user.Following userList, err = arn.DB.GetMany("User", followIDList) @@ -48,7 +49,6 @@ func Dashboard(ctx *aero.Context) string { if len(followingList) > maxFollowing { followingList = followingList[:maxFollowing] } - }) if err != nil { diff --git a/pages/threads/threads.pixy b/pages/threads/threads.pixy index 6459af81..d2dc6514 100644 --- a/pages/threads/threads.pixy +++ b/pages/threads/threads.pixy @@ -15,4 +15,9 @@ component Thread(thread *arn.Thread, posts []*arn.Post, user *arn.User) Avatar(user) .post-content - textarea(id="new-reply", placeholder="Reply...") \ No newline at end of file + textarea#new-reply(placeholder="Reply...") + + .buttons + button.action(data-action="forumReply", data-trigger="click") + Icon("mail-reply") + span Reply \ No newline at end of file diff --git a/scripts/AnimeNotifier.ts b/scripts/AnimeNotifier.ts index f371b015..0ce65f84 100644 --- a/scripts/AnimeNotifier.ts +++ b/scripts/AnimeNotifier.ts @@ -1,6 +1,6 @@ import { Application } from "./Application" import { Diff } from "./Diff" -import { findAll } from "./utils" +import { findAll, delay } from "./utils" import * as actions from "./actions" export class AnimeNotifier { @@ -153,6 +153,34 @@ export class AnimeNotifier { } } + diffURL(url: string) { + let request = fetch("/_" + url).then(response => response.text()) + + history.pushState(url, null, url) + this.app.currentPath = url + this.app.markActiveLinks() + this.loading(true) + this.unmountMountables() + + // for(let element of findAll("mountable")) { + // element.classList.remove("mountable") + // } + + delay(300).then(() => { + request + .then(html => this.app.setContent(html, true)) + .then(() => this.app.markActiveLinks()) + // .then(() => { + // for(let element of findAll("mountable")) { + // element.classList.remove("mountable") + // } + // }) + .then(() => this.app.emit("DOMContentLoaded")) + .then(() => this.loading(false)) + .catch(console.error) + }) + } + onPopState(e: PopStateEvent) { if(e.state) { this.app.load(e.state, { diff --git a/scripts/actions.ts b/scripts/actions.ts index 52a9d68a..5fc88c11 100644 --- a/scripts/actions.ts +++ b/scripts/actions.ts @@ -1,7 +1,6 @@ import { Application } from "./Application" import { AnimeNotifier } from "./AnimeNotifier" import { Diff } from "./Diff" -import { delay, findAll } from "./utils" // Save new data from an input field export function save(arn: AnimeNotifier, input: HTMLInputElement | HTMLTextAreaElement) { @@ -61,31 +60,15 @@ export function save(arn: AnimeNotifier, input: HTMLInputElement | HTMLTextAreaE // Diff export function diff(arn: AnimeNotifier, element: HTMLElement) { let url = element.dataset.url || (element as HTMLAnchorElement).getAttribute("href") - let request = fetch("/_" + url).then(response => response.text()) + arn.diffURL(url) +} - history.pushState(url, null, url) - arn.app.currentPath = url - arn.app.markActiveLinks() - arn.loading(true) - arn.unmountMountables() +// Forum reply +export function forumReply(arn: AnimeNotifier) { + let textarea = arn.app.find("new-reply") as HTMLTextAreaElement - // for(let element of findAll("mountable")) { - // element.classList.remove("mountable") - // } - - delay(300).then(() => { - request - .then(html => arn.app.setContent(html, true)) - .then(() => arn.app.markActiveLinks()) - // .then(() => { - // for(let element of findAll("mountable")) { - // element.classList.remove("mountable") - // } - // }) - .then(() => arn.app.emit("DOMContentLoaded")) - .then(() => arn.loading(false)) - .catch(console.error) - }) + console.log(textarea.value) + arn.diffURL(arn.app.currentPath) } // Search