summaryrefslogtreecommitdiff
path: root/rss.rb
diff options
context:
space:
mode:
Diffstat (limited to 'rss.rb')
-rwxr-xr-xrss.rb43
1 files changed, 18 insertions, 25 deletions
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: '<![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