mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-12-12 21:40:26 +00:00
41651f9e9b
Starring: * Fix some bugs for /rename/ * Introduce /delete/, /remove-media/ * Introduce some bugs for the methods mentioned above
73 lines
2.4 KiB
Plaintext
73 lines
2.4 KiB
Plaintext
{% import "fmt" %}
|
|
{% import "net/http" %}
|
|
{% import "github.com/bouncepaw/mycorrhiza/l18n" %}
|
|
|
|
{% func DeleteAskHTML(rq *http.Request, hyphaName string) %}
|
|
{% code
|
|
lc := l18n.FromRequest(rq)
|
|
%}
|
|
{%= modalBegin(
|
|
"delete",
|
|
hyphaName,
|
|
"",
|
|
fmt.Sprintf(lc.Get("ui.ask_delete"), beautifulLink(hyphaName))) %}
|
|
{%= modalReallyWant(hyphaName, lc.Get("ui.ask_delete_verb"), lc) %}
|
|
<p>{%s lc.Get("ui.ask_delete_tip") %}</p>
|
|
{%= modalEnd(hyphaName, true, lc) %}
|
|
{% endfunc %}
|
|
|
|
{% func RemoveMediaAskHTML(rq *http.Request, hyphaName string) %}
|
|
{% code
|
|
lc := l18n.FromRequest(rq)
|
|
%}
|
|
{%= modalBegin(
|
|
"remove-media",
|
|
hyphaName,
|
|
"",
|
|
fmt.Sprintf(lc.Get("ui.ask_remove_media"), beautifulLink(hyphaName))) %}
|
|
{%= modalReallyWant(hyphaName, lc.Get("ui.ask_remove_media_verb"), lc) %}
|
|
{%= modalEnd(hyphaName, true, lc) %}
|
|
{% endfunc %}
|
|
|
|
bloody hell !!
|
|
|
|
{% func RenameAskHTML(rq *http.Request, hyphaName string) %}
|
|
{% code
|
|
lc := l18n.FromRequest(rq)
|
|
%}
|
|
{%= modalBegin(
|
|
"rename",
|
|
hyphaName,
|
|
` method="post" enctype="multipart/form-data"`,
|
|
fmt.Sprintf(lc.Get("ui.ask_rename"), beautifulLink(hyphaName))) %}
|
|
<label for="new-name">{%s lc.Get("ui.rename_to") %}</label>
|
|
<input type="text" value="{%s hyphaName %}" required autofocus id="new-name" name="new-name"/>
|
|
|
|
<input type="checkbox" id="recursive" name="recursive" value="true" checked/>
|
|
<label for="recursive">{%s lc.Get("ui.rename_recurse") %}</label>
|
|
|
|
<p>{%s lc.Get("ui.rename_tip") %}</p>
|
|
{%= modalEnd(hyphaName, false, lc) %}
|
|
{% endfunc %}
|
|
|
|
{% func modalReallyWant(hyphaName, verb string, lc *l18n.Localizer) %}
|
|
<p class="modal__confirmation-msg">{%s= lc.Get("ui.ask_really", &l18n.Replacements{"verb": verb, "name": fmt.Sprintf("<em>%s</em>", hyphaName)}) %}</p>
|
|
{% endfunc %}
|
|
|
|
{% func modalBegin(path, hyphaName, formAttrs, legend string) %}
|
|
<div class="layout">
|
|
<main class="main-width">
|
|
<form class="modal" action="/{%s path %}/{%s hyphaName %}"{%s= formAttrs %}>
|
|
<fieldset class="modal__fieldset">
|
|
<legend class="modal__title">{%s= legend %}</legend>
|
|
{% endfunc %}
|
|
|
|
{% func modalEnd(hyphaName string, shouldFocusOnConfirm bool, lc *l18n.Localizer) %}
|
|
<button type="submit" value="Confirm" class="btn" {% if shouldFocusOnConfirm %}autofocus{% endif %}>{%s lc.Get("ui.confirm") %}</button>
|
|
<a href="/hypha/{%s hyphaName %}" class="btn btn_weak">{%s lc.Get("ui.cancel") %}</a>
|
|
</fieldset>
|
|
</form>
|
|
</main>
|
|
</div>
|
|
{% endfunc %}
|