Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
480 lines (423 loc) · 20.9 KB
/
Copy pathindex.html
File metadata and controls
480 lines (423 loc) · 20.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>RSS Archive</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
background-color: #f8f8f8;
}
input::placeholder {
color: #a3a3a3;
}
</style>
</head>
<body class="text-neutral-900 min-h-screen">
<div class="container mx-auto px-4 py-8 max-w-6xl">
<!-- Header -->
<div class="mb-8 flex justify-between items-start gap-12">
<!-- Left Column: Title and Selectors -->
<div class="flex-1">
<h1 class="text-2xl mb-4 text-neutral-600 font-semibold">Haptic daily</h1>
<!-- Filter Selectors -->
<div class="flex gap-6">
<!-- Time Filter -->
<div>
<div class="text-xs text-neutral-500 mb-2 uppercase tracking-wide font-semibold">Time</div>
<div class="flex gap-1.5 flex-wrap">
<button
id="tabAll"
onclick="filterByTime('all')"
class="px-3 py-1.5 font-medium text-xs transition border border-neutral-800 bg-neutral-800 text-white rounded">
All
</button>
<button
id="tabYear"
onclick="filterByTime('year')"
class="px-3 py-1.5 font-medium text-xs transition border border-neutral-200 text-neutral-500 hover:border-neutral-300 hover:text-neutral-700 rounded">
Year
</button>
<button
id="tabMonth"
onclick="filterByTime('month')"
class="px-3 py-1.5 font-medium text-xs transition border border-neutral-200 text-neutral-500 hover:border-neutral-300 hover:text-neutral-700 rounded">
Month
</button>
<button
id="tabWeek"
onclick="filterByTime('week')"
class="px-3 py-1.5 font-medium text-xs transition border border-neutral-200 text-neutral-500 hover:border-neutral-300 hover:text-neutral-700 rounded">
Week
</button>
</div>
</div>
<!-- Feed Source Filter -->
<div>
<div class="text-xs text-neutral-500 mb-2 uppercase tracking-wide font-semibold">Source</div>
<div id="feedSourceFilters" class="flex gap-1.5 flex-wrap">
<button
id="feedAll"
onclick="filterByFeedSource('all')"
class="px-3 py-1.5 font-medium text-xs transition border border-neutral-800 bg-neutral-800 text-white rounded">
All
</button>
<!-- Dynamic feed source buttons will be added here -->
</div>
</div>
</div>
</div>
<!-- Right Column: Top Keywords -->
<div class="w-64">
<h2 class="text-xs font-semibold text-neutral-500 mb-2 uppercase tracking-wide">Top Keywords</h2>
<div id="topKeywords" class="space-y-0.5 text-sm">
<div class="text-neutral-400 text-xs">Loading...</div>
</div>
</div>
</div>
<!-- Search Box -->
<div class="mb-6">
<input
type="text"
id="searchBox"
placeholder="Search by keyword, title, summary, or source..."
class="w-full px-4 py-3 rounded-lg border border-neutral-100 bg-white focus:outline-none focus:ring-2 focus:ring-neutral-300 transition"
/>
</div>
<!-- Stats -->
<div class="mb-4 text-sm text-neutral-500">
<span id="itemCount">Loading...</span>
</div>
<!-- Feed Items -->
<div id="feedTable">
<!-- Content will be loaded here -->
<div class="bg-white rounded-lg border border-neutral-100 px-6 py-8 text-center text-neutral-500">
Loading feed...
</div>
</div>
<script>
let allItems = [];
let currentSort = 'desc'; // newest first
let currentTimeFilter = 'all';
let currentFeedSource = 'all';
let currentSearchQuery = '';
let availableFeedSources = new Set();
let readArticles = new Set();
// Load read articles from localStorage
function loadReadArticles() {
try {
const saved = localStorage.getItem('readArticles');
if (saved) {
readArticles = new Set(JSON.parse(saved));
}
} catch (e) {
console.error('Error loading read articles:', e);
}
}
// Save read articles to localStorage
function saveReadArticles() {
try {
localStorage.setItem('readArticles', JSON.stringify(Array.from(readArticles)));
} catch (e) {
console.error('Error saving read articles:', e);
}
}
// Mark article as read
function markAsRead(articleLink) {
readArticles.add(articleLink);
saveReadArticles();
applyFilters(); // Refresh display
}
// Initialize
loadReadArticles();
// Load feed data
async function loadFeed() {
try {
// Add cache-busting timestamp to avoid stale data
const response = await fetch(`feed.json?v=${Date.now()}`);
if (!response.ok) {
throw new Error('Failed to load feed');
}
allItems = await response.json();
// Collect available feed sources
allItems.forEach(item => {
if (item.feed_source) {
availableFeedSources.add(item.feed_source);
}
});
console.log('Available feed sources:', Array.from(availableFeedSources));
console.log('Sample item:', allItems[0]);
// Create feed source filter buttons
createFeedSourceButtons();
applyFilters();
} catch (error) {
console.error('Error loading feed:', error);
document.getElementById('feedTable').innerHTML = `
<div class="bg-white rounded-lg border border-neutral-100 px-6 py-8 text-center text-neutral-500">
No feed data available. Run the Python script to fetch your RSS feed.
</div>
`;
document.getElementById('itemCount').textContent = 'No items';
}
}
// Create feed source filter buttons
function createFeedSourceButtons() {
const container = document.getElementById('feedSourceFilters');
const allButton = document.getElementById('feedAll');
// Add buttons for each feed source
availableFeedSources.forEach(feedSource => {
const button = document.createElement('button');
button.id = `feed${feedSource.replace(/\s+/g, '')}`;
button.onclick = () => filterByFeedSource(feedSource);
button.className = 'px-3 py-1.5 font-medium text-xs transition border border-neutral-200 text-neutral-500 hover:border-neutral-300 hover:text-neutral-700 rounded';
button.textContent = feedSource;
container.appendChild(button);
});
}
// Filter by feed source
function filterByFeedSource(source) {
currentFeedSource = source;
// Update button styles
document.querySelectorAll('#feedSourceFilters button').forEach(btn => {
const isActive = (source === 'all' && btn.id === 'feedAll') ||
(source !== 'all' && btn.textContent === source);
if (isActive) {
btn.className = 'px-3 py-1.5 font-medium text-xs transition border border-neutral-800 bg-neutral-800 text-white rounded';
} else {
btn.className = 'px-3 py-1.5 font-medium text-xs transition border border-neutral-200 text-neutral-500 hover:border-neutral-300 hover:text-neutral-700 rounded';
}
});
applyFilters();
}
// Apply all filters (time + feed source + search)
function applyFilters() {
let filtered = [...allItems];
// Apply time filter
if (currentTimeFilter !== 'all') {
const now = new Date();
const cutoffDate = new Date();
if (currentTimeFilter === 'week') {
cutoffDate.setDate(now.getDate() - 7);
} else if (currentTimeFilter === 'month') {
cutoffDate.setMonth(now.getMonth() - 1);
} else if (currentTimeFilter === 'year') {
cutoffDate.setFullYear(now.getFullYear() - 1);
}
filtered = filtered.filter(item => {
const itemDate = new Date(item.date);
return itemDate >= cutoffDate;
});
}
// Apply feed source filter
if (currentFeedSource !== 'all') {
filtered = filtered.filter(item => item.feed_source === currentFeedSource);
}
// Apply search filter
if (currentSearchQuery) {
filtered = filtered.filter(item => {
const keywordsMatch = item.keywords && item.keywords.some(kw =>
kw.toLowerCase().includes(currentSearchQuery)
);
return item.title.toLowerCase().includes(currentSearchQuery) ||
item.source.toLowerCase().includes(currentSearchQuery) ||
(item.description && item.description.toLowerCase().includes(currentSearchQuery)) ||
(item.ai_summary && item.ai_summary.toLowerCase().includes(currentSearchQuery)) ||
keywordsMatch;
});
}
displayItems(filtered);
updateStats(filtered.length, allItems.length);
updateTopKeywords(filtered);
}
// Filter by time period
function filterByTime(period) {
currentTimeFilter = period;
// Update button styles
['tabAll', 'tabYear', 'tabMonth', 'tabWeek'].forEach(id => {
const tab = document.getElementById(id);
const isActive = id === 'tab' + period.charAt(0).toUpperCase() + period.slice(1) ||
(period === 'all' && id === 'tabAll');
if (isActive) {
tab.className = 'px-3 py-1.5 font-medium text-xs transition border border-neutral-800 bg-neutral-800 text-white rounded';
} else {
tab.className = 'px-3 py-1.5 font-medium text-xs transition border border-neutral-200 text-neutral-500 hover:border-neutral-300 hover:text-neutral-700 rounded';
}
});
applyFilters();
}
// Display items in groups
function displayItems(items) {
const container = document.getElementById('feedTable');
if (items.length === 0) {
container.innerHTML = `
<div class="bg-white rounded-lg border border-neutral-100 px-6 py-8 text-center text-neutral-500">
No items match your filters
</div>
`;
return;
}
// Group items by date
const groupedItems = {};
items.forEach(item => {
const date = new Date(item.date);
const dateString = date.toLocaleDateString('en-US', {
year: 'numeric',
month: 'numeric',
day: 'numeric'
});
if (!groupedItems[dateString]) {
groupedItems[dateString] = [];
}
groupedItems[dateString].push(item);
});
// Render each date group as a card
container.innerHTML = Object.entries(groupedItems).map(([dateString, groupItems]) => {
const date = new Date(groupItems[0].date);
const formattedDate = date.toLocaleDateString('en-US', {
year: 'numeric',
month: 'short',
day: 'numeric'
});
const postsHtml = groupItems.map((item, index) => {
const description = item.description || '';
const aiSummary = item.ai_summary || '';
const displayText = aiSummary || description;
const keywords = item.keywords || [];
// Generate keyword pills
const keywordPills = keywords.length > 0
? keywords.map(kw => `<span class="inline-block px-2 py-0.5 text-xs bg-neutral-50 text-neutral-500 rounded-full">${escapeHtml(kw)}</span>`).join(' ')
: '';
const separator = index > 0 ? '<div class="border-t border-neutral-100"></div>' : '';
// Check relevance level
const isHighRelevance = item.relevance_level === 'high';
const relevanceIndicator = isHighRelevance
? '<span class="absolute -left-4 top-0 translate-y-1/2 w-2 h-2 bg-yellow-400 rounded-full"></span>'
: '';
// Check if article has been read
const isRead = readArticles.has(item.link);
const readClass = isRead ? 'bg-neutral-200' : '';
const hoverClass = isRead ? 'hover:bg-neutral-300' : 'hover:bg-neutral-50';
return `
${separator}
<div class="flex ${readClass} ${hoverClass} transition cursor-pointer" onclick="markAsRead('${item.link.replace(/'/g, "\\'")}')">
<div class="px-6 py-4" style="width: 75%">
<div class="relative">
${relevanceIndicator}
<a href="${item.link}" target="_blank" rel="noopener noreferrer"
class="text-neutral-700 hover:text-neutral-900 hover:underline font-medium text-sm block">
${stripHtml(item.title)}
</a>
</div>
${displayText ? `<div class="text-neutral-600 text-sm mt-2 leading-relaxed">${escapeHtml(displayText)}</div>` : ''}
</div>
<div class="px-6 py-4 text-sm" style="width: 25%">
<div class="flex items-center gap-2 mb-2">
${description && aiSummary ? `
<div class="relative group">
<div class="w-4 h-4 rounded-full bg-neutral-300 hover:bg-neutral-400 flex items-center justify-center cursor-help transition flex-shrink-0">
<span class="text-[10px] text-white">i</span>
</div>
<div class="absolute right-0 top-6 w-80 bg-neutral-800 text-white text-xs p-3 rounded shadow-lg opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-200 z-50 pointer-events-none">
<div class="font-semibold mb-1">Original Preview:</div>
${escapeHtml(description)}
</div>
</div>
` : ''}
<a href="${item.link}" target="_blank" rel="noopener noreferrer"
class="text-neutral-500 hover:text-neutral-700 hover:underline text-xs">
${escapeHtml(item.source)}
</a>
</div>
${keywordPills ? `<div class="flex flex-wrap gap-1">${keywordPills}</div>` : ''}
</div>
</div>
`;
}).join('');
return `
<div class="bg-white rounded-lg border border-neutral-200 overflow-hidden mb-6">
<div class="px-6 py-3 bg-neutral-50 border-b border-neutral-200">
<div class="text-xs font-semibold text-neutral-500 uppercase tracking-wide">
${formattedDate}
</div>
</div>
${postsHtml}
</div>
`;
}).join('');
}
// Escape HTML to prevent XSS
function escapeHtml(text) {
const div = document.createElement('div');
div.textContent = text;
return div.innerHTML;
}
// Strip HTML tags and decode entities (for titles)
function stripHtml(html) {
const div = document.createElement('div');
div.innerHTML = html;
return div.textContent || div.innerText || '';
}
// Update stats
function updateStats(showing, total) {
document.getElementById('itemCount').textContent =
showing === total
? `Showing ${total} items`
: `Showing ${showing} of ${total} items`;
}
// Update top keywords widget
function updateTopKeywords(items) {
const keywordCounts = {};
// Count keyword frequency
items.forEach(item => {
if (item.keywords && Array.isArray(item.keywords)) {
item.keywords.forEach(keyword => {
keywordCounts[keyword] = (keywordCounts[keyword] || 0) + 1;
});
}
});
// Sort by frequency and get top 5
const topKeywords = Object.entries(keywordCounts)
.sort((a, b) => b[1] - a[1])
.slice(0, 5);
// Display
const container = document.getElementById('topKeywords');
if (topKeywords.length === 0) {
container.innerHTML = '<div class="text-neutral-400 text-xs">No keywords yet</div>';
return;
}
container.innerHTML = topKeywords.map(([keyword, count]) => {
return `
<div class="flex items-center justify-between text-neutral-600">
<span>${escapeHtml(keyword)}</span>
<span class="text-neutral-500">${count}</span>
</div>
`;
}).join('');
}
// Search functionality
document.getElementById('searchBox').addEventListener('input', (e) => {
currentSearchQuery = e.target.value.toLowerCase();
applyFilters();
});
// Sort by date
function sortByDate() {
currentSort = currentSort === 'desc' ? 'asc' : 'desc';
allItems.sort((a, b) => {
const dateA = new Date(a.date);
const dateB = new Date(b.date);
return currentSort === 'desc' ? dateB - dateA : dateA - dateB;
});
// Update sort indicator
document.getElementById('sortIndicator').textContent = currentSort === 'desc' ? '▼' : '▲';
applyFilters();
}
// Load feed on page load
loadFeed();
</script>
</body>
</html>