summaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--templates/base.rs.html8
-rw-r--r--templates/home.rs.html10
-rw-r--r--templates/login.rs.html2
-rw-r--r--templates/signup.rs.html2
-rw-r--r--templates/users.rs.html4
5 files changed, 18 insertions, 8 deletions
diff --git a/templates/base.rs.html b/templates/base.rs.html
index 64a8d4e..0bf70eb 100644
--- a/templates/base.rs.html
+++ b/templates/base.rs.html
@@ -1,7 +1,7 @@
@use super::statics::*;
@use crate::Notification;
-@(authenticated: bool, notification: Option<Notification>, body: Content)
+@(user: Option<String>, notification: Option<Notification>, body: Content)
<!DOCTYPE html>
<html>
@@ -15,9 +15,9 @@
<body>
<nav>
- @if authenticated {
+ @if let Some(username) = user {
<form action="/logout" method="post">
- <button type="submit">logout</button>
+ <button type="submit">logout @username</button>
</form>
} else {
<a href="/login">log in</a>
@@ -29,4 +29,4 @@
@:body()
</body>
-</html> \ No newline at end of file
+</html>
diff --git a/templates/home.rs.html b/templates/home.rs.html
new file mode 100644
index 0000000..882b2ed
--- /dev/null
+++ b/templates/home.rs.html
@@ -0,0 +1,10 @@
+@use super::base_html;
+@use crate::User;
+
+@(user: Option<String>)
+
+@:base_html(user.clone(), None, {
+ @if let Some(username) = user {
+ <h1>logged in as @username</h1>
+ }
+})
diff --git a/templates/login.rs.html b/templates/login.rs.html
index c87866c..8547bd0 100644
--- a/templates/login.rs.html
+++ b/templates/login.rs.html
@@ -3,7 +3,7 @@
@(notification: Option<Notification>)
-@:base_html(false, None, {
+@:base_html(None, None, {
<form action="/login" method="post">
<label for="username">username:</label>
<input type="text" id="username" name="username" required="true" />
diff --git a/templates/signup.rs.html b/templates/signup.rs.html
index a482fc2..4823698 100644
--- a/templates/signup.rs.html
+++ b/templates/signup.rs.html
@@ -3,7 +3,7 @@
@(notification: Option<Notification>)
-@:base_html(false, notification, {
+@:base_html(None, notification, {
<form action="/signup" method="post">
<label for="username">username:</label>
<input type="text" id="username" name="username" required="true" />
diff --git a/templates/users.rs.html b/templates/users.rs.html
index ab1ab0f..c5b98f9 100644
--- a/templates/users.rs.html
+++ b/templates/users.rs.html
@@ -3,10 +3,10 @@
@(users: Vec<User>)
-@:base_html(false, None, {
+@:base_html(None, None, {
<ul>
@for user in users {
<li>@user.username</li>
}
</ul>
-}) \ No newline at end of file
+})