#!/usr/bin/env ruby MEDIA_DIR = '/srv/media' MEDIA_URL = 'https://media.pdp8.info' WWW_DIR = '/srv/www/pdp8-test' SNIPPETS = File.join(File.dirname(__FILE__), 'html') def nav(cat) html = '' html end def file_html(basename) path = File.join(SNIPPETS, basename + '.html') html = File.read(File.join(SNIPPETS, 'head.html')) html += nav basename html += "
').gsub("\n", '
') # + '
' cover = File.join(MEDIA_URL, dir.sub(MEDIA_DIR, ''), 'cover.webp') alt = File.read(File.join(dir, 'cover.txt')).chomp w, h = `identify -format "%w %h" #{cover}`.chomp.split(' ') html += "" html += '
#{name} | " html += "" html += ' |
Internet Archive: #{ia}" bc = if File.exist?(File.join(dir, 'bandcamp')) File.read(File.join(dir, 'bandcamp')).chomp else "https://pdp8.bandcamp.com/album/#{title.gsub(' ', '-')}" end html += "
Bandcamp: #{bc}" html += '
© pdp8 Creative Commons Attribution 4.0 International License' html += File.read(File.join(SNIPPETS, 'tail.html')) print_html 'music', html end def picture_html html = File.read(File.join(SNIPPETS, 'head.html')) html += nav 'pictures' html += '
© pdp8 Creative Commons Attribution 4.0 International License' html += File.read(File.join(SNIPPETS, 'tail.html')) print_html 'pictures', html end def video_html videos = Dir[File.join(MEDIA_DIR, 'videos', '*')].sort.reverse html = File.read(File.join(SNIPPETS, 'head.html')) html += nav 'videos' videos.each_with_index do |dir, _i| date = File.basename(dir).split('_')[0] 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 += "
"
html += lines.join('
')
html += '
© pdp8 Creative Commons Attribution 4.0 International License'
html += File.read(File.join(SNIPPETS, 'tail.html'))
print_html 'videos', html
end
def climbing_html
html = File.read(File.join(SNIPPETS, 'head.html'))
html += nav 'climbing'
Dir[File.join(MEDIA_DIR, 'climbing', '*.txt')].collect do |txt|
lines = File.read(txt).lines.collect { |l| l.chomp }
{ date: lines.shift,
text: lines.join('
'),
mp4: txt.sub(MEDIA_DIR, MEDIA_URL).sub('.txt', '.mp4'),
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 += '
" html += post[:text] html += '
© pdp8 Creative Commons Attribution 4.0 International License' html += File.read(File.join(SNIPPETS, 'tail.html')) print_html 'climbing', html end music_html # picture_html video_html climbing_html %w[about code pictures contact].each do |basename| file_html basename end last = (Dir[File.join(MEDIA_DIR, 'music', '*')] + Dir[File.join(MEDIA_DIR, 'videos', '*')]).sort_by { |d| File.basename(d) }.last.split('/')[-2] + '.html' puts `cp "#{File.join(WWW_DIR, last)}" "#{File.join(WWW_DIR, 'index.html')}"` [ 'pdp8.png', '540px-PDP-8_.jpg', 'style.css', 'slideshow.js', 'robots.txt' ].each { |f| puts `rsync -av "#{File.join(SNIPPETS, f)}" "#{WWW_DIR}"` }