summaryrefslogtreecommitdiff
path: root/publications.js
diff options
context:
space:
mode:
authorsophie <sophies@disroot.org>2026-08-31 10:42:13 +0200
committersophie <sophies@disroot.org>2026-08-31 10:42:13 +0200
commitfe437f882228b58bf16c2994470f80a2dbc134de (patch)
tree11ad203b624a80b92dad9aaddac3ef50f4e526d6 /publications.js
git commit
Diffstat (limited to 'publications.js')
-rw-r--r--publications.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/publications.js b/publications.js
new file mode 100644
index 0000000..98867f8
--- /dev/null
+++ b/publications.js
@@ -0,0 +1,50 @@
+/*
+ * sophies.rocks
+ *
+ * Copyright (C) 2026 Zofia Szweda
+ *
+ * This file is part of sophies.rocks.
+ *
+ * sophies.rocks is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * sophies.rocks is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with sophies.rocks. If not, see <https://www.gnu.org/licenses/>.
+ */
+function escapeXml(str) {
+ return String(str)
+ .replace(/&/g, '&amp;')
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;')
+ .replace(/"/g, '&quot;')
+ .replace(/'/g, '&apos;');
+}
+
+async function renderPublications() {
+ const list = document.querySelector('#recent-publications ul');
+ try {
+ const res = await fetch('/publications.json');
+ const posts = await res.json();
+ if (posts.length === 0) {
+ list.innerHTML = '<li>No publications yet.</li>';
+ return;
+ }
+ list.innerHTML = posts.map(p => `
+ <li>
+ <a href="${escapeXml(p.url)}">${escapeXml(p.title.trim())}</a>
+ ${p.date ? `<div>${escapeXml(new Date(p.date).toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }))}</div>` : ''}
+ </li>
+ `).join('');
+ } catch (err) {
+ console.error('Failed to load publications:', err);
+ list.innerHTML = "<li>Couldn't load publications right now.</li>";
+ }
+}
+renderPublications();