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 "confirm"}} - + {{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"}} + + + + + {{block "rename [[hypha]]?" .HyphaName}}Rename {{beautifulName .}}?{{end}} + + {{block "new name" .}}New name:{{end}} + + + + {{block "rename recursively" .}}Rename subhyphae too{{end}} + + {{block "rename tip" .}}If you rename this hypha, all incoming links and all relative outcoming links will break. You will also lose all history for the new name. Rename carefully.{{end}} + + {{template "confirm"}} + + + {{template "cancel"}} + + + + +{{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) -%} - - - - - {%s= fmt.Sprintf(lc.Get("ui.ask_rename"), beautifulLink(hyphaName)) %} - - {%s lc.Get("ui.rename_to") %} - - - - {%s lc.Get("ui.rename_recurse") %} - - {%s lc.Get("ui.rename_tip") %} - - {%s lc.Get("ui.confirm") %} - - - {%s lc.Get("ui.cancel") %} - - - - -{% 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:37 - qw422016.N().S(fmt.Sprintf(lc.Get("ui.ask_rename"), beautifulLink(hyphaName))) -//line views/modal.qtpl:37 - qw422016.N().S(` - - `) -//line views/modal.qtpl:39 - qw422016.E().S(lc.Get("ui.rename_to")) -//line views/modal.qtpl:39 - qw422016.N().S(` - - - - `) -//line views/modal.qtpl:43 - qw422016.E().S(lc.Get("ui.rename_recurse")) -//line views/modal.qtpl:43 - qw422016.N().S(` - - `) -//line views/modal.qtpl:45 - qw422016.E().S(lc.Get("ui.rename_tip")) -//line views/modal.qtpl:45 - qw422016.N().S(` - - `) -//line views/modal.qtpl:47 - qw422016.E().S(lc.Get("ui.confirm")) -//line views/modal.qtpl:47 - qw422016.N().S(` - - - `) -//line views/modal.qtpl:50 - qw422016.E().S(lc.Get("ui.cancel")) -//line views/modal.qtpl:50 - 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 }
{{block "rename tip" .}}If you rename this hypha, all incoming links and all relative outcoming links will break. You will also lose all history for the new name. Rename carefully.{{end}}
{%s lc.Get("ui.rename_tip") %}
`) -//line views/modal.qtpl:45 - qw422016.E().S(lc.Get("ui.rename_tip")) -//line views/modal.qtpl:45 - qw422016.N().S(`