file.stpl.html raw

<article class="repo">
  <nav class="breadcrumbs" aria-label="Path">
    <a href="<%= self.links.repo_url() %>"><%= self.links.repo() %></a>
    <span class="sep">/</span>
    <% if self.path.is_root() { %>
      <span class="current">files</span>
    <% } else { %>
      <a href="<%= self.links.url(View::File, &crate::repos::RepoPath::root()) %>">files</a>
      <% let trail = self.path.ancestry(); %>
      <% if let Some(((current, _), ancestors)) = trail.split_last() { %>
        <% for (component, ancestor) in ancestors { %>
          <span class="sep">/</span>
          <a href="<%= self.links.url(View::File, ancestor) %>"><%= component %></a>
        <% } %>
        <span class="sep">/</span>
        <span class="current"><%= current %></span>
      <% } %>
    <% } %>
  </nav>
  <% match &self.listing { Listing::Dir(entries) => { %>
    <ul class="dir-list">
      <% if !self.path.is_root() { %>
        <li class="dir-entry is-dir"><a href="<%= self.links.url(View::File, &self.path.parent()) %>">..</a></li>
      <% } %>
      <% for entry in entries { %>
        <li class="dir-entry<% if entry.is_dir { %> is-dir<% } %>">
          <a href="<%= self.links.url(View::File, &entry.path) %>"><%= entry.name %><% if entry.is_dir { %>/<% } %></a>
        </li>
      <% } %>
      <% if entries.is_empty() { %>
        <li class="empty">This directory is empty.</li>
      <% } %>
    </ul>
  <% } Listing::File(presentation) => { %>
    <%+ PresentationView { title: self.path.file_name().unwrap_or_default(), title_url: None, raw_url: &self.links.url(View::Raw, &self.path), presentation } %>
  <% } } %>
</article>