commit 3552b761e366e62005f433dd7cfea49aaa296e62
parent 2a6af070536bb9791dcbb823f007b5fd59ffef75
Author: torter <koubbamohamedrayan@gmail.com>
Date: Wed, 21 Oct 2026 13:17:29 +0000
website: board
Diffstat:
13 files changed, 400 insertions(+), 48 deletions(-)
diff --git a/.github/workflows/site.yml b/.github/workflows/site.yml
@@ -0,0 +1,40 @@
+# publishes docs/ to chamesle.org, with the board's posts fetched fresh
+name: site
+on:
+ push:
+ branches: [main]
+ paths: [docs/**, tools/site/**, .github/workflows/site.yml]
+ schedule:
+ - cron: "*/15 * * * *"
+ workflow_dispatch:
+ discussion:
+ discussion_comment:
+
+permissions:
+ contents: read
+ discussions: read
+ pages: write
+ id-token: write
+
+concurrency:
+ group: pages
+ cancel-in-progress: true
+
+jobs:
+ deploy:
+ runs-on: ubuntu-latest
+ environment:
+ name: github-pages
+ url: ${{ steps.deploy.outputs.page_url }}
+ steps:
+ - uses: actions/checkout@v4
+ - name: board posts
+ run: python3 tools/site/board.py > docs/board.json
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ - uses: actions/configure-pages@v5
+ - uses: actions/upload-pages-artifact@v3
+ with:
+ path: docs
+ - id: deploy
+ uses: actions/deploy-pages@v4
diff --git a/docs/about.html b/docs/about.html
@@ -17,6 +17,7 @@
<a href="editions.html">Editions</a>
<a href="packages.html">Packages</a>
<a href="docs.html">Docs</a>
+ <a href="board.html">Board</a>
<a href="about.html" class="here">About</a>
</nav>
</header>
diff --git a/docs/board.html b/docs/board.html
@@ -0,0 +1,114 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<title>Board - Chamesle Linux</title>
+<link rel="icon" href="img/logo.png">
+<link rel="stylesheet" href="style.css">
+</head>
+<body>
+
+<header>
+ <a class="brand" href="./"><img src="img/logo.png" alt="" width="36" height="36"> Chamesle</a>
+ <nav>
+ <a href="new.html">What's new</a>
+ <a href="download.html">Download</a>
+ <a href="editions.html">Editions</a>
+ <a href="packages.html">Packages</a>
+ <a href="docs.html">Docs</a>
+ <a href="board.html" class="here">Board</a>
+ <a href="about.html">About</a>
+ </nav>
+</header>
+
+<main>
+
+<h1>Board</h1>
+<p>Ask for help, show off your desktop, share ideas. You log in with your GitHub account, right here.</p>
+
+<div class="bar" id="sort">
+ <button data-s="hot" class="on">Hot</button>
+ <button data-s="new">New</button>
+ <button data-s="top">Top</button>
+ <a class="button" href="new.html">New post</a>
+</div>
+<div class="bar" id="cats"><button data-c="" class="on">Everything</button></div>
+<ul class="posts" id="posts"></ul>
+<p id="empty" class="small"></p>
+
+</main>
+
+<footer>
+ <p><a href="about.html">About</a> · <a href="https://github.com/tortr-rs/chamesle">GitHub</a> ·
+ <a href="https://sourceforge.net/projects/chameslerepos/">SourceForge</a></p>
+ <p>Chamesle Linux. Source code for every package is available on request.</p>
+</footer>
+
+<script>
+var CATS = {
+ 'q-a': ['Help', 'DIC_kwDOShHmjc4DJQSa', 'Q&A'],
+ 'show-and-tell': ['Show your desktop', 'DIC_kwDOShHmjc4DJQSc', 'Show and tell'],
+ 'ideas': ['Ideas', 'DIC_kwDOShHmjc4DJQSb', 'Ideas'],
+ 'general': ['General', 'DIC_kwDOShHmjc4DJQSZ', 'General'],
+ 'announcements': ['Announcements', 'DIC_kwDOShHmjc4DJQSY', 'Announcements']
+};
+function esc(s) { var d = document.createElement('div'); d.textContent = s || ''; return d.innerHTML; }
+function ago(t) {
+ var s = (Date.now() - new Date(t)) / 1000;
+ if (s < 3600) return Math.max(1, Math.round(s / 60)) + ' min ago';
+ if (s < 86400) return Math.round(s / 3600) + ' h ago';
+ if (s < 86400 * 30) return Math.round(s / 86400) + ' d ago';
+ return new Date(t).toLocaleDateString();
+}
+function giscus(el, cat, mapping, term) {
+ var s = document.createElement('script'), c = CATS[cat] || CATS.general;
+ var a = {src: 'https://giscus.app/client.js', 'data-repo': 'tortr-rs/chamesle', 'data-repo-id': 'R_kgDOShHmjQ',
+ 'data-category': c[2], 'data-category-id': c[1], 'data-mapping': mapping, 'data-term': term, 'data-strict': '1',
+ 'data-reactions-enabled': '1', 'data-emit-metadata': '0', 'data-input-position': 'top',
+ 'data-theme': 'preferred_color_scheme', 'data-lang': 'en', crossorigin: 'anonymous', async: ''};
+ for (var k in a) s.setAttribute(k, a[k]);
+ el.appendChild(s);
+}
+
+var all = [], sort = 'hot', cat = '';
+function score(p) {
+ if (sort === 'new') return +new Date(p.at);
+ if (sort === 'top') return p.v * 1000 + p.k;
+ var hours = (Date.now() - new Date(p.at)) / 3600000;
+ return (p.v + p.k / 2 + 1) / Math.pow(hours + 2, 1.5);
+}
+function show() {
+ var list = all.filter(function (p) { return !cat || p.c === cat; });
+ list.sort(function (a, b) { return score(b) - score(a); });
+ var out = document.getElementById('posts');
+ out.innerHTML = '';
+ list.forEach(function (p) {
+ var li = document.createElement('li'), c = CATS[p.c] || [p.c];
+ li.innerHTML = '<div class="votes"><span>▲</span>' + p.v + '</div><div><h3><a href="post.html?n=' + p.n + '">' +
+ esc(p.t) + '</a></h3><p>' + esc(p.b) + '</p><div class="meta"><span class="cat">' + esc(c[0]) + '</span>' +
+ (p.av ? '<img src="' + esc(p.av) + '&s=32" alt="">' : '') + esc(p.a) + ' · ' + ago(p.at) + ' · ' +
+ p.k + (p.k === 1 ? ' comment' : ' comments') + '</div></div>';
+ out.appendChild(li);
+ });
+ document.getElementById('empty').textContent = list.length ? '' : 'Nothing here yet. Be the first to post!';
+}
+var cats = document.getElementById('cats');
+Object.keys(CATS).forEach(function (k) {
+ var b = document.createElement('button'); b.dataset.c = k; b.textContent = CATS[k][0]; cats.appendChild(b);
+});
+function pick(bar, attr, set) {
+ bar.addEventListener('click', function (e) {
+ var b = e.target.closest('button'); if (!b) return;
+ bar.querySelectorAll('button').forEach(function (x) { x.classList.toggle('on', x === b); });
+ set(b.dataset[attr]); show();
+ });
+}
+pick(document.getElementById('sort'), 's', function (v) { sort = v; });
+pick(cats, 'c', function (v) { cat = v; });
+fetch('board.json').then(function (r) { return r.json(); }).then(function (d) { all = d; show(); })
+ .catch(function () { document.getElementById('empty').textContent = "Couldn't load the board. Try reloading."; });
+</script>
+
+</body>
+</html>
diff --git a/docs/board.json b/docs/board.json
@@ -0,0 +1 @@
+[]
diff --git a/docs/docs.html b/docs/docs.html
@@ -17,6 +17,7 @@
<a href="editions.html">Editions</a>
<a href="packages.html">Packages</a>
<a href="docs.html" class="here">Docs</a>
+ <a href="board.html">Board</a>
<a href="about.html">About</a>
</nav>
</header>
@@ -47,11 +48,13 @@
<h2 id="install">Installing Chamesle <span class="tag soon">0.2</span></h2>
<p>Boot the USB stick, then double-click <b>Install Chamesle</b> on the desktop.</p>
<ol>
- <li><b>Welcome:</b> pick your language. It checks you have enough space and are plugged in.</li>
- <li><b>Location</b> and <b>keyboard:</b> click your city on the map, try the keyboard in the box.</li>
- <li><b>Partitions:</b> “Install alongside” keeps Windows (drag the slider to share the space),
- “Erase disk” uses the whole thing. Tick <b>Encrypt system</b> if you want it.</li>
- <li><b>Users:</b> your name, a login name, a password and a name for the computer.</li>
+ <li><b>Language:</b> pick yours from the list.</li>
+ <li><b>Timezone:</b> click where you are on the map.</li>
+ <li><b>Keyboard:</b> pick your layout, there's a picture of it and a box to try it.</li>
+ <li><b>User account:</b> your name, a username, a password and a name for the computer.</li>
+ <li><b>Installation type:</b> “Automated” erases a disk and sets everything up, with encryption
+ if you tick it. “Manual” lets you choose partitions yourself. To keep Windows, pick Manual, open
+ GParted from there, shrink the Windows partition, and install into the free space.</li>
<li><b>Summary:</b> check it and click Install. Restart when it's done and take the stick out.</li>
</ol>
<p>Back up anything important first. Shrinking Windows works fine almost always, but “almost” isn't
diff --git a/docs/download.html b/docs/download.html
@@ -17,6 +17,7 @@
<a href="editions.html">Editions</a>
<a href="packages.html">Packages</a>
<a href="docs.html">Docs</a>
+ <a href="board.html">Board</a>
<a href="about.html">About</a>
</nav>
</header>
diff --git a/docs/editions.html b/docs/editions.html
@@ -17,6 +17,7 @@
<a href="editions.html" class="here">Editions</a>
<a href="packages.html">Packages</a>
<a href="docs.html">Docs</a>
+ <a href="board.html">Board</a>
<a href="about.html">About</a>
</nav>
</header>
diff --git a/docs/index.html b/docs/index.html
@@ -18,6 +18,7 @@
<a href="editions.html">Editions</a>
<a href="packages.html">Packages</a>
<a href="docs.html">Docs</a>
+ <a href="board.html">Board</a>
<a href="about.html">About</a>
</nav>
</header>
diff --git a/docs/new.html b/docs/new.html
@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
-<title>What's new in 0.2 - Chamesle Linux</title>
+<title>New post - Chamesle Linux</title>
<link rel="icon" href="img/logo.png">
<link rel="stylesheet" href="style.css">
</head>
@@ -12,58 +12,37 @@
<header>
<a class="brand" href="./"><img src="img/logo.png" alt="" width="36" height="36"> Chamesle</a>
<nav>
- <a href="new.html" class="here">What's new</a>
+ <a href="new.html">What's new</a>
<a href="download.html">Download</a>
<a href="editions.html">Editions</a>
<a href="packages.html">Packages</a>
<a href="docs.html">Docs</a>
+ <a href="board.html" class="here">Board</a>
<a href="about.html">About</a>
</nav>
</header>
<main>
-<h1>What's new in 0.2</h1>
-<p><span class="tag soon">in testing</span> 0.2 isn't out yet. This is what's in it. When it's ready it'll be on the
-<a href="download.html">download page</a>.</p>
-
-<h2>pkgimport: .deb and .rpm, just double-click</h2>
-<p>Most Linux apps on the web come as a <code>.deb</code> (Ubuntu, Debian) or an <code>.rpm</code> (Fedora, openSUSE).
-On Chamesle you don't have to care which. Double-click either one and <b>pkgimport</b> installs it: it converts
-the package, pulls in the libraries it needs from the Chamesle repo, and adds it to your menu. Updating and
-removing works like any other package.</p>
-<pre><code>sudo pkgimport install ~/Downloads/app.deb
-sudo pkgimport install ~/Downloads/app.rpm</code></pre>
-
-<h2>An installer</h2>
-<p>0.1 was live-only. 0.2 puts Chamesle on your disk. Double-click <b>Install Chamesle</b> on the desktop and
-answer a few questions: language, keyboard, where it goes, your name and password. Then it does the rest.</p>
-<ul>
- <li><b>Next to Windows.</b> The installer can shrink a Windows partition to make room, and you choose Windows or
- Chamesle every time the computer starts.</li>
- <li><b>Or the whole disk</b>, if you're done with what's on it.</li>
- <li><b>Encryption</b> with one tick box. Your files stay locked if the laptop gets stolen.</li>
- <li>Manual partitioning for people who want it, with ext4, btrfs or xfs.</li>
- <li>Works on both old BIOS machines and UEFI.</li>
-</ul>
-
-<h2>The Chamesle repo</h2>
-<p>The system now uses <b>apk</b> and the Chamesle repo: almost 15,000 packages, each one signed with the
-Chamesle key. Updating everything is one command:</p>
-<pre><code>sudo apk upgrade</code></pre>
-<p> <a href="packages.html">Search the packages</a>.</p>
-
-<h2>Smaller things</h2>
-<ul>
- <li>A sharper wallpaper, 4K now.</li>
- <li>Qt apps use the same theme as everything else.</li>
- <li>fastfetch shows the Chamesle logo.</li>
- <li>The boot menu of an installed system finds Windows and other systems on its own.</li>
-</ul>
-
-<h2>Still to come</h2>
-<p>The update notifier and the driver manager moved to 0.3, together with the store. Better done right
-than rushed. See the <a href="about.html#roadmap">roadmap</a>.</p>
+<p class="small"><a href="board.html">← Board</a></p>
+<h1>New post</h1>
+<form class="form" id="form">
+ <label for="cat">Where does it go?</label>
+ <select id="cat">
+ <option value="q-a">Help</option>
+ <option value="show-and-tell">Show your desktop</option>
+ <option value="ideas">Ideas</option>
+ <option value="general" selected>General</option>
+ </select>
+ <label for="title">Title</label>
+ <input id="title" maxlength="120" required placeholder="What's it about?">
+ <p><button class="button" type="submit">Next</button></p>
+</form>
+<div id="write" hidden>
+ <p><b id="shown"></b></p>
+ <p class="small">Write your post in the box below and send it. Log in with GitHub first if you haven't.</p>
+ <div class="giscus" id="box"></div>
+</div>
</main>
@@ -73,5 +52,43 @@ than rushed. See the <a href="about.html#roadmap">roadmap</a>.</p>
<p>Chamesle Linux. Source code for every package is available on request.</p>
</footer>
+<script>
+var CATS = {
+ 'q-a': ['Help', 'DIC_kwDOShHmjc4DJQSa', 'Q&A'],
+ 'show-and-tell': ['Show your desktop', 'DIC_kwDOShHmjc4DJQSc', 'Show and tell'],
+ 'ideas': ['Ideas', 'DIC_kwDOShHmjc4DJQSb', 'Ideas'],
+ 'general': ['General', 'DIC_kwDOShHmjc4DJQSZ', 'General'],
+ 'announcements': ['Announcements', 'DIC_kwDOShHmjc4DJQSY', 'Announcements']
+};
+function esc(s) { var d = document.createElement('div'); d.textContent = s || ''; return d.innerHTML; }
+function ago(t) {
+ var s = (Date.now() - new Date(t)) / 1000;
+ if (s < 3600) return Math.max(1, Math.round(s / 60)) + ' min ago';
+ if (s < 86400) return Math.round(s / 3600) + ' h ago';
+ if (s < 86400 * 30) return Math.round(s / 86400) + ' d ago';
+ return new Date(t).toLocaleDateString();
+}
+function giscus(el, cat, mapping, term) {
+ var s = document.createElement('script'), c = CATS[cat] || CATS.general;
+ var a = {src: 'https://giscus.app/client.js', 'data-repo': 'tortr-rs/chamesle', 'data-repo-id': 'R_kgDOShHmjQ',
+ 'data-category': c[2], 'data-category-id': c[1], 'data-mapping': mapping, 'data-term': term, 'data-strict': '1',
+ 'data-reactions-enabled': '1', 'data-emit-metadata': '0', 'data-input-position': 'top',
+ 'data-theme': 'preferred_color_scheme', 'data-lang': 'en', crossorigin: 'anonymous', async: ''};
+ for (var k in a) s.setAttribute(k, a[k]);
+ el.appendChild(s);
+}
+
+document.getElementById('form').addEventListener('submit', function (e) {
+ e.preventDefault();
+ var title = document.getElementById('title').value.trim(), cat = document.getElementById('cat').value;
+ if (!title) return;
+ document.getElementById('form').hidden = true;
+ document.getElementById('write').hidden = false;
+ document.getElementById('shown').textContent = title;
+ // giscus makes the discussion, titled like this, with the first message as the post
+ giscus(document.getElementById('box'), cat, 'specific', title);
+});
+</script>
+
</body>
</html>
diff --git a/docs/packages.html b/docs/packages.html
@@ -17,6 +17,7 @@
<a href="editions.html">Editions</a>
<a href="packages.html" class="here">Packages</a>
<a href="docs.html">Docs</a>
+ <a href="board.html">Board</a>
<a href="about.html">About</a>
</nav>
</header>
diff --git a/docs/post.html b/docs/post.html
@@ -0,0 +1,88 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<title>Post - Chamesle Linux</title>
+<link rel="icon" href="img/logo.png">
+<link rel="stylesheet" href="style.css">
+</head>
+<body>
+
+<header>
+ <a class="brand" href="./"><img src="img/logo.png" alt="" width="36" height="36"> Chamesle</a>
+ <nav>
+ <a href="new.html">What's new</a>
+ <a href="download.html">Download</a>
+ <a href="editions.html">Editions</a>
+ <a href="packages.html">Packages</a>
+ <a href="docs.html">Docs</a>
+ <a href="board.html" class="here">Board</a>
+ <a href="about.html">About</a>
+ </nav>
+</header>
+
+<main>
+
+<p class="small"><a href="board.html">← Board</a></p>
+<h1 id="title">Loading…</h1>
+<div class="meta" id="meta"></div>
+<div class="post-body" id="body"></div>
+<div class="giscus" id="comments"></div>
+
+</main>
+
+<footer>
+ <p><a href="about.html">About</a> · <a href="https://github.com/tortr-rs/chamesle">GitHub</a> ·
+ <a href="https://sourceforge.net/projects/chameslerepos/">SourceForge</a></p>
+ <p>Chamesle Linux. Source code for every package is available on request.</p>
+</footer>
+
+<script>
+var CATS = {
+ 'q-a': ['Help', 'DIC_kwDOShHmjc4DJQSa', 'Q&A'],
+ 'show-and-tell': ['Show your desktop', 'DIC_kwDOShHmjc4DJQSc', 'Show and tell'],
+ 'ideas': ['Ideas', 'DIC_kwDOShHmjc4DJQSb', 'Ideas'],
+ 'general': ['General', 'DIC_kwDOShHmjc4DJQSZ', 'General'],
+ 'announcements': ['Announcements', 'DIC_kwDOShHmjc4DJQSY', 'Announcements']
+};
+function esc(s) { var d = document.createElement('div'); d.textContent = s || ''; return d.innerHTML; }
+function ago(t) {
+ var s = (Date.now() - new Date(t)) / 1000;
+ if (s < 3600) return Math.max(1, Math.round(s / 60)) + ' min ago';
+ if (s < 86400) return Math.round(s / 3600) + ' h ago';
+ if (s < 86400 * 30) return Math.round(s / 86400) + ' d ago';
+ return new Date(t).toLocaleDateString();
+}
+function giscus(el, cat, mapping, term) {
+ var s = document.createElement('script'), c = CATS[cat] || CATS.general;
+ var a = {src: 'https://giscus.app/client.js', 'data-repo': 'tortr-rs/chamesle', 'data-repo-id': 'R_kgDOShHmjQ',
+ 'data-category': c[2], 'data-category-id': c[1], 'data-mapping': mapping, 'data-term': term, 'data-strict': '1',
+ 'data-reactions-enabled': '1', 'data-emit-metadata': '0', 'data-input-position': 'top',
+ 'data-theme': 'preferred_color_scheme', 'data-lang': 'en', crossorigin: 'anonymous', async: ''};
+ for (var k in a) s.setAttribute(k, a[k]);
+ el.appendChild(s);
+}
+
+var n = new URLSearchParams(location.search).get('n');
+fetch('board.json').then(function (r) { return r.json(); }).then(function (d) {
+ var p = d.filter(function (x) { return String(x.n) === n; })[0];
+ if (!p) {
+ // brand new, the board catches up within a few minutes
+ document.getElementById('title').textContent = 'New post';
+ giscus(document.getElementById('comments'), 'general', 'number', n);
+ return;
+ }
+ var c = CATS[p.c] || [p.c];
+ document.title = p.t + ' - Chamesle Linux';
+ document.getElementById('title').textContent = p.t;
+ document.getElementById('meta').innerHTML = '<span class="cat">' + esc(c[0]) + '</span>' +
+ (p.av ? '<img src="' + esc(p.av) + '&s=32" alt="">' : '') + esc(p.a) + ' · ' + ago(p.at);
+ // posts made on github keep their text in the discussion itself, giscus only shows the comments
+ if (!p.s) document.getElementById('body').textContent = p.b;
+ giscus(document.getElementById('comments'), p.c, 'number', n);
+});
+</script>
+
+</body>
+</html>
diff --git a/docs/style.css b/docs/style.css
@@ -183,3 +183,31 @@ input[type=search]:focus { outline: 2px solid var(--blue); outline-offset: -1px;
td:first-child code { white-space: nowrap; }
td:first-child:has(code) { width: auto; padding-right: 18px; }
@media (max-width: 560px) { td:first-child code { white-space: normal; word-break: break-all; } }
+
+/* board */
+.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 16px; }
+.bar a, .bar button {
+ font: inherit; font-size: 14px; color: var(--muted); background: none; cursor: pointer;
+ border: 1px solid var(--line); border-radius: 14px; padding: 3px 12px; text-decoration: none;
+}
+.bar a.on, .bar button.on { color: var(--text); border-color: var(--text); font-weight: 600; }
+.bar .button { margin-left: auto; color: #fff; background: var(--blue); border: 0; border-radius: 6px; font-size: 15px; padding: 6px 14px; }
+.posts { list-style: none; padding: 0; margin: 0; }
+.posts li { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); margin: 0; }
+.votes { min-width: 40px; text-align: center; color: var(--muted); font-weight: 600; font-size: 15px; line-height: 1.2; }
+.votes span { display: block; font-size: 18px; }
+.posts h3 { margin: 0; font-size: 17px; }
+.posts h3 a { color: var(--text); text-decoration: none; }
+.posts h3 a:hover { text-decoration: underline; }
+.posts p { margin: 2px 0 0; color: var(--muted); font-size: 15px; overflow: hidden; display: -webkit-box;
+ -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
+.meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
+.meta img { width: 16px; height: 16px; border-radius: 50%; vertical-align: -3px; margin-right: 4px; }
+.cat { font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--code); color: var(--muted); margin-right: 6px; }
+.post-body { white-space: pre-wrap; overflow-wrap: anywhere; }
+.form label { display: block; font-weight: 600; margin: 14px 0 4px; }
+.form input, .form select {
+ width: 100%; font: inherit; padding: 9px 12px; border: 1px solid var(--line); border-radius: 6px;
+ background: var(--bg); color: var(--text);
+}
+.giscus { margin-top: 24px; }
diff --git a/tools/site/board.py b/tools/site/board.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python3
+# fetch the board's posts (github discussions) into docs/board.json, run by the site workflow
+# usage: GITHUB_TOKEN=... tools/site/board.py > docs/board.json
+import json, os, sys, urllib.request
+
+REPO = ("tortr-rs", "chamesle")
+QUERY = """
+query($owner: String!, $name: String!, $after: String) {
+ repository(owner: $owner, name: $name) {
+ discussions(first: 100, after: $after, orderBy: {field: UPDATED_AT, direction: DESC}) {
+ pageInfo { hasNextPage endCursor }
+ nodes {
+ number title createdAt updatedAt upvoteCount body
+ author { login avatarUrl }
+ category { name slug }
+ reactions(content: THUMBS_UP) { totalCount }
+ comments(first: 1) { totalCount nodes { body author { login avatarUrl } } }
+ }
+ }
+ }
+}"""
+
+
+def gql(variables):
+ req = urllib.request.Request("https://api.github.com/graphql",
+ data=json.dumps({"query": QUERY, "variables": variables}).encode(),
+ headers={"Authorization": "bearer " + os.environ["GITHUB_TOKEN"],
+ "Content-Type": "application/json"})
+ with urllib.request.urlopen(req) as r:
+ return json.load(r)["data"]["repository"]["discussions"]
+
+
+posts, after = [], None
+while len(posts) < 500:
+ page = gql({"owner": REPO[0], "name": REPO[1], "after": after})
+ for d in page["nodes"]:
+ author, body = d["author"] or {"login": "ghost", "avatarUrl": ""}, d["body"]
+ comments, site = d["comments"]["totalCount"], 0
+ # posts made from the website start as a giscus discussion: the real post is its first comment
+ if author["login"] == "giscus" and d["comments"]["nodes"]:
+ first = d["comments"]["nodes"][0]
+ author, body = first["author"] or author, first["body"]
+ comments -= 1
+ site = 1
+ posts.append({
+ "n": d["number"], "t": d["title"], "c": d["category"]["slug"],
+ "a": author["login"], "av": author["avatarUrl"],
+ "at": d["createdAt"], "up": d["updatedAt"],
+ "v": d["upvoteCount"] + d["reactions"]["totalCount"],
+ "k": comments, "b": body if not site else body[:600], "s": site,
+ })
+ if not page["pageInfo"]["hasNextPage"]:
+ break
+ after = page["pageInfo"]["endCursor"]
+
+json.dump(posts, sys.stdout, separators=(",", ":"))