diff --git a/mixins/AMV.pixy b/mixins/AMV.pixy new file mode 100644 index 00000000..59b0c619 --- /dev/null +++ b/mixins/AMV.pixy @@ -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") \ No newline at end of file diff --git a/pages/amv/amv.go b/pages/amv/amv.go index d6394779..ec34971b 100644 --- a/pages/amv/amv.go +++ b/pages/amv/amv.go @@ -1,8 +1,23 @@ 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. 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)) } diff --git a/pages/amv/amv.pixy b/pages/amv/amv.pixy index 0ad63fa8..63ddb4e0 100644 --- a/pages/amv/amv.pixy +++ b/pages/amv/amv.pixy @@ -1,2 +1,17 @@ -component AMV(amv *arn.AMV, user *arn.User) - h1= amv.Title.ByUser(user) \ No newline at end of file +component AMVPage(amv *arn.AMV, user *arn.User) + AMVTabs(amv, user) + + if amv.Title.String() == "" + h1 untitled + else + 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") \ No newline at end of file diff --git a/pages/amv/edit.go b/pages/amv/edit.go new file mode 100644 index 00000000..a89c6929 --- /dev/null +++ b/pages/amv/edit.go @@ -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)) +} diff --git a/pages/amv/history.go b/pages/amv/history.go new file mode 100644 index 00000000..f8d6ec0d --- /dev/null +++ b/pages/amv/history.go @@ -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) +} diff --git a/pages/index.go b/pages/index.go index df1aebd6..bdc6629b 100644 --- a/pages/index.go +++ b/pages/index.go @@ -145,6 +145,8 @@ func Configure(app *aero.Application) { l.Page("/amvs", amvs.Latest) l.Page("/amvs/best", amvs.Best) l.Page("/amv/:id", amv.Get) + l.Page("/amv/:id/edit", amv.Edit) + l.Page("/amv/:id/history", amv.History) // Quotes l.Page("/quote/:id", quote.Get) diff --git a/utils/editform/editform.go b/utils/editform/editform.go index 032c40c5..ddfcc444 100644 --- a/utils/editform/editform.go +++ b/utils/editform/editform.go @@ -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 if idType == "" { switch field.Name { - case "AnimeID": + case "AnimeID", "MainAnimeID": idType = "Anime" case "CharacterID":