General improvements
This commit is contained in:
parent
009c73629f
commit
877b2433e4
2
main.go
2
main.go
@ -21,6 +21,7 @@ import (
|
||||
"github.com/animenotifier/notify.moe/pages/search"
|
||||
"github.com/animenotifier/notify.moe/pages/settings"
|
||||
"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/webdev"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
@ -50,6 +51,7 @@ func main() {
|
||||
app.Ajax("/forum/:tag", forum.Get)
|
||||
app.Ajax("/threads/:id", threads.Get)
|
||||
app.Ajax("/posts/:id", posts.Get)
|
||||
app.Ajax("/user", user.Get)
|
||||
app.Ajax("/user/:nick", profile.Get)
|
||||
app.Ajax("/user/:nick/threads", profile.GetThreadsByUser)
|
||||
app.Ajax("/user/:nick/animelist", animelist.Get)
|
||||
|
@ -16,12 +16,13 @@ component LoggedInMenu(user *arn.User)
|
||||
nav#navigation
|
||||
NavigationButton("Dash", "/", "inbox")
|
||||
NavigationButton("Anime", "/anime", "television")
|
||||
NavigationButton("Profile", "/+", "user")
|
||||
NavigationButton("Forum", "/forum", "comment")
|
||||
NavigationButton("Airing", "/airing", "rss")
|
||||
NavigationButton("Settings", "/settings", "cog")
|
||||
|
||||
.extra-navigation
|
||||
ExtraNavigationButton("Users", "/users", "globe")
|
||||
ExtraNavigationButton("Airing", "/airing", "rss")
|
||||
|
||||
if user.Role == "admin"
|
||||
ExtraNavigationButton("Admin", "/admin", "wrench")
|
||||
|
@ -46,7 +46,10 @@
|
||||
horizontal
|
||||
justify-content center
|
||||
margin content-padding 0
|
||||
|
||||
// Setting z-index requires setting a background as well
|
||||
z-index 10
|
||||
background-color bg-color
|
||||
|
||||
> 900px
|
||||
.anime-actions
|
||||
|
@ -18,6 +18,11 @@ func Get(ctx *aero.Context) string {
|
||||
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 threads []*arn.Thread
|
||||
var animeList *arn.AnimeList
|
||||
|
24
pages/user/user.go
Normal file
24
pages/user/user.go
Normal 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)
|
||||
}
|
@ -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() {
|
||||
for(let element of findAll(".user-image")) {
|
||||
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")
|
||||
// }
|
||||
// }
|
||||
}
|
@ -55,7 +55,7 @@ export class Application {
|
||||
this.currentPath = url
|
||||
|
||||
// Start sending a network request
|
||||
let request = this.get("/_" + url)
|
||||
let request = this.get("/_" + url).catch(error => error)
|
||||
|
||||
let onTransitionEnd = e => {
|
||||
// Ignore transitions of child elements.
|
||||
|
@ -7,9 +7,5 @@ let arn = new AnimeNotifier(app)
|
||||
document.addEventListener("DOMContentLoaded", arn.onContentLoaded.bind(arn))
|
||||
document.addEventListener("readystatechange", arn.onReadyStateChange.bind(arn))
|
||||
|
||||
window.onpopstate = e => {
|
||||
if(e.state)
|
||||
app.load(e.state, false)
|
||||
else if(app.currentPath !== app.originalPath)
|
||||
app.load(app.originalPath, false)
|
||||
}
|
||||
window.addEventListener("popstate", arn.onPopState.bind(arn))
|
||||
// window.addEventListener("resize", arn.onResize.bind(arn))
|
@ -5,6 +5,7 @@ link-color = rgb(225, 38, 15)
|
||||
link-hover-color = rgb(242, 60, 30)
|
||||
link-active-color = rgb(100, 149, 237)
|
||||
post-highlight-color = rgba(248, 165, 130, 0.7)
|
||||
bg-color = white
|
||||
|
||||
// UI
|
||||
ui-border = 1px solid rgba(0, 0, 0, 0.1)
|
||||
|
@ -4,7 +4,7 @@ loading-anim-size = 24px
|
||||
#loading
|
||||
position fixed
|
||||
bottom 1.15rem
|
||||
right calc(1.15rem + 17px)
|
||||
right 1.15rem
|
||||
pointer-events none
|
||||
|
||||
.sk-cube-grid
|
||||
|
9
tests.go
9
tests.go
@ -10,6 +10,14 @@ func init() {
|
||||
"/+Akyoto/threads",
|
||||
})
|
||||
|
||||
app.Test("/user/:nick/animelist", []string{
|
||||
"/+Akyoto/animelist",
|
||||
})
|
||||
|
||||
app.Test("/user/:nick/animelist/:id", []string{
|
||||
"/+Akyoto/animelist/7929",
|
||||
})
|
||||
|
||||
// Pages
|
||||
app.Test("/anime/:id", []string{
|
||||
"/anime/1",
|
||||
@ -92,4 +100,5 @@ func init() {
|
||||
// Disable
|
||||
app.Test("/auth/google", nil)
|
||||
app.Test("/auth/google/callback", nil)
|
||||
app.Test("/user", nil)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user