diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/class/Modelrender.php | 21 | ||||
-rw-r--r-- | app/view/templates/home.php | 18 |
2 files changed, 37 insertions, 2 deletions
diff --git a/app/class/Modelrender.php b/app/class/Modelrender.php index 638f3e3..bb6cf03 100644 --- a/app/class/Modelrender.php +++ b/app/class/Modelrender.php @@ -348,7 +348,9 @@ class Modelrender extends Modelpage $text = $this->desctitle($text, $this->page->description(), $this->page->title()); - $text = str_replace('href="http', ' class="external" target="_blank" href="http', $text); + $text = str_replace('href="http', "class=\"external\" $this->externallinkblank href=\"http", $text); + + $text = $this->shortenurl($text); $text = $this->autourl($text); @@ -366,10 +368,25 @@ class Modelrender extends Modelpage return $text; } + /** + * Shorten the urls of links whose content equals the href. + * + * @param string $text the page text as html + */ + public function shortenurl(string $text): string + { + $text = preg_replace('#<a(.*href="(https?:\/\/(.+))".*)>\2</a>#', "<a$1>$3</a>", $text); + return $text; + } + public function autourl($text) { - $text = preg_replace('#( |\R|>)(https?:\/\/((\S+)\.([^< ]+)))#', '$1<a href="$2" class="external" '. $this->externallinkblank .'>$3</a>', $text); + $text = preg_replace( + '#( |\R|(>)|(<))(https?:\/\/(\S+\.[^< ]+))(((?(3)>|))(?(2)</[^a]|))#', + "$1<a href=\"$4\" class=\"external\" $this->externallinkblank>$4</a>$6", + $text + ); return $text; } diff --git a/app/view/templates/home.php b/app/view/templates/home.php index 482ce17..4784b08 100644 --- a/app/view/templates/home.php +++ b/app/view/templates/home.php @@ -81,6 +81,24 @@ </form> </div> + + <div id="deepsearchbar" class="hidephone"> + <form action="<?= $this->url('home') ?>" method="get"> + <input type="text" name="search" value="<?= $deepsearch ?>" id="deepsearch" placeholder="deep search"> + <input type="checkbox" name="title" id="deeptitle" value="1" <?= $searchopt['title'] ? 'checked' : '' ?>> + <label for="deeptitle">title</label> + <input type="checkbox" name="description" id="deepdescription" value="1" <?= $searchopt['description'] ? 'checked' : '' ?>> + <label for="deepdescription">description</label> + <input type="checkbox" name="content" id="deepcontent" value="1" <?= $searchopt['content'] ? 'checked' : '' ?>> + <label for="deepcontent" title="Markdown content : MAIN, HEADER, NAV, ASIDE, FOOTER">content</label> + <input type="checkbox" name="other" id="deepother" value="1" <?= $searchopt['other'] ? 'checked' : '' ?>> + <label for="deepother" title="Structure content : BODY, CSS, Javascript">other</label> + <input type="checkbox" name="case" id="deepcase" value="1" <?= $searchopt['casesensitive'] ? 'checked' : '' ?>> + <label for="deepcase" title="Case sensitive or not">case sensitive</label> + <input type="submit" value="search"> + </form> + </div> + <div class="scroll"> <table id="home2table"> |