From 0555b2cd77986d916968f1443e375fad005c8d43 Mon Sep 17 00:00:00 2001 From: pdp8 Date: Mon, 4 Mar 2024 23:13:40 +0100 Subject: html.rb separated, Makefile for website generation --- music.rb | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 music.rb (limited to 'music.rb') diff --git a/music.rb b/music.rb new file mode 100755 index 0000000..e86e0c5 --- /dev/null +++ b/music.rb @@ -0,0 +1,51 @@ +#!/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 -- cgit v1.2.3