#!/usr/bin/env ruby require_relative 'lib' 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[:date]}

" html += "

" html += post[:text] html += '

' end html += '

 © pdp8 Creative Commons Attribution 4.0 International License' html += File.read(File.join(SNIPPETS, 'tail.html')) print_html 'climbing', html