deploy: cache and render source name for news items

This commit is contained in:
2026-05-27 14:19:12 +00:00
parent 79b6d4857d
commit abe61d1156
2 changed files with 5 additions and 4 deletions
+4 -3
View File
@@ -870,8 +870,8 @@ if __name__ == "__main__":
cache_file = _HOME / "kiosk-home" / "news-data.json" cache_file = _HOME / "kiosk-home" / "news-data.json"
feeds = { feeds = {
"World News": "http://feeds.bbci.co.uk/news/world/rss.xml", "World News": ("http://feeds.bbci.co.uk/news/world/rss.xml", "BBC News"),
"National News": "https://feeds.npr.org/1001/rss.xml" "National News": ("https://feeds.npr.org/1001/rss.xml", "NPR News")
} }
def scrape_article(url): def scrape_article(url):
@@ -917,7 +917,7 @@ if __name__ == "__main__":
while True: while True:
payload = {} payload = {}
for category, url in feeds.items(): for category, (url, source_name) in feeds.items():
try: try:
req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"}) req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"})
xml_raw = urllib.request.urlopen(req, timeout=12).read() xml_raw = urllib.request.urlopen(req, timeout=12).read()
@@ -953,6 +953,7 @@ if __name__ == "__main__":
"title": t_str, "title": t_str,
"summary": full_story if full_story else "Click to read the story details.", "summary": full_story if full_story else "Click to read the story details.",
"image": img_url, "image": img_url,
"source": source_name,
"date": p_str "date": p_str
}) })
payload[category] = stories payload[category] = stories
+1 -1
View File
@@ -281,7 +281,7 @@
<div class="story-content"> <div class="story-content">
${story.image ? `<img src="${story.image}" style="width:100%; max-height:450px; object-fit:cover; border-radius:16px; margin-bottom:24px; box-shadow: 0 4px 15px rgba(0,0,0,0.35);" onerror="this.style.display='none'">` : ''} ${story.image ? `<img src="${story.image}" style="width:100%; max-height:450px; object-fit:cover; border-radius:16px; margin-bottom:24px; box-shadow: 0 4px 15px rgba(0,0,0,0.35);" onerror="this.style.display='none'">` : ''}
<div class="story-summary">${formattedSummary}</div> <div class="story-summary">${formattedSummary}</div>
<div class="story-meta">⌚ Published: ${story.date || 'Recent'}</div> <div class="story-meta">📰 Source: ${story.source || 'Daily Digest'} | ⌚ Published: ${story.date || 'Recent'}</div>
</div> </div>
</div> </div>
`; `;