<!DOCTYPE html>
<html>
<% coll_name = "Collection #{@object.uuid}" %>
<% link_opts = {controller: 'collections', action: 'show_file',
                uuid: @object.uuid, reader_token: params[:reader_token]} %>
<head>
  <meta charset="utf-8">
  <title>
    <%= coll_name %> / <%= Rails.configuration.site_name %>
  </title>
  <meta name="description" content="">
  <meta name="author" content="">
  <meta name="robots" content="NOINDEX">
  <style type="text/css">
body {
  margin: 1.5em;
}
pre {
  background-color: #D9EDF7;
  border-radius: .25em;
  padding: .75em;
  overflow: auto;
}
.footer {
  font-size: 82%;
}
.footer h2 {
  font-size: 1.2em;
}
  </style>
</head>
<body>

<h1><%= coll_name %></h1>

<p>This collection of data files is being shared with you through
Arvados.  You can download individual files listed below.  To download
the entire collection with wget, try:</p>

<pre>$ wget --mirror --no-parent --no-host --cut-dirs=3 <%=
         url_for(link_opts.merge(action: 'show_file_links', only_path: false,
                                 trailing_slash: true))
       %></pre>

<h2>File Listing</h2>

<% file_tree = @object.andand.files_tree %>
<% if file_tree.andand.any? %>
  <ul id="collection_files" class="collection_files">
  <% dirstack = [file_tree.first.first] %>
  <% file_tree.take(10000).each_with_index do |(dirname, filename, size), index| %>
    <% file_path = CollectionsHelper::file_path([dirname, filename]) %>
    <% while dirstack.any? and (dirstack.last != dirname) %>
      <% dirstack.pop %></ul></li>
    <% end %>
    <li>
    <% if size.nil?  # This is a subdirectory. %>
      <% dirstack.push(File.join(dirname, filename)) %>
      <%= filename %>
      <ul class="collection_files">
    <% else %>
      <%= link_to(filename,
                  link_opts.merge(file: file_path),
                  {title: "Download #{file_path}"}) %>
      </li>
    <% end %>
  <% end %>
  <%= raw(dirstack.map { |_| "</ul>" }.join("</li>")) %>
<% else %>
  <p>No files in this collection.</p>
<% end %>

<div class="footer">
<h2>About Arvados</h2>

<p>Arvados is a free and open source software bioinformatics platform.
To learn more, visit arvados.org.
Arvados is not responsible for the files listed on this page.</p>
</div>

</body>
</html>