Autosubmit mailing list confirmation
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -42,13 +42,16 @@ func confirmGetHandler() http.HandlerFunc {
|
|||||||
renderPage(
|
renderPage(
|
||||||
w,
|
w,
|
||||||
http.StatusOK,
|
http.StatusOK,
|
||||||
|
// The confirmation should happen too quickly for the user to notice.
|
||||||
|
// This content is only shown as a fallback.
|
||||||
page{
|
page{
|
||||||
Title: "Confirm subscription",
|
Title: "Confirm subscription",
|
||||||
Heading: "Confirm your subscription",
|
Heading: "Confirm your subscription",
|
||||||
Body: "Click the button below to confirm that you want to receive updates.",
|
Body: "Your confirmation should be processed automatically. If it isn’t, click the button below to confirm that you want to receive updates.",
|
||||||
Form: &form{
|
Form: &form{
|
||||||
ActionURL: template.URL("?token=" + url.QueryEscape(token)),
|
ActionURL: template.URL("?token=" + url.QueryEscape(token)),
|
||||||
Button: "Confirm subscription",
|
Button: "Confirm subscription",
|
||||||
|
AutoSubmit: true,
|
||||||
Danger: false,
|
Danger: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ type form struct {
|
|||||||
ActionURL template.URL
|
ActionURL template.URL
|
||||||
Button string
|
Button string
|
||||||
Danger bool
|
Danger bool
|
||||||
|
AutoSubmit bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type page struct {
|
type page struct {
|
||||||
|
|||||||
@@ -88,11 +88,14 @@
|
|||||||
<h1>{{.Heading}}</h1>
|
<h1>{{.Heading}}</h1>
|
||||||
<p>{{.Body}}</p>
|
<p>{{.Body}}</p>
|
||||||
{{- if .Form}}
|
{{- if .Form}}
|
||||||
<form method="POST" action="{{.Form.ActionURL}}">
|
<form id="action-form" method="POST" action="{{.Form.ActionURL}}">
|
||||||
<button type="submit" class="{{if .Form.Danger}}danger{{else}}primary{{end}}">
|
<button type="submit" class="{{if .Form.Danger}}danger{{else}}primary{{end}}">
|
||||||
{{.Form.Button}}
|
{{.Form.Button}}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
{{- if .Form.AutoSubmit}}
|
||||||
|
<script>document.getElementById("action-form").submit();</script>
|
||||||
|
{{- end}}
|
||||||
{{- end}}
|
{{- end}}
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user