this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #18 from websages/youtube

feat: Display Youtube links as embedded player

authored by

Michael Stahnke and committed by
GitHub
ee5de529 40d651d5

+58 -7
+18
htdocs/css/screen.css
··· 177 177 color: #657786; 178 178 line-height: 1.4; 179 179 } 180 + 181 + .youtube-embed-wrapper { 182 + position: relative; 183 + padding-bottom: 56.25%; /* 16:9 aspect ratio */ 184 + height: 0; 185 + overflow: hidden; 186 + max-width: 100%; 187 + margin-top: 10px; 188 + background: #000; 189 + } 190 + 191 + .youtube-embed-wrapper iframe { 192 + position: absolute; 193 + top: 0; 194 + left: 0; 195 + width: 100%; 196 + height: 100%; 197 + }
+35 -7
htdocs/lib/tumble.pm
··· 160 160 $link_filler = $stuff->{'html'}; 161 161 } 162 162 163 - $content = 164 - '<a href="http://' . $CONFIG->{'baseurl'} . 165 - qq{/irclink/?} . 166 - $data->{$item}->{'ircLinkID'} . 167 - qq{">} . 168 - $link_filler . 169 - qq{</a>} 163 + # Handle YouTube URLs - extract video ID and create embed 164 + my $is_youtube = 0; 165 + if ($data->{$item}->{'url'} =~ /youtube\.com|youtu\.be/i) { 166 + my $video_id; 167 + my $url = $data->{$item}->{'url'}; 168 + 169 + # Handle various YouTube URL formats (case-insensitive, with or without www/protocol) 170 + if ($url =~ /(?:youtube\.com\/watch\?v=|youtube\.com\/embed\/|youtu\.be\/)([a-zA-Z0-9_-]{11})/i) { 171 + $video_id = $1; 172 + } elsif ($url =~ /youtube\.com\/watch\?.*[&?]v=([a-zA-Z0-9_-]{11})/i) { 173 + $video_id = $1; 174 + } 175 + 176 + if ($video_id) { 177 + # Create responsive YouTube embed (standalone, not wrapped in link) 178 + $content = '<div class="youtube-embed-wrapper">' . 179 + '<iframe width="560" height="315" ' . 180 + 'src="https://www.youtube.com/embed/' . $video_id . '?rel=0" ' . 181 + 'frameborder="0" ' . 182 + 'allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" ' . 183 + 'allowfullscreen></iframe>' . 184 + '</div>'; 185 + $is_youtube = 1; 186 + } 187 + } 188 + 189 + unless ($is_youtube) { 190 + $content = 191 + '<a href="http://' . $CONFIG->{'baseurl'} . 192 + qq{/irclink/?} . 193 + $data->{$item}->{'ircLinkID'} . 194 + qq{">} . 195 + $link_filler . 196 + qq{</a>}; 197 + } 170 198 171 199 }; 172 200
+5
htdocs/thtml/index.thtml
··· 32 32 return; 33 33 } 34 34 35 + // Skip OG preview for YouTube links (they're embedded directly) 36 + if (url.match(/youtube\.com|youtu\.be/i)) { 37 + return; 38 + } 39 + 35 40 // Ensure URL has protocol 36 41 if (!url.match(/^https?:\/\//)) { 37 42 url = 'http://' + url;