From 89c194dccaa8c8da161f849ce66b1d81b426daa2 Mon Sep 17 00:00:00 2001 From: Tobias O Date: Fri, 14 Nov 2025 21:43:52 +1300 Subject: [PATCH] [Enhancement] Restyle Discourse Cards for title only (#220) Excerpts are only delivered for pinned posts. So all cards apart from pinned look empty. Changed to only display (more of) the title now. closes #214 Reviewed-on: https://git.envipath.com/enviPath/enviPy/pulls/220 Co-authored-by: Tobias O Co-committed-by: Tobias O --- static/js/discourse-api.js | 9 ++++++--- templates/index/index.html | 9 +++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/static/js/discourse-api.js b/static/js/discourse-api.js index 469b73c5..f1b65020 100644 --- a/static/js/discourse-api.js +++ b/static/js/discourse-api.js @@ -63,17 +63,20 @@ class DiscourseAPI { * @returns {string} Cleaned excerpt */ extractExcerpt(excerpt) { - if (!excerpt) return 'Click to read more'; + if (!excerpt) return 'No preview available yet'; // Remove HTML tags and clean up; collapse whitespace; do not add manual ellipsis - return excerpt + const cleaned = excerpt .replace(/<[^>]*>/g, '') // Remove HTML tags .replace(/ /g, ' ') // Replace   with spaces .replace(/&/g, '&') // Replace & with & .replace(/</g, '<') // Replace < with < .replace(/>/g, '>') // Replace > with > .replace(/\s+/g, ' ') // Collapse all whitespace/newlines - .trim() + .trim(); + + // Check if excerpt is empty after cleaning + return cleaned || 'No preview available yet'; } /** diff --git a/templates/index/index.html b/templates/index/index.html index dec6ea8e..1bf16f7d 100644 --- a/templates/index/index.html +++ b/templates/index/index.html @@ -305,16 +305,13 @@ const date = new Date(topic.created_at).toLocaleDateString(); return ` -
-
-

+
+
+

${topic.title}

-
- ${topic.excerpt} -