diff options
Diffstat (limited to 'views')
-rw-r--r-- | views/collection.erb (renamed from views/index.erb) | 13 | ||||
-rw-r--r-- | views/item.erb | 54 | ||||
-rw-r--r-- | views/object.erb | 57 |
3 files changed, 63 insertions, 61 deletions
diff --git a/views/index.erb b/views/collection.erb index b512911..4455b31 100644 --- a/views/index.erb +++ b/views/collection.erb @@ -9,14 +9,13 @@ <button><%= @alt_name %></button> </form> </h1> - <% @threads.each do |item| %> - <%= html item %> - <% end %> - <% if @dir == 'inbox' %> - <form action='/delete' method='post'> - <button>Delete all</button> - </form> + <% @threads.each do |object| + @object = object %> + <%= erb :object %> <% end %> + <form action='/delete' method='post'> + <button>Delete all</button> + </form> </body> <script> const reply_buttons = document.querySelectorAll(".reply"); diff --git a/views/item.erb b/views/item.erb deleted file mode 100644 index 8036b39..0000000 --- a/views/item.erb +++ /dev/null @@ -1,54 +0,0 @@ -<div style='margin-left:<%= @item[:indent] %>em' id='<%= @item[:nr] %>'> - <b><a href='<%= @item[:actor_url] %>', target='_blank'><%= @item[:mention] %></a></b> - <% if @item[:mention] != ACCOUNT %> - <form action='/follow' method='post'> - <input type='hidden' name='follow' value='<%= @item[:mention] %>' /> - <input type='hidden' name='redirect' value='/<%= @dir.sub('inbox','') %>#<%= @item[:nr] %>' /> - <button><%= @item[:follow].capitalize %></button> - </form> - - <form action='/delete' method='post'> - <input type='hidden' name='file' value='<%= @item[:file] %>' /> - <input type='hidden' name='redirect' value='/<%= @dir.sub('inbox','') %>#<%= @item[:nr] %>' /> - <button>Delete</button> - </form> - <% if @dir == 'inbox' %> - - <form action='/archive' method='post'> - <input type='hidden' name='file' value='<%= @item[:file] %>' /> - <input type='hidden' name='redirect' value='/<%= @dir.sub('inbox','') %>#<%= @item[:nr] %>' /> - <button>Archive</button> - </form> - <% end %> - <% end %> - <%= @item[:content] %> - <% if @item[:attachment] - @item[:attachment].each do |att| - case att['mediaType'] - when /audio/ %> - <br><audio controls=''><source src='<%= att['url'] %>' type='<%= att['mediaType'] %>'></audio> - <% when /image/ %> - <br><a href='<%= att['url'] %>'><img src='<%= att['url'] %>'></a> - <% when /video/ %> - <br><video controls=''><source src='<%= att['url'] %>' type='<%= att['mediaType'] %>'></video> - <% else %> - <%= att %><br> - <a href='<%= att['url'] %>'><%= att['url'] %></a> - <% end %> - <% end %> - <% end %> - <p> - <button class="reply" data-index='<%= @item[:nr] %>'>Reply</button> - <form action='/' method='post' id='form<%= @item[:nr] %>' style='display:none;' > - <input type='hidden' name='to' value='<%= @item[:actor_url] %>' /> - <input type='hidden' name='inReplyTo' value='<%= @item[:id] %>' /> - <input type='hidden' name='redirect' value='/<%= @dir.sub('inbox','') %>#<%= @item[:nr] %>' /> - <textarea name='content'></textarea> - <br> - <button class="cancel" data-index='<%= @item[:nr] %>'>Cancel</button> - <input type='submit' value='Send'> - </form> -</div> -<% @item[:replies].each do |reply| %> - <%= html reply %> -<% end %> diff --git a/views/object.erb b/views/object.erb new file mode 100644 index 0000000..744a518 --- /dev/null +++ b/views/object.erb @@ -0,0 +1,57 @@ + +<% mention = mention @object['attributedTo'] + following_path = File.join(FOLLOWING, "#{mention}.json") + follow = File.exist?(following_path) ? 'unfollow' : 'follow' +%> +<div style='margin-left:<%= @object['indent']%>em' id='<%= @object['id'] %>'> + <b><a href='<%= @object['attributedTo'] %>', target='_blank'><%= mention %></a></b> + <form action='/<%= follow %>' method='post'> + <input type='hidden' name='follow' value='<%= @object['attributedTo'] %>' /> + <input type='hidden' name='redirect' value='/#<%= @object['id'] %>' /> + <button><%= follow.capitalize %></button> + </form> + + <form action='/delete' method='post'> + <input type='hidden' name='id' value='<%= @object['id'] %>' /> + <input type='hidden' name='redirect' value='/#<%= @object['id'] %>' /> + <button>Delete</button> + </form> + + <form action='/like' method='post'> + <input type='hidden' name='id' value='<%= @object['id'] %>' /> + <input type='hidden' name='redirect' value='/#<%= @object['id'] %>' /> + <button>Like</button> + </form> + <%= @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> + <% when /image/ %> + <br><a href='<%= att['url'] %>'><img src='<%= att['url'] %>'></a> + <% when /video/ %> + <br><video controls=''><source src='<%= att['url'] %>' type='<%= att['mediaType'] %>'></video> + <% else %> + <%= att %><br> + <a href='<%= att['url'] %>'><%= att['url'] %></a> + <% end %> + <% end %> + <% end %> + <p> + <button class='reply' data-index='<%= @object['id'] %>'>Reply</button> + <form action='/' method='post' id='form<%= @object['id'] %>' 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'] %>' /> + <textarea name='content'></textarea> + <br> + <button class='cancel' data-index='<%= @object['id'] %>'>Cancel</button> + <input type='submit' value='Send'> + </form> +</div> +<% @object['replies'].each do |reply| + @object = reply %> + <%= erb :object %> +<% end %> + |