blog/root/comments/index.gohtml

123 lines
4.2 KiB
Plaintext

{{ define "title" }}Preview Comment{{ end }}
{{ define "content" }}
{{ with .Data.Comment }}
<form action="/comments" method="POST">
<input type="hidden" name="_csrf" value="{{ $.CSRF }}">
<input type="hidden" name="thread" value="{{ .ThreadID }}">
<input type="hidden" name="subject" value="{{ .Subject }}">
<input type="hidden" name="origin" value="{{ .OriginURL }}">
{{ if $.Data.Editing -}}
<input type="hidden" name="id" value="{{ .ID }}">
<input type="hidden" name="editing" value="{{ $.Data.Editing }}">
{{ end }}
<h1>
{{- if $.Data.Deleting -}}
Delete Comment
{{- else if $.Data.Editing -}}
Edit Comment
{{- else -}}
Preview
{{- end -}}
</h1>
<hr>
{{ template "comment" . }}
<hr>
{{ if $.Data.Deleting }}
<p>Are you sure you want to delete this comment?</p>
<button type="submit"
name="submit"
value="confirm-delete"
class="btn btn-danger">
Delete Comment
</button>
<a href="{{ .OriginURL }}" class="btn btn-primary">Cancel</a>
{{ else }}
{{ if not $.CurrentUser.IsAuthenticated }}
<div class="form-group row">
<label for="name" class="col-2 col-form-label">Your name:</label>
<div class="col-10">
{{ if and $.CurrentUser.IsAuthenticated }}
{{ $.CurrentUser.Name }}
{{ else }}
<input type="text"
id="name"
name="name"
class="form-control"
value="{{ .Name }}"
placeholder="Anonymous">
{{ end }}
</div>
</div>
<div class="form-group row">
<label for="email" class="col-2 col-form-label">Your email:</label>
<div class="col-10">
<input type="email"
id="email"
name="email"
class="form-control"
aria-describedby="emailHelp"
value="{{ .Email }}"
placeholder="(optional)">
<small id="emailHelp" class="form-text text-muted">
Used for your <a href="https://en.gravatar.com/" target="_blank">Gravatar</a>
and optional thread subscription. <a href="/privacy">Privacy policy.</a>
</small>
<label class="form-check-label pl-0">
<input type="checkbox"{{ if .Subscribe }} checked{{ end }}
name="subscribe"
value="true">
<small>Notify me of future comments on this page.</small>
</label>
</div>
</div>
{{ end }}
<div class="form-group">
<label for="body">Message:</label>
<textarea
name="body"
id="body"
cols="40" rows="10"
aria-describedby="bodyHelp"
class="form-control">{{ .Body }}</textarea>
<small id="bodyHelp" class="form-text text-muted">
You may format your message using
<a href="https://daringfireball.net/projects/markdown/syntax">Markdown</a>
syntax.
</small>
</div>
<div class="form-group" style="display: none">
<div class="card">
<div class="card-header">Sanity Check</div>
<div class="card-body">
If you happen to be able to see these fields, do not change
their values.
<input type="text" name="url" value="http://" class="form-control" placeholder="Website">
<textarea name="comment" cols="80" rows="10" class="form-control" placeholder="Comment"></textarea>
</div>
</div>
</div>
<button type="submit" name="submit" value="preview" class="btn btn-primary">
Refresh Preview
</button>
<button type="submit" name="submit" value="post" class="btn btn-secondary">
Post Comment
</button>
{{ end }}
</form>
{{ end }}
{{ end }}