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> "
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
diff --git a/public/pdp8.json b/public/pdp8.json
index c066ea6..2790c62 100644
--- a/public/pdp8.json
+++ b/public/pdp8.json
@@ -26,11 +26,6 @@
"name": "Fediverse",
"value": "<a rel=\"me\" href=\"https://social.pdp8.info/pdp8\">@pdp8@social.pdp8.info</a>"
},
- {
- "type": "PropertyValue",
- "name": "Matrix",
- "value": "<a rel=\"me\" href=\"https://matrix.to/#/@pdp8:matrix.pdp8.info\">@pdp8:matrix.pdp8.info</a>"
- }
],
"endpoints": {
"sharedInbox": "https://social.pdp8.info/inbox"
@@ -40,4 +35,4 @@
"owner": "https://social.pdp8.info/pdp8",
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArDawzSl+XcJ+96sIrx+E\nsDoUQzSvoKazCgw7qOMaOGi7XxJ8riBvdRBlJ4zOEfQaxcaQgGn5JntOofqkeWvk\nIykOAzYfwY6HoUm7i1eZME2quO+CkMMq9SX9/DOqggOYtiVC9DX5FxXe5YHK7Q/n\nbo1iB6rgVS43wT0PnI6uduY4cUlvhRkX4Iht0N1GTrBlGKloRQ96KTzp+U9xF7bp\nKO87Y4yftv+d6L3ZZBfTRgWOtDXG8E4Vdvsq0aPQNBtazq0fwtBbk2G4mZtCMqyT\nvLZh8w+YPn1ICoQsKukU/q7eG29UJCz/QdZndkuv5iIm+H/c8gicGllw9rNQP2G0\nBQIDAQAB\n-----END PUBLIC KEY-----\n"
}
-}
+}
\ No newline at end of file
diff --git a/server.rb b/server.rb
index ff1c73b..a74cf0d 100644
--- a/server.rb
+++ b/server.rb
@@ -19,7 +19,6 @@ get '/' do
end
get '/outbox/:activity', provides: 'html' do
- # outbox_html params['activity']
redirect "https://pdp8.info/social/#{params['activity']}.html"
end
@@ -69,7 +68,7 @@ helpers do
@object = fetch(@object) if @object.is_a? String and @object.match(/^http/)
return unless @object
- if @object['id'] and File.readlines(VISITED, chomp: true).include? @object['id'] && !(@activity['type'] = 'Update')
+ if @object['id'] and File.readlines(VISITED, chomp: true).include? @object['id'] and !(@activity['type'] = 'Update')
return
end
@@ -88,25 +87,37 @@ helpers do
def announce
@object ||= @activity['object']
@object = fetch(@object) if @object.is_a? String and @object.match(/^http/)
- @object['announce'] = @activity['actor'] if @object
- create
+ if @object['attributedTo'] == 'https://social.pdp8.info/pdp8'
+ jj @activity
+ # FileUtils.mkdir_p File.join(INBOX_DIR, 'announce')
+ # File.open(File.join(INBOX_DIR, 'announce', @activity['published'] + '.json'), 'w+') do |f|
+ # f.puts @activity.to_json
+ # end
+ else
+ @object['announce'] = @activity['actor'] if @object
+ create
+ end
end
def like
@object ||= @activity['object']
@object = fetch(@object) if @object.is_a? String and @object.match(/^http/)
- @object['like'] = @activity['actor'] if @object
- create
+ if @object['attributedTo'] == 'https://social.pdp8.info/pdp8'
+ jj @activity
+ # FileUtils.mkdir_p File.join(INBOX_DIR, 'like')
+ # File.open(File.join(INBOX_DIR, 'like', @activity['published'] + '.json'), 'w+') { |f| f.puts @activity.to_json }
+ else
+ @object['like'] = @activity['actor'] if @object
+ create
+ end
end
def follow
- # save_item @activity, File.join(INBOX[:dir], @activity['type'].downcase, activity_name)
update_collection FOLLOWERS, @activity['actor']
create_activity 'Accept', @activity, [@activity['actor']]
end
def accept
- # save_item @activity, File.join(INBOX[:dir], @activity['type'].downcase, activity_name)
if @activity['object']['type'] == 'Follow'
update_collection FOLLOWING, @activity['object']['object']
else
@@ -122,8 +133,7 @@ helpers do
update_collection FOLLOWERS, @activity['object']['actor'], 'delete'
when 'Create', 'Announce'
file = File.join(INBOX_DIR, @activity['object']['id'].sub('https://', ''))
- # file, object = find_object @activity['object']['object']
- FileUtils.rm(file) if file and File.exist? file # and @activity['actor'] == object['attributedTo']
+ FileUtils.rm(file) if file and File.exist? file
else
p "Error: Cannot undo @activity['object']['type']"
jj @activity
@@ -147,7 +157,6 @@ helpers do
def handle_activity
type = @activity['type'].downcase.to_sym
- # save_item @activity, File.join(INBOX[:dir], @activity['type'].downcase, activity_name)
if ACTIVITIES.include? type
send(type)
else
|