From bf4f0eafe402d128a63695559134e6fe05d51a2e Mon Sep 17 00:00:00 2001 From: Vika Shleina Date: Thu, 15 Jul 2021 08:37:09 +0300 Subject: frontend: fixed site name, added thumbnail support and Markdown tutorial link --- src/frontend/mod.rs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/frontend/mod.rs b/src/frontend/mod.rs index e3dad3f..b37dfea 100644 --- a/src/frontend/mod.rs +++ b/src/frontend/mod.rs @@ -234,7 +234,9 @@ mod templates { p { "Consider telling more about yourself, your skills and interests in this note " @markup::raw("—") - " though you're free to write anything you want. (By the way, you can use Markdown here to spice up your note!)" + " though you're free to write anything you want. (By the way, you can use " + a[href="https://daringfireball.net/projects/markdown/syntax"] { "Markdown" } + " here to spice up your note!)" } textarea#first_post_content[style="width: 100%; height: 8em", placeholder="Hello! I am really excited about #IndieWeb"] {} @@ -387,7 +389,13 @@ mod templates { @if photo.is_string() { img."u-photo"[src=photo.as_str().unwrap(), loading="lazy"]; } else if photo.is_array() { - img."u-photo"[src=photo["value"].as_str().unwrap(), loading="lazy", alt=photo["alt"].as_str().unwrap_or("")]; + @if photo["thumbnail"].is_string() { + a."u-photo"[href=photo["value"].as_str().unwrap()] { + img[src=photo["thumbnail"].as_str().unwrap(), loading="lazy", alt=photo["alt"].as_str().unwrap_or("")]; + } + } else { + img."u-photo"[src=photo["value"].as_str().unwrap(), loading="lazy", alt=photo["alt"].as_str().unwrap_or("")]; + } } } } @@ -524,7 +532,7 @@ mod templates { "JavaScript isn't a menace, stop fearing it or I will switch to WebAssembly " "and knock your nico-nico-kneecaps so fast with its speed you won't even notice that... " small { "omae ha mou shindeiru" } - // NANI?!!! + @markup::raw("") } } } } @@ -745,7 +753,7 @@ pub async fn onboarding_receiver(mut req: Request(_: Request>) -> Result { @@ -800,7 +808,7 @@ pub async fn mainpage(req: Request>) -> Result { ) .build()) } else { - return Err(feed_err.into()); + Err(feed_err.into()) } } else { Ok(Response::builder(200) @@ -809,7 +817,7 @@ pub async fn mainpage(req: Request>) -> Result { Template { title: &format!("{} - Main page", url.host().unwrap().to_string()), blog_name: &backend - .get_setting("site_name", &url.host().unwrap().to_string()) + .get_setting("site_name", hcard_url) .await .unwrap_or_else(|_| "Kitty Box!".to_string()), endpoints: IndiewebEndpoints { @@ -862,6 +870,7 @@ pub async fn render_post(req: Request>) -> Resul .into()) } }; + let origin = url.origin(); Ok(Response::builder(200) .content_type("text/html; charset=utf-8") @@ -873,7 +882,7 @@ pub async fn render_post(req: Request>) -> Resul blog_name: &req .state() .storage - .get_setting("site_name", &url.host().unwrap().to_string()) + .get_setting("site_name", &(origin.ascii_serialization() + "/")) // XXX I'm pretty sure this is bound to cause issues with IDN-style domains .await .unwrap_or_else(|_| "Kitty Box!".to_string()), endpoints: IndiewebEndpoints { -- cgit 1.4.1