page: record creation time in template meta tag
authorMischa POSLAWSKY <perl@shiar.org>
Wed, 2 Dec 2020 22:46:30 +0000 (23:46 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Sat, 5 Dec 2020 00:41:21 +0000 (01:41 +0100)
Another https://ogp.me/#no_vertical object for availability start.
May be distinct from chosen (eg historic) dates shown for news articles.

Values may be reconstructed for existing files from Git history:

perl -i -pE '
close ARGV if eof;  # reset line number
$. == 1 or next;  # ignore consecutive lines
my $first = qx{git log --follow --pretty=%ai -- "$ARGV" | tail -n1}
or next;  # find earliest commit time
chomp $first;
print qq{<meta property="article:published_time" content="$first" />};
say "" unless /^<meta/;
' **/*.html

page.php

index 14b58db8060484ba3fa2f3e022b554da7d32a153..d4404fd0e22a1398783c74c332fa47435f641e3f 100644 (file)
--- a/page.php
+++ b/page.php
@@ -173,6 +173,7 @@ $Place = [
 if (!isset($Article->raw) and $User->admin("edit {$Article->link}")) {
        # open template as initial contents
        $Article->raw(file_exists("$Page/template.inc.html") ? "$Page/template.inc.html" : 'template.inc.html');
+       $Article->meta['article:published_time'] = date('Y-m-d h:i:s O');
        $Article->meta['article:author'] = '/' . $User->dir;
 }