aboutsummaryrefslogtreecommitdiff
path: root/shardweb/lib/templates/page/shard_entry.html.eex
blob: bc9edd480c70920a54486a1b599c6a49621d2cb6 (plain) (blame)
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
        <%= case @manifest do %>
          <% %SApp.Identity.Manifest{pk: pk} -> %><i class="fa fa-user"></i>
            <%= SApp.Identity.get_nick(pk) %>
            <a href="<%= identity_path(@conn, :view, pk|>Base.encode16) %>">
              <small><%= Shard.Keys.pk_display pk %></small>
            </a>

          <% %SApp.Chat.Manifest{channel: chan} -> %><i class="fa fa-hashtag"></i>
            <a href="<%= chat_path(@conn, :chat, chan) %>">
              <%= chan %>
            </a>

          <% %SApp.Chat.PrivChat.Manifest{pk_list: pk_list} -> %><i class="fa fa-comments"></i>
            <a href="<%= chat_path(@conn, :privchat,
                (pk_list |> Enum.filter(&(&1!=@pk)) |> Enum.map(&Base.encode16/1) |> Enum.join(","))) %>">
                <%= pk_list |> Enum.filter(&(&1!=@pk)) |> Enum.map(&SApp.Identity.get_nick/1) |> Enum.join(", ") %>
            </a>

          <% %SApp.Directory.Manifest{owner: owner, public: public, name: name} -> %><i class="fa fa-folder"></i>
            <%= SApp.Identity.get_nick(owner) %>
            <small><%= Shard.Keys.pk_display owner %></small>
            /
            <a href="<%= directory_path(@conn, (if public do :view_pub else :view_priv end), owner|>Base.encode16(), name) %>"><%= name %></a>
            <%= if public do %><i class="fa fa-globe"></i><% else %><i class="fa fa-lock"></i><% end %>

          <% %SApp.File.Manifest{infohash: infohash} -> %>
            <% file_info = SApp.File.get_info(Shard.Manager.find_or_start(@manifest)) %>
            <i class="fa fa-file"></i>
            <%= if file_info[:size] != nil do Size.humanize!(file_info[:size]) end %>
            <%= if file_info[:mime_type] != nil do %><code><%= file_info[:mime_type] %></code><% end %>
            <%= if file_info[:missing_blocks] != nil and file_info[:missing_blocks] > 0 do %>
              <%= file_info[:num_blocks] - file_info[:missing_blocks] %> / <%= file_info[:num_blocks] %>
            <% end %>
            <%= if file_info[:missing_blocks] == 0 do %>
              <a href="<%= directory_path(@conn, :raw_file, infohash|>Base.encode16) %>">[raw]</a>
            <% end %>

          <% x -> %> <%= inspect x %>
        <% end %>