From e4e4dedf8ca423e110787657799137444ca0f8fe Mon Sep 17 00:00:00 2001 From: pdp8 Date: Sat, 10 Feb 2024 00:09:34 +0100 Subject: outbox moved to website --- helpers.rb | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'helpers.rb') diff --git a/helpers.rb b/helpers.rb index 292c71d..4bce51f 100644 --- a/helpers.rb +++ b/helpers.rb @@ -215,4 +215,68 @@ helpers do return [file, object] if object['id'] == id end end + + def outbox_html(activity) + html = File.read('/home/ch/src/publish/html/head.html') + html += '

@pdp8@social.pdp8.info

" + html += if activity == 'create' + "posts | boosts" + elsif activity == 'announce' + "posts | boosts" + end + html += '

' + Dir[File.join(SOCIAL_DIR, 'outbox', activity, '*.json')].collect do |f| + JSON.load_file(f) + end.select { |a| a['to'].include?('https://www.w3.org/ns/activitystreams#Public') }.sort_by { |a| a['published'] }.reverse.collect { |a| a['object'] }.each do |object| + object = fetch(object) if object.is_a? String + mention = mention object['attributedTo'] + html += "
" + if activity == 'announce' + html += "#{mention} " + end + html += "#{object['published']} + #{object['content']}" + if object['attachment'] + object['attachment'].each do |att| + w = 1024 + h = 768 + case att['mediaType'] + when /audio/ + html += "
" + when /image/ + if activity == 'create' + w, h = `/etc/profiles/per-user/ch/bin/identify -format "%w %h" #{att['url'].sub( + 'https://media.pdp8.info', '/srv/media' + )}`.chomp.split(' ') end + html += "
att['name']&1` + end + end end -- cgit v1.2.3