Browse Source

Move to root path, not admin

master
Dylan Baker 3 years ago
parent
commit
7362b898f3
3 changed files with 6 additions and 6 deletions
  1. 4
    4
      src/main.rs
  2. 2
    2
      templates/index.html
  3. 0
    0
      templates/layout.html

+ 4
- 4
src/main.rs View File

@@ -91,23 +91,23 @@ async fn main() -> std::io::Result<()> {
91 91
         Ok(res)
92 92
     }));
93 93
 
94
-    app.at("/admin").get(|_| async {
94
+    app.at("/").get(|_| async {
95 95
         let tera = Tera::new("templates/**/*.html")?;
96 96
         let posts = read_all_posts().await?;
97 97
         let mut context = Context::new();
98 98
         context.insert("posts", &posts);
99
-        let html = tera.render("admin/index.html", &context)?;
99
+        let html = tera.render("index.html", &context)?;
100 100
         Ok(Body::from_string(html))
101 101
     });
102 102
 
103
-    app.at("/admin/posts")
103
+    app.at("/posts")
104 104
         .post(|mut req: tide::Request<()>| async move {
105 105
             let mut post: Post = req.body_form().await?;
106 106
             post.id = Uuid::new_v4().to_string();
107 107
             post.date = Local::now().date().naive_local().to_string();
108 108
             post.body = post.body.trim().to_owned();
109 109
             post.save()?;
110
-            Ok(tide::Redirect::new("/admin"))
110
+            Ok(tide::Redirect::new("/"))
111 111
         });
112 112
 
113 113
     app.listen("127.0.0.1:8080").await?;

templates/admin/index.html → templates/index.html View File

@@ -1,6 +1,6 @@
1
-{% extends "admin/layout.html" %} {% block content %}
1
+{% extends "layout.html" %} {% block content %}
2 2
 <h1 class="heading">Admin</h1>
3
-<form class="form" method="POST" action="/admin/posts">
3
+<form class="form" method="POST" action="/posts">
4 4
   <input type="hidden" name="id" />
5 5
   <input type="hidden" name="date" />
6 6
   <div class="form__field">

templates/admin/layout.html → templates/layout.html View File


Loading…
Cancel
Save