apps/library/templates/admin_quotes.html 3.4 K raw
1
<!doctype html>
2
<html lang="en">
3
  <head>
4
    <meta charset="UTF-8" />
5
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
    <meta name="theme-color" content="#121113" />
7
    <link rel="stylesheet" href="/assets/darkmatter.css" />
8
    <link rel="stylesheet" href="/static/styles.css" />
9
    <link rel="apple-touch-icon" sizes="180x180" href="/static/apple-touch-icon.png" />
10
    <link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png" />
11
    <link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png" />
12
    <link rel="manifest" href="/static/site.webmanifest" />
13
    <title>Library | Quotes Admin</title>
14
  </head>
15
  <body>
16
    <div class="header">
17
      <a href="/" class="logo"><h1>LIBRARY</h1></a>
18
      <nav class="links">
19
        <a href="/admin">admin</a>
20
        <a href="/admin/logout">logout</a>
21
      </nav>
22
    </div>
23
24
    {{if .Success}}<p class="success">{{.Success}}</p>{{end}}
25
    {{if .Error}}<p class="error">{{.Error}}</p>{{end}}
26
27
    <section class="admin-form">
28
      <h3>Add quote</h3>
29
      {{if not .Books}}
30
      <p class="hint">No books yet. Add a book before adding quotes.</p>
31
      {{else}}
32
      <form method="POST" action="/admin/quotes/add" class="labels-form">
33
        <input type="hidden" name="from" value="/admin/quotes" />
34
        <label>
35
          <span>Book</span>
36
          <select name="book_id" required>
37
            {{range .Books}}
38
            <option value="{{.ID}}">{{.Title}}{{if .Authors}} — {{.Authors}}{{end}}</option>
39
            {{end}}
40
          </select>
41
        </label>
42
        <label>
43
          <span>Page</span>
44
          <input type="text" name="page" placeholder="optional" />
45
        </label>
46
        <label>
47
          <span>Quote</span>
48
          <textarea name="quote" rows="2" required></textarea>
49
        </label>
50
        <button type="submit">Add quote</button>
51
      </form>
52
      {{end}}
53
    </section>
54
55
    <section class="admin-subs">
56
      <h3>All quotes ({{len .Quotes}})</h3>
57
      {{if not .Quotes}}
58
      <p class="hint">No quotes yet.</p>
59
      {{else}}
60
      {{range .Quotes}}
61
      {{$q := .}}
62
      <div class="quote-admin-row">
63
        <p class="meta"><a href="/quotes/{{$q.ID}}">view</a> · {{if $q.BookTitle}}{{$q.BookTitle}}{{else}}book #{{$q.BookID}}{{end}}</p>
64
        <form method="POST" action="/admin/quotes/{{$q.ID}}/edit" class="labels-form">
65
          <input type="hidden" name="from" value="/admin/quotes" />
66
          <label>
67
            <span>Book</span>
68
            <select name="book_id">
69
              {{range $.Books}}{{$b := .}}
70
              <option value="{{$b.ID}}"{{if eq $q.BookID $b.ID}} selected{{end}}>{{$b.Title}}{{if $b.Authors}} — {{$b.Authors}}{{end}}</option>
71
              {{end}}
72
            </select>
73
          </label>
74
          <label>
75
            <span>Page</span>
76
            <input type="text" name="page" value="{{$q.Page}}" />
77
          </label>
78
          <label>
79
            <span>Quote</span>
80
            <textarea name="quote" rows="2" required>{{$q.Quote}}</textarea>
81
          </label>
82
          <button type="submit">Save</button>
83
        </form>
84
        <form method="POST" action="/admin/quotes/{{$q.ID}}/delete" class="inline">
85
          <input type="hidden" name="from" value="/admin/quotes" />
86
          <button type="submit" class="danger">Delete</button>
87
        </form>
88
      </div>
89
      {{end}}
90
      {{end}}
91
    </section>
92
    <script src="/pwa.js" defer></script>
93
  </body>
94
</html>