1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2025-01-20 23:36:51 +00:00

Isolate hypha deletion view

This commit is contained in:
Timur Ismagilov 2022-06-16 14:05:30 +03:00
parent 66c3c1570d
commit 684c53aa8c
9 changed files with 114 additions and 184 deletions

View File

@ -23,14 +23,35 @@ var (
{{define "upload a media"}}Загрузить медиа{{end}}
{{define "upload a media tip"}}Загрузите изображение, видео или аудио. Распространённые форматы можно просматривать из браузера, остальные просто скачать. Позже вы можете дописать пояснение к этому медиа.{{end}}
{{define "upload a media btn"}}Загрузить{{end}}
{{define "delete hypha?"}}Удалить {{beautifulName .}}?{{end}}
{{define "delete [[hypha]]?"}}Удалить <a href="/hypha/{{.}}">{{beautifulName .}}</a>?{{end}}
{{define "want to delete?"}}Вы действительно хотите удалить эту гифу?{{end}}
{{define "delete tip"}}Нельзя отменить удаление гифы, но её история останется доступной.{{end}}
`
chainNaviTitle viewutil.Chain
chainEmptyHypha viewutil.Chain
chainNaviTitle viewutil.Chain
chainEmptyHypha viewutil.Chain
chainDeleteHypha 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)
}
type deleteData struct {
*viewutil.BaseData
HyphaName string
}
func DeleteHypha(meta viewutil.Meta, hyphaName string) {
viewutil.ExecutePage(meta, chainDeleteHypha, deleteData{
BaseData: &viewutil.BaseData{
Addr: "/delete/" + hyphaName,
},
HyphaName: hyphaName,
})
}
type emptyHyphaData struct {

23
hypview/view_delete.html Normal file
View File

@ -0,0 +1,23 @@
{{define "title"}}{{template "delete hypha?" .HyphaName}}{{end}}
{{define "delete hypha?"}}Delete {{beautifulName .}}?{{end}}
{{define "body"}}
<main class="main-width">
<form class="modal" action="/delete/{{.HyphaName}}" method="post">
<fieldset class="modal__fieldset">
<legend class="modal__title">
{{block "delete [[hypha]]?" .HyphaName}}Delete <a href="/hypha/{{.}}">{{beautifulName .}}</a>?{{end}}
</legend>
<p class="modal__confirmation-msg">
{{block "want to delete?" .}}Do you really want to delete this hypha?{{end}}
</p>
<p>{{block "delete tip" .}}You cannot undelete a deleted hypha but the history can still be accessed.{{end}}</p>
<button type="submit" value="Confirm" class="btn" autofocus>
{{template "confirm"}}
</button>
<a href="/hypha/{%s hyphaName %}" class="btn btn_weak">
{{template "cancel"}}
</a>
</fieldset>
</form>
</main>
{{end}}

View File

@ -50,8 +50,6 @@
"act_norights_edit": "You must be an editor to edit a hypha",
"act_norights_upload_media": "You must be an editor to upload media",
"ask_delete": "Delete %s?",
"ask_delete_tip": "In this version of Mycorrhiza Wiki you cannot undelete a deleted hypha but the history can still be accessed.",
"ask_remove_media": "Remove media from %s?",
"ask_really": "Do you really want to {{.verb}} hypha {{.name}}?",
"ask_delete_verb": "delete",

View File

@ -55,11 +55,8 @@
"act_notexist_rename": "Нельзя переименовать эту гифу, потому что она не существует",
"act_notexist_remove_media": "Нельзя убрать медиа, потому что нет такой гифы",
"ask_delete": "Удалить «%s»?",
"ask_delete_tip": "В этой версии Микоризы нельзя отменить удаление гифы, но её история останется доступной.",
"ask_remove_media": "Убрать медиа у «%s»?",
"ask_really": "Вы действительно хотите {{.verb}} гифу «{{.name}}»?",
"ask_delete_verb": "удалить",
"ask_remove_media_verb": "убрать медиа",
"revision_title": "{{.name}} из {{.rev}}",

View File

@ -2,31 +2,6 @@
{% import "net/http" %}
{% import "github.com/bouncepaw/mycorrhiza/l18n" %}
{% func DeleteAsk(rq *http.Request, hyphaName string) %}
{% code
lc := l18n.FromRequest(rq)
%}
<main class="main-width">
<form class="modal" action="/delete/{%s hyphaName %}" method="post">
<fieldset class="modal__fieldset">
<legend class="modal__title">
{%s= fmt.Sprintf(lc.Get("ui.ask_delete"), beautifulLink(hyphaName)) %}
</legend>
<p class="modal__confirmation-msg">
{%s= lc.Get("ui.ask_really", &l18n.Replacements{"verb": lc.Get("ui.ask_delete_verb"), "name": fmt.Sprintf("<em>%s</em>", hyphaName)}) %}
</p>
<p>{%s lc.Get("ui.ask_delete_tip") %}</p>
<button type="submit" value="Confirm" class="btn" autofocus>
{%s lc.Get("ui.confirm") %}
</button>
<a href="/hypha/{%s hyphaName %}" class="btn btn_weak">
{%s lc.Get("ui.cancel") %}
</a>
</fieldset>
</form>
</main>
{% endfunc %}
{% func RemoveMediaAsk(rq *http.Request, hyphaName string) %}
{% code
lc := l18n.FromRequest(rq)

View File

@ -27,7 +27,7 @@ var (
)
//line views/modal.qtpl:5
func StreamDeleteAsk(qw422016 *qt422016.Writer, rq *http.Request, hyphaName string) {
func StreamRemoveMediaAsk(qw422016 *qt422016.Writer, rq *http.Request, hyphaName string) {
//line views/modal.qtpl:5
qw422016.N().S(`
`)
@ -37,7 +37,7 @@ func StreamDeleteAsk(qw422016 *qt422016.Writer, rq *http.Request, hyphaName stri
//line views/modal.qtpl:8
qw422016.N().S(`
<main class="main-width">
<form class="modal" action="/delete/`)
<form class="modal" action="/remove-media/`)
//line views/modal.qtpl:10
qw422016.E().S(hyphaName)
//line views/modal.qtpl:10
@ -46,245 +46,162 @@ func StreamDeleteAsk(qw422016 *qt422016.Writer, rq *http.Request, hyphaName stri
<legend class="modal__title">
`)
//line views/modal.qtpl:13
qw422016.N().S(fmt.Sprintf(lc.Get("ui.ask_delete"), beautifulLink(hyphaName)))
qw422016.N().S(fmt.Sprintf(lc.Get("ui.ask_remove_media"), beautifulLink(hyphaName)))
//line views/modal.qtpl:13
qw422016.N().S(`
</legend>
<p class="modal__confirmation-msg">
`)
//line views/modal.qtpl:16
qw422016.N().S(lc.Get("ui.ask_really", &l18n.Replacements{"verb": lc.Get("ui.ask_delete_verb"), "name": fmt.Sprintf("<em>%s</em>", hyphaName)}))
qw422016.N().S(lc.Get("ui.ask_really", &l18n.Replacements{"verb": lc.Get("ui.ask_remove_media_verb"), "name": fmt.Sprintf("<em>%s</em>", hyphaName)}))
//line views/modal.qtpl:16
qw422016.N().S(`
</p>
<p>`)
//line views/modal.qtpl:18
qw422016.E().S(lc.Get("ui.ask_delete_tip"))
//line views/modal.qtpl:18
qw422016.N().S(`</p>
<button type="submit" value="Confirm" class="btn" autofocus>
`)
//line views/modal.qtpl:20
//line views/modal.qtpl:19
qw422016.E().S(lc.Get("ui.confirm"))
//line views/modal.qtpl:20
//line views/modal.qtpl:19
qw422016.N().S(`
</button>
<a href="/hypha/`)
//line views/modal.qtpl:22
//line views/modal.qtpl:21
qw422016.E().S(hyphaName)
//line views/modal.qtpl:22
//line views/modal.qtpl:21
qw422016.N().S(`" class="btn btn_weak">
`)
//line views/modal.qtpl:23
//line views/modal.qtpl:22
qw422016.E().S(lc.Get("ui.cancel"))
//line views/modal.qtpl:23
//line views/modal.qtpl:22
qw422016.N().S(`
</a>
</fieldset>
</form>
</main>
`)
//line views/modal.qtpl:28
//line views/modal.qtpl:27
}
//line views/modal.qtpl:28
func WriteDeleteAsk(qq422016 qtio422016.Writer, rq *http.Request, hyphaName string) {
//line views/modal.qtpl:28
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/modal.qtpl:28
StreamDeleteAsk(qw422016, rq, hyphaName)
//line views/modal.qtpl:28
qt422016.ReleaseWriter(qw422016)
//line views/modal.qtpl:28
}
//line views/modal.qtpl:28
func DeleteAsk(rq *http.Request, hyphaName string) string {
//line views/modal.qtpl:28
qb422016 := qt422016.AcquireByteBuffer()
//line views/modal.qtpl:28
WriteDeleteAsk(qb422016, rq, hyphaName)
//line views/modal.qtpl:28
qs422016 := string(qb422016.B)
//line views/modal.qtpl:28
qt422016.ReleaseByteBuffer(qb422016)
//line views/modal.qtpl:28
return qs422016
//line views/modal.qtpl:28
}
//line views/modal.qtpl:30
func StreamRemoveMediaAsk(qw422016 *qt422016.Writer, rq *http.Request, hyphaName string) {
//line views/modal.qtpl:30
qw422016.N().S(`
`)
//line views/modal.qtpl:32
lc := l18n.FromRequest(rq)
//line views/modal.qtpl:33
qw422016.N().S(`
<main class="main-width">
<form class="modal" action="/remove-media/`)
//line views/modal.qtpl:35
qw422016.E().S(hyphaName)
//line views/modal.qtpl:35
qw422016.N().S(`" method="post">
<fieldset class="modal__fieldset">
<legend class="modal__title">`)
//line views/modal.qtpl:37
qw422016.N().S(fmt.Sprintf(lc.Get("ui.ask_remove_media"), beautifulLink(hyphaName)))
//line views/modal.qtpl:37
qw422016.N().S(`</legend>
<p class="modal__confirmation-msg">
`)
//line views/modal.qtpl:39
qw422016.N().S(lc.Get("ui.ask_really", &l18n.Replacements{"verb": lc.Get("ui.ask_remove_media_verb"), "name": fmt.Sprintf("<em>%s</em>", hyphaName)}))
//line views/modal.qtpl:39
qw422016.N().S(`
</p>
<button type="submit" value="Confirm" class="btn" autofocus>
`)
//line views/modal.qtpl:42
qw422016.E().S(lc.Get("ui.confirm"))
//line views/modal.qtpl:42
qw422016.N().S(`
</button>
<a href="/hypha/`)
//line views/modal.qtpl:44
qw422016.E().S(hyphaName)
//line views/modal.qtpl:44
qw422016.N().S(`" class="btn btn_weak">
`)
//line views/modal.qtpl:45
qw422016.E().S(lc.Get("ui.cancel"))
//line views/modal.qtpl:45
qw422016.N().S(`
</a>
</fieldset>
</form>
</main>
`)
//line views/modal.qtpl:50
}
//line views/modal.qtpl:50
//line views/modal.qtpl:27
func WriteRemoveMediaAsk(qq422016 qtio422016.Writer, rq *http.Request, hyphaName string) {
//line views/modal.qtpl:50
//line views/modal.qtpl:27
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/modal.qtpl:50
//line views/modal.qtpl:27
StreamRemoveMediaAsk(qw422016, rq, hyphaName)
//line views/modal.qtpl:50
//line views/modal.qtpl:27
qt422016.ReleaseWriter(qw422016)
//line views/modal.qtpl:50
//line views/modal.qtpl:27
}
//line views/modal.qtpl:50
//line views/modal.qtpl:27
func RemoveMediaAsk(rq *http.Request, hyphaName string) string {
//line views/modal.qtpl:50
//line views/modal.qtpl:27
qb422016 := qt422016.AcquireByteBuffer()
//line views/modal.qtpl:50
//line views/modal.qtpl:27
WriteRemoveMediaAsk(qb422016, rq, hyphaName)
//line views/modal.qtpl:50
//line views/modal.qtpl:27
qs422016 := string(qb422016.B)
//line views/modal.qtpl:50
//line views/modal.qtpl:27
qt422016.ReleaseByteBuffer(qb422016)
//line views/modal.qtpl:50
//line views/modal.qtpl:27
return qs422016
//line views/modal.qtpl:50
//line views/modal.qtpl:27
}
//line views/modal.qtpl:52
//line views/modal.qtpl:29
func StreamRenameAsk(qw422016 *qt422016.Writer, rq *http.Request, hyphaName string) {
//line views/modal.qtpl:52
//line views/modal.qtpl:29
qw422016.N().S(`
`)
//line views/modal.qtpl:54
//line views/modal.qtpl:31
lc := l18n.FromRequest(rq)
//line views/modal.qtpl:55
//line views/modal.qtpl:32
qw422016.N().S(`
<main class="main-width">
<form class="modal" action="/rename/`)
//line views/modal.qtpl:57
//line views/modal.qtpl:34
qw422016.E().S(hyphaName)
//line views/modal.qtpl:57
//line views/modal.qtpl:34
qw422016.N().S(`" method="post" enctype="multipart/form-data">
<fieldset class="modal__fieldset">
<legend class="modal__title">`)
//line views/modal.qtpl:59
<legend class="modal__title">
`)
//line views/modal.qtpl:37
qw422016.N().S(fmt.Sprintf(lc.Get("ui.ask_rename"), beautifulLink(hyphaName)))
//line views/modal.qtpl:59
qw422016.N().S(`</legend>
//line views/modal.qtpl:37
qw422016.N().S(`
</legend>
<label for="new-name">`)
//line views/modal.qtpl:60
//line views/modal.qtpl:39
qw422016.E().S(lc.Get("ui.rename_to"))
//line views/modal.qtpl:60
//line views/modal.qtpl:39
qw422016.N().S(`</label>
<input type="text" value="`)
//line views/modal.qtpl:61
//line views/modal.qtpl:40
qw422016.E().S(hyphaName)
//line views/modal.qtpl:61
//line views/modal.qtpl:40
qw422016.N().S(`" required autofocus id="new-name" name="new-name"/>
<input type="checkbox" id="recursive" name="recursive" value="true" checked/>
<label for="recursive">`)
//line views/modal.qtpl:64
//line views/modal.qtpl:43
qw422016.E().S(lc.Get("ui.rename_recurse"))
//line views/modal.qtpl:64
//line views/modal.qtpl:43
qw422016.N().S(`</label>
<p>`)
//line views/modal.qtpl:66
//line views/modal.qtpl:45
qw422016.E().S(lc.Get("ui.rename_tip"))
//line views/modal.qtpl:66
//line views/modal.qtpl:45
qw422016.N().S(`</p>
<button type="submit" value="Confirm" class="btn">
`)
//line views/modal.qtpl:68
//line views/modal.qtpl:47
qw422016.E().S(lc.Get("ui.confirm"))
//line views/modal.qtpl:68
//line views/modal.qtpl:47
qw422016.N().S(`
</button>
<a href="/hypha/`)
//line views/modal.qtpl:70
//line views/modal.qtpl:49
qw422016.E().S(hyphaName)
//line views/modal.qtpl:70
//line views/modal.qtpl:49
qw422016.N().S(`" class="btn btn_weak">
`)
//line views/modal.qtpl:71
//line views/modal.qtpl:50
qw422016.E().S(lc.Get("ui.cancel"))
//line views/modal.qtpl:71
//line views/modal.qtpl:50
qw422016.N().S(`
</a>
</fieldset>
</form>
</main>
`)
//line views/modal.qtpl:76
//line views/modal.qtpl:55
}
//line views/modal.qtpl:76
//line views/modal.qtpl:55
func WriteRenameAsk(qq422016 qtio422016.Writer, rq *http.Request, hyphaName string) {
//line views/modal.qtpl:76
//line views/modal.qtpl:55
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/modal.qtpl:76
//line views/modal.qtpl:55
StreamRenameAsk(qw422016, rq, hyphaName)
//line views/modal.qtpl:76
//line views/modal.qtpl:55
qt422016.ReleaseWriter(qw422016)
//line views/modal.qtpl:76
//line views/modal.qtpl:55
}
//line views/modal.qtpl:76
//line views/modal.qtpl:55
func RenameAsk(rq *http.Request, hyphaName string) string {
//line views/modal.qtpl:76
//line views/modal.qtpl:55
qb422016 := qt422016.AcquireByteBuffer()
//line views/modal.qtpl:76
//line views/modal.qtpl:55
WriteRenameAsk(qb422016, rq, hyphaName)
//line views/modal.qtpl:76
//line views/modal.qtpl:55
qs422016 := string(qb422016.B)
//line views/modal.qtpl:76
//line views/modal.qtpl:55
qt422016.ReleaseByteBuffer(qb422016)
//line views/modal.qtpl:76
//line views/modal.qtpl:55
return qs422016
//line views/modal.qtpl:76
//line views/modal.qtpl:55
}

View File

@ -1,3 +1,5 @@
{{define "confirm"}}Confirm{{end}}
{{define "cancel"}}Cancel{{end}}
{{define "page"}}
<!doctype html>
<html lang="{{.Meta.Locale}}">

View File

@ -25,6 +25,8 @@ const ruText = `
{{define "close this dialog"}}Закрыть этот диалог{{end}}
{{define "login"}}Войти{{end}}
{{define "register"}}Регистрация{{end}}
{{define "confirm"}}Подтвердить{{end}}
{{define "cancel"}}Отмена{{end}}
`
func Init() {

View File

@ -3,6 +3,7 @@ package web
import (
"fmt"
"github.com/bouncepaw/mycomarkup/v5"
"github.com/bouncepaw/mycorrhiza/hypview"
"github.com/bouncepaw/mycorrhiza/mycoopts"
"github.com/bouncepaw/mycorrhiza/viewutil"
"log"
@ -69,7 +70,6 @@ func handlerDelete(w http.ResponseWriter, rq *http.Request) {
util.PrepareRq(rq)
var (
u = user.FromRequest(rq)
lc = l18n.FromRequest(rq)
h = hyphae.ByName(util.HyphaNameFromRq(rq, "delete"))
meta = viewutil.MetaFrom(w, rq)
)
@ -89,12 +89,7 @@ func handlerDelete(w http.ResponseWriter, rq *http.Request) {
}
if rq.Method == "GET" {
util.HTTP200Page(
w,
views.Base(
meta,
fmt.Sprintf(lc.Get("ui.ask_delete"), util.BeautifulName(h.CanonicalName())),
views.DeleteAsk(rq, h.CanonicalName())))
hypview.DeleteHypha(meta, h.CanonicalName())
return
}