X-Git-Url: http://git.shiar.nl/minimedit.git/blobdiff_plain/db34f863d9a47e768ac0ea9a00d1646dda069c09..772961fd4e9be46ad340cad1e55ee5f28cc5b968:/article.inc.php diff --git a/article.inc.php b/article.inc.php index 98cd475..acd219d 100644 --- a/article.inc.php +++ b/article.inc.php @@ -16,8 +16,8 @@ function showdate($parts) class ArchiveArticle { - public $raw, $preface, $title, $body; - public $meta = []; + public $raw, $title, $body; # file contents + public $meta = []; # head metadata properties function __construct($path) { @@ -41,8 +41,11 @@ class ArchiveArticle $this->meta = array_combine($meta[1], $meta[2]); # [property => content] } - @list ($this->preface, $this->title, $this->body) = - preg_split('{

(.*?)

\s*}s', $this->raw, 2, PREG_SPLIT_DELIM_CAPTURE); + // find significant contents + $this->body = preg_replace('{}s', '', $this->raw); + if (preg_match('{

(.*?)

\s*(.*)}s', $this->body, $titlematch)) { + list (, $this->title, $this->body) = $titlematch; + } } function __get($col) @@ -74,6 +77,12 @@ class ArchiveArticle return; } + function restricted() + { + $this->handler; + return $this->restricted; + } + function safetitle() { return trim($this->meta['og:title'] ?? strip_tags($this->title)); @@ -129,11 +138,9 @@ class ArchiveArticle } # paragraph contents following the page header if any - $offset = strpos($this->raw, ''); - $offset = $offset ? $offset + 5 : 0; if (preg_match('{ - \G (?> \s+ | |
]*> | \[\[[^]]*\]\] )*

\s* (.*?)

- }sx', $this->raw, $bodyp, 0, $offset)) { + \G (?> \s+ |
]*> | \[\[[^]]*\]\] )*

\s* (.*?)

+ }sx', $this->body, $bodyp, 0)) { return $bodyp[1]; } }