nieuws/replies: read contents from database
authorMischa POSLAWSKY <perl@shiar.org>
Thu, 17 Oct 2019 03:20:55 +0000 (05:20 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Sun, 27 Oct 2019 00:36:38 +0000 (02:36 +0200)
commit0cc6251412d85492cbd0af0d50176d3c70c25311
tree4b22dfa0ccb952aa23550f9e5841043cd9abeb1f
parent0243f370ae2e2188ea9bec4d859b5ee8f0c17817
nieuws/replies: read contents from database

Replace file storage by a PostgreSQL table.  Resign to the additional
dependency for this kind of social feature since it's much more appropriate
(especially with upcoming extensions), and optional similar to external
comment services.

Identical results after importing existing files:

ls melding/2*/*/*.html | perl -MFile::Slurp -lnE '
my ($page, $meta) = m{(.*)/(.*)};
my ($time, $author) = split /[:.]/, $meta;
$time .= "00" while length($time) < 14;
$time =~ s/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/$1-$2-$3 $4:$5:/g;
my $html = read_file($_);
chomp, s/\\\K/\\/g, s/\n/\\n/g, s/\t/\\t/g for $html;
say join "\t", $page, $author, $time, $html;
' | psql -c 'COPY comments (page, author, created, message) FROM STDIN'
.gitignore
database.inc.php [new file with mode: 0644]
widget/comments.sql [new file with mode: 0644]
widget/nieuws/replies.php