use splices for rendering and url-encode the public key link

This commit is contained in:
glyph 2022-03-21 16:43:22 +02:00
parent e19fa0f99d
commit 98121f4922

View File

@ -17,23 +17,21 @@ fn peers_template(peers: Vec<HashMap<String, String>>) -> Markup {
),
None => (
// set a fall-back value for name in case the data is unavailable
"name unavailable".to_string(),
"Name unavailable".to_string(),
"Profile image".to_string()
)
};
@let profile_link = format!("/scuttlebutt/profile?public_key={}", peer["id"]);
@let url_safe_peer_id = peer["id"].replace('/', "%2F");
li {
a class="list-item link" href=(profile_link) {
a class="list-item link" href={ "/scuttlebutt/profile/" (url_safe_peer_id) } {
@if peer.get("blob_path").is_some() && peer["blob_exists"] == "true" {
@let blob_path = format!("/blob/{}", peer["blob_path"]);
img id="peerImage" class="icon list-icon" src=(blob_path) alt=(name_alt);
img id="peerImage" class="icon list-icon" src={ "/blob/" (peer["blob_path"]) } alt=(name_alt);
} @else {
// use a placeholder image if we don't have the blob
img id="peerImage" class="icon icon-active list-icon" src="/icons/user.svg" alt="Placeholder profile image";
}
p id="peerName" class="font-normal list-text" { (name) };
@let name_title = format!("{}'s public key", name);
label class="label-small label-ellipsis list-label font-gray" for="peerName" title=(name_title) {
p id="peerName" class="font-normal list-text " { (name) };
label class="label-small label-ellipsis list-label font-gray" for="peerName" title={ (name) "'s public key" } {
(peer["id"])
}
}