nieuws: navigation links in common aside container
[minimedit.git] / article.inc.php
index d8ddf77b990b374d25586da8a01501ad030d21b3..98cd475b22194095fca6924c9ef4570b6eaed041 100644 (file)
@@ -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);
        }
 
@@ -110,7 +110,7 @@ class ArchiveArticle
        function story()
        {
                if ( preg_match('{
-                       \n (?: < (?: p | figure [^>]* ) >\s* )+ (<img\ [^>]*>) | \n <hr\ />
+                       (?: < (?: p | figure [^>]* ) >\s* )+ (<img\ [^>]*>) | \n <hr\ />
                }x', $this->body, $img, PREG_OFFSET_CAPTURE) ) {
                        # strip part after matching divider (image)
                        if (isset($img[1])) {
@@ -128,19 +128,12 @@ class ArchiveArticle
                        return $override;
                }
 
+               # paragraph contents following the page header if any
+               $offset = strpos($this->raw, '</h2>');
+               $offset = $offset ? $offset + 5 : 0;
                if (preg_match('{
-                       </h2> (?: \s+ | <p\sclass="nav\b.*?</p> | <div[^>]*> )* <p> \s* (.*?) </p>
-               }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, '<h2') === FALSE and preg_match('{
-                       \A (?: <div [^>]*> \s* )* <p> \s* (.*?) </p>
-               }sx', $this->raw, $bodyp)) {
+                       \G (?> \s+ | <aside\b.*?</aside> | <div [^>]*> | \[\[[^]]*\]\] )* <p> \s* (.*?) </p>
+               }sx', $this->raw, $bodyp, 0, $offset)) {
                        return $bodyp[1];
                }
        }