diff options
author | pdp8 <pdp8@pdp8.info> | 2024-02-02 20:24:01 +0100 |
---|---|---|
committer | pdp8 <pdp8@pdp8.info> | 2024-02-02 20:24:01 +0100 |
commit | 9bc8be6e2660c9225420089ff00a1215c4928ef7 (patch) | |
tree | aabc131b21589c740c97542077452063cbb2e79c /html.rb | |
parent | 6cb7fdb0588d0acb5d589cdb45ea3fe13f8a807c (diff) |
image/video width/height
Diffstat (limited to 'html.rb')
-rwxr-xr-x | html.rb | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -1,5 +1,4 @@ #!/usr/bin/env ruby -require 'erb' MEDIA_DIR = '/srv/media' MEDIA_URL = 'https://media.pdp8.info' @@ -13,6 +12,7 @@ def nav(cat) cl = c == cat ? 'item current' : 'item' html += " <a class='#{cl}' href='/#{c}.html'>#{c}</a>" end + html += " <a class='item' href='/social/create.html'>social</a>" html += " <a class='item' href='/rss.xml'>rss</a>" html += " <a id='menu' href='#' onclick='show_vertical_menu()'>≡</a>" html += '</nav>' @@ -34,7 +34,6 @@ def print_html(basename, html) out = File.join(WWW_DIR, basename + '.html') puts out File.open(out, 'w+') { |f| f.puts html } - File.open('tmp.html', 'w+') { |f| f.puts html } if basename == 'music' puts `tidy -iqm -w 0 #{out} 2>&1` end @@ -51,7 +50,8 @@ def music_html html += "<h1>#{title}</h1>" html += File.read(File.join(dir, 'README')).chomp.gsub("\n\n", '<p>').gsub("\n", '<br>') # + '<p>' cover = File.join(MEDIA_URL, dir.sub(MEDIA_DIR, ''), 'cover.webp') - html += "<img class='cover' loading='lazy' width='1024' height='1024' src='#{cover}' alt='cover'>" + w, h = `identify -format "%w %h" #{cover}`.chomp.split(' ') + html += "<img class='cover' loading='lazy' width='#{w}' height='#{h}' src='#{cover}' alt='cover'>" html += '<table>' copyrights_file = File.join(dir, 'copyrights') copyrights = File.readlines(copyrights_file).collect { |l| l.chomp } if File.exist? copyrights_file @@ -102,15 +102,15 @@ def video_html mp4 = File.join(MEDIA_URL, 'videos', File.basename(dir), title.gsub(' ', '_') + '.mp4') webm = File.join(MEDIA_URL, 'videos', File.basename(dir), title.gsub(' ', '_') + '.webm') poster = File.join(MEDIA_URL, 'videos', File.basename(dir), 'poster.png') + w, h = `ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 #{webm}`.chomp.split(',') - html += "<video controls preload='none' poster='#{poster}'> + html += "<video controls preload='none' width='#{w}' height='#{h}' poster='#{poster}'> <source src='#{webm}' type='video/webm'> <source src='#{mp4}' type='video/mp4'> </video><p> " html += lines.join('<br>') html += '</div>' - # html += '<hr>' end html += '<p> © pdp8 <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>' html += File.read(File.join(SNIPPETS, 'tail.html')) @@ -128,9 +128,10 @@ def climbing_html webm: txt.sub(MEDIA_DIR, MEDIA_URL).sub('.txt', '.webm'), webp: txt.sub(MEDIA_DIR, MEDIA_URL).sub('.txt', '.webp') } end.sort_by { |m| m[:date] }.reverse.each do |post| + w, h = `ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 #{post[:webm]}`.chomp.split(',') html += '<div class="post">' html += "<h1>#{post[:date]}</h1>" - html += "<video controls preload='none' poster=#{post[:webp]}> + html += "<video controls preload='none' width='#{w}' height='#{h}' poster=#{post[:webp]}> <source src='#{post[:webm]}' type='video/webm'> <source src='#{post[:mp4]}' type='video/mp4'> <a href=#{post[:mp4]}>#{post[:mp4]}</a> |