Style changes
This commit is contained in:
@ -12,6 +12,7 @@ import (
|
|||||||
const maxPosts = 5
|
const maxPosts = 5
|
||||||
const maxFollowing = 5
|
const maxFollowing = 5
|
||||||
|
|
||||||
|
// Get the dashboard or the frontpage when logged out.
|
||||||
func Get(ctx *aero.Context) string {
|
func Get(ctx *aero.Context) string {
|
||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
@ -19,16 +20,17 @@ func Get(ctx *aero.Context) string {
|
|||||||
return frontpage.Get(ctx)
|
return frontpage.Get(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
return Dashboard(ctx)
|
return dashboard(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get dashboard.
|
// Render the dashboard.
|
||||||
func Dashboard(ctx *aero.Context) string {
|
func dashboard(ctx *aero.Context) string {
|
||||||
var posts []*arn.Post
|
var posts []*arn.Post
|
||||||
var err error
|
var err error
|
||||||
var followIDList []string
|
var followIDList []string
|
||||||
var userList interface{}
|
var userList interface{}
|
||||||
var followingList []*arn.User
|
var followingList []*arn.User
|
||||||
|
|
||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
flow.Parallel(func() {
|
flow.Parallel(func() {
|
||||||
@ -38,7 +40,6 @@ func Dashboard(ctx *aero.Context) string {
|
|||||||
if len(posts) > maxPosts {
|
if len(posts) > maxPosts {
|
||||||
posts = posts[:maxPosts]
|
posts = posts[:maxPosts]
|
||||||
}
|
}
|
||||||
|
|
||||||
}, func() {
|
}, func() {
|
||||||
followIDList = user.Following
|
followIDList = user.Following
|
||||||
userList, err = arn.DB.GetMany("User", followIDList)
|
userList, err = arn.DB.GetMany("User", followIDList)
|
||||||
@ -48,7 +49,6 @@ func Dashboard(ctx *aero.Context) string {
|
|||||||
if len(followingList) > maxFollowing {
|
if len(followingList) > maxFollowing {
|
||||||
followingList = followingList[:maxFollowing]
|
followingList = followingList[:maxFollowing]
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -15,4 +15,9 @@ component Thread(thread *arn.Thread, posts []*arn.Post, user *arn.User)
|
|||||||
Avatar(user)
|
Avatar(user)
|
||||||
|
|
||||||
.post-content
|
.post-content
|
||||||
textarea(id="new-reply", placeholder="Reply...")
|
textarea#new-reply(placeholder="Reply...")
|
||||||
|
|
||||||
|
.buttons
|
||||||
|
button.action(data-action="forumReply", data-trigger="click")
|
||||||
|
Icon("mail-reply")
|
||||||
|
span Reply
|
@ -1,6 +1,6 @@
|
|||||||
import { Application } from "./Application"
|
import { Application } from "./Application"
|
||||||
import { Diff } from "./Diff"
|
import { Diff } from "./Diff"
|
||||||
import { findAll } from "./utils"
|
import { findAll, delay } from "./utils"
|
||||||
import * as actions from "./actions"
|
import * as actions from "./actions"
|
||||||
|
|
||||||
export class AnimeNotifier {
|
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) {
|
onPopState(e: PopStateEvent) {
|
||||||
if(e.state) {
|
if(e.state) {
|
||||||
this.app.load(e.state, {
|
this.app.load(e.state, {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { Application } from "./Application"
|
import { Application } from "./Application"
|
||||||
import { AnimeNotifier } from "./AnimeNotifier"
|
import { AnimeNotifier } from "./AnimeNotifier"
|
||||||
import { Diff } from "./Diff"
|
import { Diff } from "./Diff"
|
||||||
import { delay, findAll } from "./utils"
|
|
||||||
|
|
||||||
// Save new data from an input field
|
// Save new data from an input field
|
||||||
export function save(arn: AnimeNotifier, input: HTMLInputElement | HTMLTextAreaElement) {
|
export function save(arn: AnimeNotifier, input: HTMLInputElement | HTMLTextAreaElement) {
|
||||||
@ -61,31 +60,15 @@ export function save(arn: AnimeNotifier, input: HTMLInputElement | HTMLTextAreaE
|
|||||||
// Diff
|
// Diff
|
||||||
export function diff(arn: AnimeNotifier, element: HTMLElement) {
|
export function diff(arn: AnimeNotifier, element: HTMLElement) {
|
||||||
let url = element.dataset.url || (element as HTMLAnchorElement).getAttribute("href")
|
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)
|
// Forum reply
|
||||||
arn.app.currentPath = url
|
export function forumReply(arn: AnimeNotifier) {
|
||||||
arn.app.markActiveLinks()
|
let textarea = arn.app.find("new-reply") as HTMLTextAreaElement
|
||||||
arn.loading(true)
|
|
||||||
arn.unmountMountables()
|
|
||||||
|
|
||||||
// for(let element of findAll("mountable")) {
|
console.log(textarea.value)
|
||||||
// element.classList.remove("mountable")
|
arn.diffURL(arn.app.currentPath)
|
||||||
// }
|
|
||||||
|
|
||||||
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)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search
|
// Search
|
||||||
|
Reference in New Issue
Block a user