summaryrefslogtreecommitdiff
path: root/helpers.rb
diff options
context:
space:
mode:
authorpdp8 <pdp8@pdp8.info>2024-09-09 11:23:33 +0200
committerpdp8 <pdp8@pdp8.info>2024-09-09 11:23:33 +0200
commit54b788a3c1227903ca85788aad7e90d129cd277d (patch)
tree86c721173a715b5048e427675ce5b611bb5b61a3 /helpers.rb
parent7f3023df5be705436544b5724a6b83c2717aa0b8 (diff)
temporary handling of multiple likes/announcementsHEADmaster
Diffstat (limited to 'helpers.rb')
-rw-r--r--helpers.rb16
1 files changed, 11 insertions, 5 deletions
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 += '</h2>'
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 += '<section>'
html += "<h3>#{object['published']}</h3>"
+ mention = mention object['attributedTo']
if activity == 'announce'
html += "<b><a href='#{object['attributedTo']}' target='_blank'>#{mention}</a></b>&nbsp;"
end
@@ -259,8 +261,11 @@ helpers do
end
end
end
+ html += '</section>'
+ rescue StandardError => e
+ p e
+ jj object
end
- html += '</section>'
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