From df1f94eae420d1ffc6861a76cefc0cdf53071c80 Mon Sep 17 00:00:00 2001 From: Timur Ismagilov Date: Thu, 16 Jun 2022 14:19:42 +0300 Subject: [PATCH] Isolate hypha renaming view --- hypview/hypview.go | 21 ++++++++- hypview/view_delete.html | 2 +- hypview/view_rename.html | 26 +++++++++++ views/modal.qtpl | 27 ----------- views/modal.qtpl.go | 98 ---------------------------------------- web/mutators.go | 7 +-- 6 files changed, 47 insertions(+), 134 deletions(-) create mode 100644 hypview/view_rename.html diff --git a/hypview/hypview.go b/hypview/hypview.go index cfdd498..1e10598 100644 --- a/hypview/hypview.go +++ b/hypview/hypview.go @@ -28,25 +28,42 @@ var ( {{define "delete [[hypha]]?"}}Удалить {{beautifulName .}}?{{end}} {{define "want to delete?"}}Вы действительно хотите удалить эту гифу?{{end}} {{define "delete tip"}}Нельзя отменить удаление гифы, но её история останется доступной.{{end}} + +{{define "rename hypha?"}}Переименовать {{beautifulName .}}?{{end}} +{{define "rename [[hypha]]?"}}Переименовать {{beautifulName .}}?{{end}} +{{define "new name"}}Новое название:{{end}} +{{define "rename recursively"}}Также переименовать подгифы{{end}} +{{define "rename tip"}}Если вы переименуете эту гифу, сломаются все ссылки, ведущие на неё, а также исходящие относительные ссылки. Также вы потеряете всю текущую историю для нового названия. Переименовывайте аккуратно.{{end}} ` chainNaviTitle viewutil.Chain chainEmptyHypha viewutil.Chain chainDeleteHypha viewutil.Chain + chainRenameHypha viewutil.Chain ) func Init() { chainNaviTitle = viewutil.CopyEnRuWith(fs, "view_navititle.html", "") 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) } -type deleteData struct { +type deleteRenameData struct { *viewutil.BaseData HyphaName string } +func RenameHypha(meta viewutil.Meta, hyphaName string) { + viewutil.ExecutePage(meta, chainRenameHypha, deleteRenameData{ + BaseData: &viewutil.BaseData{ + Addr: "/rename/" + hyphaName, + }, + HyphaName: hyphaName, + }) +} + func DeleteHypha(meta viewutil.Meta, hyphaName string) { - viewutil.ExecutePage(meta, chainDeleteHypha, deleteData{ + viewutil.ExecutePage(meta, chainDeleteHypha, deleteRenameData{ BaseData: &viewutil.BaseData{ Addr: "/delete/" + hyphaName, }, diff --git a/hypview/view_delete.html b/hypview/view_delete.html index eb08429..701f3fc 100644 --- a/hypview/view_delete.html +++ b/hypview/view_delete.html @@ -14,7 +14,7 @@ - + {{template "cancel"}} diff --git a/hypview/view_rename.html b/hypview/view_rename.html new file mode 100644 index 0000000..11c5b55 --- /dev/null +++ b/hypview/view_rename.html @@ -0,0 +1,26 @@ +{{define "rename hypha?"}}Rename {{beautifulName .}}?{{end}} +{{define "title"}}{{template "rename hypha?" .HyphaName}}{{end}} +{{define "body"}} +
+ +
+{{end}} \ No newline at end of file diff --git a/views/modal.qtpl b/views/modal.qtpl index fb9258e..617975e 100644 --- a/views/modal.qtpl +++ b/views/modal.qtpl @@ -26,30 +26,3 @@ {% endfunc %} -{% func RenameAsk(rq *http.Request, hyphaName string) %} -{% code - lc := l18n.FromRequest(rq) -%} -
- -
-{% endfunc %} diff --git a/views/modal.qtpl.go b/views/modal.qtpl.go index 5edb5ad..cfabcee 100644 --- a/views/modal.qtpl.go +++ b/views/modal.qtpl.go @@ -107,101 +107,3 @@ func RemoveMediaAsk(rq *http.Request, hyphaName string) string { return qs422016 //line views/modal.qtpl:27 } - -//line views/modal.qtpl:29 -func StreamRenameAsk(qw422016 *qt422016.Writer, rq *http.Request, hyphaName string) { -//line views/modal.qtpl:29 - qw422016.N().S(` -`) -//line views/modal.qtpl:31 - lc := l18n.FromRequest(rq) - -//line views/modal.qtpl:32 - qw422016.N().S(` -
- -
-`) -//line views/modal.qtpl:55 -} - -//line views/modal.qtpl:55 -func WriteRenameAsk(qq422016 qtio422016.Writer, rq *http.Request, hyphaName string) { -//line views/modal.qtpl:55 - qw422016 := qt422016.AcquireWriter(qq422016) -//line views/modal.qtpl:55 - StreamRenameAsk(qw422016, rq, hyphaName) -//line views/modal.qtpl:55 - qt422016.ReleaseWriter(qw422016) -//line views/modal.qtpl:55 -} - -//line views/modal.qtpl:55 -func RenameAsk(rq *http.Request, hyphaName string) string { -//line views/modal.qtpl:55 - qb422016 := qt422016.AcquireByteBuffer() -//line views/modal.qtpl:55 - WriteRenameAsk(qb422016, rq, hyphaName) -//line views/modal.qtpl:55 - qs422016 := string(qb422016.B) -//line views/modal.qtpl:55 - qt422016.ReleaseByteBuffer(qb422016) -//line views/modal.qtpl:55 - return qs422016 -//line views/modal.qtpl:55 -} diff --git a/web/mutators.go b/web/mutators.go index a049105..43c846f 100644 --- a/web/mutators.go +++ b/web/mutators.go @@ -130,12 +130,7 @@ func handlerRename(w http.ResponseWriter, rq *http.Request) { ) if rq.Method == "GET" { - util.HTTP200Page( - w, - views.Base( - meta, - fmt.Sprintf(lc.Get("ui.ask_rename"), util.BeautifulName(oldHypha.CanonicalName())), - views.RenameAsk(rq, oldHypha.CanonicalName()))) + hypview.RenameHypha(meta, h.CanonicalName()) return }