From 6cb7fdb0588d0acb5d589cdb45ea3fe13f8a807c Mon Sep 17 00:00:00 2001 From: pdp8 Date: Tue, 30 Jan 2024 23:46:06 +0100 Subject: dark theme, lazy img/media loading, climbing integrated, IA links --- html.rb | 58 +++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 13 deletions(-) (limited to 'html.rb') diff --git a/html.rb b/html.rb index fd944bd..7e9d2f0 100755 --- a/html.rb +++ b/html.rb @@ -9,12 +9,12 @@ SNIPPETS = File.join(File.dirname(__FILE__), 'html') def nav(cat) html = '' html end @@ -43,30 +43,34 @@ def music_html html = File.read(File.join(SNIPPETS, 'head.html')) html += nav 'music' music.each do |dir| + next if dir.match 'alfadeo' + 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.jpeg') - html += "cover" + html += File.read(File.join(dir, 'README')).chomp.gsub("\n\n", '

').gsub("\n", '
') # + '

' + cover = File.join(MEDIA_URL, dir.sub(MEDIA_DIR, ''), 'cover.webp') + html += "cover" 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] + name = File.basename(mp3, '.mp3')[3..-1].gsub('_', ' ') # name += " ©#{copyrights[i]}" if copyrights html += '' + html += "" html += "" - html += "" html += '' end html += '
#{name} - #{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 @@ -74,7 +78,7 @@ def music_html end html += "

Bandcamp: #{bc}" html += '

' - html += '
' + # html += '
' end html += '

© pdp8 Creative Commons Attribution 4.0 International License' html += File.read(File.join(SNIPPETS, 'tail.html')) @@ -99,22 +103,50 @@ def video_html webm = File.join(MEDIA_URL, 'videos', File.basename(dir), title.gsub(' ', '_') + '.webm') poster = File.join(MEDIA_URL, 'videos', File.basename(dir), 'poster.png') - html += "

" html += lines.join('
') html += '' - html += '


' + # html += '
' end html += '

 © pdp8 Creative Commons Attribution 4.0 International License' html += File.read(File.join(SNIPPETS, 'tail.html')) print_html 'videos', html end +def climbing_html + 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('
'), + 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 += '

' + html += "

#{post[:date]}

" + html += "

+ " + html += post[:text] + html += '

' + end + html += '

 © pdp8 Creative Commons Attribution 4.0 International License' + html += File.read(File.join(SNIPPETS, 'tail.html')) + print_html 'climbing', html +end + music_html video_html +climbing_html %w[about code pictures contact].each do |basename| file_html basename -- cgit v1.2.3