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/_discussionComment.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/_discussionComment.eta')
| -rw-r--r-- | views/_discussionComment.eta | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/views/_discussionComment.eta b/views/_discussionComment.eta new file mode 100644 index 0000000..9c2cc07 --- /dev/null +++ b/views/_discussionComment.eta @@ -0,0 +1,37 @@ +<div class="box comment<%= it.comment.isAnswer ? " answer" : "" %><%= it.reply ? " reply" : "" %>" id="<%= it.comment.anchor %>"> +<% if (it.comment.hiddenReason) { %> + <div class="placeholder"><%= it.comment.hiddenReason %></div> +<% } else { %> + <header> + <span> + <% if (it.comment.author) { %> + <a href="/<%= it.comment.author %>"><%= it.comment.author %></a> + <% } else { %> + <span class="placeholder">ghost</span> + <% } %> + <% for (const label of it.comment.labels) { %> + <span class="pill"><%= label %></span> + <% } %> + <% if (it.comment.isAnswer) { %> + <span class="answered pill">Answer</span> + <% } %> + </span> + <span class="timestamp"> + <% if (it.comment.createdAt) { %> + <a href="#<%= it.comment.anchor %>"><time title="<%= it.comment.createdAt %>"><%= it.comment.createdAt.split("T")[0] %></time></a> + <% } %> + </span> + </header> + <%~ it.comment.bodyHtml %> +<% } %> +</div> + +<% if (it.comment.hiddenReplies > 0) { %> + <div class="box reply placeholder"> + <%= it.comment.hiddenReplies %> earlier + <%= it.comment.hiddenReplies === 1 ? "reply is" : "replies are" %> only on GitHub. + </div> +<% } %> +<% for (const reply of it.comment.replies) { %> + <%~ include("./_discussionComment.eta", { comment: reply, reply: true }) %> +<% } %> |
