commit
51e24669df
1
main.go
1
main.go
@ -61,6 +61,7 @@ func configure(app *aero.Application) *aero.Application {
|
|||||||
app.Ajax("/user", user.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/posts", profile.GetPostsByUser)
|
||||||
app.Ajax("/user/:nick/animelist", animelist.Get)
|
app.Ajax("/user/:nick/animelist", animelist.Get)
|
||||||
app.Ajax("/user/:nick/animelist/:id", animelistitem.Get)
|
app.Ajax("/user/:nick/animelist/:id", animelistitem.Get)
|
||||||
app.Ajax("/settings", settings.Get)
|
app.Ajax("/settings", settings.Get)
|
||||||
|
@ -1,3 +1,16 @@
|
|||||||
component PostableList(postables []arn.Postable)
|
component PostableList(postables []arn.Postable)
|
||||||
each post in postables
|
h2.thread-title= len(postables), " latest posts by ", postables[0].Author().Nick
|
||||||
a.ajax(href=post.Link())= post.Title()
|
.thread
|
||||||
|
.posts
|
||||||
|
each post in postables
|
||||||
|
.post
|
||||||
|
.post-author
|
||||||
|
Avatar(post.Author())
|
||||||
|
.post-content
|
||||||
|
p!= aero.Markdown(post.Text())
|
||||||
|
.post-toolbar
|
||||||
|
.spacer
|
||||||
|
.post-likes= len(post.Likes())
|
||||||
|
a.post-tool.post-permalink.ajax(href=post.Link(), title="Permalink")
|
||||||
|
Icon("link")
|
||||||
|
a.post-link.side-note.ajax(href=post.Link())= post.Title()
|
||||||
|
41
pages/profile/posts.go
Normal file
41
pages/profile/posts.go
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
package profile
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/aerogo/aero"
|
||||||
|
"github.com/animenotifier/arn"
|
||||||
|
"github.com/animenotifier/notify.moe/components"
|
||||||
|
)
|
||||||
|
|
||||||
|
const postLimit = 10
|
||||||
|
|
||||||
|
// GetPostsbyUser shows all forum posts of a particular user.
|
||||||
|
func GetPostsByUser(ctx *aero.Context) string {
|
||||||
|
nick := ctx.Get("nick")
|
||||||
|
user, err := arn.GetUserByNick(nick)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return ctx.Error(http.StatusNotFound, "User not found", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
posts := user.Posts()
|
||||||
|
arn.SortPostsLatestLast(posts)
|
||||||
|
|
||||||
|
var postables []arn.Postable
|
||||||
|
|
||||||
|
if len(posts) >= postLimit {
|
||||||
|
posts = posts[:postLimit]
|
||||||
|
}
|
||||||
|
|
||||||
|
postables = make([]arn.Postable, len(posts), len(posts))
|
||||||
|
|
||||||
|
for i, post := range posts {
|
||||||
|
|
||||||
|
postables[i] = arn.ToPostable(post)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctx.HTML(components.PostableList(postables))
|
||||||
|
|
||||||
|
}
|
@ -26,6 +26,7 @@ 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
|
||||||
|
var posts []*arn.Post
|
||||||
|
|
||||||
aero.Parallel(func() {
|
aero.Parallel(func() {
|
||||||
user = utils.GetUser(ctx)
|
user = utils.GetUser(ctx)
|
||||||
@ -39,7 +40,13 @@ func Profile(ctx *aero.Context, viewUser *arn.User) string {
|
|||||||
if len(threads) > maxPosts {
|
if len(threads) > maxPosts {
|
||||||
threads = threads[:maxPosts]
|
threads = threads[:maxPosts]
|
||||||
}
|
}
|
||||||
|
}, func() {
|
||||||
|
posts = viewUser.Posts()
|
||||||
|
|
||||||
|
if len(posts) > maxPosts {
|
||||||
|
posts = posts[:maxPosts]
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return ctx.HTML(components.Profile(viewUser, user, animeList, threads))
|
return ctx.HTML(components.Profile(viewUser, user, animeList, threads, posts))
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ component ProfileHeader(viewUser *arn.User, user *arn.User)
|
|||||||
|
|
||||||
.image-container.mountable
|
.image-container.mountable
|
||||||
ProfileImage(viewUser)
|
ProfileImage(viewUser)
|
||||||
|
|
||||||
.intro-container.mountable
|
.intro-container.mountable
|
||||||
h2#nick= viewUser.Nick
|
h2#nick= viewUser.Nick
|
||||||
|
|
||||||
@ -16,37 +16,37 @@ component ProfileHeader(viewUser *arn.User, user *arn.User)
|
|||||||
p.profile-field.tagline
|
p.profile-field.tagline
|
||||||
Icon("comment")
|
Icon("comment")
|
||||||
span.tagline-text No tagline yet.
|
span.tagline-text No tagline yet.
|
||||||
|
|
||||||
if viewUser.Website != ""
|
if viewUser.Website != ""
|
||||||
p.profile-field.website
|
p.profile-field.website
|
||||||
Icon("home")
|
Icon("home")
|
||||||
a(href=viewUser.WebsiteURL(), target="_blank", rel="nofollow")= viewUser.Website
|
a(href=viewUser.WebsiteURL(), target="_blank", rel="nofollow")= viewUser.Website
|
||||||
|
|
||||||
if viewUser.Accounts.Osu.Nick != "" && viewUser.Accounts.Osu.PP >= 1000
|
if viewUser.Accounts.Osu.Nick != "" && viewUser.Accounts.Osu.PP >= 1000
|
||||||
p.profile-field.osu(title="osu! performance points")
|
p.profile-field.osu(title="osu! performance points")
|
||||||
Icon("trophy")
|
Icon("trophy")
|
||||||
span= toString(int(viewUser.Accounts.Osu.PP)) + " pp"
|
span= toString(int(viewUser.Accounts.Osu.PP)) + " pp"
|
||||||
|
|
||||||
//- if viewUser.dataEditCount
|
//- if viewUser.dataEditCount
|
||||||
//- p.profile-field.editor-contribution(title="Anime data modifications")
|
//- p.profile-field.editor-contribution(title="Anime data modifications")
|
||||||
//- Icon("edit")
|
//- Icon("edit")
|
||||||
//- span= viewUser.dataEditCount
|
//- span= viewUser.dataEditCount
|
||||||
|
|
||||||
if viewUser.Registered != ""
|
if viewUser.Registered != ""
|
||||||
p.profile-field.registration-date(title="Member since")
|
p.profile-field.registration-date(title="Member since")
|
||||||
Icon("calendar")
|
Icon("calendar")
|
||||||
//- span= time.Parse(time.RFC3339, viewUser.Registered)
|
//- span= time.Parse(time.RFC3339, viewUser.Registered)
|
||||||
span= viewUser.RegisteredTime().Format("Jan 2006")
|
span= viewUser.RegisteredTime().Format("Jan 2006")
|
||||||
//- span= monthNames[joined.getMonth()] + ' ' + joined.getFullYear()
|
//- span= monthNames[joined.getMonth()] + ' ' + joined.getFullYear()
|
||||||
|
|
||||||
if viewUser.Role != ""
|
if viewUser.Role != ""
|
||||||
p.profile-field.role
|
p.profile-field.role
|
||||||
Icon("rocket")
|
Icon("rocket")
|
||||||
span= arn.Capitalize(viewUser.Role)
|
span= arn.Capitalize(viewUser.Role)
|
||||||
|
|
||||||
component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList, threads []*arn.Thread)
|
component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList, threads []*arn.Thread, posts []*arn.Post)
|
||||||
ProfileHeader(viewUser, user)
|
ProfileHeader(viewUser, user)
|
||||||
|
|
||||||
.profile-category.mountable
|
.profile-category.mountable
|
||||||
h3
|
h3
|
||||||
a.ajax(href="/+" + viewUser.Nick + "/animelist", title="View all anime") Anime
|
a.ajax(href="/+" + viewUser.Nick + "/animelist", title="View all anime") Anime
|
||||||
@ -62,10 +62,23 @@ component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList,
|
|||||||
.profile-category.mountable
|
.profile-category.mountable
|
||||||
h3
|
h3
|
||||||
a.ajax(href="/+" + viewUser.Nick + "/threads", title="View all threads") Threads
|
a.ajax(href="/+" + viewUser.Nick + "/threads", title="View all threads") Threads
|
||||||
|
|
||||||
if len(threads) == 0
|
if len(threads) == 0
|
||||||
p No threads on the forum.
|
p No threads on the forum.
|
||||||
else
|
else
|
||||||
each thread in threads
|
each thread in threads
|
||||||
ThreadLink(thread)
|
ThreadLink(thread)
|
||||||
|
h3
|
||||||
|
a.ajax(href="/+" + viewUser.Nick + "/posts", title="View all posts") Posts
|
||||||
|
if len(posts) == 0
|
||||||
|
p No posts on the forum.
|
||||||
|
else
|
||||||
|
each post in posts
|
||||||
|
.post
|
||||||
|
.post-author
|
||||||
|
Avatar(post.Author())
|
||||||
|
.post-content
|
||||||
|
p!= aero.Markdown(post.Text)
|
||||||
|
.post-toolbar.active
|
||||||
|
.spacer
|
||||||
|
.post-likes= len(post.Likes)
|
||||||
|
Loading…
Reference in New Issue
Block a user