diff options
author | pdp8 <pdp8@pdp8.info> | 2024-08-18 16:10:01 +0200 |
---|---|---|
committer | pdp8 <pdp8@pdp8.info> | 2024-08-18 16:10:01 +0200 |
commit | fdf16740af88ffa1d820dd86565e945eeb551072 (patch) | |
tree | fcc8991287a131f5477bb1e2cc2d660a18ebc7b1 /rss.rb | |
parent | 02877167870245be0986a2bb8af984c9eb3dc1dd (diff) |
pictures synced to social outbox, albums removed
Diffstat (limited to 'rss.rb')
-rwxr-xr-x | rss.rb | 43 |
1 files changed, 18 insertions, 25 deletions
@@ -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: '<![CDATA[' + note['content'] + ']]>', -# pubDate: Date.parse(note['published']).httpdate -# } -# end + items << { + title: a['name'], + link: a['url'], + guid: a['url'], + description: "<![CDATA[<img alt='#{a['name']}' src=#{a['url']}>]]>", + pubDate: updated.httpdate + } + end +end # jj items.sort_by { |i| DateTime.parse(i[:pubDate]) }.reverse |