#!/usr/bin/env ruby require_relative 'lib' music = Dir[File.join(MEDIA_DIR, 'music', '20*')].sort.reverse html = File.read(File.join(SNIPPETS, 'head.html')) html += nav 'music' html += '
← prev | faircamp webring | random | next →
' music.each do |dir| date = File.basename(dir).split('_')[0] html += "
" title = File.basename(dir).split('_')[1..-1].join(' ') html += "

#{title}

" html += File.read(File.join(dir, 'README')).chomp.gsub("\n\n", '

').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 += "#{alt}" html += '' copyrights_file = File.join(dir, 'copyrights') copyrights = File.readlines(copyrights_file).collect { |l| l.chomp } if File.exist? copyrights_file Dir[File.join(dir, '*mp3')].each_with_index do |mp3, _i| mp3 = File.join(MEDIA_URL, mp3.sub(MEDIA_DIR, '')) name = File.basename(mp3, '.mp3')[3..-1].gsub('_', ' ') html += '' html += "" html += "" html += '' end html += '
#{name}
' ia = "https://archive.org/details/pdp8_#{title.gsub(' ', '_')}" 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 += '

' end html += '

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