My personal site cherry.computer
htmx tailwind axum askama

refactor: remove unused Option from Media.url field

Now that the Apple Music fetcher supports URLs as well we can remove
some messy templating logic.

cherry.computer e46078fd eafe8fb2

verified
+13 -26
+1 -1
server/src/scrapers.rs
··· 12 12 pub name: String, 13 13 pub image: String, 14 14 pub context: String, 15 - pub url: Option<String>, 15 + pub url: String, 16 16 } 17 17 18 18 #[derive(Debug, Clone, Copy, Display, EnumString, Deserialize)]
+1 -1
server/src/scrapers/apple_music.rs
··· 121 121 name: track.attributes.name.clone(), 122 122 image: artwork_url, 123 123 context, 124 - url: Some(track.attributes.url.clone()), 124 + url: track.attributes.url.clone(), 125 125 }) 126 126 } 127 127
+1 -1
server/src/scrapers/backloggd.rs
··· 75 75 name, 76 76 image, 77 77 context: platform, 78 - url: Some(url.into()), 78 + url: url.into(), 79 79 }) 80 80 } 81 81
+1 -1
server/src/scrapers/letterboxd.rs
··· 68 68 name, 69 69 image: image_url_data.url, 70 70 context: formatted_rating, 71 - url: Some(url.into()), 71 + url: url.into(), 72 72 }) 73 73 } 74 74
+3 -3
server/src/templates/index.rs
··· 66 66 name: "Cyberpunk 2077: Ultimate Edition".to_owned(), 67 67 image: "https://images.igdb.com/igdb/image/upload/t_cover_big/co7iy1.jpg".to_owned(), 68 68 context: "Nintendo Switch 2".to_owned(), 69 - url: Some("https://backloggd.com/u/cherryfunk/logs/cyberpunk-2077-ultimate-edition/".to_owned()) 69 + url: "https://backloggd.com/u/cherryfunk/logs/cyberpunk-2077-ultimate-edition/".to_owned() 70 70 })), 71 71 (MediaType::Film, Some(Media { 72 72 name: "The Thursday Murder Club".to_owned(), 73 73 image: "https://a.ltrbxd.com/resized/film-poster/6/6/6/2/8/6/666286-the-thursday-murder-club-0-230-0-345-crop.jpg?v=4bfeae38a7".to_owned(), 74 74 context: "1 star".to_owned(), 75 - url: Some("https://letterboxd.com/ivom/film/the-thursday-murder-club/".to_owned()) 75 + url: "https://letterboxd.com/ivom/film/the-thursday-murder-club/".to_owned() 76 76 })), 77 77 (MediaType::Song, Some(Media { 78 78 name: "We Might Feel Unsound".to_owned(), 79 79 image: "https://is1-ssl.mzstatic.com/image/thumb/Music124/v4/f4/b2/8e/f4b28ee4-01c6-232c-56a7-b97fd5b0e0ae/00602527857671.rgb.jpg/240x240bb.jpg".to_owned(), 80 80 context: "James Blake — James Blake".to_owned(), 81 - url: Some("https://music.apple.com/gb/album/we-might-feel-unsound/1443124478?i=1443125024".to_owned()) 81 + url: "https://music.apple.com/gb/album/we-might-feel-unsound/1443124478?i=1443125024".to_owned() 82 82 })), 83 83 ] 84 84 }
+6 -19
server/templates/media.html
··· 1 - {% if let Some(url) = media.url %} 2 - <a href="{{ url }}" target="_blank" 3 - {% else %} 4 - <div 5 - {% endif %} 6 - class="peer/{{ media_type }} relative aspect-square max-h-50 justify-self-center hoverable:max-h-none"> 1 + <a 2 + href="{{ media.url }}" 3 + target="_blank" 4 + class="peer/{{ media_type }} relative aspect-square max-h-50 justify-self-center hoverable:max-h-none" 5 + > 7 6 <img 8 7 class="absolute inset-0 aspect-square rounded-xs object-fill" 9 8 aria-hidden="true" ··· 14 13 src="{{ media.image }}" 15 14 alt="Cover art for {{ media.name }}" 16 15 /> 17 - {% if let Some(url) = media.url %} 18 16 </a> 19 - {% else %} 20 - </div> 21 - {% endif %} 22 - {% if let Some(url) = media.url %} 23 17 <a 24 - href="{{ url }}" 18 + href="{{ media.url }}" 25 19 target="_blank" 26 - {% else %} 27 - <div 28 - {% endif %} 29 20 id="media-description-{{ media_type }}" 30 21 class="mx-2 mt-4 flex flex-col self-center peer-hover/{{ media_type }}:block hoverable:col-span-full hoverable:row-2 hoverable:hidden" 31 22 hx-swap-oob="true" 32 23 > 33 24 <p class="text-2xl text-white">{{ media.name }}</p> 34 25 <p class="text-xl text-gray-700 italic">{{ media.context }}</p> 35 - {% if let Some(url) = media.url %} 36 26 </a> 37 - {% else %} 38 - </div> 39 - {% endif %}