diff options
author | pdp8 <pdp8@pdp8.info> | 2023-07-01 00:57:48 +0200 |
---|---|---|
committer | pdp8 <pdp8@pdp8.info> | 2023-07-01 00:57:48 +0200 |
commit | 5af8d78e195c7479769240b32703d5b76843db4d (patch) | |
tree | e9d145e1318e3c47b5b2b00ce276703a14edc958 /views/object.erb | |
parent | 8dd940a1c08b02ed1ea613284b627e1f46fb13c9 (diff) |
initial refactoring of client.rb
Diffstat (limited to 'views/object.erb')
-rw-r--r-- | views/object.erb | 57 |
1 files changed, 57 insertions, 0 deletions
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 %> + |