summaryrefslogtreecommitdiff
path: root/cgithub/views/layout.eta
blob: 37289dd2952f63d7e777036d86e475c4e55980d3 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title><%= it.repo.owner %>/<%= it.repo.name %> - <%= it.path || '/' %></title>
  <link rel="stylesheet" href="/static/style.css">
  <script src="/static/refs.js" defer></script>
</head>
<body>
  <div class="box">
    <div class="repo"><a href="/<%= it.repo.owner %>"><%= it.repo.owner %></a>/<a href="/<%= it.repo.owner %>/<%= it.repo.name %>"><%= it.repo.name %></a></div>
    <pre><code>git clone https://github.com/<%= it.repo.owner %>/<%= it.repo.name %>.git
git clone git@github.com:<%= it.repo.owner %>/<%= it.repo.name %>.git</code></pre>
    <nav>
      <a href="/<%= it.repo.owner %>/<%= it.repo.name %>">Code</a>
      <a href="/<%= it.repo.owner %>/<%= it.repo.name %>/issues">Issues</a>
      <a href="/<%= it.repo.owner %>/<%= it.repo.name %>/pulls">Pull requests</a>
      <a href="/<%= it.repo.owner %>/<%= it.repo.name %>/releases">Releases</a>
      <a href="/<%= it.repo.owner %>/<%= it.repo.name %>/wiki">Wiki</a>
      <% if (it.branch) { %>
        <a href="/<%= it.repo.owner %>/<%= it.repo.name %>/commits/<%= it.branch %><%= it.path && it.path !== '/' ? '/' + it.path : '' %>">Commits</a>
      <% } %>
    </nav>
    <form action="/<%= it.repo.owner %>/<%= it.repo.name %>/search" method="get">
      <input id="search-input" type="text" name="q" placeholder="Search…" value="<%= it.q ?? "" %>">
      <select name="type">
        <option value="issues" <%= it.searchType === "issues" ? "selected" : "" %>>Issues</option>
        <option value="pullrequests" <%= it.searchType === "pullrequests" ? "selected" : "" %>>Pull requests</option>
        <option value="code" <%= it.searchType === "code" || it.searchType == null ? "selected" : "" %>>Code</option>
      </select>
      <button type="submit">Search</button>
    </form>
  </div>

  <%~ it.body %>

  <footer>Generated by cgithub commit <code><%= it.buildCommit %></code> · <a href="<%= it.githubUrl %>" rel="noreferrer">View original</a></footer>

  <script>
    document.addEventListener("keydown", function(e) {
      let shortcut = "";
      if (e.ctrlKey || e.metaKey) shortcut += "C-";
      if (e.altKey) shortcut += "A-";
      if (e.shiftKey) shortcut += "S-";
      shortcut += e.key;

      if (shortcut === "Escape") {
        document.activeElement.blur();
        return;
      }

      if (["INPUT", "TEXTAREA", "SELECT"].includes(document.activeElement.tagName)) {
        return;
      }

      if (shortcut === "/") {
        e.preventDefault();
        const input = document.getElementById('search-input');
        input.select();
        input.scrollIntoView({ block: "nearest" });
      }
    });
  </script>
</body>
</html>