summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpdp8 <pdp8@pdp8.info>2023-10-06 16:58:15 +0200
committerpdp8 <pdp8@pdp8.info>2023-10-06 16:58:15 +0200
commit443b6fd42abf9cb1392125199cca449702898327 (patch)
tree551282e32062ba302f3a589b874545a2c1363c26
parent580c684f792d6fab16c58b9a08d566cd03c72ca4 (diff)
html create/announce outboxes separated
-rw-r--r--server.rb38
-rw-r--r--views/outbox.erb26
2 files changed, 41 insertions, 23 deletions
diff --git a/server.rb b/server.rb
index e2d4896..c083cb1 100644
--- a/server.rb
+++ b/server.rb
@@ -20,8 +20,20 @@ get '/' do
redirect 'https://social.pdp8.info/outbox'
end
+get '/outbox/announce', provides: 'html' do
+ @objects = announce_outbox.collect { |a| a['object'] }
+ @type = 'announce'
+ erb :outbox
+end
+
+get '/outbox/create', provides: 'html' do
+ @objects = create_outbox.collect { |a| a['object'] }
+ @type = 'create'
+ erb :outbox
+end
+
get '/outbox', provides: 'html' do
- @activities = public_outbox
+ redirect 'https://social.pdp8.info/outbox/create'
erb :outbox
end
@@ -35,7 +47,7 @@ get '/outbox' do
end
get '/pdp8', provides: 'html' do
- redirect 'https://social.pdp8.info/outbox'
+ redirect 'https://social.pdp8.info/outbox/create'
end
get '/pdp8' do
@@ -158,14 +170,20 @@ helpers do
File.open(File.join(INBOX[:dir], 'visited'), 'a+') { |f| f.puts @object['id'] }
end
+ def create_outbox
+ Dir[File.join('outbox', 'create', '*.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
+ end
+
+ def announce_outbox
+ Dir[File.join('outbox', 'announce', '*.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
+ end
+
def public_outbox
- create = Dir[File.join('outbox', 'create', '*.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
- announce = Dir[File.join('outbox', 'announce', '*.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
- create + announce
+ create_outbox + announce_outbox
end
# https://github.com/mastodon/mastodon/blob/main/app/controllers/concerns/signature_verification.rb
@@ -220,6 +238,6 @@ helpers do
# p signature
puts comparison
# jj @activity
- # halt 403
+ halt 403
end
end
diff --git a/views/outbox.erb b/views/outbox.erb
index 7b95439..0efb78c 100644
--- a/views/outbox.erb
+++ b/views/outbox.erb
@@ -9,20 +9,21 @@
<body>
<h1><a href="https://social.pdp8.info/pdp8">pdp8@social.pdp8.info</a></h1>
music, pictures and videos: <a href="https://pdp8.info">https://pdp8.info</a>
- <% @activities.each do |activity|
- file, @object = find_object activity['object']['id']
- if @object
- mention = mention @object['attributedTo'] %>
+ <p>
+ <% if @type == 'create' %>
+ <h2>posts&nbsp;|&nbsp;<a href='/outbox/announce'>boosts</a></h2>
+ <% elsif @type = 'announce' %>
+ <h2><a href='/outbox/create'>posts</a>&nbsp;|&nbsp;boosts</h2>
+ <% end %>
+ <% @objects.each do |object|
+ mention = mention object['attributedTo'] %>
<div class='pdp8'>
- <p><b><a href='<%= @object['attributedTo'] %>' target='_blank'><%= mention %></a></b>&nbsp;
- <em><%= @object['published'] %></em>
- <% if activity['type'] == 'Announce' %>
- &nbsp;(<em>announced</em>)
- <% end %>
+ <p><b><a href='<%= object['attributedTo'] %>' target='_blank'><%= mention %></a></b>&nbsp;
+ <em><%= object['published'] %></em>
<p>
- <%= @object['content']%>
- <% if @object['attachment']
- @object['attachment'].each do |att|
+ <%= object['content']%>
+ <% if object['attachment']
+ object['attachment'].each do |att|
case att['mediaType']
when /audio/ %>
<br><audio controls=''><source src='<%= att['url'] %>' type='<%= att['mediaType'] %>'></audio>
@@ -34,7 +35,6 @@
<% end %>
<% end %>
</div>
- <% end %>
<% end %>
</body>
</html>