From 87ff7b50275f5f8804d3adf8d8e33c0839166f43 Mon Sep 17 00:00:00 2001 From: JMARyA Date: Sun, 15 Dec 2024 20:53:15 +0100 Subject: [PATCH] fix --- src/pages/components.rs | 84 +++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 45 deletions(-) diff --git a/src/pages/components.rs b/src/pages/components.rs index 43af141..b3dfda8 100644 --- a/src/pages/components.rs +++ b/src/pages/components.rs @@ -64,10 +64,10 @@ pub fn shell(content: PreEscaped, title: &str) -> PreEscaped { div class="flex justify-start px-6" { - (htmx_link("/", "flex items-center space-x-2", "stopAllVideos()", html!( + a href="/" class="flex items-center space-x-2" { img src="/favicon" alt="Logo" class="w-10 h-10 rounded-md"; span class="font-semibold text-xl" { "WatchDogs" }; - ))) + }; }; @@ -140,63 +140,57 @@ pub fn format_number(num: i32) -> String { } pub async fn video_element_wide(video: &mut Video) -> PreEscaped { - htmx_link( - &format!("/watch?v={}", video.id), - "flex items-center w-full p-4 bg-gray-900 shadow-lg rounded-lg overflow-hidden mb-2 mt-2", - "stopAllVideos()", - html!( - div class="flex-shrink-0" { - img width="480" src=(format!("/video/thumbnail?v={}", video.id)) alt="Video Thumbnail" class="w-48 h-32 object-cover rounded-md"; + html!( + a href=(format!("/watch?v={}", video.id)) class="flex items-center w-full p-4 bg-gray-900 shadow-lg rounded-lg overflow-hidden mb-2 mt-2" { + div class="flex-shrink-0" { + img width="480" src=(format!("/video/thumbnail?v={}", video.id)) alt="Video Thumbnail" class="w-48 h-32 object-cover rounded-md"; + }; + + div class="flex flex-col flex-grow ml-4" { + h3 class="text-lg font-semibold truncate mb-1" { + ( video.title ) }; - div class="flex flex-col flex-grow ml-4" { - h3 class="text-lg font-semibold truncate mb-1" { - ( video.title ) - }; + @if let Some(meta) = video.youtube_meta().await { + div class="text-sm text-gray-400 mb-2" { + span class="font-medium" { ( meta.uploader_name ) } + span { " - " } + span { ( format_date(&meta.upload_date) ) } + }; - @if let Some(meta) = video.youtube_meta().await { - div class="text-sm text-gray-400 mb-2" { - span class="font-medium" { ( meta.uploader_name ) } - span { " - " } - span { ( format_date(&meta.upload_date) ) } - }; - - div class="text-sm text-gray-400" { - span { ( format_number(meta.views) ) } - span { " views" } - span { " - " } - span class="ml-2 bg-black text-white text-xs px-2 py-1 rounded-sm opacity-90" { - (( format_seconds_to_hhmmss(video.duration) )) - }; + div class="text-sm text-gray-400" { + span { ( format_number(meta.views) ) } + span { " views" } + span { " - " } + span class="ml-2 bg-black text-white text-xs px-2 py-1 rounded-sm opacity-90" { + (( format_seconds_to_hhmmss(video.duration) )) }; }; }; - ), + }; + }; ) } pub async fn video_element(video: &mut Video) -> PreEscaped { - htmx_link( - &format!("/watch?v={}", video.id), - "max-w-sm mx-auto p-4 max-h-60 aspect-video", - "stopAllVideos()", - html!( - div class="bg-gray-900 shadow-lg rounded-lg overflow-hidden" { - div class="relative" { - img width="480" src=(format!("/video/thumbnail?v={}", video.id)) alt="Video Thumbnail" class="w-full h-auto object-cover aspect-video"; - span class="absolute bottom-2 right-2 bg-black text-white text-xs px-2 py-1 rounded-sm opacity-90" { - (( format_seconds_to_hhmmss(video.duration) )) - }; + html!( + a href=(format!("/watch?v={}", video.id)) class="max-w-sm mx-auto p-4 max-h-60 aspect-video" { + div class="bg-gray-900 shadow-lg rounded-lg overflow-hidden" { + div class="relative" { + img width="480" src=(format!("/video/thumbnail?v={}", video.id)) alt="Video Thumbnail" class="w-full h-auto object-cover aspect-video"; + span class="absolute bottom-2 right-2 bg-black text-white text-xs px-2 py-1 rounded-sm opacity-90" { + (( format_seconds_to_hhmmss(video.duration) )) }; + }; - div class="bg-gray-900 shadow-lg rounded-lg overflow-hidden" { - div class="p-4" { - h3 class="text-lg font-semibold truncate" { - ( video.title ) - }; + div class="bg-gray-900 shadow-lg rounded-lg overflow-hidden" { + div class="p-4" { + h3 class="text-lg font-semibold truncate" { + ( video.title ) }; }; }; - ), + }; + }; ) }