From 4c66a07a995c0d551cd284d6e72826b4f7748bab Mon Sep 17 00:00:00 2001 From: Joe Mou Date: Thu, 3 Sep 2026 00:08:06 -0400 Subject: 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 Claude-Session: https://claude.ai/code/session_013rQG1io1i4GJQW5RFcXNGd --- cgithub/views/_wikiNav.eta | 4 ++++ cgithub/views/layout.eta | 1 + cgithub/views/wiki.eta | 37 +++++++++++++++++++++++++++++++++++++ cgithub/views/wikiPages.eta | 16 ++++++++++++++++ 4 files changed, 58 insertions(+) create mode 100644 cgithub/views/_wikiNav.eta create mode 100644 cgithub/views/wiki.eta create mode 100644 cgithub/views/wikiPages.eta (limited to 'cgithub/views') 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 @@ + 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 %>.gitIssues Pull requests Releases + Wiki <% if (it.branch) { %> Commits <% } %> 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) %> + +
+
+ <%= it.title %> + <% if (it.updatedBy || it.updatedAt) { %> + + <% if (it.updatedBy) { %><%= it.updatedBy %> edited this page<% } %> + <% if (it.updatedAt) { %><% } %> + + <% } %> +
+ <%~ it.bodyHtml %> + <% if (it.footerHtml) { %> +
<%~ it.footerHtml %>
+ <% } %> +
+ +<% if (it.sidebarHtml) { %> +
+
Sidebar
+ <%~ it.sidebarHtml %> +
+<% } %> + +<% if (it.pages.length > 0) { %> +
+ <%= it.pages.length %> page<%= it.pages.length === 1 ? "" : "s" %> + +
+<% } %> 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) %> + + + <% for (const page of it.pages) { %> + + + + + <% } %> +
<%= page.name %> + <% if (page.updatedAt) { %> + + <% } %> +
-- cgit v1.3.1