diff options
| author | Joe Mou <dev@mou.fo> | 2026-09-03 00:08:06 -0400 |
|---|---|---|
| committer | Joe Mou <dev@mou.fo> | 2026-09-03 01:09:10 -0400 |
| commit | 4c66a07a995c0d551cd284d6e72826b4f7748bab (patch) | |
| tree | 35c53f0713a0903ed4c44d53ed17a4f47deaf4af /cgithub/views | |
| parent | 1b9d13fce99b9d798dd604f402699bb47cb1627e (diff) | |
Render repository wikis
Wikis are one of the last parts of GitHub still served as plain Rails
HTML, with no embedded JSON to read, so this scrapes the markup: a page
and any older revision of it, the _Sidebar and _Footer a wiki can
define, and the page index. Every page is already in the sidebar of
every page, since the "Show N more pages" button only unhides the rest,
so linking the whole wiki costs no second request.
Routes mirror GitHub's and resolve in its order, so an underscore name
reserved for its own actions (_pages, _history, _new, _edit) can never
be mistaken for a page; the ones we don't serve fall through to the
usual redirect. A slug reaches us decoded and has to be encoded again
rather than interpolated the way a ref is, or a page named C# would
truncate at the fragment.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013rQG1io1i4GJQW5RFcXNGd
Diffstat (limited to 'cgithub/views')
| -rw-r--r-- | cgithub/views/_wikiNav.eta | 4 | ||||
| -rw-r--r-- | cgithub/views/layout.eta | 1 | ||||
| -rw-r--r-- | cgithub/views/wiki.eta | 37 | ||||
| -rw-r--r-- | cgithub/views/wikiPages.eta | 16 |
4 files changed, 58 insertions, 0 deletions
diff --git a/cgithub/views/_wikiNav.eta b/cgithub/views/_wikiNav.eta new file mode 100644 index 0000000..cc177c7 --- /dev/null +++ b/cgithub/views/_wikiNav.eta @@ -0,0 +1,4 @@ +<nav> + <a href="/<%= it.repo.owner %>/<%= it.repo.name %>/wiki">Wiki home</a> + <a href="/<%= it.repo.owner %>/<%= it.repo.name %>/wiki/_pages">Pages</a> +</nav> diff --git a/cgithub/views/layout.eta b/cgithub/views/layout.eta index 6d1b052..1ac82cc 100644 --- a/cgithub/views/layout.eta +++ b/cgithub/views/layout.eta @@ -17,6 +17,7 @@ git clone git@github.com:<%= it.repo.owner %>/<%= it.repo.name %>.git</code></pr <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> <% } %> diff --git a/cgithub/views/wiki.eta b/cgithub/views/wiki.eta new file mode 100644 index 0000000..d6047e1 --- /dev/null +++ b/cgithub/views/wiki.eta @@ -0,0 +1,37 @@ +<% layout("./layout.eta"); it.path = "wiki/" + it.title %> + +<%~ include("./_wikiNav.eta", it) %> + +<div class="box wiki"> + <header> + <span><%= it.title %></span> + <% if (it.updatedBy || it.updatedAt) { %> + <span class="timestamp"> + <% if (it.updatedBy) { %><%= it.updatedBy %> edited this page<% } %> + <% if (it.updatedAt) { %><time title="<%= it.updatedAt %>"><%= it.updatedAt.split("T")[0] %></time><% } %> + </span> + <% } %> + </header> + <%~ it.bodyHtml %> + <% if (it.footerHtml) { %> + <footer><%~ it.footerHtml %></footer> + <% } %> +</div> + +<% if (it.sidebarHtml) { %> + <div class="box wiki"> + <header><span>Sidebar</span></header> + <%~ it.sidebarHtml %> + </div> +<% } %> + +<% if (it.pages.length > 0) { %> + <details class="box wiki-pages"> + <summary><%= it.pages.length %> page<%= it.pages.length === 1 ? "" : "s" %></summary> + <ul> + <% for (const page of it.pages) { %> + <li><a href="<%= page.href %>"><%= page.name %></a></li> + <% } %> + </ul> + </details> +<% } %> diff --git a/cgithub/views/wikiPages.eta b/cgithub/views/wikiPages.eta new file mode 100644 index 0000000..58d6d21 --- /dev/null +++ b/cgithub/views/wikiPages.eta @@ -0,0 +1,16 @@ +<% layout("./layout.eta"); it.path = "wiki/_pages" %> + +<%~ include("./_wikiNav.eta", it) %> + +<table> + <% for (const page of it.pages) { %> + <tr> + <td><a href="<%= page.href %>"><%= page.name %></a></td> + <td class="timestamp"> + <% if (page.updatedAt) { %> + <time title="<%= page.updatedAt %>"><%= page.updatedAt.split("T")[0] %></time> + <% } %> + </td> + </tr> + <% } %> +</table> |
