diff options
| author | Joe Mou <dev@mou.fo> | 2026-09-21 17:55:06 -0400 |
|---|---|---|
| committer | Joe Mou <dev@mou.fo> | 2026-09-25 01:43:53 -0400 |
| commit | 499bba129c842c00c1a28d85bc044ab609aee44e (patch) | |
| tree | bb69fa242a20e3c285fb6c41092b59f207f6855d /views/discussions.eta | |
| parent | 3204ecf1c48e730f02fb83d7c09d2c778a6f6bdd (diff) | |
Add discussions
Discussions are served from GitHub's older server-rendered HTML, with no
embeddedData JSON to read, so the scraper walks the DOM the way the pull
request and wiki code does. A discussion's timeline opens with its own
post and continues with its comments, each carrying its replies nested
inside it, which is where the recursion in _discussionComment.eta comes
from. Categories, upvotes, and the answer a Q&A discussion is marked with
all come along.
Only what GitHub renders up front is shown: neither the next page of
discussions nor the replies it hides behind a "Show N previous replies"
button are fetched, so a comment says how many replies it is missing.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'views/discussions.eta')
| -rw-r--r-- | views/discussions.eta | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/views/discussions.eta b/views/discussions.eta new file mode 100644 index 0000000..87a6903 --- /dev/null +++ b/views/discussions.eta @@ -0,0 +1,39 @@ +<% +layout("/layouts/repo.eta") +it.path = it.category ? `discussions/${it.category.slug}` : "discussions" +it.searchType = "discussions" +%> + +<nav> + <a href="/<%= it.repo.owner %>/<%= it.repo.name %>/discussions">All</a> + <% for (const category of it.categories) { %> + <a href="/<%= it.repo.owner %>/<%= it.repo.name %>/discussions/categories/<%= category.slug %>"><% if (category.emoji) { %><%= category.emoji %> <% } %><%= category.name %></a> + <% } %> +</nav> + +<% if (it.discussions.length === 0) { %> + <div class="box">No discussions found.</div> +<% } else { %> + <table> + <% for (const discussion of it.discussions) { %> + <tr> + <td> + <% if (discussion.category) { %> + <a href="/<%= it.repo.owner %>/<%= it.repo.name %>/discussions/categories/<%= discussion.category.slug %>"><%= discussion.category.name %></a> + <% } %> + </td> + <td> + <a href="/<%= it.repo.owner %>/<%= it.repo.name %>/discussions/<%= discussion.number %>"><%~ discussion.titleHtml %></a> + <% if (discussion.answered) { %> + <span class="answered pill">Answered</span> + <% } %> + </td> + <td class="timestamp"> + <% if (discussion.createdAt) { %> + <time title="<%= discussion.createdAt %>"><%= discussion.createdAt.split("T")[0] %></time> + <% } %> + </td> + </tr> + <% } %> + </table> +<% } %> |
