Added character editing UI
This commit is contained in:
parent
68bc7c4c8e
commit
76831c469f
@ -1,9 +1,20 @@
|
||||
component CharacterTabs(character *arn.Character, user *arn.User)
|
||||
.tabs
|
||||
Tab("Character", "user", character.Link())
|
||||
Tab("Edit", "pencil", character.Link() + "/edit")
|
||||
Tab("History", "history", character.Link() + "/history")
|
||||
|
||||
component CharacterDetails(character *arn.Character, characterAnime []*arn.Anime, quotes []*arn.Quote, mainQuote *arn.Quote, user *arn.User)
|
||||
.character-page
|
||||
.character-left-column
|
||||
.character-header
|
||||
.character-image-container.mountable
|
||||
img.character-image-fullsize(src=character.ImageLink("large"), alt=character.Name.Canonical)
|
||||
|
||||
.buttons
|
||||
a.button(href=character.Link() + "/edit")
|
||||
Icon("pencil")
|
||||
span Edit character
|
||||
|
||||
.character-description-container
|
||||
h1.character-name.mountable= character.Name.Canonical
|
||||
@ -11,8 +22,6 @@ component CharacterDetails(character *arn.Character, characterAnime []*arn.Anime
|
||||
.anime-alternative-title.mountable
|
||||
if character.Name.Japanese != ""
|
||||
Japanese(character.Name.Japanese)
|
||||
else
|
||||
Japanese("日本語の名前無し")
|
||||
|
||||
if mainQuote != nil
|
||||
.character-quote
|
||||
|
24
pages/character/edit.go
Normal file
24
pages/character/edit.go
Normal file
@ -0,0 +1,24 @@
|
||||
package character
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
"github.com/animenotifier/notify.moe/utils/editform"
|
||||
)
|
||||
|
||||
// Edit character.
|
||||
func Edit(ctx *aero.Context) string {
|
||||
id := ctx.Get("id")
|
||||
character, err := arn.GetCharacter(id)
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusNotFound, "Character not found", err)
|
||||
}
|
||||
|
||||
return ctx.HTML(components.CharacterTabs(character, user) + editform.Render(character, "Edit character", user))
|
||||
}
|
29
pages/character/history.go
Normal file
29
pages/character/history.go
Normal file
@ -0,0 +1,29 @@
|
||||
package character
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
|
||||
// History of the edits.
|
||||
func History(ctx *aero.Context) string {
|
||||
id := ctx.Get("id")
|
||||
user := utils.GetUser(ctx)
|
||||
character, err := arn.GetCharacter(id)
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusNotFound, "Character not found", err)
|
||||
}
|
||||
|
||||
entries := arn.FilterEditLogEntries(func(entry *arn.EditLogEntry) bool {
|
||||
return entry.ObjectType == "Character" && entry.ObjectID == id
|
||||
})
|
||||
|
||||
arn.SortEditLogEntriesLatestFirst(entries)
|
||||
|
||||
return ctx.HTML(components.CharacterTabs(character, user) + components.EditLog(entries, user))
|
||||
}
|
@ -136,6 +136,8 @@ func Configure(app *aero.Application) {
|
||||
|
||||
// Characters
|
||||
l.Page("/character/:id", character.Get)
|
||||
l.Page("/character/:id/edit", character.Edit)
|
||||
l.Page("/character/:id/history", character.History)
|
||||
|
||||
// Quotes
|
||||
l.Page("/quote/:id", quote.Get)
|
||||
|
Loading…
Reference in New Issue
Block a user