Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 3 additions & 48 deletions dashboard/inject.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,6 @@ async function fetchRSS(url, source) {
}
}

const RSS_SOURCE_FALLBACKS = {
'SBS Australia': { lat: -35.2809, lon: 149.13, region: 'Australia' },
'Indian Express': { lat: 28.6139, lon: 77.209, region: 'India' },
'The Hindu': { lat: 13.0827, lon: 80.2707, region: 'India' },
'MercoPress': { lat: -34.9011, lon: -56.1645, region: 'South America' }
};
const REGIONAL_NEWS_SOURCES = ['MercoPress', 'Indian Express', 'The Hindu', 'SBS Australia'];

export async function fetchAllNews() {
const feeds = [
// Global
Expand All @@ -197,12 +189,6 @@ export async function fetchAllNews() {
['https://rss.nytimes.com/services/xml/rss/nyt/Africa.xml', 'NYT Africa'],
// Asia-Pacific
['https://rss.nytimes.com/services/xml/rss/nyt/AsiaPacific.xml', 'NYT Asia'],
['https://www.sbs.com.au/news/topic/australia/feed', 'SBS Australia'],
// India
['https://indianexpress.com/section/india/feed/', 'Indian Express'],
['https://www.thehindu.com/news/national/feeder/default.rss', 'The Hindu'],
// South America
['https://en.mercopress.com/rss/latin-america', 'MercoPress'],
];

const results = await Promise.allSettled(
Expand All @@ -220,7 +206,7 @@ export async function fetchAllNews() {
const key = item.title.substring(0, 40).toLowerCase();
if (seen.has(key)) continue;
seen.add(key);
const geo = geoTagText(item.title) || RSS_SOURCE_FALLBACKS[item.source];
const geo = geoTagText(item.title);
if (geo) {
geoNews.push({
title: item.title.substring(0, 100),
Expand All @@ -237,23 +223,7 @@ export async function fetchAllNews() {
const cutoff = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000);
const filtered = geoNews.filter(n => !n.date || new Date(n.date) >= cutoff);
filtered.sort((a, b) => new Date(b.date || 0) - new Date(a.date || 0));

const selected = [];
const selectedKeys = new Set();
const keyFor = item => `${item.source}|${item.title}|${item.date}`;
const pushUnique = item => {
const key = keyFor(item);
if (selectedKeys.has(key)) return;
selected.push(item);
selectedKeys.add(key);
};

// Reserve a little space so newly-added regional feeds are not crowded out by larger globals.
for (const source of REGIONAL_NEWS_SOURCES) {
filtered.filter(item => item.source === source).slice(0, 2).forEach(pushUnique);
}
filtered.forEach(pushUnique);
return selected.slice(0, 50);
return filtered.slice(0, 50);
}

// === Leverageable Ideas from Signals ===
Expand Down Expand Up @@ -650,22 +620,7 @@ function buildNewsFeed(rssNews, gdeltData, tgUrgent, tgTop) {
const cutoff = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000);
const recent = feed.filter(item => !item.timestamp || new Date(item.timestamp) >= cutoff);
recent.sort((a, b) => new Date(b.timestamp || 0) - new Date(a.timestamp || 0));

const selected = [];
const selectedKeys = new Set();
const keyFor = item => `${item.type}|${item.source}|${item.headline}|${item.timestamp}`;
const pushUnique = item => {
const key = keyFor(item);
if (selectedKeys.has(key)) return;
selected.push(item);
selectedKeys.add(key);
};

for (const source of REGIONAL_NEWS_SOURCES) {
recent.filter(item => item.source === source).slice(0, 2).forEach(pushUnique);
}
recent.forEach(pushUnique);
return selected.slice(0, 50);
return recent.slice(0, 50);
}

// === CLI Mode: inject into HTML file ===
Expand Down
6 changes: 0 additions & 6 deletions dashboard/public/jarvis.html
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,6 @@
.tk-src.dw{color:#ef9a9a;border-color:rgba(239,154,154,0.3)}
.tk-src.eu{color:#ce93d8;border-color:rgba(206,147,216,0.3)}
.tk-src.af{color:#a5d6a7;border-color:rgba(165,214,167,0.3)}
.tk-src.sa{color:#ffab91;border-color:rgba(255,171,145,0.3)}
.tk-src.ind{color:#ffcc80;border-color:rgba(255,204,128,0.3)}
.tk-src.anz{color:#80cbc4;border-color:rgba(128,203,196,0.3)}
.tk-src.us{color:#90caf9;border-color:rgba(144,202,249,0.3)}
.tk-src.other{color:#b0bec5;border-color:rgba(176,190,197,0.2)}
.tk-head{font-size:11px;line-height:1.35;color:#c8d8d2;margin-top:3px}
Expand Down Expand Up @@ -1399,9 +1396,6 @@
const sl = s.toLowerCase();
// Africa-focused sources first (before generic DW/NYT)
if (sl.includes('dw africa') || sl.includes('africa news') || sl.includes('nyt africa') || sl.includes('rfi')) return 'af';
if (sl.includes('mercopress')) return 'sa';
if (sl.includes('indian express') || sl.includes('the hindu')) return 'ind';
if (sl.includes('sbs')) return 'anz';
if (sl.includes('bbc')) return 'bbc';
if (sl.includes('jazeera') || sl.includes('alj')) return 'alj';
if (sl.includes('gdelt')) return 'gdelt';
Expand Down