From 9a9776230ce8d12d305ca8db19cc76f20ae40926 Mon Sep 17 00:00:00 2001 From: Vika Date: Mon, 6 Dec 2021 20:39:04 +0300 Subject: Added support for IndieAuth client sign in This will allow readers to view private posts intended just for them. Additionally fixed bugs in patterns due to which webmentions might not have been sent. --- src/frontend/templates/mod.rs | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) (limited to 'src/frontend/templates') diff --git a/src/frontend/templates/mod.rs b/src/frontend/templates/mod.rs index 100e16d..dbc23c9 100644 --- a/src/frontend/templates/mod.rs +++ b/src/frontend/templates/mod.rs @@ -25,7 +25,7 @@ mod onboarding; pub use onboarding::OnboardingPage; markup::define! { - Template<'a>(title: &'a str, blog_name: &'a str, endpoints: IndiewebEndpoints, feeds: Vec, content: String) { + Template<'a>(title: &'a str, blog_name: &'a str, endpoints: IndiewebEndpoints, feeds: Vec, user: Option, content: String) { @markup::doctype() html { head { @@ -45,14 +45,22 @@ markup::define! { } } body { + // TODO Somehow compress headerbar into a menu when the screen space is tight nav#headerbar { ul { - // TODO print a list of feeds and allow jumping to them li { a#homepage[href="/"] { @blog_name } } @for feed in feeds.iter() { li { a[href=&feed.uid] { @feed.name } } } - li.shiftright { a#login[href="/login"] { "Login" } } + li.shiftright { + @if user.is_none() { + a#login[href="/login"] { "Sign in" } + } else { + span { + @user.as_ref().unwrap() " - " a#logout[href="/logout"] { "Sign out" } + } + } + } } } main { @@ -372,7 +380,7 @@ markup::define! { } @Feed { feed } } - ErrorPage(code: StatusCode) { + ErrorPage(code: StatusCode, msg: Option) { h1 { @format!("HTTP {} {}", code, code.canonical_reason()) } @match code { StatusCode::Unauthorized => { @@ -399,11 +407,32 @@ markup::define! { p { "Wait, do you seriously expect my website to brew you coffee? It's not a coffee machine!" } p { - small { "I could brew you some coffee tho if we meet one day... " - small { i { "i-it's nothing personal, I just like brewing coffee, b-baka!!!~ >.. { p { "It seems like you have found an error. Not to worry, it has already been logged." } } + StatusCode::BadRequest => { + @if msg.is_none() { + p { + "There was an undescribed error in your request. " + "Please try again later or with a different request." + } + } else { + p { + "There was a following error in your request: " + @msg.as_ref().unwrap() + } + } + } + _ => { + p { "It seems like you have found an error. Not to worry, it has already been logged." } + } } P { "For now, may I suggest to visit " a[href="/"] {"the main page"} " of this website?" } -- cgit 1.4.1