Added AMV editing UI
This commit is contained in:
parent
d19542b5aa
commit
42c72b6174
7
mixins/AMV.pixy
Normal file
7
mixins/AMV.pixy
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
component AMV(amv *arn.AMV, user *arn.User)
|
||||||
|
p= amv.Title.ByUser(user)
|
||||||
|
|
||||||
|
.amv.mountable
|
||||||
|
.video-container
|
||||||
|
video.video(controls="controls", controlsList="nodownload")
|
||||||
|
source(src="", type="video/webm")
|
@ -1,8 +1,23 @@
|
|||||||
package amv
|
package amv
|
||||||
|
|
||||||
import "github.com/aerogo/aero"
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/aerogo/aero"
|
||||||
|
"github.com/animenotifier/arn"
|
||||||
|
"github.com/animenotifier/notify.moe/components"
|
||||||
|
"github.com/animenotifier/notify.moe/utils"
|
||||||
|
)
|
||||||
|
|
||||||
// Get a single AMV.
|
// Get a single AMV.
|
||||||
func Get(ctx *aero.Context) string {
|
func Get(ctx *aero.Context) string {
|
||||||
return ctx.HTML("Coming soon™.")
|
id := ctx.Get("id")
|
||||||
|
amv, err := arn.GetAMV(id)
|
||||||
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return ctx.Error(http.StatusNotFound, "AMV not found", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctx.HTML(components.AMVPage(amv, user))
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,17 @@
|
|||||||
component AMV(amv *arn.AMV, user *arn.User)
|
component AMVPage(amv *arn.AMV, user *arn.User)
|
||||||
|
AMVTabs(amv, user)
|
||||||
|
|
||||||
|
if amv.Title.String() == ""
|
||||||
|
h1 untitled
|
||||||
|
else
|
||||||
h1= amv.Title.ByUser(user)
|
h1= amv.Title.ByUser(user)
|
||||||
|
|
||||||
|
component AMVTabs(amv *arn.AMV, user *arn.User)
|
||||||
|
.tabs
|
||||||
|
TabLike(strconv.Itoa(len(amv.Likes)), "heart", "amv", amv, user)
|
||||||
|
Tab("AMV", "video-camera", amv.Link())
|
||||||
|
|
||||||
|
if user != nil
|
||||||
|
Tab("Edit", "pencil", amv.Link() + "/edit")
|
||||||
|
|
||||||
|
Tab("History", "history", amv.Link() + "/history")
|
24
pages/amv/edit.go
Normal file
24
pages/amv/edit.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package amv
|
||||||
|
|
||||||
|
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 track.
|
||||||
|
func Edit(ctx *aero.Context) string {
|
||||||
|
id := ctx.Get("id")
|
||||||
|
amv, err := arn.GetAMV(id)
|
||||||
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return ctx.Error(http.StatusNotFound, "AMV not found", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctx.HTML(components.AMVTabs(amv, user) + editform.Render(amv, "Edit AMV", user))
|
||||||
|
}
|
14
pages/amv/history.go
Normal file
14
pages/amv/history.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package amv
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/animenotifier/arn"
|
||||||
|
"github.com/animenotifier/notify.moe/components"
|
||||||
|
"github.com/animenotifier/notify.moe/utils/history"
|
||||||
|
)
|
||||||
|
|
||||||
|
// History of the edits.
|
||||||
|
var History = history.Handler(renderHistory, "AMV")
|
||||||
|
|
||||||
|
func renderHistory(obj interface{}, entries []*arn.EditLogEntry, user *arn.User) string {
|
||||||
|
return components.AMVTabs(obj.(*arn.AMV), user) + components.EditLog(entries, user)
|
||||||
|
}
|
@ -145,6 +145,8 @@ func Configure(app *aero.Application) {
|
|||||||
l.Page("/amvs", amvs.Latest)
|
l.Page("/amvs", amvs.Latest)
|
||||||
l.Page("/amvs/best", amvs.Best)
|
l.Page("/amvs/best", amvs.Best)
|
||||||
l.Page("/amv/:id", amv.Get)
|
l.Page("/amv/:id", amv.Get)
|
||||||
|
l.Page("/amv/:id/edit", amv.Edit)
|
||||||
|
l.Page("/amv/:id/history", amv.History)
|
||||||
|
|
||||||
// Quotes
|
// Quotes
|
||||||
l.Page("/quote/:id", quote.Get)
|
l.Page("/quote/:id", quote.Get)
|
||||||
|
@ -120,7 +120,7 @@ func RenderField(b *bytes.Buffer, v *reflect.Value, field reflect.StructField, i
|
|||||||
// Try to infer the ID type by the field name
|
// Try to infer the ID type by the field name
|
||||||
if idType == "" {
|
if idType == "" {
|
||||||
switch field.Name {
|
switch field.Name {
|
||||||
case "AnimeID":
|
case "AnimeID", "MainAnimeID":
|
||||||
idType = "Anime"
|
idType = "Anime"
|
||||||
|
|
||||||
case "CharacterID":
|
case "CharacterID":
|
||||||
|
Loading…
Reference in New Issue
Block a user