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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. {% import "components.html" as components %}
  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <head>
  5. <meta charset="UTF-8" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7. <title>Microblog Admin</title>
  8. <style>
  9. * {
  10. box-sizing: border-box;
  11. margin: 0;
  12. padding: 0;
  13. }
  14. body {
  15. background: #aab5a9;
  16. color: #000;
  17. font-family: Verdana, Geneva, Tahoma, sans-serif;
  18. font-size: 12px;
  19. }
  20. a {
  21. color: #000;
  22. }
  23. a:hover {
  24. text-decoration: none;
  25. }
  26. .btn {
  27. cursor: pointer;
  28. padding: 0.15em 0.3em;
  29. }
  30. .danger {
  31. color: #942626;
  32. }
  33. .container {
  34. margin: auto;
  35. max-width: 800px;
  36. padding: 1em;
  37. }
  38. .header {
  39. margin: 1em 0;
  40. }
  41. .form__field {
  42. margin: 1em 0;
  43. }
  44. .form__label {
  45. display: block;
  46. margin-bottom: 0.5em;
  47. }
  48. .form__textarea,
  49. .form__text-field {
  50. font-family: Verdana, Geneva, Tahoma, sans-serif;
  51. font-size: 12px;
  52. padding: 0.25em;
  53. width: 100%;
  54. }
  55. .form__textarea {
  56. height: 200px;
  57. resize: vertical;
  58. }
  59. .post:not(:last-child) {
  60. margin: 3em 0;
  61. }
  62. .post__heading {
  63. background: white;
  64. border: 1px solid #383e37;
  65. display: flex;
  66. font-size: 12px;
  67. font-style: italic;
  68. justify-content: space-between;
  69. margin-bottom: 1em;
  70. padding: 0.5em;
  71. }
  72. .post__title {
  73. flex: 1;
  74. text-align: right;
  75. }
  76. .post__link {
  77. cursor: pointer;
  78. font-style: normal;
  79. font-weight: normal;
  80. text-decoration: underline;
  81. }
  82. .post__link:hover {
  83. text-decoration: none;
  84. }
  85. .post__body {
  86. border-top: none;
  87. padding: 0.5em;
  88. }
  89. .error {
  90. color: #942626;
  91. text-align: center;
  92. }
  93. .error__heading {
  94. margin: 2em 0 1em;
  95. }
  96. .error__message {
  97. font-size: 18px;
  98. }
  99. @media (max-width: 500px) {
  100. .form__button {
  101. width: 100%;
  102. }
  103. }
  104. </style>
  105. </head>
  106. <body>
  107. <div class="container">
  108. <header class="header">
  109. {% if logged_in %}
  110. <form action="/logout" method="POST">
  111. <input class="btn" type="submit" value="Log out" />
  112. </form>
  113. {% endif %}
  114. </header>
  115. {% block content %} {% endblock %}
  116. </div>
  117. <script>
  118. document.querySelectorAll('[data-delete]').forEach((el) => {
  119. el.addEventListener('click', (e) => {
  120. if (confirm('Are you sure? This cannot be undone.')) {
  121. let postId = e.target.dataset.delete;
  122. fetch(`/posts/${postId}`, {
  123. method: 'DELETE',
  124. }).then((r) => {
  125. r.json().then((data) => {
  126. if (data.success) {
  127. window.location = '/';
  128. }
  129. });
  130. });
  131. }
  132. });
  133. });
  134. </script>
  135. </body>
  136. </html>