General improvements

This commit is contained in:
Eduard Urbach 2017-06-20 14:16:23 +02:00
parent 009c73629f
commit 877b2433e4
11 changed files with 68 additions and 9 deletions

View File

@ -21,6 +21,7 @@ import (
"github.com/animenotifier/notify.moe/pages/search" "github.com/animenotifier/notify.moe/pages/search"
"github.com/animenotifier/notify.moe/pages/settings" "github.com/animenotifier/notify.moe/pages/settings"
"github.com/animenotifier/notify.moe/pages/threads" "github.com/animenotifier/notify.moe/pages/threads"
"github.com/animenotifier/notify.moe/pages/user"
"github.com/animenotifier/notify.moe/pages/users" "github.com/animenotifier/notify.moe/pages/users"
"github.com/animenotifier/notify.moe/pages/webdev" "github.com/animenotifier/notify.moe/pages/webdev"
"github.com/animenotifier/notify.moe/utils" "github.com/animenotifier/notify.moe/utils"
@ -50,6 +51,7 @@ func main() {
app.Ajax("/forum/:tag", forum.Get) app.Ajax("/forum/:tag", forum.Get)
app.Ajax("/threads/:id", threads.Get) app.Ajax("/threads/:id", threads.Get)
app.Ajax("/posts/:id", posts.Get) app.Ajax("/posts/:id", posts.Get)
app.Ajax("/user", user.Get)
app.Ajax("/user/:nick", profile.Get) app.Ajax("/user/:nick", profile.Get)
app.Ajax("/user/:nick/threads", profile.GetThreadsByUser) app.Ajax("/user/:nick/threads", profile.GetThreadsByUser)
app.Ajax("/user/:nick/animelist", animelist.Get) app.Ajax("/user/:nick/animelist", animelist.Get)

View File

@ -16,12 +16,13 @@ component LoggedInMenu(user *arn.User)
nav#navigation nav#navigation
NavigationButton("Dash", "/", "inbox") NavigationButton("Dash", "/", "inbox")
NavigationButton("Anime", "/anime", "television") NavigationButton("Anime", "/anime", "television")
NavigationButton("Profile", "/+", "user")
NavigationButton("Forum", "/forum", "comment") NavigationButton("Forum", "/forum", "comment")
NavigationButton("Airing", "/airing", "rss")
NavigationButton("Settings", "/settings", "cog") NavigationButton("Settings", "/settings", "cog")
.extra-navigation .extra-navigation
ExtraNavigationButton("Users", "/users", "globe") ExtraNavigationButton("Users", "/users", "globe")
ExtraNavigationButton("Airing", "/airing", "rss")
if user.Role == "admin" if user.Role == "admin"
ExtraNavigationButton("Admin", "/admin", "wrench") ExtraNavigationButton("Admin", "/admin", "wrench")

View File

@ -46,7 +46,10 @@
horizontal horizontal
justify-content center justify-content center
margin content-padding 0 margin content-padding 0
// Setting z-index requires setting a background as well
z-index 10 z-index 10
background-color bg-color
> 900px > 900px
.anime-actions .anime-actions

View File

@ -18,6 +18,11 @@ func Get(ctx *aero.Context) string {
return ctx.Error(404, "User not found", err) return ctx.Error(404, "User not found", err)
} }
return Profile(ctx, viewUser)
}
// Profile renders the user profile page of the given viewUser.
func Profile(ctx *aero.Context, viewUser *arn.User) string {
var user *arn.User var user *arn.User
var threads []*arn.Thread var threads []*arn.Thread
var animeList *arn.AnimeList var animeList *arn.AnimeList

24
pages/user/user.go Normal file
View File

@ -0,0 +1,24 @@
package user
import (
"net/http"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/pages/profile"
"github.com/animenotifier/notify.moe/utils"
)
// Get redirects /+ to /+UserName
func Get(ctx *aero.Context) string {
user := utils.GetUser(ctx)
if user == nil {
return ctx.Error(http.StatusBadRequest, "Not logged in", nil)
}
if user.Nick == "" {
return ctx.Error(http.StatusInternalServerError, "User did not set a nickname", nil)
}
return profile.Profile(ctx, user)
}

View File

@ -43,6 +43,14 @@ export class AnimeNotifier {
} }
} }
onPopState(e: PopStateEvent) {
if(e.state) {
this.app.load(e.state, false)
} else if(this.app.currentPath !== this.app.originalPath) {
this.app.load(this.app.originalPath, false)
}
}
updateAvatars() { updateAvatars() {
for(let element of findAll(".user-image")) { for(let element of findAll(".user-image")) {
let img = element as HTMLImageElement let img = element as HTMLImageElement
@ -60,4 +68,14 @@ export class AnimeNotifier {
} }
} }
} }
// onResize(e: UIEvent) {
// let hasScrollbar = this.app.content.clientHeight === this.app.content.scrollHeight
// if(hasScrollbar) {
// this.app.content.classList.add("has-scrollbar")
// } else {
// this.app.content.classList.remove("has-scrollbar")
// }
// }
} }

