A web blog and personal homepage engine written in Go.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
2.9 KiB

  1. {{ define "title" }}Ask Me Anything{{ end }}
  2. {{ define "content" }}
  3. {{ $Q := .V.Q }}
  4. <div class="card">
  5. <div class="card-body">
  6. <form action="/ask" method="POST">
  7. {{ CSRF }}
  8. <div class="form-group row">
  9. <div class="col-12 col-md-2">
  10. <label class="col-form-label" for="name">Name:</label>
  11. </div>
  12. <div class="col-12 col-md-10">
  13. <input type="text" class="form-control" id="name" name="name" value="{{ $Q.Name }}" placeholder="Anonymous">
  14. </div>
  15. </div>
  16. <div class="form-group row">
  17. <label class="col-12" for="question">Question: <small>(required)</small></label>
  18. <textarea cols="80" rows="6"
  19. class="col-12 form-control"
  20. name="question"
  21. id="question"
  22. placeholder="Ask me anything">{{ $Q.Question }}</textarea>
  23. </div>
  24. <div class="form-group row">
  25. <div class="col">
  26. <button type="submit"
  27. name="submit"
  28. value="ask"
  29. class="btn btn-primary">Ask away!</button>
  30. </div>
  31. </div>
  32. </form>
  33. </div>
  34. </div>
  35. {{ if gt (len .V.Recent) 0 }}
  36. <div class="card mt-4">
  37. <div class="card-header">
  38. Recently Answered
  39. </div>
  40. <div class="card-body">
  41. {{ range .V.Recent }}
  42. <strong>{{ or .Name "Anonymous" }}</strong> asks:
  43. <p>{{ .Question }}</p>
  44. <p>
  45. <a href="/{{ .Post.Fragment }}">Read answer&gt;</a>
  46. </p>
  47. <p class="blog-meta">
  48. <em title="{{ .CreatedAt.Format "Jan 2 2006 15:04:05 MST" }}">
  49. {{ .CreatedAt.Format "January 2, 2006" }}
  50. </em>
  51. </p>
  52. <hr class="my-4">
  53. {{ end }}
  54. <p>
  55. <a href="/tagged/ask">&rarr; More questions &amp; answers</a>
  56. </p>
  57. </div>
  58. </div>
  59. {{ end }}
  60. {{ if .LoggedIn }}
  61. <div class="card mt-4">
  62. <div class="card-header bg-secondary text-light">
  63. Pending Questions
  64. </div>
  65. <div class="card-body">
  66. {{ if not .V.Pending }}
  67. <em>There are no pending questions.</em>
  68. {{ end }}
  69. {{ range .V.Pending }}
  70. <p>
  71. <strong>{{ or .Name "Anonymous" }}</strong> asks:<br>
  72. <small class="text-muted">
  73. <em>{{ .CreatedAt.Format "January 2, 2006 @ 15:04 MST" }}</em> by
  74. </small>
  75. </p>
  76. <p>
  77. {{ .Question }}
  78. </p>
  79. <div id="form-{{ .ID }}" class="dhtml-forms">
  80. <form method="POST" action="/ask/answer">
  81. {{ CSRF }}
  82. <input type="hidden" name="id" value="{{ .ID }}">
  83. <textarea cols="80" rows="4"
  84. class="form-control"
  85. name="answer"
  86. required="required"
  87. placeholder="Answer (Markdown formatting allowed)"></textarea>
  88. <div class="btn-group mt-3">
  89. <button type="submit" name="submit" value="answer" class="btn btn-primary">
  90. Answer
  91. </button>
  92. <button type="submit" name="submit" value="delete" class="btn btn-danger">
  93. Delete
  94. </button>
  95. </div>
  96. </form>
  97. </div>
  98. <div id="button-{{ .ID }}" class="dhtml-buttons" style="display: none">
  99. <button type="button" class="btn" id="show-{{ .ID }}" class="dhtml-show-button">Answer or delete</button>
  100. </div>
  101. <hr>
  102. {{ end }}
  103. </div>
  104. </div>
  105. {{ end }}{# if .LoggedIn #}
  106. {{ end }}