-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblogpost.php
More file actions
632 lines (548 loc) · 19.5 KB
/
blogpost.php
File metadata and controls
632 lines (548 loc) · 19.5 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
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
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AKBIF - Building a Legacy of Faith</title>
<link rel="stylesheet" href="about.css">
<style>
/* Blog-specific styles */
.blog-hero {
background: linear-gradient(rgba(0,0,0,0.4), rgba(0,0,0,0.4)), url('mosque.jpg');
background-size: cover;
background-position: center;
height: 50vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
color: white;
position: relative;
margin-top: 80px;
}
.blog-hero::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: radial-gradient(circle at center, transparent 30%, rgba(0,0,0,0.3));
}
.blog-hero-content {
position: relative;
z-index: 2;
animation: fadeIn 1s ease-out;
}
.blog-hero h1 {
font-size: 3rem;
margin-bottom: 1rem;
font-weight: bold;
text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}
.blog-hero p {
font-size: 1.2rem;
opacity: 0.9;
max-width: 600px;
}
.blog-container {
max-width: 1000px;
margin: 0 auto;
padding: 4rem 2rem;
background: #f8fafc;
min-height: 100vh;
}
.blog-grid {
display: grid;
gap: 2rem;
animation: fadeIn 0.8s ease-out 0.3s both;
}
.blog-post {
background: white;
border-radius: 15px;
padding: 2rem;
box-shadow: 0 8px 25px rgba(0,0,0,0.1);
transition: all 0.3s ease;
position: relative;
overflow: hidden;
}
.blog-post::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 4px;
background: linear-gradient(90deg, #F9DC26, #1D5050);
}
.blog-post:hover {
transform: translateY(-5px);
box-shadow: 0 15px 35px rgba(0,0,0,0.15);
}
.blog-post-title {
font-size: 1.8rem;
font-weight: bold;
color: #1D5050;
margin-bottom: 1rem;
transition: color 0.3s ease;
}
.blog-post:hover .blog-post-title {
color: #F9DC26;
}
.blog-post-meta {
display: flex;
gap: 1rem;
color: #666;
font-size: 0.9rem;
margin-bottom: 1.5rem;
flex-wrap: wrap;
}
.blog-post-meta span {
display: flex;
align-items: center;
gap: 0.3rem;
}
.blog-post-excerpt {
color: #555;
line-height: 1.7;
margin-bottom: 1.5rem;
font-size: 1.1rem;
}
.blog-post-content {
color: #444;
line-height: 1.8;
font-size: 1rem;
}
.blog-post-content h1, .blog-post-content h2, .blog-post-content h3 {
color: #1D5050;
margin: 1.5rem 0 1rem 0;
}
.blog-post-content p {
margin-bottom: 1rem;
}
.blog-post-content ul, .blog-post-content ol {
margin: 1rem 0;
padding-left: 2rem;
}
.blog-post-content blockquote {
border-left: 4px solid #F9DC26;
padding-left: 1rem;
margin: 1.5rem 0;
font-style: italic;
color: #666;
}
.read-more-btn {
background: #1D5050;
color: white;
padding: 0.8rem 1.5rem;
border: none;
border-radius: 25px;
cursor: pointer;
font-weight: bold;
transition: all 0.3s ease;
position: relative;
overflow: hidden;
}
.read-more-btn::before {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg, transparent, rgba(249, 220, 38, 0.3), transparent);
transition: left 0.5s;
}
.read-more-btn:hover::before {
left: 100%;
}
.read-more-btn:hover {
background: #F9DC26;
color: #1D5050;
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(29, 80, 80, 0.3);
}
.no-posts {
text-align: center;
padding: 4rem 2rem;
color: #666;
animation: fadeIn 0.8s ease-out;
}
.no-posts h3 {
font-size: 2rem;
margin-bottom: 1rem;
color: #1D5050;
}
.loading {
text-align: center;
padding: 4rem;
animation: fadeIn 0.5s ease-out;
}
.loading-spinner {
border: 4px solid #f3f3f3;
border-top: 4px solid #F9DC26;
border-radius: 50%;
width: 50px;
height: 50px;
animation: spin 1s linear infinite;
margin: 0 auto 1rem;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.error-message {
background: #fee;
color: #c33;
padding: 1rem;
border-radius: 8px;
margin-bottom: 2rem;
border-left: 4px solid #c33;
animation: slideInLeft 0.5s ease-out;
}
/* Responsive Design */
@media (max-width: 768px) {
.nav-links {
display: none;
}
.mobile-menu-btn {
display: block;
}
.blog-hero h1 {
font-size: 2rem;
}
.blog-hero p {
font-size: 1rem;
}
.blog-container {
padding: 2rem 1rem;
}
.blog-post {
padding: 1.5rem;
}
.blog-post-title {
font-size: 1.5rem;
}
}
/* Pagination */
.pagination {
display: flex;
justify-content: center;
gap: 0.5rem;
margin-top: 3rem;
animation: fadeIn 0.8s ease-out 0.5s both;
}
.pagination button {
padding: 0.8rem 1.2rem;
border: 2px solid #1D5050;
background: white;
color: #1D5050;
border-radius: 8px;
cursor: pointer;
transition: all 0.3s ease;
font-weight: bold;
}
.pagination button:hover:not(:disabled) {
background: #1D5050;
color: white;
transform: translateY(-2px);
}
.pagination button.active {
background: #F9DC26;
border-color: #F9DC26;
color: #1D5050;
}
.pagination button:disabled {
opacity: 0.5;
cursor: not-allowed;
}
/* Back to top button */
.back-to-top {
position: fixed;
bottom: 2rem;
right: 2rem;
background: #F9DC26;
color: #1D5050;
border: none;
border-radius: 50%;
width: 50px;
height: 50px;
cursor: pointer;
transition: all 0.3s ease;
opacity: 0;
visibility: hidden;
font-size: 1.2rem;
font-weight: bold;
z-index: 100;
}
.back-to-top.visible {
opacity: 1;
visibility: visible;
}
.back-to-top:hover {
background: #1D5050;
color: #F9DC26;
transform: translateY(-3px);
box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}
</style>
</head>
<body>
<!-- Navigation -->
<nav class="navbar" id="navbar">
<div class="nav-container">
<div class="logo">
<img src="logo.png" alt="AKBIF Logo">
</div>
<ul class="nav-links" id="navLinks">
<li style="--i: 0"><a href="homepage.html">Home</a></li>
<li style="--i: 1"><a href="about.html">About Us</a></li>
<li style="--i: 2"><a href="mosqueproject.html">Project</a></li>
<li style="--i: 3"><a href="sadaqah.html">Sadaqah Jariyah</a></li>
<li style="--i: 4"><a href="gallerypage.php">Gallery</a></li>
<li style="--i: 5"><a href="blogpost.php" class="active">Updates</a></li>
<li style="--i: 6"><a href="contactUs.html">Contact Us</a></li>
</ul>
<button class="donate-btn">Donate Now</button>
<button class="mobile-menu-btn" id="mobileMenuBtn">☰</button>
</div>
</nav>
<!-- Hero Section -->
<section class="blog-hero">
<div class="blog-hero-content">
<h1>Latest Updates & News</h1>
<p>Stay informed about our latest projects, community updates, and spiritual reflections</p>
</div>
</section>
<!-- Blog Container -->
<div class="blog-container">
<!-- Loading State -->
<div id="loading" class="loading">
<div class="loading-spinner"></div>
<p>Loading latest updates...</p>
</div>
<!-- Error Message -->
<div id="error-message" class="error-message" style="display: none;">
<strong>Unable to load blog posts.</strong> Please check your connection and try again.
</div>
<!-- Blog Posts Grid -->
<div id="blog-grid" class="blog-grid" style="display: none;">
<!-- Blog posts will be loaded here -->
</div>
<!-- No Posts Message -->
<div id="no-posts" class="no-posts" style="display: none;">
<h3>📝 No Updates Yet</h3>
<p>We're working on bringing you the latest updates. Please check back soon!</p>
</div>
<!-- Pagination -->
<div id="pagination" class="pagination" style="display: none;">
<button id="prev-btn" onclick="changePage(-1)">← Previous</button>
<span id="page-info"></span>
<button id="next-btn" onclick="changePage(1)">Next →</button>
</div>
</div>
<!-- Back to Top Button -->
<button class="back-to-top" id="backToTop" onclick="scrollToTop()">↑</button>
<script>
// Global variables
let blogPosts = [];
let currentPage = 1;
const postsPerPage = 5;
let totalPages = 1;
// Initialize page
document.addEventListener('DOMContentLoaded', function() {
loadBlogPosts();
setupScrollEffects();
});
// Load blog posts from API
async function loadBlogPosts() {
try {
showLoading(true);
const response = await fetch('public-blog.php');
const result = await response.json();
if (result.success && result.data) {
blogPosts = result.data;
totalPages = Math.ceil(blogPosts.length / postsPerPage);
displayBlogPosts();
setupPagination();
} else {
showNoPosts();
}
} catch (error) {
console.error('Error loading blog posts:', error);
showError();
} finally {
showLoading(false);
}
}
// Display blog posts for current page
function displayBlogPosts() {
const container = document.getElementById('blog-grid');
if (blogPosts.length === 0) {
showNoPosts();
return;
}
const startIndex = (currentPage - 1) * postsPerPage;
const endIndex = startIndex + postsPerPage;
const currentPosts = blogPosts.slice(startIndex, endIndex);
let html = '';
currentPosts.forEach((post, index) => {
const excerpt = post.excerpt || (post.content ? stripHtml(post.content).substring(0, 200) + '...' : 'No excerpt available');
const animationDelay = index * 0.1;
html += `
<article class="blog-post" style="animation-delay: ${animationDelay}s">
<h2 class="blog-post-title">${escapeHtml(post.title || 'Untitled Post')}</h2>
<div class="blog-post-meta">
<span>👤 ${escapeHtml(post.author || 'AKBIF Team')}</span>
<span>📅 ${formatDate(post.created_at || new Date().toISOString())}</span>
<span>📖 ${estimateReadTime(post.content || '')}</span>
</div>
<div class="blog-post-excerpt">
${escapeHtml(excerpt)}
</div>
<button class="read-more-btn" onclick="expandPost(${post.id || index}, this)">
Read More
</button>
<div class="blog-post-content" id="content-${post.id || index}" style="display: none; margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid #eee;">
${post.content || '<p>Content not available.</p>'}
</div>
</article>
`;
});
container.innerHTML = html;
container.style.display = 'grid';
}
// Expand/collapse post content
function expandPost(postId, button) {
const content = document.getElementById(`content-${postId}`);
const isExpanded = content.style.display !== 'none';
if (isExpanded) {
content.style.display = 'none';
button.textContent = 'Read More';
button.style.background = '#1D5050';
button.style.color = 'white';
} else {
content.style.display = 'block';
button.textContent = 'Read Less';
button.style.background = '#F9DC26';
button.style.color = '#1D5050';
// Smooth scroll to the expanded content
setTimeout(() => {
content.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
}, 100);
}
}
// Setup pagination
function setupPagination() {
const pagination = document.getElementById('pagination');
const prevBtn = document.getElementById('prev-btn');
const nextBtn = document.getElementById('next-btn');
const pageInfo = document.getElementById('page-info');
if (totalPages <= 1) {
pagination.style.display = 'none';
return;
}
pagination.style.display = 'flex';
pageInfo.textContent = `Page ${currentPage} of ${totalPages}`;
prevBtn.disabled = currentPage === 1;
nextBtn.disabled = currentPage === totalPages;
}
// Change page
function changePage(direction) {
const newPage = currentPage + direction;
if (newPage >= 1 && newPage <= totalPages) {
currentPage = newPage;
displayBlogPosts();
setupPagination();
// Smooth scroll to top of blog container
document.querySelector('.blog-container').scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
}
// Utility functions
function showLoading(show) {
const loading = document.getElementById('loading');
const blogGrid = document.getElementById('blog-grid');
const errorMessage = document.getElementById('error-message');
const noPosts = document.getElementById('no-posts');
if (show) {
loading.style.display = 'block';
blogGrid.style.display = 'none';
errorMessage.style.display = 'none';
noPosts.style.display = 'none';
} else {
loading.style.display = 'none';
}
}
function showError() {
document.getElementById('error-message').style.display = 'block';
document.getElementById('blog-grid').style.display = 'none';
document.getElementById('no-posts').style.display = 'none';
}
function showNoPosts() {
document.getElementById('no-posts').style.display = 'block';
document.getElementById('blog-grid').style.display = 'none';
document.getElementById('error-message').style.display = 'none';
}
function escapeHtml(text) {
if (!text) return '';
const div = document.createElement('div');
div.textContent = text;
return div.innerHTML;
}
function stripHtml(html) {
if (!html) return '';
const div = document.createElement('div');
div.innerHTML = html;
return div.textContent || div.innerText || '';
}
function formatDate(dateString) {
try {
const date = new Date(dateString);
return date.toLocaleDateString('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric'
});
} catch (error) {
return 'Recently';
}
}
function estimateReadTime(content) {
if (!content) return '1 min read';
const words = stripHtml(content).split(/\s+/).length;
const minutes = Math.ceil(words / 200); // Average reading speed
return `${minutes} min read`;
}
// Scroll effects
function setupScrollEffects() {
const navbar = document.getElementById('navbar');
const backToTop = document.getElementById('backToTop');
window.addEventListener('scroll', () => {
// Navbar scroll effect
if (window.scrollY > 100) {
navbar.classList.add('scrolled');
backToTop.classList.add('visible');
} else {
navbar.classList.remove('scrolled');
backToTop.classList.remove('visible');
}
});
}
function scrollToTop() {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
}
// Mobile menu toggle (if you want to implement it)
document.getElementById('mobileMenuBtn').addEventListener('click', function() {
const navLinks = document.getElementById('navLinks');
navLinks.style.display = navLinks.style.display === 'flex' ? 'none' : 'flex';
});
</script>
</body>
</html>