diff --git a/hypview/hypview.go b/hypview/hypview.go index df800dd..e8917cf 100644 --- a/hypview/hypview.go +++ b/hypview/hypview.go @@ -71,12 +71,17 @@ var ( {{define "rename recursively"}}Также переименовать подгифы{{end}} {{define "rename tip"}}Переименовывайте аккуратно. Документация на английском.{{end}} {{define "leave redirection"}}Оставить перенаправление{{end}} + +{{define "remove media from x?"}}Убрать медиа у {{beautifulName .}}?{{end}} +{{define "remove media from [[x]]?"}}Убрать медиа у {{beautifulName .HyphaName}}?{{end}} +{{define "remove media for real?"}}Вы точно хотите убрать медиа у гифы «{{beautifulName .HyphaName}}»?{{end}} ` chainNaviTitle viewutil.Chain chainEditHypha viewutil.Chain chainEmptyHypha viewutil.Chain chainDeleteHypha viewutil.Chain chainRenameHypha viewutil.Chain + chainRemoveMedia viewutil.Chain ) func Init() { @@ -85,6 +90,7 @@ func Init() { chainEmptyHypha = viewutil.CopyEnRuWith(fs, "view_empty_hypha.html", ruTranslation) chainDeleteHypha = viewutil.CopyEnRuWith(fs, "view_delete.html", ruTranslation) chainRenameHypha = viewutil.CopyEnRuWith(fs, "view_rename.html", ruTranslation) + chainRemoveMedia = viewutil.CopyEnRuWith(fs, "view_remove_media.html", ruTranslation) } type editData struct { @@ -126,13 +132,13 @@ func RenameHypha(meta viewutil.Meta, hyphaName string) { }) } -type deleteData struct { +type deleteRemoveMediaData struct { *viewutil.BaseData HyphaName string } func DeleteHypha(meta viewutil.Meta, hyphaName string) { - viewutil.ExecutePage(meta, chainDeleteHypha, deleteData{ + viewutil.ExecutePage(meta, chainDeleteHypha, deleteRemoveMediaData{ BaseData: &viewutil.BaseData{ Addr: "/delete/" + hyphaName, }, @@ -140,6 +146,15 @@ func DeleteHypha(meta viewutil.Meta, hyphaName string) { }) } +func RemoveMedia(meta viewutil.Meta, hyphaName string) { + viewutil.ExecutePage(meta, chainRemoveMedia, deleteRemoveMediaData{ + BaseData: &viewutil.BaseData{ + Addr: "/remove-media/" + hyphaName, + }, + HyphaName: hyphaName, + }) +} + type emptyHyphaData struct { Meta viewutil.Meta HyphaName string diff --git a/hypview/remove_media.qtpl b/hypview/remove_media.qtpl deleted file mode 100644 index 617975e..0000000 --- a/hypview/remove_media.qtpl +++ /dev/null @@ -1,28 +0,0 @@ -{% import "fmt" %} -{% import "net/http" %} -{% import "github.com/bouncepaw/mycorrhiza/l18n" %} - -{% func RemoveMediaAsk(rq *http.Request, hyphaName string) %} -{% code - lc := l18n.FromRequest(rq) -%} - - - - - {%s= fmt.Sprintf(lc.Get("ui.ask_remove_media"), beautifulLink(hyphaName)) %} - - - {%s= lc.Get("ui.ask_really", &l18n.Replacements{"verb": lc.Get("ui.ask_remove_media_verb"), "name": fmt.Sprintf("%s", hyphaName)}) %} - - - {%s lc.Get("ui.confirm") %} - - - {%s lc.Get("ui.cancel") %} - - - - -{% endfunc %} - diff --git a/hypview/remove_media.qtpl.go b/hypview/remove_media.qtpl.go deleted file mode 100644 index 2ce45fb..0000000 --- a/hypview/remove_media.qtpl.go +++ /dev/null @@ -1,109 +0,0 @@ -// Code generated by qtc from "remove_media.qtpl". DO NOT EDIT. -// See https://github.com/valyala/quicktemplate for details. - -//line hypview/remove_media.qtpl:1 -package hypview - -//line hypview/remove_media.qtpl:1 -import "fmt" - -//line hypview/remove_media.qtpl:2 -import "net/http" - -//line hypview/remove_media.qtpl:3 -import "github.com/bouncepaw/mycorrhiza/l18n" - -//line hypview/remove_media.qtpl:5 -import ( - qtio422016 "io" - - qt422016 "github.com/valyala/quicktemplate" -) - -//line hypview/remove_media.qtpl:5 -var ( - _ = qtio422016.Copy - _ = qt422016.AcquireByteBuffer -) - -//line hypview/remove_media.qtpl:5 -func StreamRemoveMediaAsk(qw422016 *qt422016.Writer, rq *http.Request, hyphaName string) { -//line hypview/remove_media.qtpl:5 - qw422016.N().S(` -`) -//line hypview/remove_media.qtpl:7 - lc := l18n.FromRequest(rq) - -//line hypview/remove_media.qtpl:8 - qw422016.N().S(` - - - - - `) -//line hypview/remove_media.qtpl:13 - qw422016.N().S(fmt.Sprintf(lc.Get("ui.ask_remove_media"), beautifulLink(hyphaName))) -//line hypview/remove_media.qtpl:13 - qw422016.N().S(` - - - `) -//line hypview/remove_media.qtpl:16 - qw422016.N().S(lc.Get("ui.ask_really", &l18n.Replacements{"verb": lc.Get("ui.ask_remove_media_verb"), "name": fmt.Sprintf("%s", hyphaName)})) -//line hypview/remove_media.qtpl:16 - qw422016.N().S(` - - - `) -//line hypview/remove_media.qtpl:19 - qw422016.E().S(lc.Get("ui.confirm")) -//line hypview/remove_media.qtpl:19 - qw422016.N().S(` - - - `) -//line hypview/remove_media.qtpl:22 - qw422016.E().S(lc.Get("ui.cancel")) -//line hypview/remove_media.qtpl:22 - qw422016.N().S(` - - - - -`) -//line hypview/remove_media.qtpl:27 -} - -//line hypview/remove_media.qtpl:27 -func WriteRemoveMediaAsk(qq422016 qtio422016.Writer, rq *http.Request, hyphaName string) { -//line hypview/remove_media.qtpl:27 - qw422016 := qt422016.AcquireWriter(qq422016) -//line hypview/remove_media.qtpl:27 - StreamRemoveMediaAsk(qw422016, rq, hyphaName) -//line hypview/remove_media.qtpl:27 - qt422016.ReleaseWriter(qw422016) -//line hypview/remove_media.qtpl:27 -} - -//line hypview/remove_media.qtpl:27 -func RemoveMediaAsk(rq *http.Request, hyphaName string) string { -//line hypview/remove_media.qtpl:27 - qb422016 := qt422016.AcquireByteBuffer() -//line hypview/remove_media.qtpl:27 - WriteRemoveMediaAsk(qb422016, rq, hyphaName) -//line hypview/remove_media.qtpl:27 - qs422016 := string(qb422016.B) -//line hypview/remove_media.qtpl:27 - qt422016.ReleaseByteBuffer(qb422016) -//line hypview/remove_media.qtpl:27 - return qs422016 -//line hypview/remove_media.qtpl:27 -} diff --git a/hypview/view_remove_media.html b/hypview/view_remove_media.html new file mode 100644 index 0000000..3edd8d8 --- /dev/null +++ b/hypview/view_remove_media.html @@ -0,0 +1,22 @@ +{{define "remove media from x?"}}Remove media from {{beautifulName .}}?{{end}} +{{define "title"}}{{template "remove media from x?" .HyphaName}}{{end}} +{{define "body"}} + + + + + {{block "remove media from [[x]]?" .}}Remove media from {{beautifulName .HyphaName}}?{{end}} + + + {{block "remove media for real?" .}}Do you really want to remove media from hypha ‘{{beautifulName .HyphaName}}’?{{end}} + + + {{template "confirm"}} + + + {{template "cancel"}} + + + + +{{end}} \ No newline at end of file diff --git a/web/mutators.go b/web/mutators.go index 7c86b9d..e85ddda 100644 --- a/web/mutators.go +++ b/web/mutators.go @@ -1,7 +1,6 @@ package web import ( - "fmt" "git.sr.ht/~bouncepaw/mycomarkup/v5" "html/template" "log" @@ -37,7 +36,6 @@ func handlerRemoveMedia(w http.ResponseWriter, rq *http.Request) { util.PrepareRq(rq) var ( u = user.FromRequest(rq) - lc = l18n.FromRequest(rq) h = hyphae.ByName(util.HyphaNameFromRq(rq, "remove-media")) meta = viewutil.MetaFrom(w, rq) ) @@ -46,14 +44,7 @@ func handlerRemoveMedia(w http.ResponseWriter, rq *http.Request) { return } if rq.Method == "GET" { - util.HTTP200Page( - w, - viewutil.Base( - meta, - fmt.Sprintf(lc.Get("ui.ask_remove_media"), util.BeautifulName(h.CanonicalName())), - hypview.RemoveMediaAsk(rq, h.CanonicalName()), - map[string]string{}, - )) + hypview.RemoveMedia(viewutil.MetaFrom(w, rq), h.CanonicalName()) return } switch h := h.(type) {
- {%s= lc.Get("ui.ask_really", &l18n.Replacements{"verb": lc.Get("ui.ask_remove_media_verb"), "name": fmt.Sprintf("%s", hyphaName)}) %} -
- `) -//line hypview/remove_media.qtpl:16 - qw422016.N().S(lc.Get("ui.ask_really", &l18n.Replacements{"verb": lc.Get("ui.ask_remove_media_verb"), "name": fmt.Sprintf("%s", hyphaName)})) -//line hypview/remove_media.qtpl:16 - qw422016.N().S(` -
+ {{block "remove media for real?" .}}Do you really want to remove media from hypha ‘{{beautifulName .HyphaName}}’?{{end}} +