summaryrefslogtreecommitdiff
path: root/cgithub/views/tree.eta
blob: 4194216ea3afbd8904c1b1b71055860cd0f4b3ab (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
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title><%= it.repo.owner %>/<%= it.repo.name %> - <%= it.path || 'root' %></title>
  <link rel="stylesheet" href="/static/style.css">
</head>
<body>
  <header>
    <h1><%= it.repo.owner %>/<%= it.repo.name %></h1>
    <div>branch: <%= it.branch %></div>
    <% if (it.path) { %>
      <div>
        path: <a href="/<%= it.repo.owner %>/<%= it.repo.name %>/tree/<%= it.branch %>">root</a><%
        const pathParts = it.path.split('/').filter(p => p);
        let currentPath = '';
        for (const part of pathParts) {
          currentPath += (currentPath ? '/' : '') + part;
        %>/<a href="/<%= it.repo.owner %>/<%= it.repo.name %>/tree/<%= it.branch %>/<%= currentPath %>"><%= part %></a><%
        } %>
      </div>
    <% } %>
  </header>

  <table>
    <% for (const item of it.items) { %>
      <tr>
        <td>
          <span class="icon"><%= item.contentType === 'directory' ? '📁' : '📄' %></span>
          <% if (item.contentType === 'directory') { %>
            <a href="/<%= it.repo.owner %>/<%= it.repo.name %>/tree/<%= it.branch %>/<%= item.path %>"><%= item.name %></a>
          <% } else { %>
            <%= item.name %>
          <% } %>
        </td>
      </tr>
    <% } %>
  </table>

  <footer>Generated by cgithub</footer>
</body>
</html>