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("/threads/:id", threads.Get)
app.Ajax("/posts/:id", posts.Get) app.Ajax("/posts/:id", posts.Get)
app.Ajax("/user/:nick", profile.Get) app.Ajax("/user/:nick", profile.Get)
app.Ajax("/user/:nick/threads", threads.GetByUser)
app.Ajax("/airing", airing.Get) app.Ajax("/airing", airing.Get)
app.Ajax("/users", users.Get) app.Ajax("/users", users.Get)
app.Ajax("/awards", awards.Get) app.Ajax("/awards", awards.Get)

View File

@ -2,4 +2,4 @@ component AnimeGrid(animeList []*arn.Anime)
.anime-grid .anime-grid
each anime in animeList each anime in animeList
a.anime-grid-cell.ajax(href="/anime/" + toString(anime.ID)) 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 //- if providers.Nyaa && providers.Nyaa.episodes !== undefined
//- span(class=providers.Nyaa.episodes === 0 ? "entry-error" : "entry-ok")= providers.Nyaa.episodes + " eps" //- 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 h3.anime-section-name Links
.light-button-group .light-button-group
//- if anime.Links != nil //- if anime.Links != nil

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -4,16 +4,28 @@ import (
"github.com/aerogo/aero" "github.com/aerogo/aero"
"github.com/animenotifier/arn" "github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components" "github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
) )
const maxPosts = 5
// Get ... // Get ...
func Get(ctx *aero.Context) string { func Get(ctx *aero.Context) string {
nick := ctx.Get("nick") nick := ctx.Get("nick")
user, err := arn.GetUserByNick(nick) viewUser, err := arn.GetUserByNick(nick)
user := utils.GetUser(ctx)
if err != nil { if err != nil {
return ctx.Error(404, "User not found", err) 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 .profile
img.profile-cover(src=viewUser.CoverImageURL()) img.profile-cover(src=viewUser.CoverImageURL())
@ -22,10 +22,10 @@ component Profile(viewUser *arn.User, user *arn.User)
//- Icon("home") //- Icon("home")
//- a(href=viewUser.website.startsWith('http') ? viewUser.website : 'http://' + viewUser.website, target='_blank', rel='nofollow')= viewUser.website.replace('http://', '').replace('https://', '') //- 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 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")
//- i.fa.fa-trophy Icon("trophy")
//- span= parseInt(viewUser.osuDetails.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")
@ -44,20 +44,17 @@ component Profile(viewUser *arn.User, user *arn.User)
Icon("rocket") Icon("rocket")
span= arn.Capitalize(viewUser.Role) span= arn.Capitalize(viewUser.Role)
//- .a //- nav.light-button-group
//- h3 Category //- a.light-button(href="#") Bio
//- a.light-button(href="#") Anime
//- a.light-button(href="#") Forum
//- .a .profile-category
//- h3 Category h3 Forum
//- .a each thread in threads
//- h3 Category ThreadLink(thread)
//- .a .side-note
//- h3 Category a.ajax(href="/+" + viewUser.Nick + "/threads") View all threads
//- .a
//- h3 Category
//- .a
//- h3 Category

View File

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