summaryrefslogtreecommitdiff
path: root/src/index/templates.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/index/templates.rs')
-rw-r--r--src/index/templates.rs127
1 files changed, 0 insertions, 127 deletions
diff --git a/src/index/templates.rs b/src/index/templates.rs
deleted file mode 100644
index d56972c..0000000
--- a/src/index/templates.rs
+++ /dev/null
@@ -1,127 +0,0 @@
-use maud::{html, Markup, DOCTYPE};
-
-use crate::repo::{channel::Channel, login::Login};
-
-pub fn authenticated<'c>(login: Login, channels: impl IntoIterator<Item = &'c Channel>) -> Markup {
- html! {
- (DOCTYPE)
- head {
- title { "hi" }
- }
- body {
- section {
- (channel_list(channels))
- (create_channel())
- }
- section {
- (logout_form(&login.name))
- }
- }
- }
-}
-
-fn channel_list<'c>(channels: impl IntoIterator<Item = &'c Channel>) -> Markup {
- html! {
- ul {
- @for channel in channels {
- (channel_list_entry(&channel))
- }
- }
- }
-}
-
-fn channel_list_entry(channel: &Channel) -> Markup {
- html! {
- li {
- a href=(format!("/{}", channel.id)) {
- (channel.name) " (" (channel.id) ")"
- }
- }
- }
-}
-
-fn create_channel() -> Markup {
- html! {
- form action="/create" method="post" {
- label {
- "name"
- input name="name" type="text" {}
- }
- button {
- "start channel"
- }
- }
- }
-}
-
-fn logout_form(name: &str) -> Markup {
- html! {
- form action="/logout" method="post" {
- button { "bye, " (name) }
- }
- }
-}
-
-pub fn unauthenticated() -> Markup {
- html! {
- (DOCTYPE)
- head {
- title { "hi" }
- }
- body {
- (login_form())
- }
- }
-}
-
-fn login_form() -> Markup {
- html! {
- form action="/login" method="post" {
- label {
- "login"
- input name="name" type="text" {}
- }
- label {
- "password"
- input name="password" type="password" {}
- }
- button { "hi" }
- }
- }
-}
-
-pub fn channel(channel: &Channel) -> Markup {
- html! {
- (DOCTYPE)
- head {
- title { "hi - " (channel.name) }
- script src="/js/channel.js" {}
- template id="message" {
- p {
- span.sender { "(sender)" }
- ": "
- span.message { "(message)" }
- " (at "
- span.sent_at { "(sent_at)" }
- ")" }
- }
- meta name="channel" content=(channel.id) {}
- link rel="events" href=(format!("/events?channel={}", channel.id)) {}
- }
- body {
- section class="messages" {}
- section {
- form action=(format!("/{}/send", channel.id)) method="post" {
- label {
- "message"
- input name="message" type="text" autofocus {}
- }
- button { "send" }
- }
- }
- section {
- a href="/" { "back" }
- }
- }
- }
-}