diff options
author | Arno Richter <oelna@oelna.de> | 2022-12-13 23:45:48 +0100 |
---|---|---|
committer | Arno Richter <oelna@oelna.de> | 2022-12-13 23:45:48 +0100 |
commit | a2efa08d3529758b67db5b8687f8df43de63f1d0 (patch) | |
tree | fe1543c9bc8f82a95e84693932556b6cbec99383 | |
parent | 67b51e9f905c568444741eaad0eb5d82df7f09c8 (diff) | |
download | microblog-a2efa08d3529758b67db5b8687f8df43de63f1d0.tar.gz microblog-a2efa08d3529758b67db5b8687f8df43de63f1d0.tar.bz2 microblog-a2efa08d3529758b67db5b8687f8df43de63f1d0.zip |
display edit times of posts. add a config option to disable.
-rw-r--r-- | config-dist.php | 3 | ||||
-rw-r--r-- | css/microblog.css | 6 | ||||
-rw-r--r-- | index.php | 2 | ||||
-rw-r--r-- | templates/single.inc.php | 7 | ||||
-rw-r--r-- | templates/timeline.inc.php | 7 |
5 files changed, 22 insertions, 3 deletions
diff --git a/config-dist.php b/config-dist.php index 96b0423..2036e72 100644 --- a/config-dist.php +++ b/config-dist.php @@ -34,7 +34,8 @@ $config = array( 'oauth_access_token_secret' => '', 'consumer_key' => '', 'consumer_secret' => '' - ) + ), + 'show_edits' => true, // displays the modification time of posts ); $config['xmlrpc'] = function_exists('xmlrpc_server_create'); diff --git a/css/microblog.css b/css/microblog.css index 0490d80..1bc41be 100644 --- a/css/microblog.css +++ b/css/microblog.css @@ -103,6 +103,12 @@ nav.main li + li a { grid-column-start: span 3; } +.wrap .post-timestamp time.modified { + display: block; + color: hsla(0, 0%, 0%, 0.2); + mix-blend-mode: multiply; +} + .wrap .post-meta { grid-column-start: span 3; } @@ -4,6 +4,8 @@ // check user credentials $config['logged_in'] = check_login(); + $config['show_edits'] = !empty($config['show_edits']) ? $config['show_edits'] : true; + // subpages $template = 'timeline'; if(is_numeric(path(0))) { diff --git a/templates/single.inc.php b/templates/single.inc.php index cd01127..29184d4 100644 --- a/templates/single.inc.php +++ b/templates/single.inc.php @@ -86,7 +86,12 @@ $datetime = date_format($date, 'Y-m-d H:i:s'); $formatted_time = date_format($date, 'M d Y H:i'); ?> - <span class="post-timestamp"><time datetime="<?= $datetime ?>" data-unix-time="<?= $post['post_timestamp'] ?>"><?= $formatted_time ?></time></span> + <span class="post-timestamp"> + <time class="published" datetime="<?= $datetime ?>" data-unix-time="<?= $post['post_timestamp'] ?>"><?= $formatted_time ?></time> + <?php if(is_numeric($post['post_edited']) && $config['show_edits']): ?> + <time class="modified" datetime="<?= gmdate('Y-m-d\TH:i:s\Z', $post['post_edited']) ?>" data-unix-time="<?= $post['post_edited'] ?>">Edited on <?= date('M d Y H:i', $post['post_edited']) ?></time> + <?php endif; ?> + </span> <nav class="post-meta"> <?php if($config['logged_in']): ?><ul> <?php if(is_numeric($post['post_deleted'])): ?> diff --git a/templates/timeline.inc.php b/templates/timeline.inc.php index a29e9dd..bc06de9 100644 --- a/templates/timeline.inc.php +++ b/templates/timeline.inc.php @@ -37,7 +37,12 @@ $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> + <a class="post-timestamp" href="<?= $config['url'] ?>/<?= $post['id'] ?>"> + <time class="published" datetime="<?= $datetime ?>" data-unix-time="<?= $post['post_timestamp'] ?>"><?= $formatted_time ?></time> + <?php if(is_numeric($post['post_edited']) && $config['show_edits']): ?> + <time class="modified" datetime="<?= gmdate('Y-m-d\TH:i:s\Z', $post['post_edited']) ?>" data-unix-time="<?= $post['post_edited'] ?>">Edited on <?= date('M d Y H:i', $post['post_edited']) ?></time> + <?php endif; ?> + </a> <nav class="post-meta"> <?php if($config['logged_in']): ?><ul> <li><a href="<?= $config['url'] ?>/<?= $post['id'] ?>/edit">Edit</a></li> |