broadfield-dev commited on
Commit
7e454f3
·
verified ·
1 Parent(s): d8b8e62

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +20 -196
templates/index.html CHANGED
@@ -5,147 +5,29 @@
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>News Feed Hub</title>
7
  <style>
8
- body {
9
- font-family: 'Arial', sans-serif;
10
- margin: 0;
11
- padding: 20px;
12
- background-color: #f5f5f5; /* Light grey background from screenshot */
13
- color: #333;
14
- }
15
- h1 {
16
- text-align: center;
17
- color: #2c3e50;
18
- margin-bottom: 20px;
19
- font-size: 2em;
20
- }
21
- .search-container {
22
- text-align: center;
23
- margin: 20px 0;
24
- }
25
- .search-bar {
26
- width: 50%;
27
- padding: 12px;
28
- font-size: 16px;
29
- border: 2px solid #3498db; /* Blue from screenshot */
30
- border-radius: 25px;
31
- box-shadow: 0 2px 5px rgba(0,0,0,0.1);
32
- outline: none;
33
- transition: border-color 0.3s;
34
- background-color: white;
35
- }
36
- .search-bar:focus {
37
- border-color: #2980b9;
38
- }
39
- .category-section {
40
- margin: 30px 0;
41
- }
42
- .category-title {
43
- background-color: #3498db; /* Blue header from screenshot */
44
- color: white;
45
- padding: 10px;
46
- border-radius: 5px;
47
- font-size: 1.4em;
48
- text-align: center;
49
- margin-bottom: 15px;
50
- }
51
- .tiles {
52
- display: grid;
53
- grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
54
- gap: 20px;
55
- justify-content: center;
56
- }
57
- .article-tile {
58
- background-color: white;
59
- padding: 15px;
60
- border-radius: 8px;
61
- box-shadow: 0 4px 8px rgba(0,0,0,0.1); /* Subtle shadow like screenshot */
62
- transition: transform 0.2s;
63
- overflow: hidden;
64
- border: 1px solid #e0e0e0; /* Subtle grey outline from screenshot */
65
- }
66
- .article-tile:hover {
67
- transform: scale(1.05);
68
- box-shadow: 0 6px 12px rgba(0,0,0,0.15);
69
- }
70
- .article-tile img, .article-tile svg {
71
- width: 100%;
72
- height: 150px;
73
- object-fit: cover;
74
- border-radius: 5px;
75
- }
76
- .title a {
77
- font-size: 1.1em;
78
- color: #2c3e50;
79
- text-decoration: none;
80
- display: block;
81
- margin: 10px 0;
82
- font-weight: bold;
83
- }
84
- .title a:hover {
85
- color: #3498db;
86
- }
87
- .description {
88
- color: #555;
89
- font-size: 0.9em;
90
- margin: 5px 0;
91
- line-height: 1.4;
92
- }
93
- .published {
94
- font-size: 0.8em;
95
- color: #95a5a6;
96
- margin-top: 10px;
97
- }
98
- #loading {
99
- display: none; /* Initially hidden, shown during search */
100
- position: fixed;
101
- top: 0;
102
- left: 0;
103
- width: 100%;
104
- height: 100%;
105
- background: rgba(0,0,0,0.5);
106
- z-index: 1000;
107
- }
108
- .loader {
109
- position: absolute;
110
- top: 50%;
111
- left: 50%;
112
- transform: translate(-50%, -50%);
113
- width: 50px;
114
- height: 50px;
115
- border: 5px solid #f3f3f3;
116
- border-top: 5px solid #3498db;
117
- border-radius: 50%;
118
- animation: spin 1s linear infinite;
119
- }
120
- @keyframes spin {
121
- 0% { transform: translate(-50%, -50%) rotate(0deg); }
122
- 100% { transform: translate(-50%, -50%) rotate(360deg); }
123
- }
124
- .loading-message {
125
- text-align: center;
126
- margin-top: 20px;
127
- color: #2c3e50;
128
- font-size: 1em;
129
- }
130
- .no-articles {
131
- text-align: center;
132
- color: #2c3e50;
133
- font-size: 1.2em;
134
- margin-top: 20px;
135
- }
136
  </style>
137
  </head>
138
  <body>
139
- <div id="loading"><div class="loader"></div></div>
140
  <h1>News Feed Hub</h1>
141
  <div class="search-container">
142
- <form method="POST" action="/search" id="searchForm">
143
- <input type="text" name="search" class="search-bar" placeholder="Search news semantically...">
144
  </form>
145
  </div>
146
- {% if loading_new_feeds %}
147
- <div class="loading-message">Loading new RSS feeds in the background...</div>
148
- {% endif %}
149
  {% if has_articles %}
150
  {% for category, articles in categorized_articles.items() %}
151
  <div class="category-section">
@@ -156,11 +38,9 @@
156
  {% if article.image != "svg" %}
157
  <img src="{{ article.image }}" alt="Article Image">
158
  {% else %}
