Forum activity shown in user profiles

This commit is contained in:
Eduard Urbach 2017-06-08 14:46:38 +02:00
parent 4a6e4378ce
commit 4f7ef694c8
13 changed files with 100 additions and 44 deletions

View File

@ -51,6 +51,7 @@ func main() {
app.Ajax("/threads/:id", threads.Get)
app.Ajax("/posts/:id", posts.Get)
app.Ajax("/user/:nick", profile.Get)
app.Ajax("/user/:nick/threads", threads.GetByUser)
app.Ajax("/airing", airing.Get)
app.Ajax("/users", users.Get)
app.Ajax("/awards", awards.Get)

View File

@ -2,4 +2,4 @@ component AnimeGrid(animeList []*arn.Anime)
.anime-grid
each anime in animeList
a.anime-grid-cell.ajax(href="/anime/" + toString(anime.ID))
img.anime-grid-image(src=anime.Image.Small, alt=anime.Title.Romaji, title=anime.Title.Romaji + " (" + toString(anime.Watching()) + ")")
img.anime-grid-image(src=anime.Image.Small, alt=anime.Title.Romaji, title=anime.Title.Romaji + " (" + toString(anime.Rating.Overall) + ")")

3
mixins/PostableList.pixy Normal file
View File

@ -0,0 +1,3 @@
component PostableList(postables []arn.Postable)
each post in postables
a.ajax(href=post.Link())= post.Title()

View File

@ -121,6 +121,9 @@ component Anime(anime *arn.Anime)
//- if providers.Nyaa && providers.Nyaa.episodes !== undefined
//- span(class=providers.Nyaa.episodes === 0 ? "entry-error" : "entry-ok")= providers.Nyaa.episodes + " eps"
h3.anime-section-name Reviews
p Coming soon.
h3.anime-section-name Links
.light-button-group
//- if anime.Links != nil

View File

@ -66,8 +66,9 @@
vertical
.sources
font-size 0.8em
font-size 0.8rem
opacity 0.5
margin-top 0.5rem
.relations
horizontal-wrap

View File

@ -1,12 +1,14 @@
component Forum(tag string, threads []*arn.Thread)
h2.page-title Forum
ForumTags
each thread in threads
ThreadLink(thread)
ThreadList(threads)
button#load-more-threads Load more
component ThreadList(threads []*arn.Thread)
each thread in threads
ThreadLink(thread)
component ThreadLink(thread *arn.Thread)
.thread-link(data-sticky=thread.Sticky)
.post-author.thread-author

View File

@ -3,23 +3,17 @@ component Forums
ForumTags
component ForumTags
.forum-tags
.forum-tags.light-button-group
ForumCategory("All", "")
span |
ForumCategory("General", "/general")
span |
ForumCategory("News", "/news")
span |
ForumCategory("Anime", "/anime")
span |
ForumCategory("Updates", "/update")
span |
ForumCategory("Suggestions", "/suggestion")
span |
ForumCategory("Bugs", "/bug")
component ForumCategory(title string, suffix string)
a.ajax(href="/forum" + suffix)= title
a.light-button.ajax(href="/forum" + suffix)= title
//- a.grid-cell.ajax(href="/forum/" + category)
//- .grid-text
//- GridIcon(arn.GetForumIcon(category))

View File

@ -1,5 +1,5 @@
component Post(post *arn.Post)
Postable(post.ToPostable(), nil, "")
.thread-source
.side-note
a.ajax(href=post.Thread().Link())= post.Thread().Title

View File

@ -1,3 +1,3 @@
.thread-source
.side-note
font-size 0.9rem
text-align right !important

View File

@ -4,16 +4,28 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
const maxPosts = 5
// Get ...
func Get(ctx *aero.Context) string {
nick := ctx.Get("nick")
user, err := arn.GetUserByNick(nick)
viewUser, err := arn.GetUserByNick(nick)
user := utils.GetUser(ctx)
if err != nil {
return ctx.Error(404, "User not found", err)
}
return ctx.HTML(components.Profile(user, nil))
threads := viewUser.Threads()
arn.SortThreadsByDate(threads)
if len(threads) > maxPosts {
threads = threads[:maxPosts]
}
return ctx.HTML(components.Profile(viewUser, user, threads))
}

View File

@ -1,4 +1,4 @@
component Profile(viewUser *arn.User, user *arn.User)
component Profile(viewUser *arn.User, user *arn.User, threads []*arn.Thread)
.profile
img.profile-cover(src=viewUser.CoverImageURL())
@ -22,10 +22,10 @@ component Profile(viewUser *arn.User, user *arn.User)
//- Icon("home")
//- a(href=viewUser.website.startsWith('http') ? viewUser.website : 'http://' + viewUser.website, target='_blank', rel='nofollow')= viewUser.website.replace('http://', '').replace('https://', '')
//- if user != nil && (user.osu || user.osuDetails) && viewUser.osuDetails && viewUser.osuDetails.pp >= 1000
//- p.profile-field.osu(title='osu! performance points')
//- i.fa.fa-trophy
//- span= parseInt(viewUser.osuDetails.pp) + ' pp'
if viewUser.Accounts.Osu.Nick != "" && viewUser.Accounts.Osu.PP >= 1000
p.profile-field.osu(title="osu! performance points")
Icon("trophy")
span= toString(int(viewUser.Accounts.Osu.PP)) + " pp"
//- if viewUser.dataEditCount
//- p.profile-field.editor-contribution(title="Anime data modifications")
@ -44,20 +44,17 @@ component Profile(viewUser *arn.User, user *arn.User)
Icon("rocket")
span= arn.Capitalize(viewUser.Role)
//- .a
//- h3 Category
//- .a
//- h3 Category
//- .a
//- h3 Category
//- .a
//- h3 Category
//- .a
//- h3 Category
//- .a
//- h3 Category
//- nav.light-button-group
//- a.light-button(href="#") Bio
//- a.light-button(href="#") Anime
//- a.light-button(href="#") Forum
.profile-category
h3 Forum
each thread in threads
ThreadLink(thread)
.side-note
a.ajax(href="/+" + viewUser.Nick + "/threads") View all threads

View File

@ -17,6 +17,19 @@ profile-boot-duration = 2s
overflow hidden
.profile-field
text-align center
< 600px
.profile
vertical
align-items center
.intro-container
align-items center
margin-top calc(content-padding * 1.5)
padding-left content-padding
animation appear
0%
transform rotateX(90deg)
@ -48,17 +61,23 @@ animation cover-animation
.profile-image
border-radius 3px
width 320px !important
height 320px !important
object-fit cover
width 100%
height auto
.image-container
// ...
flex 1
max-width 320px
.intro-container
vertical
align-items flex-start
padding content-padding
padding-top 0
padding-left content-padding * 2
max-width 900px
padding-left calc(content-padding * 2)
max-width 900px
// Categories
.profile-category
// padding content-padding

View File

@ -0,0 +1,24 @@
package threads
import (
"net/http"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
)
// GetByUser ...
func GetByUser(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)
}
threads := user.Threads()
arn.SortThreadsByDate(threads)
return ctx.HTML(components.ThreadList(threads))
}