diff options
Diffstat (limited to 'cgithub/views')
| -rw-r--r-- | cgithub/views/_nav.eta | 4 | ||||
| -rw-r--r-- | cgithub/views/_refs.eta | 6 | ||||
| -rw-r--r-- | cgithub/views/_tree.eta | 2 | ||||
| -rw-r--r-- | cgithub/views/blob.eta | 2 | ||||
| -rw-r--r-- | cgithub/views/commits.eta | 2 |
5 files changed, 10 insertions, 6 deletions
diff --git a/cgithub/views/_nav.eta b/cgithub/views/_nav.eta index eb7ed42..a20fbbc 100644 --- a/cgithub/views/_nav.eta +++ b/cgithub/views/_nav.eta @@ -6,7 +6,7 @@ <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"> <%= refLabel %> ▾ </button> - <dialog class="ref-selector-menu" id="ref-selector-menu" closedby="any" data-owner="<%= it.repo.owner %>" data-repo="<%= it.repo.name %>"> + <dialog class="ref-selector-menu" id="ref-selector-menu" closedby="any" data-owner="<%= it.repo.owner %>" data-repo="<%= it.repo.name %>" data-view="<%= it.view %>"<% if (it.path && it.path !== "/") { %> data-path="<%= it.path %>"<% } %>> <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> @@ -22,7 +22,7 @@ currentPath += (currentPath ? '/' : '') + part; const isLast = i === pathParts.length - 1; if (isLast) { - %>/<%= part %><%= it.isTree ? "/" : "" %><% + %>/<%= part %><%= it.view === "tree" ? "/" : "" %><% } else { %>/<a href="/<%= it.repo.owner %>/<%= it.repo.name %>/tree/<%= it.branch %>/<%= currentPath %>"><%= part %></a><% } diff --git a/cgithub/views/_refs.eta b/cgithub/views/_refs.eta index 2450c4b..9d951cc 100644 --- a/cgithub/views/_refs.eta +++ b/cgithub/views/_refs.eta @@ -1,10 +1,14 @@ +<% +const linkPrefix = `/${it.repo.owner}/${it.repo.name}/${it.view}/`; +const linkSuffix = it.path ? `/${it.path}` : ""; +%> <% 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> + <a href="<%= linkPrefix %><%= ref.name %><%= linkSuffix %>"><%= ref.name %></a> <% if (ref.isDefault) { %><span class="ref-selector-badge">default</span><% } %> </li> <% } %> diff --git a/cgithub/views/_tree.eta b/cgithub/views/_tree.eta index fc7707b..a3c943d 100644 --- a/cgithub/views/_tree.eta +++ b/cgithub/views/_tree.eta @@ -1,4 +1,4 @@ -<%~ include("./_nav.eta", {...it, isTree: true}) %> +<%~ include("./_nav.eta", {...it, view: "tree"}) %> <% const commitPath = it.path && it.path !== "/" ? it.path : ""; %> <div class="placeholder commit box" data-src="/api/<%= it.repo.owner %>/<%= it.repo.name %>/latest-commit/<%= it.branch %>/<%= commitPath %>"> diff --git a/cgithub/views/blob.eta b/cgithub/views/blob.eta index 50f92a9..ed1e84b 100644 --- a/cgithub/views/blob.eta +++ b/cgithub/views/blob.eta @@ -1,6 +1,6 @@ <% layout("./layout.eta"); it.searchType = "code" %> -<%~ include("./_nav.eta", it) %> +<%~ include("./_nav.eta", {...it, view: "blob"}) %> <div> <% if (it.language) { %> diff --git a/cgithub/views/commits.eta b/cgithub/views/commits.eta index 2ddcba3..5cf0beb 100644 --- a/cgithub/views/commits.eta +++ b/cgithub/views/commits.eta @@ -1,6 +1,6 @@ <% layout("./layout.eta") %> -<%~ include("./_nav.eta", {...it, isTree: false}) %> +<%~ include("./_nav.eta", {...it, view: "commits"}) %> <% for (const group of it.commitGroups) { %> <h3><%= group.title %></h3> |
