X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/15a408fca4266bcfd04289cb2d21af5057120035..f2df190a6c4a0128eb351bc398cffd0edf8d6096:/article.inc.php?ds=sidebyside
diff --git a/article.inc.php b/article.inc.php
index da18368..dbc545f 100644
--- a/article.inc.php
+++ b/article.inc.php
@@ -22,7 +22,7 @@ class ArchiveArticle
function __construct($path)
{
$this->page = preg_replace('{^\.(?:/|$)}', '', $path);
- $this->link = preg_replace('{(?:/index)?\.html$}', '', $this->page);
+ $this->link = preg_replace('{(?:(?:/|^)index)?\.html$}', '', $this->page);
$this->raw($this->page);
}
@@ -50,6 +50,30 @@ class ArchiveArticle
return $this->$col = $this->$col(); # run method and cache
}
+ function handler()
+ {
+ $path = $this->link;
+ $this->path = '';
+ $this->restricted = FALSE;
+ while (TRUE) {
+ if (file_exists("$path/.private")) {
+ $this->restricted = $path;
+ }
+
+ if (file_exists("$path/index.php")) {
+ return $path;
+ }
+
+ $up = strrpos($path, '/');
+ $this->path = substr($path, $up) . $this->path;
+ $path = substr($path, 0, $up);
+ if ($up === FALSE) {
+ break;
+ }
+ }
+ return;
+ }
+
function safetitle()
{
return trim($this->meta['og:title'] ?? strip_tags($this->title));
@@ -86,7 +110,7 @@ class ArchiveArticle
function story()
{
if ( preg_match('{
- \n (?: < (?: p | figure [^>]* ) >\s* )+ (]*>) | \n
|
\s* (.*?)
- }sx', $this->raw, $bodyp, PREG_OFFSET_CAPTURE)) { - # fallback paragraph contents following the page header - if ($bodyp[1][1] < 256) { - return $bodyp[1][0]; - } - } - - # starting paragraph for documents without title (assumed simple/partial) - if (strpos($this->raw, '\s* (.*?)
- }sx', $this->raw, $bodyp)) { + \G (?: \s+ ||
\s* (.*?)
+ }sx', $this->raw, $bodyp, 0, $offset)) { return $bodyp[1]; } }