-<% if @object.andand.files.andand.any? %>
- <% link_opts = {controller: 'collections', action: 'show_file',
- uuid: @object.uuid, reader_token: params[:reader_token]} %>
- <ul>
- <% @object.files.map { |spec|
- CollectionsHelper::file_path(spec)
- }.each do |path| %>
- <li><%= link_to(path, link_opts.merge(file: path)) %></li>
+<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 %>