-
Notifications
You must be signed in to change notification settings - Fork 0
/
bloglist.php
120 lines (116 loc) · 4.91 KB
/
bloglist.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
<?php function bloglist($location, $category = null, $post = null) {
$bloglist = json_decode(file_get_contents('blog/posts.json', true));
if($location === "navbar") {
echo "<h4>\n";
foreach($bloglist->blog as $year) {
foreach($year as $post) {
echo " <a href=\"/blog/" . $post->uri . "/\">" . $post->navtitle . "</a>\n";
}
}
echo " </h4>\n";
}
elseif($location === "home") {
$homeCount = 0;
foreach($bloglist->blog as $year) {
foreach($year as $post) {
$homeCount++;
echo "\n <div class=\"recent-post clearboth\">
<h2 class=\"no-mar-bottom\"><a href=\"/blog/" . $post->uri . "/\">" . $post->title . "</a></h2>
<p class=\"two-mar-top recents-date\">" . $post->date . "</p>
<p class=\"snippet\">" . $post->snippet . " <b><u><i><a href=\"/blog/" . $post->uri . "/\"><span class=\"continue-reading\">Continue reading...</span></a></i></u></b></p>";
bloglist("tags", null, $post);
echo " </div>";
if($homeCount >= 4) {
break 2;
}
echo "<hr>";
}
}
}
elseif($location === "tags") {
echo "\n <p class=\"tags\">\n";
foreach(explode(",", $post->tags) as $tag) {
echo " <b><a href=\"/blog/category/" . str_replace(' ', '-', strtolower($tag)) . "/\"><span class=\"tag-" . str_replace(' ', '-', strtolower($tag)) . "\">" . $tag . "</span></a></b>\n";
}
echo " </p>\n";
}
elseif($location === "recents") {
$recentsCount = 0;
foreach($bloglist->blog as $year) {
foreach($year as $post) {
$recentsCount++;
echo " <a href=\"/blog/" . $post->uri . "/\">
<h4 class=\"no-mar-bottom\">" . $post->title . "</h4>
<h5 class=\"two-no-mar\">" . $post->shortdesc . "</h5>
<h5 class=\"two-mar-top\">" . $post->date . "</h5>
</a>\n";
if($recentsCount >= 4) {
break 2;
}
}
}
}
elseif($location === "blog") {
$latestYear = 2018; //Temporary year code
foreach($bloglist->blog as $year) {
echo "\n <br><div class=\"blog-group\">
<div class=\"blog-year\"><h1>" . $latestYear-- . "</h1></div>
<div class=\"blog-brace1\"></div>
<div class=\"blog-brace2\"></div>
<div>
<div class=\"blog-brace3\"></div>
<div class=\"blog-brace4\"></div>
<div class=\"blog-brace5\"></div>
</div>
<div class=\"blog-list\">\n";
foreach($year as $post) {
echo " <h3><a href=\"/blog/" . $post->uri . "/\">" . $post->title . "</a></h3>
<p class=\"two-no-mar\"><b>" . $post->longdesc . "</b></p>
<p class=\"two-no-mar\">" . $post->date . "</p>";
bloglist("tags", null, $post);
}
echo " </div>
</div>\n";
}
}
elseif($location === "tag") {
echo "<!DOCTYPE html>
<html lang=\"en\">
<!--Copyright Jamie Scaife-->
<!--Legal Information at https://www.jamieweb.net/contact-->
<head>
<title>Blog</title>
<meta name=\"description\" content=\"Blog posts in category: '" . $category . "'\">
<meta name=\"keywords\" content=\"Jamie, Scaife, jamie scaife, jamiescaife, jamieonubuntu, jamie90437, jamie90437x, jamieweb, jamieweb.net\">
<meta name=\"author\" content=\"Jamie Scaife\">
<link href=\"/jamie.css\" rel=\"stylesheet\">
<link href=\"https://www.jamieweb.net/blog/category/" . str_replace(' ', '-', strtolower($category)) . "/\" rel=\"canonical\">
</head>
<body>\n\n";
include "navbar.php";
echo "\n<div class=\"body\">
<h1>Category: '" . $category . "'</h1>
<hr>
<div class=\"blog-list\">\n";
foreach($bloglist->blog as $year) {
foreach($year as $post) {
$tags = explode(",", $post->tags);
if(in_array($category, $tags)) {
echo " <h3><a href=\"/blog/" . $post->uri . "/\">" . $post->title . "</a></h3>
<p class=\"two-no-mar\"><b>" . $post->longdesc . "</b></p>
<p class=\"two-no-mar\">" . $post->date . "</p>
<p class=\"tags\">\n";
foreach($tags as $tag) {
echo " <b><a href=\"/blog/category/" . str_replace(' ', '-', strtolower($tag)) . "/\"><span class=\"tag-" . str_replace(' ', '-', strtolower($tag)) . "\">" . $tag . "</span></a></b>\n";
}
echo " </p>\n";
}
}
}
echo " </div>\n";
include_once "footer.php";
echo "\n\n</body>
</html>";
}
}
?>