diff options
Diffstat (limited to 'server.rb')
-rw-r--r-- | server.rb | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -24,19 +24,30 @@ get '/' do redirect 'https://pdp8.info' end +get '/outbox' do + files = Dir[File.join('outbox', 'create', '*.json')] + Dir[File.join('outbox', 'announce', '*.json')] + activities = files.collect { |f| JSON.parse(File.read(f)) } + ids = activities.sort_by { |a| a['published'] }.collect { |a| a['id'] } + { '@context' => 'https://www.w3.org/ns/activitystreams', + 'id' => 'https://social.pdp8.info/outbox', + 'type' => 'OrderedCollection', + 'totalItems' => ids.size, + 'orderedItems' => ids }.to_json +end + get '/pdp8', provides: 'html' do redirect 'https://pdp8.info' end +get '/pdp8' do + send_file(File.join(PUBLIC_DIR, 'pdp8.json'), type: CONTENT_TYPE) +end + get '/.well-known/webfinger' do halt 404 unless request['resource'] == "acct:#{MENTION}" send_file(WEBFINGER, type: 'application/jrd+json') end -get '/pdp8' do - send_file(File.join(PUBLIC_DIR, 'pdp8.json'), type: CONTENT_TYPE) -end - ['/following', '/followers'].each do |path| get path do send_file(File.join(PUBLIC_DIR, path) + '.json', type: CONTENT_TYPE) |