summaryrefslogtreecommitdiff
path: root/climbing.rb
blob: 139925db53a3878a61c3abd9b587fa2c837ea6ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/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|
  html += '<div class="post">'
  html += "<h1>#{post[:date]}</h1>"
  html += "<video controls preload='none' 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 += File.read(File.join(SNIPPETS, 'tail.html'))
print_html 'climbing', html