-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathblogs.html
More file actions
738 lines (602 loc) · 35.5 KB
/
Copy pathblogs.html
File metadata and controls
738 lines (602 loc) · 35.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
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
<!DOCTYPE html><html class="dark" lang="en"><head>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<link rel="icon" type="image/png" href="./Favicon.png?v=2">
<link rel="apple-touch-icon" sizes="180x180" href="./favicon_io/apple-touch-icon.png?v=1">
<link rel="icon" type="image/png" sizes="32x32" href="./favicon_io/favicon-32x32.png?v=1">
<link rel="icon" type="image/png" sizes="16x16" href="./favicon_io/favicon-16x16.png?v=1">
<link rel="manifest" href="./favicon_io/site.webmanifest?v=1">
<link href="https://fonts.googleapis.com" rel="preconnect">
<link crossorigin="" href="https://fonts.gstatic.com" rel="preconnect">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:wght,FILL@100..700,0..1&display=swap" rel="stylesheet">
<script src="https://cdn.tailwindcss.com?plugins=forms,container-queries"></script>
<script type="module" src="./assets/tailwind-theme.js"></script>
<link rel="stylesheet" href="./assets/common-styles.css">
<script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2"></script>
<title>Developer Blog | Omnikon</title>
<meta name="keywords" content="Omnikon, Open Source, Hackathons, AI, Machine Learning, Programming, Student Developers, GitHub, Developer Community, Coding, Web Development, React, Next.js, TypeScript">
<meta name="theme-color" content="#050505">
<!-- Open Graph -->
<!-- Twitter Card -->
<!-- Structured Data -->
<link rel="icon" type="image/png" sizes="192x192" href="./favicon_io/android-chrome-192x192.png?v=1">
<link rel="icon" type="image/png" sizes="512x512" href="./favicon_io/android-chrome-512x512.png?v=1">
<meta name="description" content="Read the latest technical articles, tutorials, and insights from the Omnikon blog.">
<link rel="canonical" href="https://omnikonhub.com/blogs.html">
<meta property="og:title" content="Developer Blog | Omnikon">
<meta property="og:description" content="Read the latest technical articles, tutorials, and insights from the Omnikon blog.">
<meta property="og:url" content="https://omnikonhub.com/blogs.html">
<meta property="og:type" content="website">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Developer Blog | Omnikon">
<meta name="twitter:description" content="Read the latest technical articles, tutorials, and insights from the Omnikon blog.">
<meta name="robots" content="index, follow">
<meta name="view-transition" content="same-origin">
<link rel="stylesheet" href="./assets/hackathon-window.css">
<script type="module" src="./assets/hackathon-window.js"></script><script type="application/ld+json">[
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "Home",
"item": "https://omnikonhub.com/"
},
{
"@type": "ListItem",
"position": 2,
"name": "Developer Blog",
"item": "https://omnikonhub.com/blogs.html"
}
]
},
{
"@context": "https://schema.org",
"@type": "Blog",
"name": "Developer Blog | Omnikon"
}
]</script><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8663425706426895" crossorigin="anonymous"></script></head><body class="text-on-surface antialiased min-h-screen flex flex-col selection:bg-primary selection:text-background grid-bg">
<header class="bg-background dark:bg-background border-b border-surface-variant sticky top-0 z-50 w-full shadow-[0_4px_24px_rgba(0,0,0,0.4)]">
<div class="flex justify-between items-center w-full px-gutter py-4 max-w-container-max mx-auto">
<a class="text-headline-md font-headline-md font-bold text-on-surface dark:text-on-surface tracking-tight hover:text-primary transition-colors flex items-center gap-2" href="./index.html">
<span class="text-primary font-code-sm text-code-sm">>_</span>
Omnikon
</a>
<nav class="hidden md:flex items-center gap-6">
<a class="text-on-surface-variant hover:text-on-surface hover:bg-surface-container-high transition-colors duration-200 text-label-mono font-label-mono px-3 py-2 rounded-DEFAULT" href="./index.html">Home</a>
<a class="text-on-surface-variant hover:text-on-surface hover:bg-surface-container-high transition-colors duration-200 text-label-mono font-label-mono px-3 py-2 rounded-DEFAULT" href="./faqs.html">FAQs</a>
<a class="text-on-surface-variant hover:text-on-surface hover:bg-surface-container-high transition-colors duration-200 text-label-mono font-label-mono px-3 py-2 rounded-DEFAULT" href="./guidelines.html">Guidelines</a>
<a class="text-on-surface-variant hover:text-on-surface hover:bg-surface-container-high transition-colors duration-200 text-label-mono font-label-mono px-3 py-2 rounded-DEFAULT" href="./codeOfConduct.html">Code of Conduct</a>
<a class="text-primary border-b-2 border-primary pb-1 scale-95 duration-100 text-label-mono font-label-mono px-3 py-2" href="./blogs.html">Blogs</a>
<a class="text-on-surface-variant hover:text-on-surface hover:bg-surface-container-high transition-colors duration-200 text-label-mono font-label-mono px-3 py-2 rounded-DEFAULT" href="./licence.html">License</a>
</nav>
<div class="hidden md:flex">
<a class="bg-primary text-background font-label-mono text-label-mono px-4 py-2 hover:shadow-[0_0_12px_rgba(255,49,49,0.4)] transition-all flex items-center gap-2 group" href="https://github.com/Omnikon-Org" target="_blank">
<span class="material-symbols-outlined text-[18px] group-hover:scale-110 transition-transform" data-icon="star" data-weight="fill" style="font-variation-settings: 'FILL' 1;">star</span>
Star on GitHub
</a>
</div>
<button class="md:hidden text-primary p-2 border border-surface-variant rounded-DEFAULT" aria-label="menu">
<span class="material-symbols-outlined" data-icon="menu">menu</span>
</button>
</div>
</header>
<main class="flex-grow w-full max-w-container-max mx-auto px-margin-mobile md:px-gutter py-section-gap flex flex-col gap-10"><nav class="breadcrumbs-ui py-4 max-w-container-max mx-auto px-gutter text-sm text-on-surface-variant" aria-label="breadcrumb"><a href="index.html" class="hover:text-primary">Home</a> > <span>Developer Blog</span></nav>
<header class="flex flex-col md:flex-row justify-between items-start md:items-end gap-6 border-b border-surface-variant pb-8 relative">
<div class="absolute -left-4 top-0 h-full w-[2px] bg-surface-variant"></div>
<div class="absolute -left-4 top-0 h-8 w-[2px] bg-primary animate-pulse-glow"></div>
<div class="space-y-4">
<div class="flex items-center gap-3">
<div class="h-2 w-2 rounded-full bg-primary animate-pulse-glow"></div>
<span class="text-primary font-code-sm text-code-sm uppercase tracking-widest opacity-80">SYS.BLOG.INIT</span>
</div>
<h1 class="text-3xl sm:text-4xl lg:text-display-lg font-display-lg text-on-surface font-bold terminal-cursor">Blogs & Articles</h1>
<p class="font-body-base text-body-base text-on-surface-variant max-w-2xl">
Insights, tutorials, project updates, and developer stories from the Omnikon community.
</p>
</div>
<button id="add-blog-btn" class="hidden bg-primary text-background font-label-mono text-label-mono px-6 py-3 hover:shadow-[0_0_15px_rgba(255,49,49,0.5)] transition-all items-center gap-2 border border-primary font-bold" aria-label="add
Add Blog">
<span class="material-symbols-outlined text-sm">add</span>
Add Blog
</button>
</header>
<section class="grid grid-cols-1 md:grid-cols-3 gap-6 border border-surface-variant bg-surface-container-low p-6">
<div class="flex items-center gap-4 p-4 border-r border-surface-variant/30 last:border-none">
<div class="w-12 h-12 border border-primary/30 flex items-center justify-center text-primary bg-primary/5 rounded-full">
<span class="material-symbols-outlined">description</span>
</div>
<div>
<div id="stat-articles" class="text-headline-md font-bold text-on-surface">0</div>
<div class="text-code-sm font-code-sm text-on-surface-variant uppercase tracking-wider">Total Articles</div>
</div>
</div>
<div class="flex items-center gap-4 p-4 border-r border-surface-variant/30 last:border-none">
<div class="w-12 h-12 border border-primary/30 flex items-center justify-center text-primary bg-primary/5 rounded-full">
<span class="material-symbols-outlined">person</span>
</div>
<div>
<div id="stat-authors" class="text-headline-md font-bold text-on-surface">0</div>
<div class="text-code-sm font-code-sm text-on-surface-variant uppercase tracking-wider">Total Authors</div>
</div>
</div>
<div class="flex items-center gap-4 p-4 last:border-none">
<div class="w-12 h-12 border border-primary/30 flex items-center justify-center text-primary bg-primary/5 rounded-full">
<span class="material-symbols-outlined">rss_feed</span>
</div>
<div>
<div id="stat-platforms" class="text-headline-md font-bold text-on-surface">0</div>
<div class="text-code-sm font-code-sm text-on-surface-variant uppercase tracking-wider">Platforms</div>
</div>
</div>
</section>
<section class="flex flex-col md:flex-row justify-between items-center gap-4 bg-surface-container-lowest border border-surface-variant p-4">
<div class="flex items-center gap-2 border border-surface-variant px-3 py-2 w-full md:max-w-md focus-within:border-primary/70 transition-colors">
<span class="material-symbols-outlined text-on-surface-variant text-sm">search</span>
<input id="search-input" type="text" placeholder="Search by title, description, or author..." class="bg-transparent text-on-surface outline-none border-none p-0 text-sm w-full focus:ring-0">
</div>
<div class="flex gap-4 w-full md:w-auto">
<select id="platform-filter" class="bg-surface-container border border-surface-variant text-on-surface px-4 py-2 text-sm focus:border-primary outline-none cursor-pointer flex-1 md:flex-none">
<option value="all">All Platforms</option>
<option value="Dev.to">Dev.to</option>
<option value="Hashnode">Hashnode</option>
<option value="Medium">Medium</option>
<option value="Substack">Substack</option>
<option value="GitHub Pages">GitHub Pages</option>
<option value="Personal Blog">Personal Blog</option>
</select>
<select id="date-sort" class="bg-surface-container border border-surface-variant text-on-surface px-4 py-2 text-sm focus:border-primary outline-none cursor-pointer flex-1 md:flex-none">
<option value="desc">Newest First</option>
<option value="asc">Oldest First</option>
</select>
</div>
</section>
<section id="loading-state" class="flex flex-col items-center justify-center py-20 gap-4">
<div class="h-10 w-10 border-2 border-t-primary border-surface-variant rounded-full animate-spin"></div>
<p class="font-code-sm text-code-sm text-on-surface-variant">Loading article indexes...</p>
</section>
<section id="empty-state" class="hidden flex flex-col items-center justify-center py-20 text-center border border-dashed border-surface-variant p-10">
<span class="material-symbols-outlined text-primary text-5xl mb-4">post_add</span>
<h3 class="text-headline-md font-bold text-on-surface mb-2">No Articles Listed</h3>
<p class="text-on-surface-variant font-body-base text-sm max-w-sm mb-6">
Be the first to share knowledge with the Omnikon community.
</p>
<button onclick="openModal()" class="bg-primary text-background font-label-mono text-label-mono px-4 py-2 border border-primary hover:shadow-[0_0_12px_rgba(255,49,49,0.4)] transition-all" aria-label="Share an Article">
Share an Article
</button>
</section>
<section id="articles-grid" class="hidden grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"></section>
</main>
<div id="add-modal" class="fixed inset-0 bg-background/80 backdrop-blur-md z-[100] hidden items-center justify-center p-4">
<div class="bg-surface border border-surface-variant w-full max-w-lg p-6 flex flex-col gap-6 relative shadow-[0_12px_40px_rgba(0,0,0,0.8)]">
<div class="flex justify-between items-center border-b border-surface-variant pb-4">
<span class="text-on-surface font-label-mono text-sm tracking-widest font-bold">ADD NEW ARTICLE</span>
<button onclick="closeModal()" class="text-on-surface-variant hover:text-primary transition-colors" aria-label="close">
<span class="material-symbols-outlined text-sm">close</span>
</button>
</div>
<div id="modal-scrape-phase" class="flex flex-col gap-4">
<div class="space-y-2">
<label class="text-code-sm font-code-sm text-on-surface-variant block">ARTICLE URL</label>
<input id="input-url" type="url" placeholder="https://dev.to/username/my-awesome-article" class="w-full bg-surface-container-low border border-surface-variant p-3 text-on-surface text-sm outline-none focus:border-primary">
</div>
<div class="space-y-2">
<label class="text-code-sm font-code-sm text-on-surface-variant block">ADMIN SECRET</label>
<input id="input-secret" type="password" placeholder="Enter admin key to authorize insert" class="w-full bg-surface-container-low border border-surface-variant p-3 text-on-surface text-sm outline-none focus:border-primary">
</div>
<button id="modal-btn-next" onclick="scrapeMetadata()" class="bg-primary text-background font-label-mono text-label-mono py-3 font-bold flex items-center justify-center gap-2 hover:shadow-[0_0_12px_rgba(255,49,49,0.4)] transition-all" aria-label="troubleshoot
Scrape Metadata">
<span class="material-symbols-outlined text-sm">troubleshoot</span>
Scrape Metadata
</button>
</div>
<div id="modal-loading-phase" class="hidden flex flex-col items-center justify-center py-10 gap-4">
<div class="h-8 w-8 border-2 border-t-primary border-surface-variant rounded-full animate-spin"></div>
<p class="font-code-sm text-code-sm text-on-surface-variant">Parsing metadata server-side...</p>
</div>
<div id="modal-preview-phase" class="hidden flex flex-col gap-4 max-h-[60vh] overflow-y-auto pr-1">
<div class="border border-surface-variant p-3 bg-surface-container-lowest text-xs text-primary font-code-sm flex items-center gap-2 mb-2">
<span class="material-symbols-outlined text-sm">info</span>
Please review extracted metadata before saving.
</div>
<div class="space-y-2">
<label class="text-code-sm font-code-sm text-on-surface-variant block">TITLE</label>
<input id="preview-title" type="text" class="w-full bg-surface-container-low border border-surface-variant p-2.5 text-on-surface text-sm outline-none focus:border-primary">
</div>
<div class="space-y-2">
<label class="text-code-sm font-code-sm text-on-surface-variant block">DESCRIPTION</label>
<textarea id="preview-desc" rows="3" class="w-full bg-surface-container-low border border-surface-variant p-2.5 text-on-surface text-sm outline-none focus:border-primary resize-none"></textarea>
</div>
<div class="grid grid-cols-2 gap-4">
<div class="space-y-2">
<label class="text-code-sm font-code-sm text-on-surface-variant block">AUTHOR</label>
<input id="preview-author" type="text" class="w-full bg-surface-container-low border border-surface-variant p-2.5 text-on-surface text-sm outline-none focus:border-primary">
</div>
<div class="space-y-2">
<label class="text-code-sm font-code-sm text-on-surface-variant block">PLATFORM</label>
<select id="preview-platform" class="w-full bg-surface-container-low border border-surface-variant p-2.5 text-on-surface text-sm outline-none focus:border-primary">
<option value="Dev.to">Dev.to</option>
<option value="Hashnode">Hashnode</option>
<option value="Medium">Medium</option>
<option value="Substack">Substack</option>
<option value="GitHub Pages">GitHub Pages</option>
<option value="Personal Blog">Personal Blog</option>
</select>
</div>
</div>
<div class="space-y-2">
<label class="text-code-sm font-code-sm text-on-surface-variant block">FEATURED IMAGE URL</label>
<input id="preview-image" type="text" class="w-full bg-surface-container-low border border-surface-variant p-2.5 text-on-surface text-sm outline-none focus:border-primary">
</div>
<button id="modal-btn-save" onclick="saveBlog()" class="bg-primary text-background font-label-mono text-label-mono py-3 font-bold mt-2 hover:shadow-[0_0_15px_rgba(255,49,49,0.5)] transition-all" aria-label="Publish Article">
Publish Article
</button>
</div>
<div id="modal-error" class="hidden text-xs text-error bg-error/10 border border-error/20 p-3 flex items-center gap-2">
<span class="material-symbols-outlined text-sm">warning</span>
<span id="modal-error-text">Failed to perform action</span>
</div>
</div>
</div>
<footer class="bg-background dark:bg-background border-t border-surface-variant relative z-10 py-6 sm:py-8 md:py-12 mt-auto">
<div class="max-w-container-max mx-auto px-4 sm:px-gutter grid grid-cols-2 md:grid-cols-4 gap-6 sm:gap-8">
<div>
<h3 class="text-lg sm:text-xl font-bold mb-2 sm:mb-4">Omnikon</h3>
<p class="text-on-surface-variant text-xs sm:text-sm">Open Source Community for Developers.</p>
</div>
<div>
<h3 class="font-bold text-sm sm:text-base mb-2 sm:mb-4">Pages</h3>
<ul class="space-y-1.5 sm:space-y-2 text-xs sm:text-sm">
<li><a href="index.html" class="hover:text-primary transition-colors">Home</a></li>
<li><a href="javascript:void(0)" onclick="window.openHackathonWindow()" class="hover:text-primary transition-colors">Hackathon</a></li>
<li><a href="projects.html" class="hover:text-primary transition-colors">Projects</a></li>
<li><a href="blogs.html" class="hover:text-primary transition-colors">Blog</a></li>
</ul>
</div>
<div>
<h3 class="font-bold text-sm sm:text-base mb-2 sm:mb-4">Community</h3>
<ul class="space-y-1.5 sm:space-y-2 text-xs sm:text-sm">
<li><a href="members.html" class="hover:text-primary transition-colors">Members</a></li>
<li><a href="achievements.html" class="hover:text-primary transition-colors">Community</a></li>
<li><a href="docs.html" class="hover:text-primary transition-colors">Docs</a></li>
<li><a href="about.html" class="hover:text-primary transition-colors">About</a></li>
<li><a href="contact.html" class="hover:text-primary transition-colors">Contact</a></li>
</ul>
</div>
<div>
<h3 class="font-bold text-sm sm:text-base mb-2 sm:mb-4">Socials</h3>
<ul class="space-y-1.5 sm:space-y-2 text-xs sm:text-sm">
<li><a href="https://github.com/Omnikon-Org" target="_blank" class="hover:text-primary transition-colors">GitHub</a></li>
<li><a href="https://discord.gg/yWtjK2Tb8T" target="_blank" class="hover:text-primary transition-colors">Discord</a></li>
<li><a href="#" target="_blank" class="hover:text-primary transition-colors">LinkedIn</a></li>
</ul>
</div>
</div>
</footer>
<script>
window.env = {};
(async function() {
try {
const responseJson = await fetch('env-public.json');
if (responseJson.ok) {
window.env = await responseJson.json();
}
try {
const responseEnv = await fetch('.env');
if (responseEnv.ok) {
const text = await responseEnv.text();
text.split('').forEach(line => {
const parts = line.split('=');
if (parts.length >= 2) {
const key = parts[0].trim();
const val = parts.slice(1).join('=').trim().replace(/^["']|["']$/g, '');
window.env[key] = val;
}
});
}
} catch(err) { /* .env missing on prod */ }
} catch (e) {
console.warn('Environment loading error:', e);
} finally {
window.envLoaded = true;
window.dispatchEvent(new CustomEvent('envLoaded'));
}
})();
</script>
<script>
let supabaseClient = null;
let allBlogs = [];
let currentScrapedBlog = null;
// Load admin secret from localStorage if exists
document.addEventListener('DOMContentLoaded', () => {
const savedSecret = localStorage.getItem('omnikon_admin_secret');
if (savedSecret) {
document.getElementById('input-secret').value = savedSecret;
}
});
// Listen to Env Loaded Event to initialize Supabase
window.addEventListener('envLoaded', () => {
const supabaseUrl = window.env?.SUPABASE_URL || window.env?.NEXT_PUBLIC_SUPABASE_URL;
const supabaseAnonKey = window.env?.SUPABASE_ANON_KEY || window.env?.NEXT_PUBLIC_SUPABASE_ANON_KEY;
if (!supabaseUrl || !supabaseAnonKey) {
console.error('Supabase credentials missing.');
showErrorState('Supabase client credentials are not configured in your environments.');
document.getElementById('loading-state').classList.add('hidden');
return;
}
try {
let normalizedUrl = supabaseUrl.trim();
if (normalizedUrl.endsWith('/rest/v1/')) {
normalizedUrl = normalizedUrl.slice(0, -9);
} else if (normalizedUrl.endsWith('/rest/v1')) {
normalizedUrl = normalizedUrl.slice(0, -8);
}
supabaseClient = supabase.createClient(normalizedUrl, supabaseAnonKey);
fetchBlogs();
} catch (e) {
console.error('Supabase initialization failed:', e);
showErrorState('Failed to initialize connection to Supabase.');
}
});
// Fetch blogs from Supabase
async function fetchBlogs() {
if (!supabaseClient) return;
try {
const { data, error } = await supabaseClient
.from('blogs')
.select('*')
.order('published_at', { ascending: false });
if (error) throw error;
allBlogs = data || [];
renderBlogs();
} catch (e) {
console.error('Failed to retrieve blogs:', e);
showErrorState('Could not retrieve articles from database index.');
}
}
// Render articles & statistics
function renderBlogs() {
document.getElementById('loading-state').classList.add('hidden');
// Update stats
const articlesCount = allBlogs.length;
const authors = new Set(allBlogs.map(b => b.author.trim()));
const platforms = new Set(allBlogs.map(b => b.platform.trim()));
animateCounter('stat-articles', articlesCount);
animateCounter('stat-authors', authors.size);
animateCounter('stat-platforms', platforms.size);
if (articlesCount === 0) {
document.getElementById('empty-state').classList.remove('hidden');
document.getElementById('articles-grid').classList.add('hidden');
return;
}
document.getElementById('empty-state').classList.add('hidden');
document.getElementById('articles-grid').classList.remove('hidden');
// Apply filters & search
const searchQuery = document.getElementById('search-input').value.toLowerCase().trim();
const platformFilter = document.getElementById('platform-filter').value;
const dateSort = document.getElementById('date-sort').value;
let filtered = [...allBlogs];
if (searchQuery) {
filtered = filtered.filter(b =>
b.title.toLowerCase().includes(searchQuery) ||
(b.description && b.description.toLowerCase().includes(searchQuery)) ||
b.author.toLowerCase().includes(searchQuery)
);
}
if (platformFilter !== 'all') {
filtered = filtered.filter(b => b.platform === platformFilter);
}
filtered.sort((a, b) => {
const dateA = new Date(a.published_at || a.created_at).getTime();
const dateB = new Date(b.published_at || b.created_at).getTime();
return dateSort === 'desc' ? dateB - dateA : dateA - dateB;
});
// Generate Cards Grid
const grid = document.getElementById('articles-grid');
grid.innerHTML = '';
if (filtered.length === 0) {
grid.innerHTML = `<div class="col-span-full py-10 text-center font-code-sm text-code-sm text-on-surface-variant">No matching articles found.</div>`;
return;
}
filtered.forEach(blog => {
const card = document.createElement('article');
card.className = 'border border-surface-variant bg-surface-container p-4 flex flex-col gap-4 glow-hover transition-all';
// Image template fallback
const imgUrl = blog.image || './public/LogoOmnikon.jpeg';
// Platform badge styling
let badgeBg = 'bg-primary/10 border-primary/20 text-primary';
if (blog.platform === 'Dev.to') badgeBg = 'bg-neutral-800 border-neutral-700 text-neutral-200';
else if (blog.platform === 'Medium') badgeBg = 'bg-white/10 border-white/20 text-white';
else if (blog.platform === 'Hashnode') badgeBg = 'bg-blue-600/10 border-blue-500/20 text-blue-400';
else if (blog.platform === 'Substack') badgeBg = 'bg-orange-500/10 border-orange-500/20 text-orange-400';
const publishedDate = new Date(blog.published_at).toLocaleDateString('en-US', {
year: 'numeric',
month: 'short',
day: 'numeric'
});
card.innerHTML = `
<div class="h-44 w-full bg-surface-container-lowest overflow-hidden border border-surface-variant relative">
<img src="${imgUrl}" alt="${blog.title}" loading="lazy" class="w-full h-full object-cover">
<span class="absolute top-2 right-2 border px-2 py-0.5 text-[10px] font-label-mono uppercase tracking-wider ${badgeBg}">
${blog.platform}
</span>
</div>
<div class="flex flex-col gap-2 flex-grow">
<div class="flex justify-between items-center text-xs font-code-sm text-on-surface-variant">
<span>By: ${blog.author}</span>
<span>${publishedDate}</span>
</div>
<h3 class="text-on-surface font-label-mono font-bold text-sm line-clamp-2 hover:text-primary transition-colors cursor-pointer" onclick="window.open('${blog.url}', '_blank')">
${blog.title}
</h3>
<p class="text-on-surface-variant font-body-base text-xs line-clamp-3 leading-relaxed">
${blog.description || 'No description available.'}
</p>
</div>
<div class="flex items-center justify-between border-t border-surface-variant/30 pt-3">
<a href="${blog.url}" target="_blank" class="text-primary hover:underline text-xs font-label-mono flex items-center gap-1.5 uppercase font-bold">
Read Article
<span class="material-symbols-outlined text-xs">open_in_new</span>
</a>
</div>
`;
grid.appendChild(card);
});
}
// Modal Control
const modal = document.getElementById('add-modal');
function openModal() {
modal.classList.remove('hidden');
modal.classList.add('flex');
document.getElementById('input-url').focus();
}
function closeModal() {
modal.classList.add('hidden');
modal.classList.remove('flex');
resetModal();
}
function resetModal() {
document.getElementById('modal-scrape-phase').classList.remove('hidden');
document.getElementById('modal-loading-phase').classList.add('hidden');
document.getElementById('modal-preview-phase').classList.add('hidden');
document.getElementById('modal-error').classList.add('hidden');
document.getElementById('input-url').value = '';
currentScrapedBlog = null;
}
// Trigger scraping server-side
async function scrapeMetadata() {
const url = document.getElementById('input-url').value.trim();
const secret = document.getElementById('input-secret').value.trim();
if (!url) {
showModalError('Please enter a valid URL');
return;
}
// Validate secret exists
const adminSecret = window.env?.ADMIN_SECRET;
if (adminSecret && secret !== adminSecret) {
showModalError('Invalid admin authorization key.');
return;
}
// Save secret to localStorage for convenience
if (secret) {
localStorage.setItem('omnikon_admin_secret', secret);
}
document.getElementById('modal-scrape-phase').classList.add('hidden');
document.getElementById('modal-loading-phase').classList.remove('hidden');
document.getElementById('modal-error').classList.add('hidden');
try {
const scrapeUrl = `/api/scrape?url=${encodeURIComponent(url)}`;
const response = await fetch(scrapeUrl);
const data = await response.json();
if (!response.ok) {
throw new Error(data.error || 'Metadata extraction failed');
}
currentScrapedBlog = data;
populatePreview(data);
} catch (e) {
console.warn('Scraping error:', e);
// On scraping failure, fallback to manual inputs
showModalError('Automatic metadata extraction failed. Please fill details manually.');
currentScrapedBlog = { url, title: '', description: '', image: '', author: '', platform: 'Personal Blog', published_at: new Date().toISOString() };
populatePreview(currentScrapedBlog);
}
}
function populatePreview(blog) {
document.getElementById('modal-loading-phase').classList.add('hidden');
document.getElementById('modal-preview-phase').classList.remove('hidden');
document.getElementById('preview-title').value = blog.title || '';
document.getElementById('preview-desc').value = blog.description || '';
document.getElementById('preview-author').value = blog.author || '';
document.getElementById('preview-platform').value = blog.platform || 'Personal Blog';
document.getElementById('preview-image').value = blog.image || '';
}
// Insert blog into Supabase
async function saveBlog() {
if (!supabaseClient) return;
const url = currentScrapedBlog.url;
const secret = document.getElementById('input-secret').value.trim();
// Server validation/double check
const adminSecret = window.env?.ADMIN_SECRET;
if (adminSecret && secret !== adminSecret) {
showModalError('Unauthorized transaction.');
return;
}
const title = document.getElementById('preview-title').value.trim();
const description = document.getElementById('preview-desc').value.trim();
const author = document.getElementById('preview-author').value.trim();
const platform = document.getElementById('preview-platform').value;
const image = document.getElementById('preview-image').value.trim();
if (!title || !author) {
showModalError('Title and Author fields are required.');
return;
}
const payload = {
url,
title,
description,
author,
platform,
image,
published_at: currentScrapedBlog.published_at || new Date().toISOString()
};
try {
const { data, error } = await supabaseClient
.from('blogs')
.insert([payload]);
if (error) {
if (error.code === '23505') {
throw new Error('This article has already been added to the database.');
}
throw error;
}
closeModal();
fetchBlogs();
} catch (e) {
showModalError(e.message || 'Failed to save the article to database.');
}
}
// Modal error reporting
function showModalError(msg) {
document.getElementById('modal-scrape-phase').classList.remove('hidden');
document.getElementById('modal-loading-phase').classList.add('hidden');
const errArea = document.getElementById('modal-error');
errArea.classList.remove('hidden');
document.getElementById('modal-error-text').textContent = msg;
}
function showErrorState(msg) {
document.getElementById('loading-state').innerHTML = `<p class="text-error font-code-sm text-code-sm flex items-center gap-2"><span class="material-symbols-outlined text-sm">error</span> ${msg}</p>`;
}
// Animate stats counter
function animateCounter(id, targetValue) {
const el = document.getElementById(id);
if (!el) return;
let start = 0;
const duration = 800; // ms
const stepTime = Math.abs(Math.floor(duration / targetValue)) || 20;
if (targetValue === 0) {
el.textContent = '0';
return;
}
const timer = setInterval(() => {
start += 1;
el.textContent = start;
if (start >= targetValue) {
el.textContent = targetValue;
clearInterval(timer);
}
}, stepTime);
}
// Hook listeners for filters
document.getElementById('search-input').addEventListener('input', renderBlogs);
document.getElementById('platform-filter').addEventListener('change', renderBlogs);
document.getElementById('date-sort').addEventListener('change', renderBlogs);
document.getElementById('add-blog-btn').addEventListener('click', openModal);
</script>
<script src="https://www.gstatic.com/firebasejs/10.8.0/firebase-app-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/10.8.0/firebase-auth-compat.js"></script>
<script type="module" src="auth.js"></script>
<script type="module" src="./particles.js"></script>
</body></html>