aboutsummaryrefslogtreecommitdiff
path: root/views
diff options
context:
space:
mode:
Diffstat (limited to 'views')
-rw-r--r--views/_latestCommit.eta16
-rw-r--r--views/_nav.eta11
-rw-r--r--views/_refs.eta17
-rw-r--r--views/_tree.eta3
-rw-r--r--views/layout.eta1
5 files changed, 47 insertions, 1 deletions
diff --git a/views/_latestCommit.eta b/views/_latestCommit.eta
new file mode 100644
index 0000000..18d22a1
--- /dev/null
+++ b/views/_latestCommit.eta
@@ -0,0 +1,16 @@
+<div class="commit box">
+ <div>
+ <div>
+ <%~ it.commit.shortMessageHtml %>
+ </div>
+ <div class="commit-author">
+ <% for (const author of it.commit.authors) { %>
+ <a href="/<%= author.login %>"><%= author.login %></a>
+ <% } %>
+ <time class="timestamp" title="<%= it.commit.date %>"><%= it.commit.date.split("T")[0] %></time>
+ </div>
+ </div>
+ <div class="commit-sha">
+ <code><%= it.commit.oid.substring(0, 7) %></code>
+ </div>
+</div>
diff --git a/views/_nav.eta b/views/_nav.eta
index 338a6a6..e3fbdcf 100644
--- a/views/_nav.eta
+++ b/views/_nav.eta
@@ -1,5 +1,14 @@
<section>
- <div class="branch"><img src="/static/icons/git-branch.svg" alt="branch" class="icon"> <%= it.branch %></div>
+ <button type="button" class="ref-selector-button branch" command="show-modal" commandfor="ref-selector-menu">
+ <img src="/static/icons/git-branch.svg" alt="branch" class="icon"> <%= it.branch %> ▾
+ </button>
+ <dialog class="ref-selector-menu" id="ref-selector-menu" closedby="any" data-owner="<%= it.repo.owner %>" data-repo="<%= it.repo.name %>">
+ <div class="ref-selector-tabs">
+ <button type="button" class="active" data-ref-type="branches">Branches</button>
+ <button type="button" data-ref-type="tags">Tags</button>
+ </div>
+ <div class="ref-selector-list">Loading…</div>
+ </dialog>
<% if (it.path && it.path !== "/") { %>
<a href="/<%= it.repo.owner %>/<%= it.repo.name %>/tree/<%= it.branch %>">(top)</a><%
const pathParts = it.path.split('/').filter(p => p);
diff --git a/views/_refs.eta b/views/_refs.eta
new file mode 100644
index 0000000..2450c4b
--- /dev/null
+++ b/views/_refs.eta
@@ -0,0 +1,17 @@
+<% if (it.refs.length === 0) { %>
+ <div class="ref-selector-empty">No <%= it.type %> found.</div>
+<% } else { %>
+ <ul class="ref-selector-items">
+ <% for (const ref of it.refs) { %>
+ <li>
+ <a href="/<%= it.repo.owner %>/<%= it.repo.name %>/tree/<%= ref.name %>"><%= ref.name %></a>
+ <% if (ref.isDefault) { %><span class="ref-selector-badge">default</span><% } %>
+ </li>
+ <% } %>
+ </ul>
+<% } %>
+<% if (it.hasMore) { %>
+ <div class="ref-selector-more">
+ <a href="/<%= it.repo.owner %>/<%= it.repo.name %>/<%= it.type %>">View all <%= it.type %></a>
+ </div>
+<% } %>
diff --git a/views/_tree.eta b/views/_tree.eta
index ed6eee9..a0ecfab 100644
--- a/views/_tree.eta
+++ b/views/_tree.eta
@@ -1,5 +1,8 @@
<%~ include("./_nav.eta", {...it, isTree: true}) %>
+<% const commitPath = it.path && it.path !== "/" ? it.path : ""; %>
+<div class="latest-commit-placeholder box" data-src="/api/<%= it.repo.owner %>/<%= it.repo.name %>/latest-commit/<%= it.branch %>/<%= commitPath %>">Loading latest commit…</div>
+
<table>
<% for (const item of it.items) { %>
<tr>
diff --git a/views/layout.eta b/views/layout.eta
index dd523d1..a80bd1d 100644
--- a/views/layout.eta
+++ b/views/layout.eta
@@ -5,6 +5,7 @@
<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">