diff options
Diffstat (limited to 'climbing.rb')
-rwxr-xr-x | climbing.rb | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/climbing.rb b/climbing.rb index 139925d..c016bfa 100755 --- a/climbing.rb +++ b/climbing.rb @@ -1,25 +1,23 @@ #!/usr/bin/env ruby require_relative 'lib' +climbing = Dir[File.join(MEDIA_DIR, 'climbing', '*')].select { |f| File.directory? f }.sort.reverse 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> +climbing.each do |dir| + date = File.basename(dir) + html += "<div class='post' id='#{date}'>" + html += "<h1>#{date}</h1>" + mp4 = Dir[File.join(dir, '*.mp4')].first.sub(MEDIA_DIR, MEDIA_URL) + webm = Dir[File.join(dir, '*.webm')].first.sub(MEDIA_DIR, MEDIA_URL) + poster = Dir[File.join(dir, '*.webp')].first.sub(MEDIA_DIR, MEDIA_URL) + html += "<video controls preload='none' poster='#{poster}'> + <source src='#{webm}' type='video/webm'> + <source src='#{mp4}' type='video/mp4'> + <a href=#{mp4}>#{mp4}</a> </video><p> " - html += post[:text] + html += File.read(File.join(dir, 'README')) html += '</div>' end html += File.read(File.join(SNIPPETS, 'tail.html')) |