-
Notifications
You must be signed in to change notification settings - Fork 1
/
filtered_posts.php
196 lines (150 loc) · 5.78 KB
/
filtered_posts.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
<?php include('config.php'); ?>
<?php include('includes/public_functions.php'); ?>
<?php include('includes/head_section.php'); ?>
<?php
// Get posts under a particular topic
if (isset($_GET['topic'])) {
$topic_id = $_GET['topic'];
$posts = getPublishedPostsByTopic($topic_id);
}
?>
<title>TailBlog | Home </title>
</head>
<body>
<!-- Navbar -->
<?php include( ROOT_PATH . '/includes/navbar.php'); ?>
<!-- // Navbar -->
<!-- content -->
<div class="content">
<h2 class="font-medium leading-tight text-5xl mt-0 mb-2 ">
Articles on <u><?php echo getTopicNameById($topic_id); ?></u>
</h2>
<hr>
<!-- This is an example component -->
<section class="flex flex-row flex-wrap mx-auto">
<?php foreach ($posts as $post): ?>
<!-- Card Component -->
<div
class="transition-all duration-150 flex w-full px-4 py-6 md:w-1/2 lg:w-1/3"
>
<div
class="flex flex-col items-stretch min-h-full pb-4 mb-6 transition-all duration-150 bg-white rounded-lg shadow-lg hover:shadow-2xl"
>
<div class="md:flex-shrink-0">
<img src="<?php echo BASE_URL . '/static/images/' . $post['image']; ?>" class="object-fill w-full rounded-lg rounded-b-none md:h-56" >
</div>
<div class="flex items-center justify-between px-4 py-2 overflow-hidden">
<?php if (isset($post['topic']['name'])): ?>
<a
href="<?php echo BASE_URL . $post['topic']['id'] .'/topic' ?>"
class="btn category">
<span class="text-xs font-medium text-blue-600 uppercase">
<?php echo $post['topic']['name'] ?>
</span>
</a>
<?php endif ?>
<div class="flex flex-row items-center">
<div
class="text-xs font-medium text-gray-500 flex flex-row items-center mr-2"
>
<svg
class="w-4 h-4 mr-1"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"
></path>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"
></path>
</svg>
<span>1.5k</span>
</div>
<div
class="text-xs font-medium text-gray-500 flex flex-row items-center mr-2"
>
<svg
class="w-4 h-4 mr-1"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"
></path>
</svg>
<span>25</span>
</div>
<div
class="text-xs font-medium text-gray-500 flex flex-row items-center"
>
<svg
class="w-4 h-4 mr-1"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M14 10h4.764a2 2 0 011.789 2.894l-3.5 7A2 2 0 0115.263 21h-4.017c-.163 0-.326-.02-.485-.06L7 20m7-10V5a2 2 0 00-2-2h-.095c-.5 0-.905.405-.905.905 0 .714-.211 1.412-.608 2.006L7 11v9m7-10h-2M7 20H5a2 2 0 01-2-2v-6a2 2 0 012-2h2.5"
></path>
</svg>
<span>7</span>
</div>
</div>
</div>
<hr class="border-gray-300" />
<div class="flex flex-wrap items-center flex-1 px-4 py-1 text-center mx-auto">
<a href="blog/<?php echo $post['slug']; ?>"class="hover:underline">
<h2 class="text-2xl font-bold tracking-normal text-gray-800"><?php echo $post['title'] ?> </h2>
</div>
<hr class="border-gray-300" />
<section class="px-4 py-2 mt-2">
<div class="flex items-center justify-between">
<div class="flex items-center flex-1">
<img
class="object-cover h-10 rounded-full"
src="https://thumbs.dreamstime.com/b/default-avatar-photo-placeholder-profile-icon-eps-file-easy-to-edit-default-avatar-photo-placeholder-profile-icon-124557887.jpg"
alt="Avatar"
/>
<div class="flex flex-col mx-2">
<span class="mx-1 text-xs text-gray-600"><?php echo date("F j, Y ", strtotime($post["created_at"])); ?></span>
</div>
</div>
<a href="blog/<?php echo $post['slug']; ?>">
<button
type="button"
class="border border-indigo-500 bg-indigo-500 text-white rounded-md px-4 py-2 m-2 transition duration-500 ease select-none hover:bg-indigo-600 focus:outline-none focus:shadow-outline"
>
Read
</button>
</a>
</div>
</section>
</div>
</div>
<!-- Card Component -->
<?php endforeach ?>
</section>
<!-- // content -->
</div>
<!-- // container -->
<!-- Footer -->
<?php include( ROOT_PATH . '/includes/footer.php'); ?>
<!-- // Footer -->