Browse Source

Set up admin template

master
Dylan Baker 3 years ago
parent
commit
a5d5fed7ec
5 changed files with 81 additions and 18 deletions
  1. 1
    1
      src/main.rs
  2. 0
    1
      templates/admin.html
  3. 16
    0
      templates/admin/index.html
  4. 64
    0
      templates/admin/layout.html
  5. 0
    16
      templates/layout.html

+ 1
- 1
src/main.rs View File

@@ -26,7 +26,7 @@ async fn main() -> Result<()> {
26 26
 
27 27
     app.at("/admin").get(|_| async {
28 28
         let tera = Tera::new("templates/**/*.html")?;
29
-        let html = tera.render("admin.html", &Context::new())?;
29
+        let html = tera.render("admin/index.html", &Context::new())?;
30 30
         Ok(Body::from_string(html))
31 31
     });
32 32
 

+ 0
- 1
templates/admin.html View File

@@ -1 +0,0 @@
1
-{% extends "layout.html" %} {% block content %} {% endblock %}

+ 16
- 0
templates/admin/index.html View File

@@ -0,0 +1,16 @@
1
+{% extends "admin/layout.html" %} {% block content %}
2
+<h1 class="heading">Admin</h1>
3
+<form class="form" method="POST" action="/posts">
4
+  <div class="form__field">
5
+    <label for="title" class="form__label">Title</label>
6
+    <input class="form__text-field" type="text" name="title" />
7
+  </div>
8
+  <div class="form__field">
9
+    <label for="body" class="form__label">Body</label>
10
+    <textarea class="form__textarea" name="body"></textarea>
11
+  </div>
12
+  <div class="form__field">
13
+    <input class="form__button" type="submit" value="Post" />
14
+  </div>
15
+</form>
16
+{% endblock %}

+ 64
- 0
templates/admin/layout.html View File

@@ -0,0 +1,64 @@
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
+    <title>Microblog Admin</title>
7
+    <style>
8
+      * {
9
+        box-sizing: border-box;
10
+        margin: 0;
11
+        padding: 0;
12
+      }
13
+
14
+      body {
15
+        background: #aab5a9;
16
+        font-family: Verdana, Geneva, Tahoma, sans-serif;
17
+        font-size: 12px;
18
+      }
19
+
20
+      .container {
21
+        margin: auto;
22
+        max-width: 800px;
23
+        padding: 1em;
24
+      }
25
+
26
+      .form__field {
27
+        margin: 1em 0;
28
+      }
29
+
30
+      .form__label {
31
+        display: block;
32
+        margin-bottom: 0.5em;
33
+      }
34
+
35
+      .form__textarea,
36
+      .form__text-field {
37
+        font-family: Verdana, Geneva, Tahoma, sans-serif;
38
+        font-size: 12px;
39
+        padding: 0.25em;
40
+        width: 100%;
41
+      }
42
+
43
+      .form__textarea {
44
+        height: 200px;
45
+        resize: vertical;
46
+      }
47
+
48
+      .form__button {
49
+        padding: 0.25em 1em;
50
+      }
51
+
52
+      @media (max-width: 500px) {
53
+        .form__button {
54
+          width: 100%;
55
+        }
56
+      }
57
+    </style>
58
+  </head>
59
+  <body>
60
+    <div class="container">
61
+      {% block content %} {% endblock %}
62
+    </div>
63
+  </body>
64
+</html>

+ 0
- 16
templates/layout.html View File

@@ -1,16 +0,0 @@
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
-    <title>Microblog Admin</title>
7
-    <style>
8
-      body {
9
-        background: #aab5a9;
10
-      }
11
-    </style>
12
-  </head>
13
-  <body>
14
-    {% block content %} {% endblock %}
15
-  </body>
16
-</html>

Loading…
Cancel
Save