summaryrefslogtreecommitdiff
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php19
1 files changed, 11 insertions, 8 deletions
diff --git a/index.php b/index.php
index 6126901..a7b36dd 100644
--- a/index.php
+++ b/index.php
@@ -1,14 +1,17 @@
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/lib/time.php';
+include_once $_SERVER['DOCUMENT_ROOT'] . '/lib/post.php';
if (file_exists("{$_SERVER['DOCUMENT_ROOT']}/projects.json") && $contents = file_get_contents("{$_SERVER['DOCUMENT_ROOT']}/projects.json")) {
$projects = json_decode($contents, true);
}
if (file_exists("{$_SERVER['DOCUMENT_ROOT']}/links.json") && $contents = file_get_contents("{$_SERVER['DOCUMENT_ROOT']}/links.json")) {
$links = json_decode($contents, true);
}
-$db = new PDO("sqlite:{$_SERVER['DOCUMENT_ROOT']}/database.db");
-$stmt = $db->query("SELECT id, title, posted_at FROM statuses ORDER BY posted_at DESC LIMIT 1");
-$last_status = $stmt->fetch(PDO::FETCH_ASSOC) ?: null;
+
+$posts = get_posts();
+if (!empty($posts)) {
+ $last_post = $posts[0];
+}
?>
<!DOCTYPE html>
<html>
@@ -58,12 +61,12 @@ $last_status = $stmt->fetch(PDO::FETCH_ASSOC) ?: null;
<?php endforeach; ?>
</section>
<?php endif; ?>
- <?php if (isset($last_status)): ?>
+ <?php if (isset($last_post)): ?>
<div class="status">
- <p>Last status posted <?= format_timestamp(time() - strtotime($last_status['posted_at'])) ?> ago: <a
- href="/status/?id=<?= $last_status['id'] ?>"><?= $last_status['title'] ?? 'No title.' ?></a></p>
- <p style="font-size:10px;"><a href="/status/">[more...]</a> <a href="/rss.php"><img
- src="/static/img/rss.png" alt="[rss]"></a></p>
+ <p>Last post was <?= format_timestamp(time() - $last_post['time']) ?> ago: <a
+ href="/blog/<?= urlencode($last_post['name']) ?>"><?= $last_post['name'] ?? 'No title.' ?></a></p>
+ <p style="font-size:10px;"><a href="/blog/">[more...]</a> <a href="/rss.xml"><img src="/static/img/rss.png"
+ alt="[rss]"></a></p>
</div>
<?php endif; ?>
<?php if (isset($links)): ?>