]*> | \[\[[^]]*\]\] )*
\s* (.*?)
+ }sx', $this->body, $bodyp, 0)) {
return $bodyp[1];
}
}
@@ -104,14 +145,17 @@ class ArchiveArticle
$this->story;
return $this->img;
}
-
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];
}
}
-
function thumb($size = '300x')
{
if (!$this->image or $this->image[0] !== '/') return;
@@ -121,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;
+ }
+}