summary refs log tree commit diff
path: root/views
diff options
context:
space:
mode:
authorpdp8 <pdp8@pdp8.info>2023-07-02 00:37:33 +0200
committerpdp8 <pdp8@pdp8.info>2023-07-02 00:37:33 +0200
commit7f38d569d8dd2491d1b9b8bc0ff1ae016b02f34f (patch)
tree5ddd0eba0dce147e8b799351a9f3e20945a08118 /views
parent086709cae3da7a01a011fe906004c8685fdd2ed0 (diff)
activity sending/storage unified (send_signed -> outbox)
Diffstat (limited to 'views')
-rw-r--r--views/collection.erb9
-rw-r--r--views/object.erb35
2 files changed, 28 insertions, 16 deletions
diff --git a/views/collection.erb b/views/collection.erb
index 8dd3878..4cc449f 100644
--- a/views/collection.erb
+++ b/views/collection.erb
@@ -5,7 +5,7 @@
   </head>
   <body>
     <h1><%= @dir %>
-    <% dirs = ['inbox','outbox','archive']
+    <% dirs = ['inbox','outbox','shared']
       dirs.delete(@dir)
       dirs.each do |d| %>
       <form action='/<%= d %>' method='get'>
@@ -13,13 +13,18 @@
       </form>
     <% end %>
     </h1>
-    <% @threads.each do |object|
+    <% @idx = 0
+       @threads.each do |object|
        @object = object %>
       <%= erb :object %>
     <% end %>
+    <% unless @dir == 'shared' %>
     <form action='/delete' method='post'>
+      <input type='hidden' name='dir' value='/<%= @dir %>' />
+      <input type='hidden' name='anchor' value='/<%= @dir %>' />
       <button>Delete all</button>
     </form>
+    <% end %>
   </body>
   <script>
     const reply_buttons = document.querySelectorAll(".reply");
diff --git a/views/object.erb b/views/object.erb
index 744a518..3e6e617 100644
--- a/views/object.erb
+++ b/views/object.erb
@@ -1,26 +1,31 @@
-
-<% mention = mention @object['attributedTo']
-   following_path = File.join(FOLLOWING, "#{mention}.json")
-   follow = File.exist?(following_path) ? 'unfollow' : 'follow'
+<% @idx +=1
+   mention = mention @object['attributedTo']
+   follow = File.exist?(File.join(FOLLOWING_DIR, "#{mention}.json")) ? 'unfollow' : 'follow'
 %>
-<div style='margin-left:<%= @object['indent']%>em' id='<%= @object['id'] %>'>
+<div style='margin-left:<%= @object['indent']%>em' id='<%= @idx %>'>
   <b><a href='<%= @object['attributedTo'] %>', target='_blank'><%= mention %></a></b>&nbsp;
   <form action='/<%= follow %>' method='post'>
     <input type='hidden' name='follow' value='<%= @object['attributedTo'] %>' />
-    <input type='hidden' name='redirect' value='/#<%= @object['id'] %>' />
+    <input type='hidden' name='anchor' value='/<%= @dir %>#<%= @idx %>' />
     <button><%= follow.capitalize %></button>
   </form>
   &nbsp;
+  <em><%= @object['published'] %></em>
+  &nbsp;
   <form action='/delete' method='post'>
     <input type='hidden' name='id' value='<%= @object['id'] %>' />
-    <input type='hidden' name='redirect' value='/#<%= @object['id'] %>' />
+    <input type='hidden' name='dir' value='<%= @dir %>' />
+    <input type='hidden' name='anchor' value='/<%= @dir %>#<%= @idx %>' />
     <button>Delete</button>
   </form>
   &nbsp;
-  <form action='/like' method='post'>
+  <% unless @dir == 'shared' %>
+  <form action='/share' method='post'>
     <input type='hidden' name='id' value='<%= @object['id'] %>' />
-    <input type='hidden' name='redirect' value='/#<%= @object['id'] %>' />
-    <button>Like</button>
+    <input type='hidden' name='dir' value='<%= @dir %>' />
+    <input type='hidden' name='anchor' value='/<%= @dir %>#<%= @idx %>' />
+    <button>Share</button>
+  <% end %>
   </form>
   <%= @object['content'] %>
   <% if @object['attachment']
@@ -39,16 +44,18 @@
     <% end %>
   <% end %>
   <p>
-  <button class='reply' data-index='<%= @object['id'] %>'>Reply</button>
-  <form action='/' method='post' id='form<%= @object['id'] %>' style='display:none;' >
+  <% unless @dir == 'shared' %>
+  <button class='reply' data-index='<%= @idx %>'>Reply</button>
+  <form action='/' method='post' id='form<%= @idx %>' style='display:none;' >
     <input type='hidden' name='to' value='<%= @object['attributedTo'] %>' />
     <input type='hidden' name='inReplyTo' value='<%= @object['id'] %>' />
-    <input type='hidden' name='redirect' value='/#<%= @object['id'] %>' />
+    <input type='hidden' name='anchor' value='/<%= @dir %>#<%= @idx %>' />
     <textarea name='content'></textarea>
     <br>
-    <button class='cancel' data-index='<%= @object['id'] %>'>Cancel</button>
+    <button class='cancel' data-index='<%= @idx %>'>Cancel</button>
     <input type='submit' value='Send'>
   </form>
+  <% end %>
 </div>
 <% @object['replies'].each do |reply|
     @object = reply %>