diff options
Diffstat (limited to 'views/object.erb')
-rw-r--r-- | views/object.erb | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/views/object.erb b/views/object.erb index 6ac9f43..b4b7d89 100644 --- a/views/object.erb +++ b/views/object.erb @@ -1,32 +1,38 @@ <% @idx +=1 mention = mention @object['attributedTo'] JSON.parse(File.read(FOLLOWING))['orderedItems'].include?(@object['attributedTo']) ? follow='unfollow' : follow='follow' + @indent = 0 unless @object['inReplyTo'] %> -<div style='margin-left:<%= @object['indent']%>em' id='<%= @idx %>'> +<div style='margin-left:<%= @indent%>em' id='<%= @idx %>'> <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='anchor' value='/<%= @dir %>#<%= @idx %>' /> + <input type='hidden' name='anchor' value='/<%= @box %>#<%= @idx %>' /> <button><%= follow.capitalize %></button> </form> - - <em><%= @object['published'] %></em> - - <form action='/delete' method='post'> - <input type='hidden' name='id' value='<%= @object['id'] %>' /> - <input type='hidden' name='dir' value='<%= @dir %>' /> - <input type='hidden' name='anchor' value='/<%= @dir %>#<%= @idx %>' /> - <button>Delete</button> - </form> - - <% unless @dir == 'shared' %> - <form action='/share' method='post'> - <input type='hidden' name='id' value='<%= @object['id'] %>' /> - <input type='hidden' name='dir' value='<%= @dir %>' /> - <input type='hidden' name='anchor' value='/<%= @dir %>#<%= @idx %>' /> - <button>Share</button> + <% unless @object['inReplyTo'] %> + + <em><%= @object['published'] %></em> + + <form action='/delete' method='post'> + <input type='hidden' name='id' value='<%= @object['id'] %>' /> + <input type='hidden' name='dir' value='<%= @box %>' /> + <input type='hidden' name='anchor' value='/<%= @box %>#<%= @idx %>' /> + <button>Delete</button> + </form> + <% end %> + <% unless @box == 'shared' %> + + <form action='/share' method='post'> + <input type='hidden' name='id' value='<%= @object['id'] %>' /> + <input type='hidden' name='dir' value='<%= @box %>' /> + <input type='hidden' name='anchor' value='/<%= @box %>#<%= @idx %>' /> + <button>Share</button> + </form> + <% end %> + <% unless @object['content'].match(/^<p>/) %> + <p> <% end %> - </form> <%= @object['content'] %> <% if @object['attachment'] @object['attachment'].each do |att| @@ -44,12 +50,12 @@ <% end %> <% end %> <p> - <% unless @dir == 'shared' %> + <% unless @box == '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='anchor' value='/<%= @dir %>#<%= @idx %>' /> + <input type='hidden' name='anchor' value='/<%= @box %>#<%= @idx %>' /> <textarea name='content'></textarea> <br> <button class='cancel' data-index='<%= @idx %>'>Cancel</button> @@ -58,6 +64,7 @@ <% end %> </div> <% @object['replies'].each do |reply| + @indent += 2 @object = reply %> <%= erb :object %> <% end %> |