From 628a39772933c58908f2ec68cc05b027e939b207 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Mon, 11 Feb 2019 01:09:30 +0100 Subject: [PATCH] nieuws: first paragraph teaser as page description Enable previews in social media links. Also used in search results. --- head.inc.php | 3 +++ nieuws.inc.php | 7 +++++++ nieuws/index.php | 1 + 3 files changed, 11 insertions(+) diff --git a/head.inc.php b/head.inc.php index ff63971..1e57e66 100644 --- a/head.inc.php +++ b/head.inc.php @@ -4,6 +4,9 @@ <?= htmlspecialchars($Place['title']) ?> + + + diff --git a/nieuws.inc.php b/nieuws.inc.php index 40313e4..6d84d1a 100644 --- a/nieuws.inc.php +++ b/nieuws.inc.php @@ -86,6 +86,13 @@ class ArchiveArticle return $rest; } + function teaser() + { + if (preg_match('{

(.*?)

}s', $this->body, $bodyp)) { + return $bodyp[1]; + } + } + function img() { $this->body; diff --git a/nieuws/index.php b/nieuws/index.php index 4ffaa23..71048d5 100644 --- a/nieuws/index.php +++ b/nieuws/index.php @@ -12,6 +12,7 @@ if ($page and !is_numeric($page)) { $edit = !empty($User['admin']) ? htmlspecialchars(@$_GET['edit']) : NULL; $article = new ArchiveArticle("$Page$Args.html"); $Place['title'] = $edit ?: $article->title; + $Place['description'] = $article->teaser; $Place[1] = ' '.$article->date.''; print preg_replace('{(?<=

)(.*?)(?=

)}', ($edit ?: '\1').' [[1]]', ob_get_clean()); if ($article->file and $article->image) { -- 2.30.0