1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-12-12 05:20:26 +00:00

Move the unattach modal to the views module

This commit is contained in:
bouncepaw 2021-02-22 22:38:41 +05:00
parent 4798d94a94
commit 7f82805992
7 changed files with 125 additions and 179 deletions

View File

@ -12,6 +12,7 @@ import (
"github.com/bouncepaw/mycorrhiza/templates"
"github.com/bouncepaw/mycorrhiza/user"
"github.com/bouncepaw/mycorrhiza/util"
"github.com/bouncepaw/mycorrhiza/views"
)
func init() {
@ -63,7 +64,7 @@ var handlerUnattachAsk = factoryHandlerAsker(
"unattach-ask",
shroom.CanUnattach,
"Unattach %s?",
templates.UnattachAskHTML,
views.UnattachAskHTML,
)
var handlerDeleteAsk = factoryHandlerAsker(

View File

@ -24,6 +24,11 @@ func StreamDefaultCSS(qw422016 *qt422016.Writer) {
`)
//line templates/asset.qtpl:2
qw422016.N().S(`/* General element positions, from small to big */
.modal__title { font-size: 2rem; }
.modal__confirmation-msg { margin: 0 0 .5rem 0; }
.modal__action { display: inline-block; font-size: 1rem; padding: .25rem; border-radius: .25rem; }
.modal__submit { border: 1px #999 solid; }
.modal__cancel { border: 1px #999 dashed; text-decoration: none; }
/* Phones and whatnot */
.layout { display: grid; row-gap: 1rem; }
header { width: 100%; margin-bottom: 1rem; }
@ -90,7 +95,8 @@ header { width: 100%; margin-bottom: 1rem; }
*, *::before, *::after {box-sizing: border-box;}
html { height:100%; padding:0; }
body {height:100%; margin:0; font-size:16px; font-family: 'PT Sans', 'Liberation Sans', sans-serif;}
body {height:100%; margin:0; }
body, input { font-size:16px; font-family: 'PT Sans', 'Liberation Sans', sans-serif;}
main > form {margin-bottom:1rem;}
textarea {font-size:16px; font-family: 'PT Sans', 'Liberation Sans', sans-serif;}

View File

@ -1,4 +1,9 @@
/* General element positions, from small to big */
.modal__title { font-size: 2rem; }
.modal__confirmation-msg { margin: 0 0 .5rem 0; }
.modal__action { display: inline-block; font-size: 1rem; padding: .25rem; border-radius: .25rem; }
.modal__submit { border: 1px #999 solid; }
.modal__cancel { border: 1px #999 dashed; text-decoration: none; }
/* Phones and whatnot */
.layout { display: grid; row-gap: 1rem; }
header { width: 100%; margin-bottom: 1rem; }
@ -65,7 +70,8 @@ header { width: 100%; margin-bottom: 1rem; }
*, *::before, *::after {box-sizing: border-box;}
html { height:100%; padding:0; }
body {height:100%; margin:0; font-size:16px; font-family: 'PT Sans', 'Liberation Sans', sans-serif;}
body {height:100%; margin:0; }
body, input { font-size:16px; font-family: 'PT Sans', 'Liberation Sans', sans-serif;}
main > form {margin-bottom:1rem;}
textarea {font-size:16px; font-family: 'PT Sans', 'Liberation Sans', sans-serif;}

View File

@ -1,26 +0,0 @@
{% import "net/http" %}
{% func UnattachAskHTML(rq *http.Request, hyphaName string, isOld bool) %}
{%= navHTML(rq, hyphaName, "unattach-ask") %}
<div class="layout">
<main class="main-width">
{%- if isOld -%}
<section>
<h1>Unattach {%s hyphaName %}?</h1>
<p>Do you really want to unattach hypha <em>{%s hyphaName %}</em>?</p>
<p><a href="/unattach-confirm/{%s hyphaName %}"><strong>Confirm</strong></a></p>
<p><a href="/page/{%s hyphaName %}">Cancel</a></p>
</section>
{%- else -%}
{%= cannotUnattachDueToNonExistence(hyphaName) %}
{%- endif -%}
</main>
</div>
{% endfunc %}
{% func cannotUnattachDueToNonExistence(hyphaName string) %}
<section>
<h1>Cannot unattach {%s hyphaName %}</h1>
<p>This hypha does not exist.</p>
<p><a href="/page/{%s hyphaName %}">Go back</a></p>
</section>
{% endfunc %}

View File

@ -1,150 +0,0 @@
// Code generated by qtc from "unattach.qtpl". DO NOT EDIT.
// See https://github.com/valyala/quicktemplate for details.
//line templates/unattach.qtpl:1
package templates
//line templates/unattach.qtpl:1
import "net/http"
//line templates/unattach.qtpl:2
import (
qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate"
)
//line templates/unattach.qtpl:2
var (
_ = qtio422016.Copy
_ = qt422016.AcquireByteBuffer
)
//line templates/unattach.qtpl:2
func StreamUnattachAskHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName string, isOld bool) {
//line templates/unattach.qtpl:2
qw422016.N().S(`
`)
//line templates/unattach.qtpl:3
streamnavHTML(qw422016, rq, hyphaName, "unattach-ask")
//line templates/unattach.qtpl:3
qw422016.N().S(`
<div class="layout">
<main class="main-width">
`)
//line templates/unattach.qtpl:6
if isOld {
//line templates/unattach.qtpl:6
qw422016.N().S(` <section>
<h1>Unattach `)
//line templates/unattach.qtpl:8
qw422016.E().S(hyphaName)
//line templates/unattach.qtpl:8
qw422016.N().S(`?</h1>
<p>Do you really want to unattach hypha <em>`)
//line templates/unattach.qtpl:9
qw422016.E().S(hyphaName)
//line templates/unattach.qtpl:9
qw422016.N().S(`</em>?</p>
<p><a href="/unattach-confirm/`)
//line templates/unattach.qtpl:10
qw422016.E().S(hyphaName)
//line templates/unattach.qtpl:10
qw422016.N().S(`"><strong>Confirm</strong></a></p>
<p><a href="/page/`)
//line templates/unattach.qtpl:11
qw422016.E().S(hyphaName)
//line templates/unattach.qtpl:11
qw422016.N().S(`">Cancel</a></p>
</section>
`)
//line templates/unattach.qtpl:13
} else {
//line templates/unattach.qtpl:13
qw422016.N().S(` `)
//line templates/unattach.qtpl:14
streamcannotUnattachDueToNonExistence(qw422016, hyphaName)
//line templates/unattach.qtpl:14
qw422016.N().S(`
`)
//line templates/unattach.qtpl:15
}
//line templates/unattach.qtpl:15
qw422016.N().S(`</main>
</div>
`)
//line templates/unattach.qtpl:18
}
//line templates/unattach.qtpl:18
func WriteUnattachAskHTML(qq422016 qtio422016.Writer, rq *http.Request, hyphaName string, isOld bool) {
//line templates/unattach.qtpl:18
qw422016 := qt422016.AcquireWriter(qq422016)
//line templates/unattach.qtpl:18
StreamUnattachAskHTML(qw422016, rq, hyphaName, isOld)
//line templates/unattach.qtpl:18
qt422016.ReleaseWriter(qw422016)
//line templates/unattach.qtpl:18
}
//line templates/unattach.qtpl:18
func UnattachAskHTML(rq *http.Request, hyphaName string, isOld bool) string {
//line templates/unattach.qtpl:18
qb422016 := qt422016.AcquireByteBuffer()
//line templates/unattach.qtpl:18
WriteUnattachAskHTML(qb422016, rq, hyphaName, isOld)
//line templates/unattach.qtpl:18
qs422016 := string(qb422016.B)
//line templates/unattach.qtpl:18
qt422016.ReleaseByteBuffer(qb422016)
//line templates/unattach.qtpl:18
return qs422016
//line templates/unattach.qtpl:18
}
//line templates/unattach.qtpl:20
func streamcannotUnattachDueToNonExistence(qw422016 *qt422016.Writer, hyphaName string) {
//line templates/unattach.qtpl:20
qw422016.N().S(`
<section>
<h1>Cannot unattach `)
//line templates/unattach.qtpl:22
qw422016.E().S(hyphaName)
//line templates/unattach.qtpl:22
qw422016.N().S(`</h1>
<p>This hypha does not exist.</p>
<p><a href="/page/`)
//line templates/unattach.qtpl:24
qw422016.E().S(hyphaName)
//line templates/unattach.qtpl:24
qw422016.N().S(`">Go back</a></p>
</section>
`)
//line templates/unattach.qtpl:26
}
//line templates/unattach.qtpl:26
func writecannotUnattachDueToNonExistence(qq422016 qtio422016.Writer, hyphaName string) {
//line templates/unattach.qtpl:26
qw422016 := qt422016.AcquireWriter(qq422016)
//line templates/unattach.qtpl:26
streamcannotUnattachDueToNonExistence(qw422016, hyphaName)
//line templates/unattach.qtpl:26
qt422016.ReleaseWriter(qw422016)
//line templates/unattach.qtpl:26
}
//line templates/unattach.qtpl:26
func cannotUnattachDueToNonExistence(hyphaName string) string {
//line templates/unattach.qtpl:26
qb422016 := qt422016.AcquireByteBuffer()
//line templates/unattach.qtpl:26
writecannotUnattachDueToNonExistence(qb422016, hyphaName)
//line templates/unattach.qtpl:26
qs422016 := string(qb422016.B)
//line templates/unattach.qtpl:26
qt422016.ReleaseByteBuffer(qb422016)
//line templates/unattach.qtpl:26
return qs422016
//line templates/unattach.qtpl:26
}

18
views/unattach.qtpl Normal file
View File

@ -0,0 +1,18 @@
{% import "net/http" %}
{% import "github.com/bouncepaw/mycorrhiza/util" %}
{% func UnattachAskHTML(rq *http.Request, hyphaName string, isOld bool) %}
{%= NavHTML(rq, hyphaName, "unattach-ask") %}
<div class="layout">
<main class="main-width">
<form class="modal" action="/unattach-confirm/{%s hyphaName %}">
<fieldset class="modal__fieldset">
<legend class="modal__title">Unattach {%s util.BeautifulName(hyphaName) %}?</legend>
<p class="modal__confirmation-msg">Do you really want to unattach hypha <em>{%s hyphaName %}</em>?</p>
<input type="submit" value="Confirm" class="modal__action modal__submit" autofocus>
<a href="/hypha/{%s hyphaName %}" class="modal__action modal__cancel">Cancel</a>
</fieldset>
</form>
</main>
</div>
{% endfunc %}

91
views/unattach.qtpl.go Normal file
View File

@ -0,0 +1,91 @@
// Code generated by qtc from "unattach.qtpl". DO NOT EDIT.
// See https://github.com/valyala/quicktemplate for details.
//line views/unattach.qtpl:1
package views
//line views/unattach.qtpl:1
import "net/http"
//line views/unattach.qtpl:2
import "github.com/bouncepaw/mycorrhiza/util"
//line views/unattach.qtpl:4
import (
qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate"
)
//line views/unattach.qtpl:4
var (
_ = qtio422016.Copy
_ = qt422016.AcquireByteBuffer
)
//line views/unattach.qtpl:4
func StreamUnattachAskHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName string, isOld bool) {
//line views/unattach.qtpl:4
qw422016.N().S(`
`)
//line views/unattach.qtpl:5
StreamNavHTML(qw422016, rq, hyphaName, "unattach-ask")
//line views/unattach.qtpl:5
qw422016.N().S(`
<div class="layout">
<main class="main-width">
<form class="modal" action="/unattach-confirm/`)
//line views/unattach.qtpl:8
qw422016.E().S(hyphaName)
//line views/unattach.qtpl:8
qw422016.N().S(`">
<fieldset class="modal__fieldset">
<legend class="modal__title">Unattach `)
//line views/unattach.qtpl:10
qw422016.E().S(util.BeautifulName(hyphaName))
//line views/unattach.qtpl:10
qw422016.N().S(`?</legend>
<p class="modal__confirmation-msg">Do you really want to unattach hypha <em>`)
//line views/unattach.qtpl:11
qw422016.E().S(hyphaName)
//line views/unattach.qtpl:11
qw422016.N().S(`</em>?</p>
<input type="submit" value="Confirm" class="modal__action modal__submit" autofocus>
<a href="/hypha/`)
//line views/unattach.qtpl:13
qw422016.E().S(hyphaName)
//line views/unattach.qtpl:13
qw422016.N().S(`" class="modal__action modal__cancel">Cancel</a>
</fieldset>
</form>
</main>
</div>
`)
//line views/unattach.qtpl:18
}
//line views/unattach.qtpl:18
func WriteUnattachAskHTML(qq422016 qtio422016.Writer, rq *http.Request, hyphaName string, isOld bool) {
//line views/unattach.qtpl:18
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/unattach.qtpl:18
StreamUnattachAskHTML(qw422016, rq, hyphaName, isOld)
//line views/unattach.qtpl:18
qt422016.ReleaseWriter(qw422016)
//line views/unattach.qtpl:18
}
//line views/unattach.qtpl:18
func UnattachAskHTML(rq *http.Request, hyphaName string, isOld bool) string {
//line views/unattach.qtpl:18
qb422016 := qt422016.AcquireByteBuffer()
//line views/unattach.qtpl:18
WriteUnattachAskHTML(qb422016, rq, hyphaName, isOld)
//line views/unattach.qtpl:18
qs422016 := string(qb422016.B)
//line views/unattach.qtpl:18
qt422016.ReleaseByteBuffer(qb422016)
//line views/unattach.qtpl:18
return qs422016
//line views/unattach.qtpl:18
}