View File

@ -55,7 +55,7 @@ export class Application {
this.currentPath = url this.currentPath = url
// Start sending a network request // Start sending a network request
let request = this.get("/_" + url) let request = this.get("/_" + url).catch(error => error)
let onTransitionEnd = e => { let onTransitionEnd = e => {
// Ignore transitions of child elements. // Ignore transitions of child elements.

View File

@ -7,9 +7,5 @@ let arn = new AnimeNotifier(app)
document.addEventListener("DOMContentLoaded", arn.onContentLoaded.bind(arn)) document.addEventListener("DOMContentLoaded", arn.onContentLoaded.bind(arn))
document.addEventListener("readystatechange", arn.onReadyStateChange.bind(arn)) document.addEventListener("readystatechange", arn.onReadyStateChange.bind(arn))
window.onpopstate = e => { window.addEventListener("popstate", arn.onPopState.bind(arn))
if(e.state) // window.addEventListener("resize", arn.onResize.bind(arn))
app.load(e.state, false)
else if(app.currentPath !== app.originalPath)
app.load(app.originalPath, false)
}

View File

@ -5,6 +5,7 @@ link-color = rgb(225, 38, 15)
link-hover-color = rgb(242, 60, 30) link-hover-color = rgb(242, 60, 30)
link-active-color = rgb(100, 149, 237) link-active-color = rgb(100, 149, 237)
post-highlight-color = rgba(248, 165, 130, 0.7) post-highlight-color = rgba(248, 165, 130, 0.7)
bg-color = white
// UI // UI
ui-border = 1px solid rgba(0, 0, 0, 0.1) ui-border = 1px solid rgba(0, 0, 0, 0.1)

View File

@ -4,7 +4,7 @@ loading-anim-size = 24px
#loading #loading
position fixed position fixed
bottom 1.15rem bottom 1.15rem
right calc(1.15rem + 17px) right 1.15rem
pointer-events none pointer-events none
.sk-cube-grid .sk-cube-grid

View File

@ -10,6 +10,14 @@ func init() {
"/+Akyoto/threads", "/+Akyoto/threads",
}) })
app.Test("/user/:nick/animelist", []string{
"/+Akyoto/animelist",
})
app.Test("/user/:nick/animelist/:id", []string{
"/+Akyoto/animelist/7929",
})
// Pages // Pages
app.Test("/anime/:id", []string{ app.Test("/anime/:id", []string{
"/anime/1", "/anime/1",
@ -92,4 +100,5 @@ func init() {
// Disable // Disable
app.Test("/auth/google", nil) app.Test("/auth/google", nil)
app.Test("/auth/google/callback", nil) app.Test("/auth/google/callback", nil)
app.Test("/user", nil)
} }