- }sx', $this->raw, $bodyp, PREG_OFFSET_CAPTURE)) {
- # fallback paragraph contents following the page header
- if ($bodyp[1][1] < 256) {
- return $bodyp[1][0];
- }
+ \G (?> \s+ |
]*> | \[\[[^]]*\]\] )*
\s* (.*?)
+ }sx', $this->body, $bodyp, 0)) {
+ return $bodyp[1];
}
}
@@ -107,6 +147,11 @@ class ArchiveArticle
}
function image()
{
+ if ($override = @$this->meta['og:image']) {
+ # prefer specific page image if found in metadata
+ return $override;
+ }
+
if ( preg_match('/\bsrc="([^"]*)"/', $this->img, $src) ) {
return $src[1];
}
@@ -120,3 +165,41 @@ class ArchiveArticle
);
}
}
+
+class PageSearch
+{
+ function __construct($path = '.')
+ {
+ $this->iterator = new RecursiveCallbackFilterIterator(
+ new RecursiveDirectoryIterator($path),
+ function ($current) {
+ if ($current->getFilename()[0] === '.') {
+ # skip hidden files and directories
+ return FALSE;
+ }
+ if ($current->isLink()) {
+ # ignore symlinks, original contents only
+ return FALSE;
+ }
+ if ($current->isDir()) {
+ # traverse subdirectories unless untracked in any amount
+ return !file_exists("$current/.gitignore");
+ }
+ # match **/*.html
+ return preg_match('/(?getFilename());
+ }
+ );
+ }
+
+ function files()
+ {
+ # order alphabetically by link
+ $dir = iterator_to_array(new RecursiveIteratorIterator($this->iterator));
+ array_walk($dir, function (&$row, $name) {
+ # prepare values for sorting (directory index first)
+ $row = preg_replace('{/index\.html$}', '', $name);
+ });
+ asort($dir);
+ return $dir;
+ }
+}