From 122867b04f347e87d2dca6a4658a7d2f7edcfb98 Mon Sep 17 00:00:00 2001
From: Nemo <commits@captnemo.in>
Date: Sun, 13 Oct 2024 18:08:50 +0530
Subject: [PATCH] add a no news notification

---
 index.html              | 20 ++++++++++++++++++++
 _plugins/fetch_posts.rb |  6 ++++--
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/index.html b/index.html
index 2cfdc97..aff1ac2 100644
--- a/index.html
+++ a/index.html
@@ -1,13 +1,15 @@
 ---
 title: "Beatroot News: Text-only"
 layout: default
 ---
+{% assign totalPostCount = 0 %}
 <div class="topic-container">
 <h1 class="topic-heading">{{page.title}}</h1>
 <div class="hr-line"></div>
 {% include date.html %}
 {% for T in site.data.topics %}
 {% assign post_count = T[1] %}
+{% assign totalPostCount = totalPostCount | plus: post_count %}
 {% if post_count > 0 %}
 <div class="topic-{{T[0]|downcase}} news-topic">
 <h2><a href="/{{T[0]}}/">{{T[0] | capitalize}}</a></h2>
@@ -18,11 +20,27 @@
 	{% endfor %}
 </div>
 {% endif %}
-
 {% endfor %}
+
+{% if totalPostCount == 0  %}
+<div class="topic-container">
+<h1 class="topic-heading">We have no news</h1>
+	<div style="position:relative" class="detailswrapper">
+		This website fetches news from the <a href="https://app.beatrootnews.com/">Beatroot News
+		</a> website, which hasn't been updated recently. We intentionally only shows news from
+		yesterday and tomorrow, so there's no news here as a result.
+
+		Check back later for updates.
+	</div>
+</div>
 
+{% else %}
 <br><button id="hidden-notifier">Show <span id="hidden-count"></span> hidden topic(s)</button>
 
 <p>❖ - Syndicated news, primarily from PTI</p>
 <p>Dark/Light border on the right denotes articles from today/yesterday</p>
 </div>
+{% endif %}
+
+
+
diff --git a/_plugins/fetch_posts.rb b/_plugins/fetch_posts.rb
index bc16c48..fbe0002 100644
--- a/_plugins/fetch_posts.rb
+++ a/_plugins/fetch_posts.rb
@@ -100,11 +100,13 @@
     end
 
     Jekyll.logger.info 'News:', "Generated #{site.data['topics'].values.sum} article pages"
+    
     # These are fallback checks to make sure if we have a bug or get bad data,
     # we don't update the website with not enough news
     # better to fail the build than show an empty website.
-    raise 'Not enough articles, not updating website' if site.data['topics'].values.sum < 10
-    raise 'Not enough topics, not updating website' if site.data['topics'].size < 5
+    # Currently commented out, since we haven't seen updates in a while.
+    # raise 'Not enough articles, not updating website' if site.data['topics'].values.sum < 10
+    # raise 'Not enough topics, not updating website' if site.data['topics'].size < 5
   end
 
   private
--
rgit 0.1.5