summaryrefslogtreecommitdiff
path: root/views/object.erb
blob: 3e6e6173b567fee38e2346a673f95fe14999fd68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<% @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='<%= @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='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='dir' value='<%= @dir %>' />
    <input type='hidden' name='anchor' value='/<%= @dir %>#<%= @idx %>' />
    <button>Delete</button>
  </form>
  &nbsp;
  <% 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>
  <% end %>
  </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>
  <% 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='anchor' value='/<%= @dir %>#<%= @idx %>' />
    <textarea name='content'></textarea>
    <br>
    <button class='cancel' data-index='<%= @idx %>'>Cancel</button>
    <input type='submit' value='Send'>
  </form>
  <% end %>
</div>
<% @object['replies'].each do |reply|
    @object = reply %>
  <%= erb :object %>
<% end %>