-
Notifications
You must be signed in to change notification settings - Fork 0
/
market-analysis-rss.html
347 lines (304 loc) · 12.9 KB
/
market-analysis-rss.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-5W5SWP43');</script>
<!-- End Google Tag Manager -->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Get the latest market analysis and insights from top sources like Cointelegraph, Blockchain News, and CoinDesk. Stay updated with current trends and news.">
<title>Latest Market Analysis | Cointelegraph, Blockchain News, CoinDesk</title>
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<link rel="canonical" href="https://diego9621.github.io/market-analysis-rss.html">
<meta name="google-site-verification" content="pxUf802VTAASjqVZvlySS0cyPYUlPphLGaAmWqLu3V8">
<style>
.rss-feed-section {
max-width: 1000px;
margin: 0 auto;
padding: 2rem 1rem;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.rss-feed-section h2 {
text-align: center;
font-size: 2rem;
color: #333;
margin-bottom: 1rem;
}
.filter-bar {
width: 100%;
margin-bottom: 20px;
text-align: center;
}
.filter-bar select {
padding: 10px;
font-size: 1em;
border: 1px solid #e2e8f0;
border-radius: 5px;
}
.rss-item {
margin-bottom: 20px;
padding-bottom: 20px;
border-bottom: 1px solid #e2e8f0;
display: flex;
flex-direction: column;
}
.rss-item h3 {
margin: 0;
font-size: 1.5em;
color: #2b6cb0;
}
.rss-item h3 a {
text-decoration: none;
color: #2b6cb0;
}
.rss-item h3 a:hover {
text-decoration: underline;
}
.rss-item p {
margin: 10px 0 0;
color: #4a5568;
line-height: 1.6;
}
.rss-item img {
max-width: 100%;
height: auto;
display: block;
margin: 15px 0;
border-radius: 10px;
max-height: 300px; /* Restricting max height */
object-fit: cover; /* Ensures the image fits well */
}
.source-label {
display: flex;
align-items: center;
margin-bottom: 10px;
flex-direction: column; /* Changed to column to stack elements vertically */
}
.source-label img {
height: 40px; /* Fixed height */
object-fit: contain; /* Maintain aspect ratio */
margin-right: 0; /* Removed right margin */
margin-bottom: 5px; /* Added bottom margin */
}
.rss-item .date {
font-size: 0.9em;
color: #718096;
margin-bottom: 10px; /* Added margin bottom */
text-align: center; /* Center aligned text */
}
.load-more {
width: 100%;
max-width: 900px;
margin: 20px 0;
text-align: center;
}
.load-more button {
padding: 10px 20px;
font-size: 1em;
background-color: #2b6cb0;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
}
.load-more button:hover {
background-color: #2c5282;
}
</style>
</head>
<body>
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-5W5SWP43"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
<header>
<nav>
<ul>
<li><a href="index.html#home">Home</a></li>
<li><a href="index.html#about">About</a></li>
<li><a href="index.html#projects">Projects</a></li>
<li><a href="index.html#blog">Blog</a></li>
<li><a href="index.html#contact">Contact</a></li>
</ul>
</nav>
</header>
<main>
<section class="rss-feed-section">
<h1>Latest Market Analysis</h1>
<div class="filter-bar">
<select id="feed-filter">
<option value="all">All Sources</option>
<option value="https://cointelegraph.com/rss">Cointelegraph</option>
<option value="https://blockchain.news/RSS/">Blockchain News</option>
<option value="https://www.coindesk.com/arc/outboundfeeds/rss/">CoinDesk</option>
</select>
</div>
<div id="rss-feed"></div>
<div class="load-more">
<button id="load-more-button">Load More</button>
</div>
</section>
</main>
<footer>
<ul class="social-links">
<li><a href="https://github.com/your-profile" target="_blank"><i class="fab fa-github"></i> GitHub</a></li>
<li><a href="https://linkedin.com/in/your-profile" target="_blank"><i class="fab fa-linkedin"></i> LinkedIn</a></li>
<li><a href="https://twitter.com/your-profile" target="_blank"><i class="fab fa-twitter"></i> Twitter</a></li>
</ul>
<p>© Diego 2024 | All Rights Reserved</p>
</footer>
<script>
const sources = {
'https://cointelegraph.com/rss': {
name: 'Cointelegraph',
logo: 'https://getlogovector.com/wp-content/uploads/2019/10/cointelegraph-logo-vector.png'
},
'https://blockchain.news/RSS/': {
name: 'Blockchain News',
logo: 'https://image.blockchain.news/sharedimage/blockchain_Logo_black-02%20.jpg'
},
'https://www.coindesk.com/arc/outboundfeeds/rss/': {
name: 'CoinDesk',
logo: 'https://upload.wikimedia.org/wikipedia/commons/thumb/4/40/CoinDesk_logo.svg/640px-CoinDesk_logo.svg.png'
}
};
let allItems = [];
let displayedItems = 0;
const itemsPerPage = 5;
let selectedSource = 'all';
async function fetchRSSFeed(url) {
const proxy = 'https://api.allorigins.win/get?url=';
const response = await fetch(proxy + encodeURIComponent(url));
if (!response.ok) {
throw new Error('Network response was not ok ' + response.statusText);
}
const data = await response.json();
const parser = new DOMParser();
const xml = parser.parseFromString(data.contents, 'application/xml');
if (xml.querySelector('parsererror')) {
throw new Error('Error parsing XML');
}
return xml;
}
async function loadRSSFeeds() {
try {
const urls = Object.keys(sources);
let items = [];
for (const url of urls) {
const xml = await fetchRSSFeed(url);
const feedItems = Array.from(xml.querySelectorAll('item')).map(item => ({ item, source: sources[url], url }));
items = items.concat(feedItems);
}
// Sort items by publication date (if available)
items.sort((a, b) => {
const dateA = new Date(a.item.querySelector('pubDate')?.textContent || 0);
const dateB = new Date(b.item.querySelector('pubDate')?.textContent || 0);
return dateB - dateA;
});
allItems = items;
renderItems();
} catch (error) {
console.error('Error fetching or parsing RSS feed:', error);
document.getElementById('rss-feed').innerHTML = '<p>Failed to load RSS feed. Please try again later.</p>';
}
}
function renderItems() {
const feedContainer = document.getElementById('rss-feed');
feedContainer.innerHTML = '';
displayedItems = 0;
const filteredItems = selectedSource === 'all'
? allItems
: allItems.filter(item => item.url === selectedSource);
const itemsToShow = filteredItems.slice(displayedItems, displayedItems + itemsPerPage);
itemsToShow.forEach(({ item, source }) => {
const title = item.querySelector('title').textContent;
const link = item.querySelector('link').textContent;
let description = item.querySelector('description').textContent;
const pubDate = new Date(item.querySelector('pubDate')?.textContent).toLocaleDateString();
let image = item.querySelector('media\\:content, enclosure[type^="image"]')?.getAttribute('url');
if (!image) {
const tempDiv = document.createElement('div');
tempDiv.innerHTML = description;
image = tempDiv.querySelector('img')?.src;
}
// Remove existing "read more" if present
description = description.replace(/\(read more\)/g, '').trim();
// Append "read more" link
description += ` <a href="${link}" target="_blank">(read more)</a>`;
const itemHTML = `
<div class="rss-item">
<div class="source-label">
<img src="${source.logo}" alt="${source.name} logo">
</div>
<span class="date">${pubDate}</span>
<h3><a href="${link}" target="_blank">${title}</a></h3>
${image ? `<img src="${image}" alt="${title}">` : ''}
<p>${description.replace(/<img[^>]*>/g, '')}</p>
</div>`;
feedContainer.innerHTML += itemHTML;
displayedItems++;
});
if (displayedItems >= filteredItems.length) {
document.getElementById('load-more-button').style.display = 'none';
} else {
document.getElementById('load-more-button').style.display = 'block';
}
}
document.getElementById('feed-filter').addEventListener('change', (e) => {
selectedSource = e.target.value;
renderItems();
});
document.getElementById('load-more-button').addEventListener('click', () => {
const feedContainer = document.getElementById('rss-feed');
const filteredItems = selectedSource === 'all'
? allItems
: allItems.filter(item => item.url === selectedSource);
const itemsToShow = filteredItems.slice(displayedItems, displayedItems + itemsPerPage);
itemsToShow.forEach(({ item, source }) => {
const title = item.querySelector('title').textContent;
const link = item.querySelector('link').textContent;
let description = item.querySelector('description').textContent;
const pubDate = new Date(item.querySelector('pubDate')?.textContent).toLocaleDateString();
let image = item.querySelector('media\\:content, enclosure[type^="image"]')?.getAttribute('url');
if (!image) {
const tempDiv = document.createElement('div');
tempDiv.innerHTML = description;
image = tempDiv.querySelector('img')?.src;
}
// Remove existing "read more" if present
description = description.replace(/\(read more\)/g, '').trim();
// Append "read more" link
description += ` <a href="${link}" target="_blank">(read more)</a>`;
const itemHTML = `
<div class="rss-item">
<div class="source-label">
<img src="${source.logo}" alt="${source.name} logo">
</div>
<span class="date">${pubDate}</span>
<h3><a href="${link}" target="_blank">${title}</a></h3>
${image ? `<img src="${image}" alt="${title}">` : ''}
<p>${description.replace(/<img[^>]*>/g, '')}</p>
</div>`;
feedContainer.innerHTML += itemHTML;
displayedItems++;
});
if (displayedItems >= filteredItems.length) {
document.getElementById('load-more-button').style.display = 'none';
}
});
loadRSSFeeds();
</script>
</body>
</html>