-
Notifications
You must be signed in to change notification settings - Fork 49
/
blog.php
268 lines (243 loc) · 14.4 KB
/
blog.php
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
<?php
$currentpage = "blog.php";
include("header.php");
?>
<script>
var rssFeedUrl = 'proxy-xml.php?url=https://blog.freecad.org/feed/';
var categoryImages = {
'Development Updates': 'images/Development-Updates.avif',
'Tutorials': 'images/Tutorials.avif',
'User Story': 'images/User-Story.avif',
'Events': 'images/Events.avif',
'default': 'images/Development-Updates.avif'
};
var request = new XMLHttpRequest();
request.open('GET', rssFeedUrl, true);
request.onreadystatechange = function() {
if (request.readyState === 4 && request.status === 200) {
var parser = new DOMParser();
var rssFeed = parser.parseFromString(request.responseText, 'application/xml');
var blogItems = rssFeed.getElementsByTagName('item');
var blogHtml = '';
for (var i = 0; i < blogItems.length; i++) {
var title = blogItems[i].getElementsByTagName('title')[0].textContent;
var link = blogItems[i].getElementsByTagName('link')[0].textContent;
var description = blogItems[i].getElementsByTagName('description')[0].textContent;
var contentEncoded = blogItems[i].getElementsByTagName('content:encoded')[0]?.textContent || '';
var tempDiv = document.createElement('div');
tempDiv.innerHTML = contentEncoded;
var firstImage = tempDiv.querySelector('img');
var imageUrl = firstImage ? firstImage.src : '';
if (!imageUrl) {
var category = blogItems[i].getElementsByTagName('category')[0]?.textContent || 'default';
imageUrl = categoryImages[category] || categoryImages['default'];
}
var imageOrderClass = i % 2 === 1 ? 'order-lg-last' : '';
blogHtml += `
<section class="row section d-flex align-items-center justify-content-around rounded mb-5">
<div class="col-lg-5 rounded model-backround p-2 ${imageOrderClass}">
<img class="img-fluid" src="${imageUrl}" alt="Blog Image" loading="lazy"/>
</div>
<div class="col-lg-6 text-light text-center text-lg-start rounded text-backround">
<h3 class="section-title mt-3">${title}</h3>
<p class="section-body">
${description}
</p>
<a class="btn btn-light rounded-pill mt-3" role="button" href="${link}"><?php echo _('Learn more'); ?></a>
</div>
</section>
`;
}
document.getElementById('rss-content').innerHTML = blogHtml;
} else if (request.readyState === 4) {}
};
request.send();
</script>
<main id="main" class="container-fluid">
<div id="rss-content" >
<section class="row section d-flex align-items-center justify-content-around rounded mb-5">
<div class="col-lg-5 rounded model-backround p-2 ">
<div class="placeholder-glow">
<div class="placeholder img-fluid bg-secondary" style="width: 100%; height: 350px;"></div>
</div>
</div>
<div class="col-lg-6 text-light text-center text-lg-start rounded text-backround">
<h3 class="section-title mt-3 placeholder-glow">
<span class="placeholder col-6 bg-secondary"></span>
</h3>
<p class="section-body placeholder-glow">
<span class="placeholder col-12 bg-secondary"></span>
<span class="placeholder col-8 bg-secondary"></span>
<span class="placeholder col-10 bg-secondary"></span>
</p>
<a href="#" class="btn btn-light rounded-pill mt-3 placeholder-glow disabled placeholder col-4"></a>
</div>
</section>
<section class="row section d-flex align-items-center justify-content-around rounded mb-5">
<div class="col-lg-5 rounded model-backround p-2 order-lg-last">
<div class="placeholder-glow">
<div class="placeholder img-fluid bg-secondary" style="width: 100%; height: 350px;"></div>
</div>
</div>
<div class="col-lg-6 text-light text-center text-lg-start rounded text-backround">
<h3 class="section-title mt-3 placeholder-glow">
<span class="placeholder col-6 bg-secondary"></span>
</h3>
<p class="section-body placeholder-glow">
<span class="placeholder col-12 bg-secondary"></span>
<span class="placeholder col-8 bg-secondary"></span>
<span class="placeholder col-10 bg-secondary"></span>
</p>
<a href="#" class="btn btn-light rounded-pill mt-3 placeholder-glow disabled placeholder col-4"></a>
</div>
</section>
<section class="row section d-flex align-items-center justify-content-around rounded mb-5">
<div class="col-lg-5 rounded model-backround p-2 ">
<div class="placeholder-glow">
<div class="placeholder img-fluid bg-secondary" style="width: 100%; height: 350px;"></div>
</div>
</div>
<div class="col-lg-6 text-light text-center text-lg-start rounded text-backround">
<h3 class="section-title mt-3 placeholder-glow">
<span class="placeholder col-6 bg-secondary"></span>
</h3>
<p class="section-body placeholder-glow">
<span class="placeholder col-12 bg-secondary"></span>
<span class="placeholder col-8 bg-secondary"></span>
<span class="placeholder col-10 bg-secondary"></span>
</p>
<a href="#" class="btn btn-light rounded-pill mt-3 placeholder-glow disabled placeholder col-4"></a>
</div>
</section>
<section class="row section d-flex align-items-center justify-content-around rounded mb-5">
<div class="col-lg-5 rounded model-backround p-2 order-lg-last">
<div class="placeholder-glow">
<div class="placeholder img-fluid bg-secondary" style="width: 100%; height: 350px;"></div>
</div>
</div>
<div class="col-lg-6 text-light text-center text-lg-start rounded text-backround">
<h3 class="section-title mt-3 placeholder-glow">
<span class="placeholder col-6 bg-secondary"></span>
</h3>
<p class="section-body placeholder-glow">
<span class="placeholder col-12 bg-secondary"></span>
<span class="placeholder col-8 bg-secondary"></span>
<span class="placeholder col-10 bg-secondary"></span>
</p>
<a href="#" class="btn btn-light rounded-pill mt-3 placeholder-glow disabled placeholder col-4"></a>
</div>
</section>
<section class="row section d-flex align-items-center justify-content-around rounded mb-5">
<div class="col-lg-5 rounded model-backround p-2 ">
<div class="placeholder-glow">
<div class="placeholder img-fluid bg-secondary" style="width: 100%; height: 350px;"></div>
</div>
</div>
<div class="col-lg-6 text-light text-center text-lg-start rounded text-backround">
<h3 class="section-title mt-3 placeholder-glow">
<span class="placeholder col-6 bg-secondary"></span>
</h3>
<p class="section-body placeholder-glow">
<span class="placeholder col-12 bg-secondary"></span>
<span class="placeholder col-8 bg-secondary"></span>
<span class="placeholder col-10 bg-secondary"></span>
</p>
<a href="#" class="btn btn-light rounded-pill mt-3 placeholder-glow disabled placeholder col-4"></a>
</div>
</section>
<section class="row section d-flex align-items-center justify-content-around rounded mb-5">
<div class="col-lg-5 rounded model-backround p-2 order-lg-last">
<div class="placeholder-glow">
<div class="placeholder img-fluid bg-secondary" style="width: 100%; height: 350px;"></div>
</div>
</div>
<div class="col-lg-6 text-light text-center text-lg-start rounded text-backround">
<h3 class="section-title mt-3 placeholder-glow">
<span class="placeholder col-6 bg-secondary"></span>
</h3>
<p class="section-body placeholder-glow">
<span class="placeholder col-12 bg-secondary"></span>
<span class="placeholder col-8 bg-secondary"></span>
<span class="placeholder col-10 bg-secondary"></span>
</p>
<a href="#" class="btn btn-light rounded-pill mt-3 placeholder-glow disabled placeholder col-4"></a>
</div>
</section>
<section class="row section d-flex align-items-center justify-content-around rounded mb-5">
<div class="col-lg-5 rounded model-backround p-2 ">
<div class="placeholder-glow">
<div class="placeholder img-fluid bg-secondary" style="width: 100%; height: 350px;"></div>
</div>
</div>
<div class="col-lg-6 text-light text-center text-lg-start rounded text-backround">
<h3 class="section-title mt-3 placeholder-glow">
<span class="placeholder col-6 bg-secondary"></span>
</h3>
<p class="section-body placeholder-glow">
<span class="placeholder col-12 bg-secondary"></span>
<span class="placeholder col-8 bg-secondary"></span>
<span class="placeholder col-10 bg-secondary"></span>
</p>
<a href="#" class="btn btn-light rounded-pill mt-3 placeholder-glow disabled placeholder col-4"></a>
</div>
</section>
<section class="row section d-flex align-items-center justify-content-around rounded mb-5">
<div class="col-lg-5 rounded model-backround p-2 order-lg-last">
<div class="placeholder-glow">
<div class="placeholder img-fluid bg-secondary" style="width: 100%; height: 350px;"></div>
</div>
</div>
<div class="col-lg-6 text-light text-center text-lg-start rounded text-backround">
<h3 class="section-title mt-3 placeholder-glow">
<span class="placeholder col-6 bg-secondary"></span>
</h3>
<p class="section-body placeholder-glow">
<span class="placeholder col-12 bg-secondary"></span>
<span class="placeholder col-8 bg-secondary"></span>
<span class="placeholder col-10 bg-secondary"></span>
</p>
<a href="#" class="btn btn-light rounded-pill mt-3 placeholder-glow disabled placeholder col-4"></a>
</div>
</section>
<section class="row section d-flex align-items-center justify-content-around rounded mb-5">
<div class="col-lg-5 rounded model-backround p-2 ">
<div class="placeholder-glow">
<div class="placeholder img-fluid bg-secondary" style="width: 100%; height: 350px;"></div>
</div>
</div>
<div class="col-lg-6 text-light text-center text-lg-start rounded text-backround">
<h3 class="section-title mt-3 placeholder-glow">
<span class="placeholder col-6 bg-secondary"></span>
</h3>
<p class="section-body placeholder-glow">
<span class="placeholder col-12 bg-secondary"></span>
<span class="placeholder col-8 bg-secondary"></span>
<span class="placeholder col-10 bg-secondary"></span>
</p>
<a href="#" class="btn btn-light rounded-pill mt-3 placeholder-glow disabled placeholder col-4"></a>
</div>
</section>
<section class="row section d-flex align-items-center justify-content-around rounded mb-5">
<div class="col-lg-5 rounded model-backround p-2 order-lg-last">
<div class="placeholder-glow">
<div class="placeholder img-fluid bg-secondary" style="width: 100%; height: 350px;"></div>
</div>
</div>
<div class="col-lg-6 text-light text-center text-lg-start rounded text-backround">
<h3 class="section-title mt-3 placeholder-glow">
<span class="placeholder col-6 bg-secondary"></span>
</h3>
<p class="section-body placeholder-glow">
<span class="placeholder col-12 bg-secondary"></span>
<span class="placeholder col-8 bg-secondary"></span>
<span class="placeholder col-10 bg-secondary"></span>
</p>
<a href="#" class="btn btn-light rounded-pill mt-3 placeholder-glow disabled placeholder col-4"></a>
</div>
</section>
</div>
<div class="text-center">
<a class="btn btn-light rounded-pill mt-3 " role="button" href="https://blog.freecad.org/page/2/"><?php echo _('All Blogs'); ?></a>
</div>
</main>
<?php include 'footer.php'; ?>