Improved groups
This commit is contained in:
parent
217e35f752
commit
6a92dc23bb
@ -12,11 +12,17 @@ func main() {
|
|||||||
|
|
||||||
ticker := time.NewTicker(500 * time.Millisecond)
|
ticker := time.NewTicker(500 * time.Millisecond)
|
||||||
|
|
||||||
for user := range arn.MustStreamUsers() {
|
allUsers, _ := arn.AllUsers()
|
||||||
|
|
||||||
|
for _, user := range allUsers {
|
||||||
// Get osu info
|
// Get osu info
|
||||||
if user.RefreshOsuInfo() == nil {
|
if user.RefreshOsuInfo() == nil {
|
||||||
arn.PrettyPrint(user.Accounts.Osu)
|
arn.PrettyPrint(user.Accounts.Osu)
|
||||||
user.Save()
|
|
||||||
|
// Fetch user again to prevent writing old data
|
||||||
|
updatedUser, _ := arn.GetUser(user.ID)
|
||||||
|
updatedUser.Accounts.Osu = user.Accounts.Osu
|
||||||
|
updatedUser.Save()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for rate limiter
|
// Wait for rate limiter
|
||||||
|
@ -27,7 +27,7 @@ component SoundTrackFooter(track *arn.SoundTrack)
|
|||||||
span posted
|
span posted
|
||||||
span.utc-date(data-date=track.Created)
|
span.utc-date(data-date=track.Created)
|
||||||
span by
|
span by
|
||||||
a.ajax(href=track.CreatedByUser().Link())= track.CreatedByUser().Nick + " "
|
a.ajax(href=track.Creator().Link())= track.Creator().Nick + " "
|
||||||
|
|
||||||
component ExternalMedia(media *arn.ExternalMedia)
|
component ExternalMedia(media *arn.ExternalMedia)
|
||||||
iframe.lazy(data-src=media.EmbedLink(), allowfullscreen="allowfullscreen")
|
iframe.lazy(data-src=media.EmbedLink(), allowfullscreen="allowfullscreen")
|
@ -2,6 +2,7 @@ package groups
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"sort"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/arn"
|
"github.com/animenotifier/arn"
|
||||||
@ -9,6 +10,8 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/utils"
|
"github.com/animenotifier/notify.moe/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const groupsPerPage = 12
|
||||||
|
|
||||||
// Get ...
|
// Get ...
|
||||||
func Get(ctx *aero.Context) string {
|
func Get(ctx *aero.Context) string {
|
||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
@ -17,9 +20,21 @@ func Get(ctx *aero.Context) string {
|
|||||||
return !group.IsDraft
|
return !group.IsDraft
|
||||||
})
|
})
|
||||||
|
|
||||||
|
sort.Slice(groups, func(i, j int) bool {
|
||||||
|
if len(groups[i].Members) == len(groups[j].Members) {
|
||||||
|
return groups[i].Created > groups[j].Created
|
||||||
|
}
|
||||||
|
|
||||||
|
return len(groups[i].Members) > len(groups[j].Members)
|
||||||
|
})
|
||||||
|
|
||||||
|
if len(groups) > groupsPerPage {
|
||||||
|
groups = groups[:groupsPerPage]
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ctx.Error(http.StatusInternalServerError, "Error fetching groups", err)
|
return ctx.Error(http.StatusInternalServerError, "Error fetching groups", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx.HTML(components.Groups(groups, user))
|
return ctx.HTML(components.Groups(groups, groupsPerPage, user))
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
component Groups(groups []*arn.Group, user *arn.User)
|
component Groups(groups []*arn.Group, groupsPerPage int, user *arn.User)
|
||||||
.tabs
|
.tabs
|
||||||
Tab("Groups", "users", "/groups")
|
Tab("Groups", "users", "/groups")
|
||||||
|
|
||||||
@ -15,11 +15,17 @@ component Groups(groups []*arn.Group, user *arn.User)
|
|||||||
Icon("pencil")
|
Icon("pencil")
|
||||||
span Edit draft
|
span Edit draft
|
||||||
|
|
||||||
.groups
|
#load-more-target.groups
|
||||||
each group in groups
|
each group in groups
|
||||||
.group
|
a.group.mountable.ajax(href=group.Link())
|
||||||
h3.group-name= group.Name
|
img.group-image.lazy(data-src=group.ImageURL(), alt=group.Name)
|
||||||
.group-tagline= group.Tagline
|
.group-info
|
||||||
.group-member-count
|
h3.group-name= group.Name
|
||||||
Icon("user")
|
.group-tagline= group.Tagline
|
||||||
span= len(group.Members)
|
.group-member-count
|
||||||
|
Icon("user")
|
||||||
|
span= len(group.Members)
|
||||||
|
|
||||||
|
if len(groups) == groupsPerPage
|
||||||
|
.buttons
|
||||||
|
LoadMore(groupsPerPage)
|
@ -1,15 +1,32 @@
|
|||||||
|
group-padding-y = 0.75rem
|
||||||
|
group-padding-x = 0.75rem
|
||||||
|
|
||||||
.groups
|
.groups
|
||||||
horizontal-wrap
|
horizontal-wrap
|
||||||
justify-content space-around
|
justify-content space-around
|
||||||
|
|
||||||
.group
|
.group
|
||||||
vertical
|
horizontal
|
||||||
ui-element
|
ui-element
|
||||||
position relative
|
position relative
|
||||||
width 100%
|
width 100%
|
||||||
max-width 500px
|
max-width 520px
|
||||||
padding 0.5rem 1rem
|
padding group-padding-y group-padding-x
|
||||||
margin calc(content-padding / 2)
|
margin calc(content-padding / 2)
|
||||||
|
color text-color
|
||||||
|
|
||||||
|
:hover
|
||||||
|
color white
|
||||||
|
background-color rgb(60, 60, 60)
|
||||||
|
|
||||||
|
.group-image
|
||||||
|
width 70px
|
||||||
|
height 70px
|
||||||
|
margin-right 1rem
|
||||||
|
border-radius ui-element-border-radius
|
||||||
|
|
||||||
|
.group-info
|
||||||
|
vertical
|
||||||
|
|
||||||
.group-name
|
.group-name
|
||||||
horizontal
|
horizontal
|
||||||
|
@ -38,7 +38,7 @@ component Track(track *arn.SoundTrack)
|
|||||||
span Posted
|
span Posted
|
||||||
span.utc-date(data-date=track.Created)
|
span.utc-date(data-date=track.Created)
|
||||||
span by
|
span by
|
||||||
span= track.CreatedByUser().Nick
|
span= track.Creator().Nick
|
||||||
|
|
||||||
span .
|
span .
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ ui-background = rgb(254, 254, 254)
|
|||||||
// ui-background = linear-gradient(to bottom, rgba(0, 0, 0, 0.02) 0%, rgba(0, 0, 0, 0.037) 100%)
|
// ui-background = linear-gradient(to bottom, rgba(0, 0, 0, 0.02) 0%, rgba(0, 0, 0, 0.037) 100%)
|
||||||
// ui-hover-background = linear-gradient(to bottom, rgba(0, 0, 0, 0.01) 0%, rgba(0, 0, 0, 0.027) 100%)
|
// ui-hover-background = linear-gradient(to bottom, rgba(0, 0, 0, 0.01) 0%, rgba(0, 0, 0, 0.027) 100%)
|
||||||
ui-disabled-color = rgb(224, 224, 224)
|
ui-disabled-color = rgb(224, 224, 224)
|
||||||
|
ui-element-border-radius = 3px
|
||||||
|
|
||||||
// Input
|
// Input
|
||||||
input-focus-border-color = rgb(248, 165, 130)
|
input-focus-border-color = rgb(248, 165, 130)
|
||||||
|
@ -26,7 +26,7 @@ mixin noise-strong
|
|||||||
mixin ui-element
|
mixin ui-element
|
||||||
border 1px solid ui-border-color
|
border 1px solid ui-border-color
|
||||||
background ui-background
|
background ui-background
|
||||||
border-radius 3px
|
border-radius ui-element-border-radius
|
||||||
default-transition
|
default-transition
|
||||||
:hover
|
:hover
|
||||||
border-color ui-hover-border-color
|
border-color ui-hover-border-color
|
||||||
|
Loading…
Reference in New Issue
Block a user