Implemented editor score
This commit is contained in:
parent
bf5ee9798b
commit
0127ea0f1c
@ -35,6 +35,14 @@ component Sidebar(user *arn.User)
|
||||
|
||||
if arn.IsDevelopment()
|
||||
SidebarButton("Groups", "/groups", "users")
|
||||
|
||||
if user != nil && (user.Role == "editor" || user.Role == "admin")
|
||||
if user.Role == "admin"
|
||||
SidebarButton("Admin", "/admin", "wrench")
|
||||
|
||||
if (user.Role == "editor" || user.Role == "admin")
|
||||
SidebarButton("Editor", "/editor", "pencil")
|
||||
|
||||
SidebarButton("Log", "/log", "list")
|
||||
|
||||
//- Disabled:
|
||||
@ -54,13 +62,6 @@ component Sidebar(user *arn.User)
|
||||
Icon("search")
|
||||
FuzzySearch
|
||||
|
||||
if user != nil
|
||||
if user.Role == "admin"
|
||||
SidebarButton("Admin", "/admin", "wrench")
|
||||
|
||||
if user.Role == "editor"
|
||||
SidebarButton("Editor", "/editor", "pencil")
|
||||
|
||||
a.sidebar-link.action(href="#", data-action="toggleTheme", data-trigger="click")
|
||||
.sidebar-button
|
||||
Icon("paint-brush")
|
||||
|
@ -2,6 +2,7 @@ package editor
|
||||
|
||||
import (
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
@ -14,5 +15,27 @@ func Get(ctx *aero.Context) string {
|
||||
return ctx.Redirect("/")
|
||||
}
|
||||
|
||||
return ctx.HTML(components.Editor(ctx.URI(), user))
|
||||
logEntries := arn.FilterEditLogEntries(func(entry *arn.EditLogEntry) bool {
|
||||
return entry.UserID == user.ID
|
||||
})
|
||||
|
||||
score := 0
|
||||
|
||||
for _, entry := range logEntries {
|
||||
switch entry.Action {
|
||||
case "create":
|
||||
score += 10
|
||||
|
||||
case "edit":
|
||||
score += 2
|
||||
|
||||
case "delete", "arrayRemove":
|
||||
score++
|
||||
|
||||
case "arrayAppend":
|
||||
// No score
|
||||
}
|
||||
}
|
||||
|
||||
return ctx.HTML(components.Editor(ctx.URI(), score, user))
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
component Editor(url string, user *arn.User)
|
||||
component Editor(url string, score int, user *arn.User)
|
||||
EditorTabs(url)
|
||||
h1.mountable= "Welcome to the Editor Panel, " + user.Nick + "!"
|
||||
|
||||
.feature-cards
|
||||
.feature-card.mountable
|
||||
.feature-card-icon.editor-score 0
|
||||
.feature-card-icon.editor-score= score
|
||||
|
||||
p.feature-card-text Your contribution score (wip).
|
||||
p.feature-card-text Your contribution score.
|
||||
|
||||
component EditorTabs(url string)
|
||||
.tabs
|
||||
|
Loading…
Reference in New Issue
Block a user