X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/1abb286e88defee799e43cdd296914f74f722bde..ea6a673181cd8b44ea04ef6578651fbd5c329060:/article.inc.php diff --git a/article.inc.php b/article.inc.php index bc8dbff..e3a3ee8 100644 --- a/article.inc.php +++ b/article.inc.php @@ -16,10 +16,17 @@ function showdate($parts) class ArchiveArticle { + public $raw, $preface, $title, $body; + function __construct($path) { $this->page = $path; $this->link = preg_replace('{(?:/index)?\.html$}', '', $path); + if (file_exists($this->page)) { + $this->raw = file_get_contents($this->page); + @list ($this->preface, $this->title, $this->body) = + preg_split('{
(.*?)
}s', $this->story, $bodyp)) { - return $bodyp[1]; + if (preg_match('{ + ]* content="([^">]*)" + }x', $this->preface, $meta)) { + # prefer specific page description if found (assume before title) + #TODO: strip from body contents + return $meta[1]; + } + if (preg_match('{ + (?: \s+ ||
(.*?)
+ }sx', $this->raw, $bodyp, PREG_OFFSET_CAPTURE)) { + # fallback paragraph contents following the page header + if ($bodyp[1][1] < 256) { + return $bodyp[1][0]; + } } }