-
Notifications
You must be signed in to change notification settings - Fork 2
/
index2.html
846 lines (787 loc) · 35.3 KB
/
index2.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
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
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Article List</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
ul {
list-style-type: none;
padding: 0;
}
li {
margin-bottom: 10px;
}
a {
text-decoration: none;
color: #007bff;
}
</style>
</head>
<body>
<h1>Article List</h1>
<ul id="article-list"></ul>
<script>
document.addEventListener('DOMContentLoaded', async function () {
// GitHub Gist API endpoint
const gistApiEndpoint = 'https://api.github.com/users/sh20raj/gists'; // Replace 'yourusername' with your GitHub username
const tagToFilter = 'ArticlePlanet'; // Replace with the specific tag you use for Article Planet Gists
try {
// Fetch the list of Gists
const response = await fetch(gistApiEndpoint);
const gistsData = await response.json();
// Filter Gists that contain the specified tag in their descriptions
const articleGists = gistsData.filter(gist => gist.description && gist.description.includes(tagToFilter));
// Extract relevant information from each Article Planet Gist
const articles = articleGists.map(gist => {
const title = gist.description || 'Untitled';
const gistId = gist.id;
const gistUrl = gist.html_url;
return `<li><a href="post.html?id=${gistId}" >${title}</a></li>`;
});
// Display the list of articles
document.getElementById('article-list').innerHTML = articles.join('');
} catch (error) {
console.error('Error fetching Gists:', error);
document.getElementById('article-list').innerHTML = '<li>Error loading articles.</li>';
}
});
</script>
</body>
</html>
-2-2-2H8c-1
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<meta name="description" content="" />
<meta name="author" content="" />
<link rel="icon" href="logo.png" />
<title>ArticlePlanet - Write, Learn and Share Stories with the world</title>
<!-- Bootstrap core CSS -->
<link href="assets/css/bootstrap.min.css" rel="stylesheet" />
<!-- Fonts -->
<link
href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/css?family=Righteous"
rel="stylesheet"
/>
<!-- Custom styles for this template -->
<link href="assets/css/mediumish.css" rel="stylesheet" />
</head>
<body>
<!-- Begin Nav
================================================== -->
<nav
class="navbar navbar-toggleable-md navbar-light bg-white fixed-top mediumnavigation">
<button
class="navbar-toggler navbar-toggler-right"
type="button"
data-toggle="collapse"
data-target="#navbarsExampleDefault"
aria-controls="navbarsExampleDefault"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="container">
<!-- Begin Logo -->
<a class="navbar-brand" href="index.html">
<img src="assets/img/logo.png" alt="logo" />
</a>
<!-- End Logo -->
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
<!-- Begin Menu -->
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="index.html"
>Home <span class="sr-only">(current)</span></a
>
</li>
<li class="nav-item">
<a class="nav-link" href="new/">Write</a>
</li>
<li class="nav-item">
<a id="account" class="nav-link" href="login.html">Login</a>
</li>
</ul>
<!-- End Menu -->
<!-- Begin Search -->
<form class="form-inline my-2 my-lg-0">
<input
class="form-control mr-sm-2"
type="text"
placeholder="Search"
/>
<span class="search-icon"
><svg
class="svgIcon-use"
width="25"
height="25"
viewbox="0 0 25 25"
>
<path
d="M20.067 18.933l-4.157-4.157a6 6 0 1 0-.884.884l4.157 4.157a.624.624 0 1 0 .884-.884zM6.5 11c0-2.62 2.13-4.75 4.75-4.75S16 8.38 16 11s-2.13 4.75-4.75 4.75S6.5 13.62 6.5 11z"
></path></svg></span>
</form>
<!-- End Search -->
</div>
</div>
</nav>
<!-- End Nav
================================================== -->
<!-- Begin Site Title
================================================== -->
<div class="container">
<div class="mainheading">
<h1 class="sitetitle">ArticlePlanet</h1>
<p class="lead">Write, Learn and Share Stories with the world</p>
</div>
<!-- End Site Title
================================================== -->
<!-- Begin Featured
================================================== -->
<section class="featured-posts">
<div class="section-title">
<h2><span>Featured</span></h2>
</div>
<div class="card-columns listfeaturedtag" id="postcontainer">
<!-- begin post
<div class="card">
<div class="row">
<div class="col-md-5 wrapthumbnail">
<a href="post.html">
<div class="thumbnail" style="background-image:url(assets/img/demopic/1.jpg);">
</div>
</a>
</div>
<div class="col-md-7">
<div class="card-block">
<h2 class="card-title"><a href="post.html">We're living some strange times</a></h2>
<h4 class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</h4>
<div class="metafooter">
<div class="wrapfooter">
<span class="meta-footer-thumb">
<a href="author.html"><img class="author-thumb" src="https://www.gravatar.com/avatar/e56154546cf4be74e393c62d1ae9f9d4?s=250&d=mm&r=x" alt="Sal"></a>
</span>
<span class="author-meta">
<span class="post-name"><a href="author.html">Steve</a></span><br/>
<span class="post-date">22 July 2017</span><span class="dot"></span><span class="post-read">6 min read</span>
</span>
<span class="post-read-more"><a href="post.html" title="Read Story"><svg class="svgIcon-use" width="25" height="25" viewbox="0 0 25 25"><path d="M19 6c0-1.1-.9-2-2-2H8c-1.1 0-2 .9-2 2v14.66h.012c.01.103.045.204.12.285a.5.5 0 0 0 .706.03L12.5 16.85l5.662 4.126a.508.508 0 0 0 .708-.03.5.5 0 0 0 .118-.285H19V6zm-6.838 9.97L7 19.636V6c0-.55.45-1 1-1h9c.55 0 1 .45 1 1v13.637l-5.162-3.668a.49.49 0 0 0-.676 0z" fill-rule="evenodd"></path></svg></a></span>
</div>
</div>
</div>
</div>
</div>
</div>
end post -->
</div>
</section>
<script>
document.addEventListener("DOMContentLoaded", async function () {
// GitHub Gist API endpoint
const gistApiEndpoint = "https://api.github.com/users/sh20raj/gists"; // Replace 'yourusername' with your GitHub username
const tagToFilter = "ArticlePlanet"; // Replace with the specific tag you use for Article Planet Gists
try {
// Fetch the list of Gists
const response = await fetch(gistApiEndpoint);
const gistsData = await response.json();
// Filter Gists that contain the specified tag in their descriptions
const articleGists = gistsData;
// Extract relevant information from each Article Planet Gist
const articles = await Promise.all(
articleGists.map(async (gist) => {
const title = gist.description || "Untitled";
const gistId = gist.id;
const gistUrl = gist.html_url;
// Extract date and cover URL from the Markdown content
const markdownContentResponse = await fetch(
gist.files[Object.keys(gist.files)[0]].raw_url
);
const markdownContent = await markdownContentResponse.text();
function extractMetadata(markdown) {
const match = markdown.match(/^---([\s\S]*?)---([\s\S]*)/);
const metadata = {};
if (match && match[1]) {
const metadataText = match[1].trim();
metadataText.split("\n").forEach((line) => {
const [key, ...valueParts] = line
.split(":")
.map((item) => item.trim());
metadata[key] = valueParts
.join(":")
.replace(/(^"|"$)/g, "")
.trim();
});
// Convert tags to an array
metadata.tags = metadata.tags
? metadata.tags.split(",").map((tag) => tag.trim())
: [];
}
return metadata;
}
const meta = extractMetadata(markdownContent);
console.log(meta.title);
if(!meta.ArticlePlanet){
return '';
}
function convertToRelativeDate(dateString) {
const currentDate = new Date();
const providedDate = new Date(dateString);
const timeDifferenceInSeconds = Math.floor((currentDate - providedDate) / 1000);
if (timeDifferenceInSeconds < 60) {
return 'just now';
} else if (timeDifferenceInSeconds < 3600) {
const minutes = Math.floor(timeDifferenceInSeconds / 60);
return `${minutes} minute${minutes > 1 ? 's' : ''} ago`;
} else if (timeDifferenceInSeconds < 86400) {
const hours = Math.floor(timeDifferenceInSeconds / 3600);
return `${hours} hour${hours > 1 ? 's' : ''} ago`;
} else if (timeDifferenceInSeconds < 2592000) {
const days = Math.floor(timeDifferenceInSeconds / 86400);
return `${days} day${days > 1 ? 's' : ''} ago`;
} else {
// You can add more conditions for months and years as needed
return 'more than a month ago';
}
}
let date = convertToRelativeDate(meta.datePublished);
let coverUrl = meta.cover;
console.log(coverUrl);
// Create HTML elements based on the fetched Gists
return `
<!-- begin post -->
<div class="card">
<div class="row">
<div class="col-md-5 wrapthumbnail">
<a href="post.html?id=${gistId}">
<div class="thumbnail" style="background-image:url(${coverUrl || "https://random.imagecdn.app/500/500"+"?id="+gistId});"></div>
</a>
</div>
<div class="col-md-7">
<div class="card-block">
<h2 class="card-title"><a href="post.html?id=${gistId}">${title}</a></h2>
<h4 class="card-text"></h4>
<div class="metafooter">
<div class="wrapfooter">
<span class="meta-footer-thumb">
<a href="author.html"><img class="author-thumb" src="${gist.owner.avatar_url}" alt="${gist.owner.login}"></a>
</span>
<span class="author-meta">
<span class="post-name"><a href="author.html">${gist.owner.login}</a></span><br/>
<span class="post-date">${date}</span><span class="dot"></span><span class="post-read">6 min read</span>
</span>
<span class="post-read-more"><a href="post.html?id=${gistId}" title="Read Story"><svg class="svgIcon-use" width="25" height="25" viewbox="0 0 25 25"><path d="M19 6c0-1.1-.9-2-2-2H8c-1.1 0-2 .9-2 2v14.66h.012c.01.103.045.204.12.285a.5.5 0 0 0 .706.03L12.5 16.85l5.662 4.126a.508.508 0 0 0 .708-.03.5.5 0 0 0 .118-.285H19V6zm-6.838 9.97L7 19.636V6c0-.55.45-1 1-1h9c.55 0 1 .45 1 1v13.637l-5.162-3.668a.49.49 0 0 0-.676 0z" fill-rule="evenodd"></path></svg></a></span>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- end post -->
`;
})
);
// Insert the generated HTML into the postcontainer
document.getElementById("postcontainer").innerHTML =
articles.join("");
} catch (error) {
console.error("Error fetching Gists:", error);
document.getElementById("postcontainer").innerHTML =
"<p>Error loading articles.</p>";
}
});
</script>
<!-- End Featured
================================================== -->
<!-- Begin List Posts
================================================== -->
<section class="recent-posts">
<div class="section-title">
<h2><span>All Stories</span></h2>
</div>
<div id="section2-container" class="card-columns listrecent">
<!-- begin post -->
<div class="card">
<a href="post.html">
<img class="img-fluid" src="assets/img/demopic/5.jpg" alt="" />
</a>
<div class="card-block">
<h2 class="card-title">
<a href="post.html"
>Autumn doesn't have to be nostalgic, you know?</a
>
</h2>
<h4 class="card-text">
This is a longer card with supporting text below as a natural
lead-in to additional content. This content is a little bit
longer.
</h4>
<div class="metafooter">
<div class="wrapfooter">
<span class="meta-footer-thumb">
<a href="author.html"
><img
class="author-thumb"
src="https://www.gravatar.com/avatar/e56154546cf4be74e393c62d1ae9f9d4?s=250&d=mm&r=x"
alt="Sal"
/></a>
</span>
<span class="author-meta">
<span class="post-name"><a href="author.html">Sal</a></span
><br />
<span class="post-date">22 July 2017</span
><span class="dot"></span
><span class="post-read">6 min read</span>
</span>
<span class="post-read-more"
><a href="post.html" title="Read Story"
><svg
class="svgIcon-use"
width="25"
height="25"
viewbox="0 0 25 25"
>
<path
d="M19 6c0-1.1-.9-2-2-2H8c-1.1 0-2 .9-2 2v14.66h.012c.01.103.045.204.12.285a.5.5 0 0 0 .706.03L12.5 16.85l5.662 4.126a.508.508 0 0 0 .708-.03.5.5 0 0 0 .118-.285H19V6zm-6.838 9.97L7 19.636V6c0-.55.45-1 1-1h9c.55 0 1 .45 1 1v13.637l-5.162-3.668a.49.49 0 0 0-.676 0z"
fill-rule="evenodd"
></path></svg></a
></span>
</div>
</div>
</div>
</div>
<!-- end post -->
<!-- begin post -->
<div class="card">
<a href="post.html">
<img class="img-fluid" src="assets/img/demopic/6.jpg" alt="" />
</a>
<div class="card-block">
<h2 class="card-title">
<a href="post.html">Best galleries in the world with photos</a>
</h2>
<h4 class="card-text">
This is a longer card with supporting text below as a natural
lead-in to additional content. This content is a little bit
longer.
</h4>
<div class="metafooter">
<div class="wrapfooter">
<span class="meta-footer-thumb">
<a href="author.html"
><img
class="author-thumb"
src="https://www.gravatar.com/avatar/e56154546cf4be74e393c62d1ae9f9d4?s=250&d=mm&r=x"
alt="Sal"
/></a>
</span>
<span class="author-meta">
<span class="post-name"><a href="author.html">Sal</a></span
><br />
<span class="post-date">22 July 2017</span
><span class="dot"></span
><span class="post-read">6 min read</span>
</span>
<span class="post-read-more"
><a href="post.html" title="Read Story"
><svg
class="svgIcon-use"
width="25"
height="25"
viewbox="0 0 25 25"
>
<path
d="M19 6c0-1.1-.9-2-2-2H8c-1.1 0-2 .9-2 2v14.66h.012c.01.103.045.204.12.285a.5.5 0 0 0 .706.03L12.5 16.85l5.662 4.126a.508.508 0 0 0 .708-.03.5.5 0 0 0 .118-.285H19V6zm-6.838 9.97L7 19.636V6c0-.55.45-1 1-1h9c.55 0 1 .45 1 1v13.637l-5.162-3.668a.49.49 0 0 0-.676 0z"
fill-rule="evenodd"
></path></svg></a
></span>
</div>
</div>
</div>
</div>
<!-- end post -->
<!-- begin post -->
<div class="card">
<a href="post.html">
<img class="img-fluid" src="assets/img/demopic/7.jpg" alt="" />
</a>
<div class="card-block">
<h2 class="card-title">
<a href="post.html">Little red dress and a perfect summer</a>
</h2>
<h4 class="card-text">
This is a longer card with supporting text below as a natural
lead-in to additional content. This content is a little bit
longer.
</h4>
<div class="metafooter">
<div class="wrapfooter">
<span class="meta-footer-thumb">
<a href="author.html"
><img
class="author-thumb"
src="https://www.gravatar.com/avatar/e56154546cf4be74e393c62d1ae9f9d4?s=250&d=mm&r=x"
alt="Sal"
/></a>
</span>
<span class="author-meta">
<span class="post-name"><a href="author.html">Sal</a></span
><br />
<span class="post-date">22 July 2017</span
><span class="dot"></span
><span class="post-read">6 min read</span>
</span>
<span class="post-read-more"
><a href="post.html" title="Read Story"
><svg
class="svgIcon-use"
width="25"
height="25"
viewbox="0 0 25 25"
>
<path
d="M19 6c0-1.1-.9-2-2-2H8c-1.1 0-2 .9-2 2v14.66h.012c.01.103.045.204.12.285a.5.5 0 0 0 .706.03L12.5 16.85l5.662 4.126a.508.508 0 0 0 .708-.03.5.5 0 0 0 .118-.285H19V6zm-6.838 9.97L7 19.636V6c0-.55.45-1 1-1h9c.55 0 1 .45 1 1v13.637l-5.162-3.668a.49.49 0 0 0-.676 0z"
fill-rule="evenodd"
></path></svg></a
></span>
</div>
</div>
</div>
</div>
<!-- end post -->
<!-- begin post -->
<div class="card">
<a href="post.html">
<img class="img-fluid" src="assets/img/demopic/8.jpg" alt="" />
</a>
<div class="card-block">
<h2 class="card-title">
<a href="post.html"
>Thinking outside the box can help you prosper</a
>
</h2>
<h4 class="card-text">
This is a longer card with supporting text below as a natural
lead-in to additional content. This content is a little bit
longer.
</h4>
<div class="metafooter">
<div class="wrapfooter">
<span class="meta-footer-thumb">
<a href="author.html"
><img
class="author-thumb"
src="https://www.gravatar.com/avatar/e56154546cf4be74e393c62d1ae9f9d4?s=250&d=mm&r=x"
alt="Sal"
/></a>
</span>
<span class="author-meta">
<span class="post-name"><a href="author.html">Sal</a></span
><br />
<span class="post-date">22 July 2017</span
><span class="dot"></span
><span class="post-read">6 min read</span>
</span>
<span class="post-read-more"
><a href="post.html" title="Read Story"
><svg
class="svgIcon-use"
width="25"
height="25"
viewbox="0 0 25 25"
>
<path
d="M19 6c0-1.1-.9-2-2-2H8c-1.1 0-2 .9-2 2v14.66h.012c.01.103.045.204.12.285a.5.5 0 0 0 .706.03L12.5 16.85l5.662 4.126a.508.508 0 0 0 .708-.03.5.5 0 0 0 .118-.285H19V6zm-6.838 9.97L7 19.636V6c0-.55.45-1 1-1h9c.55 0 1 .45 1 1v13.637l-5.162-3.668a.49.49 0 0 0-.676 0z"
fill-rule="evenodd"
></path></svg></a
></span>
</div>
</div>
</div>
</div>
<!-- end post -->
<!-- begin post -->
<div class="card">
<a href="post.html">
<img class="img-fluid" src="assets/img/demopic/9.jpg" alt="" />
</a>
<div class="card-block">
<h2 class="card-title">
<a href="post.html"
>10 Things you should know about choosing your house</a
>
</h2>
<h4 class="card-text">
This is a longer card with supporting text below as a natural
lead-in to additional content. This content is a little bit
longer.
</h4>
<div class="metafooter">
<div class="wrapfooter">
<span class="meta-footer-thumb">
<a href="author.html"
><img
class="author-thumb"
src="https://www.gravatar.com/avatar/e56154546cf4be74e393c62d1ae9f9d4?s=250&d=mm&r=x"
alt="Sal"
/></a>
</span>
<span class="author-meta">
<span class="post-name"><a href="author.html">Sal</a></span
><br />
<span class="post-date">22 July 2017</span
><span class="dot"></span
><span class="post-read">6 min read</span>
</span>
<span class="post-read-more"
><a href="post.html" title="Read Story"
><svg
class="svgIcon-use"
width="25"
height="25"
viewbox="0 0 25 25"
>
<path
d="M19 6c0-1.1-.9-2-2-2H8c-1.1 0-2 .9-2 2v14.66h.012c.01.103.045.204.12.285a.5.5 0 0 0 .706.03L12.5 16.85l5.662 4.126a.508.508 0 0 0 .708-.03.5.5 0 0 0 .118-.285H19V6zm-6.838 9.97L7 19.636V6c0-.55.45-1 1-1h9c.55 0 1 .45 1 1v13.637l-5.162-3.668a.49.49 0 0 0-.676 0z"
fill-rule="evenodd"
></path></svg></a
></span>
</div>
</div>
</div>
</div>
<!-- end post -->
<!-- begin post -->
<div class="card">
<a href="post.html">
<img class="img-fluid" src="assets/img/demopic/10.jpg" alt="" />
</a>
<div class="card-block">
<h2 class="card-title">
<a href="post.html"
>Visiting the world means learning cultures</a
>
</h2>
<h4 class="card-text">
This is a longer card with supporting text below as a natural
lead-in to additional content. This content is a little bit
longer.
</h4>
<div class="metafooter">
<div class="wrapfooter">
<span class="meta-footer-thumb">
<a href="author.html"
><img
class="author-thumb"
src="https://www.gravatar.com/avatar/e56154546cf4be74e393c62d1ae9f9d4?s=250&d=mm&r=x"
alt="Sal"
/></a>
</span>
<span class="author-meta">
<span class="post-name"><a href="author.html">Sal</a></span
><br />
<span class="post-date">22 July 2017</span
><span class="dot"></span
><span class="post-read">6 min read</span>
</span>
<span class="post-read-more"
><a href="post.html" title="Read Story"
><svg
class="svgIcon-use"
width="25"
height="25"
viewbox="0 0 25 25"
>
<path
d="M19 6c0-1.1-.9-2-2-2H8c-1.1 0-2 .9-2 2v14.66h.012c.01.103.045.204.12.285a.5.5 0 0 0 .706.03L12.5 16.85l5.662 4.126a.508.508 0 0 0 .708-.03.5.5 0 0 0 .118-.285H19V6zm-6.838 9.97L7 19.636V6c0-.55.45-1 1-1h9c.55 0 1 .45 1 1v13.637l-5.162-3.668a.49.49 0 0 0-.676 0z"
fill-rule="evenodd"
></path></svg></a
></span>
</div>
</div>
</div>
</div>
<!-- end post -->
</div>
</section>
<!-- Container for Section 2 -->
<script>
document.addEventListener("DOMContentLoaded", async function () {
// GitHub Gist API endpoint
const gistApiEndpoint = "https://api.github.com/users/"+ (localStorage.username?localStorage.username:"sh20raj") +"/gists"; // Replace 'yourusername' with your GitHub username
const tagToFilter = "ArticlePlanet"; // Replace with the specific tag you use for Article Planet Gists
try {
// Fetch the list of Gists
const response = await fetch(gistApiEndpoint);
const gistsData = await response.json();
// Filter Gists that contain the specified tag in their descriptions
const articleGists = gistsData;
// Extract relevant information from each Article Planet Gist
const articles = await Promise.all(
articleGists.map(async (gist) => {
const title = gist.description || "Untitled";
const gistId = gist.id;
const gistUrl = gist.html_url;
// Extract date and cover URL from the Markdown content
const markdownContentResponse = await fetch(
gist.files[Object.keys(gist.files)[0]].raw_url
);
const markdownContent = await markdownContentResponse.text();
function extractMetadata(markdown) {
const match = markdown.match(/^---([\s\S]*?)---([\s\S]*)/);
const metadata = {};
if (match && match[1]) {
const metadataText = match[1].trim();
metadataText.split("\n").forEach((line) => {
const [key, ...valueParts] = line
.split(":")
.map((item) => item.trim());
metadata[key] = valueParts
.join(":")
.replace(/(^"|"$)/g, "")
.trim();
});
// Convert tags to an array
metadata.tags = metadata.tags
? metadata.tags.split(",").map((tag) => tag.trim())
: [];
}
return metadata;
}
const meta = extractMetadata(markdownContent);
console.log(meta.title);
if(!meta.ArticlePlanet){
return '';
}
function convertToRelativeDate(dateString) {
const currentDate = new Date();
const providedDate = new Date(dateString);
const timeDifferenceInSeconds = Math.floor((currentDate - providedDate) / 1000);
if (timeDifferenceInSeconds < 60) {
return 'just now';
} else if (timeDifferenceInSeconds < 3600) {
const minutes = Math.floor(timeDifferenceInSeconds / 60);
return `${minutes} minute${minutes > 1 ? 's' : ''} ago`;
} else if (timeDifferenceInSeconds < 86400) {
const hours = Math.floor(timeDifferenceInSeconds / 3600);
return `${hours} hour${hours > 1 ? 's' : ''} ago`;
} else if (timeDifferenceInSeconds < 2592000) {
const days = Math.floor(timeDifferenceInSeconds / 86400);
return `${days} day${days > 1 ? 's' : ''} ago`;
} else {
// You can add more conditions for months and years as needed
return 'more than a month ago';
}
}
let date = convertToRelativeDate(meta.datePublished);
let coverUrl = meta.cover;
console.log(coverUrl);
// Create HTML elements based on the fetched Gists
return `
<!-- begin post -->
<div class="card">
<a href="post.html?id=${gistId}">
<img class="img-fluid" src="${coverUrl || "https://random.imagecdn.app/500/500"+"?id="+gistId}" alt="" />
</a>
<div class="card-block">
<h2 class="card-title">
<a href="posts/${gistId}"
>${title}?</a
>
</h2>
<h4 class="card-text">
</h4>
<div class="metafooter">
<div class="wrapfooter">
<span class="meta-footer-thumb">
<a href="author.html"
><img
class="author-thumb"
src="${gist.owner.avatar_url}"
alt="${gist.owner.avatar_url}"
/></a>
</span>
<span class="author-meta">
<span class="post-name"><a href="author.html">${gist.owner.login}</a></span
><br />
<span class="post-date">${date}</span
><span class="dot"></span
><span class="post-read">2 min read</span>
</span>
<span class="post-read-more"
><a href="posts/${gistId}" title="Read Story"
><svg
class="svgIcon-use"
width="25"
height="25"
viewbox="0 0 25 25"
>
<path
d="M19 6c0-1.1-.9-2-2-2H8c-1.1 0-2 .9-2 2v14.66h.012c.01.103.045.204.12.285a.5.5 0 0 0 .706.03L12.5 16.85l5.662 4.126a.508.508 0 0 0 .708-.03.5.5 0 0 0 .118-.285H19V6zm-6.838 9.97L7 19.636V6c0-.55.45-1 1-1h9c.55 0 1 .45 1 1v13.637l-5.162-3.668a.49.49 0 0 0-.676 0z"
fill-rule="evenodd"
></path></svg></a
></span>
</div>
</div>
</div>
</div>
<!-- end post -->
`;
})
);
// Insert the generated HTML into the postcontainer
document.getElementById("section2-container").innerHTML =
articles.join("");
} catch (error) {
console.error("Error fetching Gists:", error);
document.getElementById("section2-container").innerHTML =
"<p>Error loading articles.</p>";
}
});
</script>
<!-- End List Posts
================================================== -->
<!-- Begin Footer
================================================== -->
<div class="container">
<div class="footer">
<p class="pull-left">Copyright © 2024 ArticlePlanet</p>
<p class="pull-right">
ArticlePlanet by
<a target="_blank" href="https://linktr.ee/cxdiin">CXDI</a>
</p>
<div class="clearfix"></div>
</div>
</div>
<!-- End Footer
================================================== -->
</div>
<!-- /.container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="assets/js/jquery.min.js"></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js"
integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb"
crossorigin="anonymous"
></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/ie10-viewport-bug-workaround.js"></script>
<script src="site.js"></script>
</body>
</html>