Initial commit: RSS feed dashboard aggregating YouTube, Reddit and RT

- PHP 8 + PDO SQLite cache with on-demand TTL refresh and dedup by link hash
- laminas-feed + Guzzle for RSS/Atom parsing and HTTP
- Bootstrap 5 UI with source and time-range filters, AJAX load-more
- User cron-free deployment under Apache/php-fpm; .htaccess hardening
This commit is contained in:
Harwinder Sekhon
2026-10-05 17:07:48 -04:00
commit ad4dc6b984
21 changed files with 2732 additions and 0 deletions
+124
View File
@@ -0,0 +1,124 @@
(function () {
'use strict';
var feed = document.getElementById('feed');
if (!feed) {
return;
}
var loadMoreBtn = document.getElementById('load-more');
var emptyState = document.getElementById('feed-empty');
var spinner = loadMoreBtn ? loadMoreBtn.querySelector('.spinner-border') : null;
var apiUrl = feed.dataset.api;
var source = feed.dataset.source || '';
var range = feed.dataset.range || '';
var currentPage = parseInt(feed.dataset.page, 10) || 1;
var hasMore = feed.dataset.hasMore === '1';
var loading = false;
function timeAgo(iso) {
var ts = Date.parse(iso);
if (isNaN(ts)) {
return '';
}
var diff = Math.floor((Date.now() - ts) / 1000);
if (diff < 60) {
return 'just now';
}
var units = [
[31536000, 'y'], [2592000, 'mo'], [604800, 'w'],
[86400, 'd'], [3600, 'h'], [60, 'm']
];
for (var i = 0; i < units.length; i++) {
if (diff >= units[i][0]) {
return Math.floor(diff / units[i][0]) + units[i][1] + ' ago';
}
}
return 'just now';
}
function refreshTimes() {
document.querySelectorAll('time[data-timestamp]').forEach(function (el) {
var text = timeAgo(el.dataset.timestamp);
if (text) {
el.textContent = text;
}
});
}
function setLoading(isLoading) {
if (!loadMoreBtn) {
return;
}
loadMoreBtn.disabled = isLoading;
if (spinner) {
spinner.classList.toggle('d-none', !isLoading);
}
}
function updateButton() {
if (!loadMoreBtn) {
return;
}
loadMoreBtn.classList.toggle('d-none', !hasMore);
}
function loadMore() {
if (loading || !hasMore) {
return;
}
loading = true;
setLoading(true);
var params = new URLSearchParams({ page: String(currentPage + 1) });
if (source) {
params.set('source', source);
}
if (range) {
params.set('range', range);
}
fetch(apiUrl + '?' + params.toString(), {
headers: { 'Accept': 'application/json' }
})
.then(function (response) {
if (!response.ok) {
throw new Error('HTTP ' + response.status);
}
return response.json();
})
.then(function (data) {
if (data.html) {
feed.insertAdjacentHTML('beforeend', data.html);
}
currentPage = data.page;
hasMore = Boolean(data.has_more);
feed.dataset.page = String(currentPage);
feed.dataset.hasMore = hasMore ? '1' : '0';
if (emptyState) {
emptyState.classList.toggle('d-none', data.total > 0);
}
refreshTimes();
updateButton();
})
.catch(function (error) {
console.error('Failed to load more items:', error);
})
.finally(function () {
loading = false;
setLoading(false);
});
}
if (loadMoreBtn) {
loadMoreBtn.addEventListener('click', loadMore);
}
refreshTimes();
window.setInterval(refreshTimes, 60000);
})();
+439
View File
@@ -0,0 +1,439 @@
:root {
--ink: #160b2e;
--ink-soft: #5b5178;
--bg: #f4f1ff;
--surface: #ffffff;
--line: #e6dffb;
--accent: #6a3dff;
--youtube: #ff1f4b;
--reddit: #ff6a00;
--rt: #00c389;
--sun: #ffc24b;
--display: "Space Grotesk", system-ui, sans-serif;
--body: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
--mono: "JetBrains Mono", ui-monospace, monospace;
}
/* ---------- Shell ---------- */
.app-body {
position: relative;
min-height: 100vh;
background-color: var(--bg);
color: var(--ink);
font-family: var(--body);
-webkit-font-smoothing: antialiased;
}
.app-body::before {
content: "";
position: fixed;
inset: 0;
z-index: 0;
pointer-events: none;
background:
radial-gradient(42rem 30rem at 6% -8%, rgba(106, 61, 255, 0.18), transparent 62%),
radial-gradient(36rem 26rem at 98% -4%, rgba(255, 31, 75, 0.14), transparent 60%),
radial-gradient(34rem 26rem at 52% 112%, rgba(0, 195, 137, 0.16), transparent 62%),
radial-gradient(30rem 22rem at 82% 78%, rgba(255, 106, 0, 0.12), transparent 60%);
}
.site-header,
main {
position: relative;
z-index: 1;
}
/* ---------- Header ---------- */
.site-header {
position: sticky;
top: 0;
z-index: 20;
background: rgba(255, 255, 255, 0.78);
border-bottom: 1px solid var(--line);
backdrop-filter: saturate(180%) blur(16px);
-webkit-backdrop-filter: saturate(180%) blur(16px);
}
.brand {
display: inline-flex;
align-items: center;
gap: 0.65rem;
text-decoration: none;
}
.brand-mark {
width: 26px;
height: 26px;
border-radius: 9px;
background: conic-gradient(from 220deg, var(--accent), var(--youtube), var(--reddit), var(--rt), var(--accent));
box-shadow: 0 6px 16px rgba(106, 61, 255, 0.4);
}
.brand-text {
font-family: var(--display);
font-weight: 700;
font-size: 1.12rem;
letter-spacing: -0.01em;
color: var(--ink);
}
.brand-text em {
font-style: normal;
background: linear-gradient(90deg, var(--accent), var(--youtube) 55%, var(--reddit));
-webkit-background-clip: text;
background-clip: text;
color: transparent;
}
.header-meta {
gap: 0.55rem;
font-size: 0.76rem;
color: var(--ink-soft);
}
.header-meta .sep {
opacity: 0.4;
}
.pulse {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--rt);
animation: pulse 2.2s ease-out infinite;
}
@keyframes pulse {
0% { box-shadow: 0 0 0 0 rgba(0, 195, 137, 0.55); }
70% { box-shadow: 0 0 0 9px rgba(0, 195, 137, 0); }
100% { box-shadow: 0 0 0 0 rgba(0, 195, 137, 0); }
}
.spectrum-rail {
height: 5px;
background: linear-gradient(90deg,
var(--accent), var(--youtube) 32%, var(--reddit) 60%, var(--sun) 78%, var(--rt));
}
/* ---------- Filter pills ---------- */
.filter-pills {
gap: 0.5rem;
}
.filter-pill {
--pill: var(--accent);
display: inline-flex;
align-items: center;
gap: 0.5rem;
padding: 0.42rem 0.95rem;
border-radius: 999px;
border: 1px solid var(--line);
background: rgba(255, 255, 255, 0.7);
color: var(--ink);
font-weight: 600;
font-size: 0.86rem;
text-decoration: none;
white-space: nowrap;
transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.filter-pill .pill-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--pill);
transition: background 0.15s ease;
}
.filter-pill:hover {
transform: translateY(-1px);
box-shadow: 0 8px 18px -10px var(--pill);
color: var(--ink);
}
.filter-pill.active {
background: var(--pill);
border-color: transparent;
color: #fff;
box-shadow: 0 10px 22px -10px var(--pill);
}
.filter-pill.active .pill-dot {
background: rgba(255, 255, 255, 0.9);
}
.refresh-chip {
display: inline-flex;
align-items: center;
gap: 0.4rem;
padding: 0.32rem 0.7rem;
border-radius: 999px;
background: rgba(106, 61, 255, 0.1);
color: var(--accent);
font-size: 0.72rem;
font-weight: 500;
}
/* ---------- Time range ---------- */
.toolbar-label {
font-size: 0.66rem;
letter-spacing: 0.14em;
text-transform: uppercase;
color: var(--ink-soft);
padding-right: 0.15rem;
}
.range-pills {
gap: 0.35rem;
}
.range-pill {
display: inline-flex;
align-items: center;
padding: 0.32rem 0.75rem;
border-radius: 999px;
border: 1px solid var(--line);
background: rgba(255, 255, 255, 0.7);
color: var(--ink-soft);
font-size: 0.78rem;
font-weight: 600;
text-decoration: none;
white-space: nowrap;
transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.range-pill:hover {
color: var(--ink);
border-color: var(--accent);
transform: translateY(-1px);
}
.range-pill.active {
background: var(--accent);
border-color: transparent;
color: #fff;
box-shadow: 0 10px 22px -10px var(--accent);
}
/* ---------- Cards ---------- */
.feed-card {
--src: var(--accent);
position: relative;
border: 1px solid var(--line);
border-top: 4px solid var(--src);
border-radius: 18px;
background: var(--surface);
overflow: hidden;
box-shadow: 0 1px 2px rgba(22, 11, 46, 0.04), 0 14px 34px -26px rgba(22, 11, 46, 0.5);
transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.feed-card:hover {
transform: translateY(-4px);
box-shadow: 0 20px 44px -20px rgba(22, 11, 46, 0.4);
box-shadow: 0 20px 44px -20px color-mix(in srgb, var(--src) 55%, transparent);
}
.feed-thumb-link {
position: relative;
display: block;
overflow: hidden;
background: #efeaff;
}
.feed-thumb-link::after {
content: "";
position: absolute;
inset: 0;
pointer-events: none;
background: linear-gradient(to top, rgba(22, 11, 46, 0.5), transparent 52%);
}
.feed-thumb {
width: 100%;
aspect-ratio: 16 / 9;
object-fit: cover;
display: block;
transition: transform 0.4s ease;
}
.feed-card:hover .feed-thumb {
transform: scale(1.06);
}
.thumb-tag,
.source-chip {
font-family: var(--mono);
font-size: 0.64rem;
font-weight: 600;
letter-spacing: 0.09em;
text-transform: uppercase;
color: #fff;
background: var(--src);
}
.thumb-tag {
position: absolute;
left: 0.7rem;
bottom: 0.7rem;
z-index: 1;
padding: 0.24rem 0.6rem;
border-radius: 999px;
box-shadow: 0 6px 16px -6px rgba(22, 11, 46, 0.6);
}
.source-chip {
display: inline-flex;
align-items: center;
padding: 0.2rem 0.55rem;
border-radius: 999px;
}
.feed-card .card-body {
padding: 1rem 1.1rem 1.1rem;
}
.feed-name {
font-size: 0.68rem;
letter-spacing: 0.02em;
color: var(--ink-soft);
}
.feed-card .card-title {
font-family: var(--display);
font-size: 1.02rem;
font-weight: 600;
line-height: 1.32;
}
.feed-card .card-title a {
color: var(--ink);
text-decoration: none;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
transition: color 0.15s ease;
}
.feed-card .card-title a:hover {
color: var(--src);
}
.feed-card .card-text {
font-size: 0.86rem;
line-height: 1.55;
color: var(--ink-soft);
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
}
.card-footer-meta {
border-top: 1px dashed var(--line);
}
.author {
font-size: 0.78rem;
color: var(--ink-soft);
}
.timestamp {
font-size: 0.72rem;
font-weight: 500;
color: var(--src);
}
.mono {
font-family: var(--mono);
}
/* ---------- Empty state ---------- */
.empty-state {
padding: 4.5rem 1rem;
color: var(--ink-soft);
}
.empty-mark {
width: 58px;
height: 58px;
margin: 0 auto 1rem;
border-radius: 20px;
background: conic-gradient(from 220deg, var(--accent), var(--youtube), var(--reddit), var(--rt), var(--accent));
filter: saturate(1.1);
animation: spin 12s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
.empty-title {
font-family: var(--display);
font-size: 1.15rem;
color: var(--ink);
}
/* ---------- Button ---------- */
.btn-energy {
border: 0;
border-radius: 999px;
padding: 0.7rem 1.7rem;
font-family: var(--display);
font-weight: 600;
color: #fff;
background: linear-gradient(100deg, var(--accent), var(--youtube) 48%, var(--reddit) 78%, var(--rt));
background-size: 160% 100%;
box-shadow: 0 14px 30px -14px rgba(106, 61, 255, 0.8);
transition: transform 0.15s ease, background-position 0.4s ease, box-shadow 0.15s ease;
}
.btn-energy:hover,
.btn-energy:focus {
color: #fff;
transform: translateY(-2px);
background-position: 100% 0;
box-shadow: 0 18px 36px -14px rgba(255, 31, 75, 0.7);
}
.btn-energy:disabled {
opacity: 0.65;
transform: none;
color: #fff;
}
.alert-soft {
border: 1px solid #ffe1a8;
border-radius: 14px;
background: #fff8ea;
color: #7a5a12;
}
/* ---------- Focus & motion ---------- */
a:focus-visible,
button:focus-visible {
outline: 3px solid rgba(106, 61, 255, 0.55);
outline-offset: 2px;
border-radius: 8px;
}
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
animation-duration: 0.001ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.001ms !important;
}
}