diff options
author | Vika <vika@fireburn.ru> | 2023-06-15 22:44:50 +0300 |
---|---|---|
committer | Vika <vika@fireburn.ru> | 2023-06-15 22:44:50 +0300 |
commit | 2f5df555ecf70dbaf7f059723813ea099e12879d (patch) | |
tree | 57b9e0a951ae21859342cf3f1a456c999a5c750d /kittybox-rs | |
parent | 9a28da3ac18f60329474e6b48a77f07e57ba88d4 (diff) | |
download | kittybox-2f5df555ecf70dbaf7f059723813ea099e12879d.tar.zst |
Smallish code tweaks
- cleaner format!() - syndication links - broke up a long line
Diffstat (limited to 'kittybox-rs')
-rw-r--r-- | kittybox-rs/src/indieauth/mod.rs | 4 | ||||
-rw-r--r-- | kittybox-rs/templates/src/mf2.rs | 20 | ||||
-rw-r--r-- | kittybox-rs/templates/src/templates.rs | 2 |
3 files changed, 23 insertions, 3 deletions
diff --git a/kittybox-rs/src/indieauth/mod.rs b/kittybox-rs/src/indieauth/mod.rs index f71b5be..cf3278a 100644 --- a/kittybox-rs/src/indieauth/mod.rs +++ b/kittybox-rs/src/indieauth/mod.rs @@ -150,12 +150,14 @@ async fn authorization_endpoint_get<A: AuthBackend, D: Storage + 'static>( Extension(http): Extension<reqwest::Client>, Extension(auth): Extension<A> ) -> Response { - let me = format!("https://{}/", host).parse().unwrap(); + let me = format!("https://{host}/").parse().unwrap(); let h_app = { + tracing::debug!("Sending request to {} to fetch metadata", request.client_id); match http.get(request.client_id.clone()).send().await { Ok(response) => { let url = response.url().clone(); let text = response.text().await.unwrap(); + tracing::debug!("Received {} bytes in response", text.len()); match microformats::from_html(&text, url) { Ok(mf2) => { if let Some(relation) = mf2.rels.items.get(&request.redirect_uri) { diff --git a/kittybox-rs/templates/src/mf2.rs b/kittybox-rs/templates/src/mf2.rs index 893cf7b..0e03dc6 100644 --- a/kittybox-rs/templates/src/mf2.rs +++ b/kittybox-rs/templates/src/mf2.rs @@ -178,6 +178,17 @@ markup::define! { } } } + @if let Some(links) = post["properties"]["syndication"].as_array() { + @if !links.is_empty() { + hr; + ul { + "Also published on:" + @for url in links.iter().filter_map(|i| i.as_str()) { + li { a."u-syndication"[href=url] { @url } } + } + } + } + } @if post["properties"]["location"].is_array() || post["properties"]["checkin"].is_array() { div { @if post["properties"]["checkin"].is_array() { @@ -307,7 +318,14 @@ markup::define! { @if card["properties"]["url"].is_array() { ul { "Can be found elsewhere at:" - @for url in card["properties"]["url"].as_array().unwrap().iter().filter_map(|v| v.as_str()).filter(|v| v != &card["properties"]["uid"][0].as_str().unwrap()).filter(|v| !v.starts_with(&card["properties"]["author"][0].as_str().unwrap())) { + @for url in card["properties"]["url"] + .as_array() + .unwrap() + .iter() + .filter_map(|v| v.as_str()) + .filter(|v| v != &card["properties"]["uid"][0].as_str().unwrap()) + .filter(|v| !v.starts_with(card["properties"]["author"][0].as_str().unwrap())) + { li { a."u-url"[href=url, rel="me"] { @url } } } } diff --git a/kittybox-rs/templates/src/templates.rs b/kittybox-rs/templates/src/templates.rs index 10c84a7..9826bfc 100644 --- a/kittybox-rs/templates/src/templates.rs +++ b/kittybox-rs/templates/src/templates.rs @@ -93,7 +93,7 @@ markup::define! { @Feed { feed } } ErrorPage(code: StatusCode, msg: Option<String>) { - h1 { @format!("HTTP {}", code) } + h1 { @format!("HTTP {code}") } @match *code { StatusCode::UNAUTHORIZED => { p { "Looks like you need to authenticate yourself before seeing this page. Try logging in with IndieAuth using the Login button above!" } |