-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
271 lines (234 loc) · 9.75 KB
/
index.html
File metadata and controls
271 lines (234 loc) · 9.75 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BD Trending - কী চলছে বাংলাদেশে?</title>
<style>
/* Basic Reset & Fonts */
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
margin: 0;
background-color: #f4f7f6;
color: #333;
}
/* Header Styling */
header {
background-color: #ffffff;
padding: 1rem 2rem;
border-bottom: 1px solid #ddd;
display: flex;
justify-content: space-between;
align-items: center;
position: sticky;
top: 0;
z-index: 1000;
}
header h1 {
margin: 0;
font-size: 1.5rem;
color: #1a1a1a;
}
header a.admin-login {
text-decoration: none;
color: #007bff;
font-weight: 500;
}
/* Main Container */
.container {
max-width: 1200px;
margin: 1.5rem auto;
padding: 0 1rem;
}
/* Tabs for Platforms */
.tabs {
display: flex;
flex-wrap: wrap;
border-bottom: 2px solid #ddd;
margin-bottom: 1.5rem;
}
.tab {
padding: 0.8rem 1.2rem;
cursor: pointer;
border: none;
background: none;
font-size: 1rem;
font-weight: 500;
color: #555;
position: relative;
transition: color 0.2s;
}
.tab:hover {
color: #000;
}
.tab.active {
color: #007bff;
border-bottom: 3px solid #007bff;
}
/* Trending Items Grid */
.trending-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 1.5rem;
}
.card {
background-color: #fff;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0,0,0,0.08);
overflow: hidden;
transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover {
transform: translateY(-5px);
box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}
.card a {
text-decoration: none;
color: inherit;
display: block;
padding: 1.2rem;
}
.card h3 {
margin: 0 0 0.5rem 0;
font-size: 1.1rem;
line-height: 1.4;
}
.card .meta {
font-size: 0.85rem;
color: #777;
display: flex;
align-items: center;
gap: 0.5rem;
}
.card .source-icon {
width: 16px;
height: 16px;
}
/* Loading Spinner */
.loader {
text-align: center;
padding: 3rem;
font-size: 1.2rem;
}
/* Responsive Design */
@media (max-width: 600px) {
header {
flex-direction: column;
gap: 0.5rem;
padding: 1rem;
}
.tabs {
justify-content: center;
}
}
</style>
</head>
<body>
<header>
<h1>BD Trending</h1>
<a href="/admin.html" class="admin-login">Admin Login</a>
</header>
<main class="container">
<!-- Platform Tabs -->
<nav class="tabs">
<button class="tab active" data-platform="all">All</button>
<button class="tab" data-platform="youtube">YouTube</button>
<button class="tab" data-platform="facebook">Facebook</button>
<button class="tab" data-platform="x">X (Twitter)</button>
<button class="tab" data-platform="tiktok">TikTok</button>
<button class="tab" data-platform="rss">News</button>
</nav>
<!-- Category Filter (Optional) -->
<!-- You can add a dropdown here for categories like 'politics', 'sports', etc. -->
<!-- Content Area -->
<div id="trending-content" class="trending-grid">
<!-- JavaScript will populate this area -->
<div class="loader">Loading trending topics...</div>
</div>
</main>
<script>
// Placeholder data to show the design without API connection
const placeholderData = [
{ url: '#', title: 'নির্বাচনকে সামনে রেখে রাজনৈতিক দলগুলোর প্রস্তুতি', source: 'rss:The Daily Star', publishedAt: '2025-09-05T10:30:00Z' },
{ url: '#', title: 'BPL 2025: Player Draft Highlights and Team Analysis', source: 'youtube', publishedAt: '2025-09-05T09:00:00Z' },
{ url: '#', title: 'ঢাকা মেট্রো রেলের নতুন রুট উদ্বোধন করলেন প্রধানমন্ত্রী', source: 'facebook', publishedAt: '2025-09-05T12:00:00Z' },
{ url: '#', title: 'Trending hashtag #DhakaLife goes viral on X', source: 'x', publishedAt: '2025-09-05T11:45:00Z' },
{ url: '#', title: 'নতুন আইফোন নিয়ে বাংলাদেশের প্রযুক্তিপ্রেমীদের মধ্যে উত্তেজনা', source: 'rss:bdnews24', publishedAt: '2025-09-05T08:20:00Z' },
{ url: '#', title: 'This new food challenge is taking over TikTok in Bangladesh!', source: 'tiktok', publishedAt: '2025-09-05T13:10:00Z' },
{ url: '#', title: 'Stock market sees a major surge after policy change', source: 'facebook', publishedAt: '2025-09-05T06:55:00Z' },
{ url: '#', title: 'Shakib Al Hasan’s latest interview about the world cup', source: 'youtube', publishedAt: '2025-09-05T14:00:00Z' },
];
// Function to render items
function renderItems(items) {
const grid = document.getElementById('trending-content');
if (!items || items.length === 0) {
grid.innerHTML = '<p>No trending items found for this platform.</p>';
return;
}
grid.innerHTML = items.map(item => `
<article class="card">
<a href="${item.url}" target="_blank" rel="noopener noreferrer">
<h3>${item.title}</h3>
<div class="meta">
<img src="https://www.google.com/s2/favicons?domain=${getDomain(item.source)}" class="source-icon" alt="${item.source}">
<span>${formatSource(item.source)} · ${new Date(item.publishedAt).toLocaleString("en-BD")}</span>
</div>
</a>
</article>
`).join('');
}
function getDomain(source) {
if (source.startsWith('rss:')) return source.split(':')[1].trim().replace(/\s/g, '').toLowerCase() + '.com';
return source + '.com';
}
function formatSource(source) {
if (source.startsWith('rss:')) return source.split(':')[1].trim();
return source.charAt(0).toUpperCase() + source.slice(1);
}
// Initial render with placeholder data
document.addEventListener('DOMContentLoaded', () => {
renderItems(placeholderData);
// In a real application, you would call:
// loadTrendingData();
});
// Tab switching logic (for demo)
const tabs = document.querySelectorAll('.tab');
tabs.forEach(tab => {
tab.addEventListener('click', () => {
tabs.forEach(t => t.classList.remove('active'));
tab.classList.add('active');
const platform = tab.dataset.platform;
// In a real app, you would fetch data for the selected platform:
// loadTrendingData(platform);
// For this demo, we'll just show the same data
document.getElementById('trending-content').innerHTML = `<div class="loader">Loading ${platform} trends...</div>`;
setTimeout(() => renderItems(placeholderData), 500); // Simulate network delay
});
});
// --- REAL API FETCHING LOGIC (to be implemented) ---
/*
async function loadTrendingData(platform = 'all') {
const contentDiv = document.getElementById('trending-content');
contentDiv.innerHTML = '<div class="loader">Loading...</div>';
try {
// The API endpoint is from your Node.js server
let url = '/api/trending';
// Note: The provided backend doesn't filter by source, only by category/lang.
// You would need to modify the backend or filter on the frontend.
// For now, we fetch all and filter here.
const response = await fetch(url);
const data = await response.json();
let itemsToShow = data.items;
if (platform !== 'all') {
itemsToShow = data.items.filter(item => item.source.startsWith(platform) || (platform === 'rss' && item.source.startsWith('rss:')));
}
renderItems(itemsToShow);
} catch (error) {
console.error("Failed to load trending data:", error);
contentDiv.innerHTML = '<p>Could not load data. Please try again later.</p>';
}
}
*/
</script>
</body>
</html>