From 54b788a3c1227903ca85788aad7e90d129cd277d Mon Sep 17 00:00:00 2001 From: pdp8 Date: Mon, 9 Sep 2024 11:23:33 +0200 Subject: temporary handling of multiple likes/announcements --- helpers.rb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'helpers.rb') diff --git a/helpers.rb b/helpers.rb index ad0bd42..4fbad8b 100644 --- a/helpers.rb +++ b/helpers.rb @@ -4,7 +4,7 @@ helpers do def save_inbox(item) return unless item['id'] - path = File.join(INBOX_DIR, item['id'].sub('https://', '')) + path = File.join(INBOX_DIR, item['id'].sub('https://', '').sub(%r{/$}, '')) # remove trailing slashes FileUtils.mkdir_p File.dirname(path) File.open(path, 'w+') { |f| f.puts item.to_json } end @@ -235,12 +235,14 @@ helpers do 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| + end.select { |a| a['to'].include?('https://www.w3.org/ns/activitystreams#Public') }.sort_by { |a| a['published'] }.reverse[0..49].collect { |a| a['object'] }.each do |object| object = fetch(object) if object.is_a? String - if object - mention = mention object['attributedTo'] + next unless object + + begin html += '
' html += "

#{object['published']}

" + mention = mention object['attributedTo'] if activity == 'announce' html += "#{mention} " end @@ -259,8 +261,11 @@ helpers do end end end + html += '
' + rescue StandardError => e + p e + jj object end - html += '' end html += File.read(File.join(SNIPPETS, 'tail.html')) %w[pdp8 pdp8-test].each do |d| @@ -269,5 +274,6 @@ helpers do File.open(out, 'w+') { |f| f.puts(html) } puts `/etc/profiles/per-user/ch/bin/tidy -iqm -w 0 #{out} 2>&1` end + `cd /home/ch/src/wgen && /home/ch/.nix-profile/bin/make` if activity == 'create' # update pictures.html end end -- cgit v1.2.3