| 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 | 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/quotes">quotes</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 | <article class="book-card admin"> |
| 28 | {{if .Book.CoverURL}} |
| 29 | <img class="book-cover" src="{{.Book.CoverURL}}" alt="" loading="lazy" /> |
| 30 | {{else}} |
| 31 | <div class="book-cover placeholder"></div> |
| 32 | {{end}} |
| 33 | <div class="book-info"> |
| 34 | <h2 class="book-title">{{.Book.Title}}</h2> |
| 35 | <p class="book-authors">{{.Book.Authors}}</p> |
| 36 | {{if .Book.ISBN}}<p class="book-meta">ISBN: {{.Book.ISBN}}</p>{{end}} |
| 37 | </div> |
| 38 | </article> |
| 39 | |
| 40 | <section class="admin-form"> |
| 41 | <h3>Edit book</h3> |
| 42 | <form method="POST" action="/admin/books/{{.Book.ID}}/edit" class="labels-form"> |
| 43 | <input type="hidden" name="from" value="/admin/books/{{.Book.ID}}" /> |
| 44 | <label> |
| 45 | <span>Title</span> |
| 46 | <input type="text" name="title" value="{{.Book.Title}}" required /> |
| 47 | </label> |
| 48 | <label> |
| 49 | <span>Authors</span> |
| 50 | <input type="text" name="authors" value="{{.Book.Authors}}" required /> |
| 51 | </label> |
| 52 | <label> |
| 53 | <span>ISBN</span> |
| 54 | <input type="text" name="isbn" value="{{.Book.ISBN}}" /> |
| 55 | </label> |
| 56 | <label> |
| 57 | <span>Cover URL</span> |
| 58 | <input type="text" name="cover_url" value="{{.Book.CoverURL}}" /> |
| 59 | </label> |
| 60 | <label> |
| 61 | <span>Notes</span> |
| 62 | <textarea name="notes" rows="2">{{.Book.Notes}}</textarea> |
| 63 | </label> |
| 64 | <button type="submit">Save book</button> |
| 65 | </form> |
| 66 | </section> |
| 67 | |
| 68 | <section class="admin-form"> |
| 69 | <h3>Add quote</h3> |
| 70 | <form method="POST" action="/admin/quotes/add" class="labels-form"> |
| 71 | <input type="hidden" name="book_id" value="{{.Book.ID}}" /> |
| 72 | <input type="hidden" name="from" value="/admin/books/{{.Book.ID}}" /> |
| 73 | <label> |
| 74 | <span>Page</span> |
| 75 | <input type="text" name="page" placeholder="optional" /> |
| 76 | </label> |
| 77 | <label> |
| 78 | <span>Quote</span> |
| 79 | <textarea name="quote" rows="4" required></textarea> |
| 80 | </label> |
| 81 | <button type="submit">Add quote</button> |
| 82 | </form> |
| 83 | </section> |
| 84 | |
| 85 | <section class="admin-subs"> |
| 86 | <h3>Quotes ({{len .Quotes}})</h3> |
| 87 | {{if not .Quotes}} |
| 88 | <p class="hint">No quotes from this book yet.</p> |
| 89 | {{else}} |
| 90 | {{range .Quotes}} |
| 91 | <div class="quote-admin-row"> |
| 92 | <p class="meta"><a href="/quotes/{{.ID}}">view</a></p> |
| 93 | <form method="POST" action="/admin/quotes/{{.ID}}/edit" class="labels-form"> |
| 94 | <input type="hidden" name="book_id" value="{{.BookID}}" /> |
| 95 | <input type="hidden" name="from" value="/admin/books/{{$.Book.ID}}" /> |
| 96 | <label> |
| 97 | <span>Page</span> |
| 98 | <input type="text" name="page" value="{{.Page}}" /> |
| 99 | </label> |
| 100 | <label> |
| 101 | <span>Quote</span> |
| 102 | <textarea name="quote" rows="3" required>{{.Quote}}</textarea> |
| 103 | </label> |
| 104 | <button type="submit">Save</button> |
| 105 | </form> |
| 106 | <form method="POST" action="/admin/quotes/{{.ID}}/delete" class="inline"> |
| 107 | <input type="hidden" name="from" value="/admin/books/{{$.Book.ID}}" /> |
| 108 | <button type="submit" class="danger">Delete</button> |
| 109 | </form> |
| 110 | </div> |
| 111 | {{end}} |
| 112 | {{end}} |
| 113 | </section> |
| 114 | <script src="/pwa.js" defer></script> |
| 115 | </body> |
| 116 | </html> |