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 --- rss.rb | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) (limited to 'rss.rb') diff --git a/rss.rb b/rss.rb index 68c9632..58c9483 100755 --- a/rss.rb +++ b/rss.rb @@ -4,8 +4,6 @@ require 'date' require 'time' require 'json' -# SOCIAL = '/srv/social/outbox/object/note/' - items = [] %w[music videos climbing].each do |cat| Dir[File.join(MEDIA_DIR, cat, '*')].each do |dir| @@ -27,30 +25,25 @@ items = [] end end -Dir[File.join MEDIA_DIR, 'pictures', 'albums', '*'].each do |album| - items << { - title: File.basename(album).sub('_', ' '), - link: File.join('https://pdp8.info', 'pictures.html#' + File.basename(album)), - guid: File.join('https://pdp8.info', 'pictures.html#' + File.basename(album)), - pubDate: File.mtime(album).httpdate - } -end +Dir[File.join(OUTBOX_DIR, 'create', '*.json')] + .collect { |f| JSON.load_file(f) } + .select { |a| a['to'].include?('https://www.w3.org/ns/activitystreams#Public') } + .select { |a| a['object'] and a['object']['attachment'] } + .collect { |a| a['object'] } + .each do |object| + updated = Date.parse object['published'] + object['attachment'].each do |a| + next unless a['url'] =~ %r{pictures/webp} and a['mediaType'] == 'image/webp' -# duplication of music/video posts? -# Dir[File.join(SOCIAL, '*.json')].each do |json| -# note = JSON.parse(File.read(json)) -# next unless note['attributedTo'] == 'https://social.pdp8.info/pdp8' and note['to'].include?('https://www.w3.org/ns/activitystreams#Public') -# -# # TODO: add enclosures for attachments -# # tags -# items << { -# title: note['published'], -# link: 'https://pdp8.info/social/create.html#' + note['published'], -# guid: note['id'], -# description: '', -# pubDate: Date.parse(note['published']).httpdate -# } -# end + items << { + title: a['name'], + link: a['url'], + guid: a['url'], + description: "]]>", + pubDate: updated.httpdate + } + end +end # jj items.sort_by { |i| DateTime.parse(i[:pubDate]) }.reverse -- cgit v1.2.3