summaryrefslogtreecommitdiff
path: root/climbing.rb
diff options
context:
space:
mode:
authorpdp8 <pdp8@pdp8.info>2024-03-04 23:13:40 +0100
committerpdp8 <pdp8@pdp8.info>2024-03-04 23:13:40 +0100
commit0555b2cd77986d916968f1443e375fad005c8d43 (patch)
tree84112db3509f5d9b40fe41abd14fa6bc1c41303d /climbing.rb
parent6b40f3b54efabb740e825ba3d94b5695c2b98ede (diff)
html.rb separated, Makefile for website generation
Diffstat (limited to 'climbing.rb')
-rwxr-xr-xclimbing.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/climbing.rb b/climbing.rb
new file mode 100755
index 0000000..6705aba
--- /dev/null
+++ b/climbing.rb
@@ -0,0 +1,28 @@
+#!/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('<br>'),
+ 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 += '<div class="post">'
+ html += "<h1>#{post[:date]}</h1>"
+ 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>
+ </video><p>
+ "
+ html += post[:text]
+ html += '</div>'
+end
+html += '<p>&nbsp;&copy; 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'))
+print_html 'climbing', html