From 729bf77efb0812d0aed6234576fdd06effa5019e Mon Sep 17 00:00:00 2001 From: Vika Date: Mon, 24 Oct 2022 00:51:46 +0300 Subject: indieauth: parse application metadata --- kittybox-rs/templates/src/indieauth.rs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'kittybox-rs/templates/src/indieauth.rs') diff --git a/kittybox-rs/templates/src/indieauth.rs b/kittybox-rs/templates/src/indieauth.rs index e901d7b..908cd2c 100644 --- a/kittybox-rs/templates/src/indieauth.rs +++ b/kittybox-rs/templates/src/indieauth.rs @@ -5,7 +5,7 @@ markup::define! { AuthorizationRequestPage( request: AuthorizationRequest, credentials: Vec, - app: serde_json::Value, + app: Option, user: serde_json::Value ) { script[type="module"] { @@ -31,12 +31,27 @@ document.getElementById("indieauth_page").addEventListener("submit", submit_hand } p."mini-h-card" { - @if let Some(icon) = app["properties"]["logo"][0].as_str() { + @if let Some(icon) = app + .as_ref() + .and_then(|app| app["properties"]["logo"][0].as_str()) + { img.app_icon[src=icon]; + } else if let Some(icon) = app + .as_ref() + .and_then(|app| app["properties"]["logo"][0].as_object()) + { + img.app_icon[src=icon["src"].as_str().unwrap(), alt=icon["alt"].as_str().unwrap()]; } span { - a[href=app["properties"]["url"][0].as_str().unwrap()] { - @app["properties"]["name"][0].as_str().unwrap() + a[href=app + .as_ref() + .and_then(|app| app["properties"]["url"][0].as_str()) + .unwrap_or_else(|| request.client_id.as_str()) + ] { + @app + .as_ref() + .and_then(|app| app["properties"]["name"][0].as_str()) + .unwrap_or_else(|| request.client_id.as_str()) } " wants to confirm your identity." } -- cgit 1.4.1