From a3ab009e96db2269dcf3f6dd1c103aa885186ee4 Mon Sep 17 00:00:00 2001 From: pdp8 Date: Sun, 30 Jul 2023 16:45:03 +0200 Subject: media moved to media.pdp8.info, drone release --- html.rb | 134 +++++++++++++++++++++++++++---------------------- rss.rb | 71 ++++++++++++++++---------- snippets/contact.html | 10 +++- snippets/pictures.html | 22 ++++---- snippets/slideshow.js | 2 +- 5 files changed, 141 insertions(+), 98 deletions(-) diff --git a/html.rb b/html.rb index e39f5fc..5b8a9e2 100755 --- a/html.rb +++ b/html.rb @@ -1,120 +1,134 @@ #!/usr/bin/env ruby +require 'erb' -ROOT = ARGV[0] -SNIPPETS = File.join(File.dirname(__FILE__), "snippets") +MEDIA_DIR = '/srv/media' +MEDIA_URL = 'https://media.pdp8.info' +WWW_DIR = '/srv/www/pdp8-test' +SNIPPETS = File.join(File.dirname(__FILE__), 'snippets') -def nav cat - html = "' html end -def file_html basename - path = File.join(SNIPPETS, basename + ".html") - html = File.read(File.join(SNIPPETS, "head.html")) +def file_html(basename) + path = File.join(SNIPPETS, basename + '.html') + html = File.read(File.join(SNIPPETS, 'head.html')) html += nav basename html += "
" html += File.read(path) - html += "
" - html += File.read(File.join(SNIPPETS, "tail.html")) + html += '' + html += File.read(File.join(SNIPPETS, 'tail.html')) print_html basename, html end -def print_html basename, html - out = File.join(ROOT, basename + ".html") +def print_html(basename, html) + out = File.join(WWW_DIR, basename + '.html') puts out - File.open(out, "w+") { |f| f.puts html } + File.open(out, 'w+') { |f| f.puts html } + File.open('tmp.html', 'w+') { |f| f.puts html } if basename == 'music' puts `tidy -iqm -w 0 #{out} 2>&1` end def music_html - music = Dir[File.join(ROOT, "music", "*")].sort.reverse - html = File.read(File.join(SNIPPETS, "head.html")) - html += nav "music" - music.each_with_index do |dir, i| - date = File.basename(dir).split("_")[0] + music = Dir[File.join(MEDIA_DIR, 'music', '*')].sort.reverse + html = File.read(File.join(SNIPPETS, 'head.html')) + html += nav 'music' + music.each do |dir| + date = File.basename(dir).split('_')[0] html += "
" - title = File.basename(dir).split("_")[1..-1].join(" ") + title = File.basename(dir).split('_')[1..-1].join(' ') html += "

#{title}

" - html += File.read(File.join(dir, "README")) + "

" - cover = File.join("/", dir.sub(ROOT, ''), "cover.jpeg") + 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 += "" - Dir[File.join(dir, "*mp3")].each do |mp3| - mp3 = mp3.sub(ROOT, '') - html += "" + 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 += " ©#{copyrights[i]}" if copyrights + html += '' html += "" - html += "" - html += "" + html += "" + html += '' end - html += "
#{File.basename(mp3, '.mp3')[3..-1]}
#{name}
" - bc = "https://pdp8.bandcamp.com/album/#{title.gsub(' ', '-')}" + html += '' + 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 += "

" - html += "
" + html += '' + html += '
' end html += '

© pdp8 Creative Commons Attribution 4.0 International License' - html += File.read(File.join(SNIPPETS, "tail.html")) - print_html "music", html + html += File.read(File.join(SNIPPETS, 'tail.html')) + print_html 'music', html end def video_html - videos = Dir[File.join(ROOT, "videos", "*")].sort.reverse - html = File.read(File.join(SNIPPETS, "head.html")) - html += nav "videos" - videos.each_with_index do |dir, i| - date = File.basename(dir).split("_")[0] + videos = Dir[File.join(MEDIA_DIR, 'videos', '*')].sort.reverse + html = File.read(File.join(SNIPPETS, 'head.html')) + html += nav 'videos' + videos.each_with_index do |dir, _i| + date = File.basename(dir).split('_')[0] html += "

" - title = File.basename(dir).split("_")[1..-1].join(" ") + title = File.basename(dir).split('_')[1..-1].join(' ') html += "

#{title}

" - txt = File.read(File.join(dir, "README")) + txt = File.read(File.join(dir, 'README')) txt = txt.gsub(/(http\S*)/, '\1') lines = txt.split("\n") - html += lines.shift + "

" + html += lines.shift + '