159
- <svg width="100%" height="150" viewBox="0 0 300 150" xmlns="http://www.w3.org/2000/svg">
160
- <rect width="300" height="150" fill="#e0e0e0"/>
161
- <text x="50%" y="50%" text-anchor="middle" dy=".3em" font-size="20" fill="#666">
162
- No Image Available
163
- </text>
164
  </svg>
165
  {% endif %}
166
  <div class="title"><a href="{{ article.link }}" target="_blank">{{ article.title }}</a></div>
@@ -172,63 +52,7 @@
172
  </div>
173
  {% endfor %}
174
  {% else %}
175
- <div class="no-articles">No articles available. New RSS feeds are loading in the background...</div>
176
  {% endif %}
177
-
178
- <script>
179
- document.addEventListener('DOMContentLoaded', () => {
180
- const form = document.getElementById('searchForm');
181
- const loading = document.getElementById('loading');
182
-
183
- form.addEventListener('submit', (event) => {
184
- event.preventDefault();
185
- loading.style.display = 'block';
186
- fetch('/search', {
187
- method: 'POST',
188
- body: new FormData(form)
189
- })
190
- .then(response => response.text())
191
- .then(html => {
192
- document.documentElement.innerHTML = html;
193
- loading.style.display = 'none';
194
- })
195
- .catch(error => {
196
- console.error('Error:', error);
197
- loading.style.display = 'none';
198
- alert('Failed to perform search. Please try again.');
199
- });
200
- });
201
-
202
- // Poll until new feeds are loaded
203
- if ("{{ loading_new_feeds }}" === "True") {
204
- function checkNewFeeds() {
205
- fetch('/check_feeds', { timeout: 5000 }) // Add timeout to prevent hang
206
- .then(response => {
207
- if (!response.ok) throw new Error('Network response was not ok');
208
- return response.json();
209
- })
210
- .then(data => {
211
- if (data.status === "loaded") {
212
- location.reload(); // Refresh to show new articles
213
- document.querySelector('.loading-message').style.display = 'none';
214
- } else if (data.status === "error") {
215
- console.error('Error loading new feeds:', data.message);
216
- loading.style.display = 'none';
217
- alert('Failed to load new RSS feeds. Please try again.');
218
- } else {
219
- setTimeout(checkNewFeeds, 1000); // Check every second
220
- }
221
- })
222
- .catch(error => {
223
- console.error('Error checking new feeds:', error);
224
- loading.style.display = 'none';
225
- alert('Network error while loading new feeds. Please try again.');
226
- });
227
- }
228
- checkNewFeeds();
229
- document.querySelector('.loading-message').style.display = 'block';
230
- }
231
- });
232
- </script>
233
  </body>
234
  </html>
 
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>News Feed Hub</title>
7
  <style>
8
+ body { font-family: Arial, sans-serif; margin: 20px; background-color: #f5f5f5; color: #333; }
9
+ h1 { text-align: center; color: #2c3e50; }
10
+ .search-container { text-align: center; margin: 20px 0; }
11
+ .search-bar { width: 50%; padding: 10px; border: 2px solid #3498db; border-radius: 25px; }
12
+ .category-section { margin: 20px 0; }
13
+ .category-title { background-color: #3498db; color: white; padding: 10px; border-radius: 5px; }
14
+ .tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
15
+ .article-tile { background: white; padding: 15px; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
16
+ .article-tile img, .article-tile svg { width: 100%; height: 150px; object-fit: cover; border-radius: 5px; }
17
+ .title a { font-size: 1.1em; color: #2c3e50; text-decoration: none; }
18
+ .title a:hover { color: #3498db; }
19
+ .description { color: #555; font-size: 0.9em; }
20
+ .published { font-size: 0.8em; color: #95a5a6; }
21
+ .no-articles { text-align: center; color: #2c3e50; margin-top: 20px; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  </style>
23
  </head>
24
  <body>
 
25
  <h1>News Feed Hub</h1>
26
  <div class="search-container">
27
+ <form method="POST" action="/search">
28
+ <input type="text" name="search" class="search-bar" placeholder="Search news...">
29
  </form>
30
  </div>
 
 
 
31
  {% if has_articles %}
32
  {% for category, articles in categorized_articles.items() %}
33
  <div class="category-section">
 
38
  {% if article.image != "svg" %}
39
  <img src="{{ article.image }}" alt="Article Image">
40
  {% else %}
41
+ <svg width="100%" height="150" xmlns="http://www.w3.org/2000/svg">
42
+ <rect width="100%" height="100%" fill="#e0e0e0"/>
43
+ <text x="50%" y="50%" text-anchor="middle" dy=".3em" fill="#666">No Image</text>
 
 
44
  </svg>
45
  {% endif %}
46
  <div class="title"><a href="{{ article.link }}" target="_blank">{{ article.title }}</a></div>
 
52
  </div>
53
  {% endfor %}
54
  {% else %}
55
+ <div class="no-articles">No articles available yet. Try refreshing the page.</div>
56
  {% endif %}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  </body>
58
  </html>