diff options
author | Arno Richter <oelna@oelna.de> | 2022-12-13 22:27:21 +0100 |
---|---|---|
committer | Arno Richter <oelna@oelna.de> | 2022-12-13 22:27:44 +0100 |
commit | 0b075f3ea2616cfde4d976199a69ba631174a336 (patch) | |
tree | bb1feef58d9c714f6c3fb0b75f1e52b0181cf2af /templates/timeline.inc.php | |
parent | f0e3ff408db8ee40611f75cdf96892f90034bd60 (diff) | |
download | microblog-0b075f3ea2616cfde4d976199a69ba631174a336.tar.gz microblog-0b075f3ea2616cfde4d976199a69ba631174a336.tar.bz2 microblog-0b075f3ea2616cfde4d976199a69ba631174a336.zip |
gave up and sorted files into a directory structure. made snippets for header, nav and footer. made it easier to add additional css files as themes. prepare a little for addition of a real template engine. added a css reset file to share between themes, if warranted.
Diffstat (limited to 'templates/timeline.inc.php')
-rw-r--r-- | templates/timeline.inc.php | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/templates/timeline.inc.php b/templates/timeline.inc.php new file mode 100644 index 0000000..234ea83 --- /dev/null +++ b/templates/timeline.inc.php @@ -0,0 +1,57 @@ +<?php + if(!defined('ROOT')) die('Don\'t call this directly.'); + + // never cache the timeline (?) + header('Expires: Sun, 01 Jan 2014 00:00:00 GMT'); + header('Cache-Control: no-store, no-cache, must-revalidate'); + header('Cache-Control: post-check=0, pre-check=0', FALSE); + header('Pragma: no-cache'); + + // pagination + $current_page = (path(0) == 'page' && is_numeric(path(1))) ? (int) path(1) : 1; + $posts_count = db_posts_count(); + $total_pages = ceil($posts_count / $config['posts_per_page']); + $offset = ($current_page-1)*$config['posts_per_page']; + + // get posts + $posts = db_select_posts(NOW, $config['posts_per_page'], 'desc', $offset); + + $title_suffix = ''; + require(ROOT.DS.'snippets'.DS.'header.snippet.php'); + +?><body> + <div class="wrap"> + <?php require(ROOT.DS.'snippets'.DS.'nav.snippet.php'); ?> + <ul class="posts"> + <?php if(!empty($posts)): ?> + <?php foreach($posts as $post): ?> + <li data-post-id="<?= $post['id'] ?>"> + <?php + $date = date_create(); + date_timestamp_set($date, $post['post_timestamp']); + + $datetime = date_format($date, 'Y-m-d H:i:s'); + $formatted_time = date_format($date, 'M d Y H:i'); + ?> + <a class="post-timestamp" href="<?= $config['url'] ?>/<?= $post['id'] ?>"><time datetime="<?= $datetime ?>" data-unix-time="<?= $post['post_timestamp'] ?>"><?= $formatted_time ?></time></a> + <nav class="post-meta"> + <?php if($config['logged_in']): ?><ul> + <li><a href="<?= $config['url'] ?>/<?= $post['id'] ?>/edit">Edit</a></li> + <li><a href="<?= $config['url'] ?>/<?= $post['id'] ?>/delete">Delete</a></li> + </ul><?php endif; ?> + </nav> + <div class="post-content"><?= nl2br(autolink($post['post_content'])) ?></div> + </li> + <?php endforeach; ?> + </ul> + <?php else: ?> + <p>No posts found.</p> + <?php endif; ?> + <div class="pagination"> + <?php if ($current_page > 1): ?><a href="<?= $config['url'] ?>/page/<?= $current_page - 1 ?>" class="previous">newer updates</a><?php endif; ?> + <?php if ($current_page < $total_pages): ?><a href="<?= $config['url'] ?>/page/<?= $current_page + 1 ?>" class="next">older updates</a><?php endif; ?> + </div> + </div> + <?php require(ROOT.DS.'snippets'.DS.'footer.snippet.php'); ?> +</body> +</html> |