From fdf16740af88ffa1d820dd86565e945eeb551072 Mon Sep 17 00:00:00 2001 From: pdp8 Date: Sun, 18 Aug 2024 16:10:01 +0200 Subject: pictures synced to social outbox, albums removed --- pictures.rb | 89 +++++++++++-------------------------------------------------- 1 file changed, 15 insertions(+), 74 deletions(-) (limited to 'pictures.rb') diff --git a/pictures.rb b/pictures.rb index 71b06d4..89b770c 100755 --- a/pictures.rb +++ b/pictures.rb @@ -1,82 +1,23 @@ #!/usr/bin/env ruby require_relative 'lib' -require 'fileutils' - -PICTURE_PATH = '/srv/media/pictures' -WEBP_PATH = File.join PICTURE_PATH, 'webp' -TXT_PATH = File.join PICTURE_PATH, 'txt' - -ALBUM_PATH = File.join PICTURE_PATH, 'albums' - -PICTURE_URL = File.join MEDIA_URL, 'pictures' -WEBP_URL = File.join PICTURE_URL, 'webp' -THUMB_URL = File.join PICTURE_URL, 'thumb' -JPEG_URL = File.join PICTURE_URL, 'jpeg' - -def meta(img, album) - basename = File.basename(img, File.extname(img)) - path = File.join(WEBP_PATH, basename + '.webp') - { - basename: basename, - webp: File.join(WEBP_URL, basename + '.webp'), - txt: File.join(TXT_PATH, basename + '.txt'), - src: File.join(JPEG_URL, basename + File.extname(img)), - thumb: File.join(THUMB_URL, basename + '.webp'), - href: File.join('/pictures', File.basename(album), - File.basename(img, File.extname(img)) + '.html') - } -end - -albums = Dir[File.join ALBUM_PATH, '*'].sort_by { |a| File.mtime a }.reverse - -albums.each do |album| - www_dir = File.join('/srv/www/pdp8-test/pictures', File.basename(album)) - FileUtils.mkdir_p www_dir - `cd /srv/www/pdp8-test/pictures; git add #{File.basename(album)}` - images = File.readlines(album, chomp: true) - n = images.size - images.each_with_index do |img, i| - before = meta(images[(i - 1) % n], album)[:href] - after = meta(images[(i + 1) % n], album)[:href] - meta = meta img, album - html = File.read(File.join(SNIPPETS, 'head.html')) - html += nav 'pictures' - html += "
" - html += '&1` - end -end +require 'json' html = File.read(File.join(SNIPPETS, 'head.html')) html += nav 'pictures' -albums.each do |album| - www_dir = File.join('/srv/www/pdp8-test/pictures', File.basename(album)) - FileUtils.mkdir_p www_dir - images = File.readlines(album, chomp: true) - n = images.size - html += "
" - html += "

#{File.basename(album).gsub('_', ' ')}

\n" - html += "