' - mp4 = File.join("/videos", File.basename(dir), title.gsub(" ", "_") + ".mp4") - webm = File.join("/videos", File.basename(dir), title.gsub(" ", "_") + ".webm") - poster = File.join("/videos", File.basename(dir), "poster.png") + mp4 = File.join(MEDIA_URL, 'videos', File.basename(dir), title.gsub(' ', '_') + '.mp4') + 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 += lines.join('
') + html += '' + html += '
' end html += '

 © pdp8 Creative Commons Attribution 4.0 International License' - html += File.read(File.join(SNIPPETS, "tail.html")) - print_html "videos", html + html += File.read(File.join(SNIPPETS, 'tail.html')) + print_html 'videos', html end music_html video_html -["about", "code", "pictures", "contact"].each do |basename| +%w[about code pictures contact].each do |basename| file_html basename end -last = (Dir[File.join(ROOT, "music", "*")] + Dir[File.join(ROOT, "videos", "*")]).sort_by { |d| File.basename(d) }.last.split("/")[-2] + '.html' -puts `cp "#{File.join(ROOT, last)}" "#{File.join(ROOT, "index.html")}"` +last = (Dir[File.join(MEDIA_DIR, 'music', '*')] + Dir[File.join(MEDIA_DIR, 'videos', '*')]).sort_by { |d| + File.basename(d) +}.last.split('/')[-2] + '.html' +puts `cp "#{File.join(WWW_DIR, last)}" "#{File.join(WWW_DIR, 'index.html')}"` [ - "pdp8.png", - "540px-PDP-8_.jpg", - "style.css", - "slideshow.js", - "robots.txt" -].each { |f| puts `rsync -av "#{File.join(SNIPPETS, f)}" "#{ROOT}"` } + 'pdp8.png', + '540px-PDP-8_.jpg', + 'style.css', + 'slideshow.js', + 'robots.txt' +].each { |f| puts `rsync -av "#{File.join(SNIPPETS, f)}" "#{WWW_DIR}"` } diff --git a/rss.rb b/rss.rb index b700f55..47b47c0 100755 --- a/rss.rb +++ b/rss.rb @@ -1,32 +1,51 @@ #!/usr/bin/env ruby -require "rss" +require 'date' +MEDIA = '/srv/media/' +WWW = '/srv/www/pdp8-test/' +items = [] +%w[music videos].each do |cat| + Dir[File.join(MEDIA, cat, '*')].each do |dir| + date = File.basename(dir).split('_')[0] + updated = Date.parse(date) # .strftime('%Y-%m-%d') + items << { + title: File.basename(dir).split('_')[1..-1].join(' '), + link: File.join('https://pdp8.info', cat + '.html#' + date), + description: File.read(File.join(dir, 'README')).chomp.sub(/^\n/, '').sub("\n\n", "\n"), + pubDate: updated.httpdate, + 'dc:date' => updated.rfc3339 + } + end +end +date = Dir[File.join(MEDIA, 'pictures', '*.jpeg')].last.split('_')[0] +updated = Date.parse(date) # .strftime('%Y%m%d') +items << { + title: 'pictures', + link: 'https://pdp8.info/pictures.html', + pubDate: updated.httpdate, + 'dc:date' => updated.rfc3339 +} -ROOT = ARGV[0] +xml = [' + + + pdp8 + https://pdp8.info + music, pictures and videos + en'] +date = DateTime.now +xml << " #{date.httpdate}" +xml << " #{date.rfc3339}" -rss = RSS::Maker.make("2.0") do |maker| - maker.channel.language = "en" - maker.channel.author = "pdp8" - maker.channel.updated = Time.now.to_s - maker.channel.link = "https://pdp8.info" - maker.channel.title = "pdp8" - maker.channel.description = "music, pictures and videos" - ["music", "videos"].each do |cat| - Dir[File.join(ROOT, cat, "*")].each do |dir| - maker.items.new_item do |item| - item.title = File.basename(dir).split("_")[1..-1].join(" ") - date = File.basename(dir).split("_")[0] - item.link = File.join("https://pdp8.info", cat + ".html#" + date) - item.updated = Time.parse(date).strftime("%Y-%m-%d") - item.description = File.read(File.join(dir, "README")).chomp.sub(/^\n/, '').sub("\n\n", "\n") - end - end - end - maker.items.new_item do |item| - item.title = "pictures" - item.link = "https://pdp8.info/pictures.html" - date = Dir[File.join(ROOT, "pictures", "*.jpeg")].last.split("_")[0] - item.updated = Time.parse(date).strftime("%Y%m%d") +items.sort_by { |i| i['dc:date'] }.each do |item| + xml << ' ' + item.each do |k, v| + xml << " <#{k}>#{v}" end + xml << ' ' end +xml << ' +' -File.open(File.join(ROOT, "rss.xml"), "w+") { |f| f.puts rss } +File.open(File.join(WWW, 'rss.xml'), 'w+') { |f| f.puts xml.join("\n") } diff --git a/snippets/contact.html b/snippets/contact.html index a454e64..4582664 100644 --- a/snippets/contact.html +++ b/snippets/contact.html @@ -1,9 +1,15 @@

email

info@pdp8.info +

fediverse

+@pdp8@social.pdp8.info +

newsletter

subscribe

-send a mail to info@pdp8.info with subscribe in the subject (your address will be used only for the newsletter and won't be shared with anyone) +send a mail to info@pdp8.info with subscribe in the subject +(your address will be used only for the newsletter and won't be shared with anyone)

unsubscribe

-send a mail to info@pdp8.info with unsubscribe in the subject +send a mail to info@pdp8.info with unsubscribe in the +subject \ No newline at end of file diff --git a/snippets/pictures.html b/snippets/pictures.html index 359de8d..25bf1c2 100644 --- a/snippets/pictures.html +++ b/snippets/pictures.html @@ -1,18 +1,22 @@ - + - +
- - -

© pdp8 Creative Commons Attribution 4.0 International License + + +

© pdp8 Creative Commons Attribution 4.0 + International License

- - + \ No newline at end of file diff --git a/snippets/slideshow.js b/snippets/slideshow.js index 23d7c3e..ea265e4 100644 --- a/snippets/slideshow.js +++ b/snippets/slideshow.js @@ -75,6 +75,6 @@ function next() { } function update() { - src('image',"/pictures/"+selection[current]) + src('image',"https://media.pdp8.info/pictures/"+selection[current]) } -- cgit v1.2.3