Skip to content

Commit

Permalink
config param to disable URL checker see #322
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-peugnet committed Nov 25, 2024
1 parent d6b8fff commit abf3add
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
11 changes: 11 additions & 0 deletions app/class/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ abstract class Config
protected static bool $externallinkblank = true;
protected static bool $internallinkblank = false;
protected static bool $urllinker = true;
protected static bool $urlchecker = true;
protected static bool $deletelinktocache = true;
protected static int $defaultprivacy = 0;
protected static string $homepage = 'default';
Expand Down Expand Up @@ -297,6 +298,11 @@ public static function urllinker(): bool
return self::$urllinker;
}

public static function urlchecker(): bool
{
return self::$urlchecker;
}

public static function deletelinktocache(): bool
{
return self::$deletelinktocache;
Expand Down Expand Up @@ -536,6 +542,11 @@ public static function seturllinker($urllinker)
self::$urllinker = boolval($urllinker);
}

public static function seturlchecker($urlchecker)
{
self::$urlchecker = boolval($urlchecker);
}

public static function setdeletelinktocache($deletelinktocache)
{
self::$deletelinktocache = boolval($deletelinktocache);
Expand Down
3 changes: 2 additions & 1 deletion app/class/Controllerhome.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public function desktop()
$vars['deepsearch'] = $deepsearch['regex'];
$vars['searchopt'] = $deepsearch['searchopt'];
$vars['display'] = $display;
$vars['urlchecker'] = Config::urlchecker();

if ($display === 'graph') {
$vars['layout'] = $_GET['layout'] ?? 'cose-bilkent';
Expand Down Expand Up @@ -327,7 +328,7 @@ public function multiedit()
public function multirender(): void
{
$pagelist = $_POST['pagesid'] ?? [];
$checkurl = boolval($_POST['checkurl']);
$checkurl = Config::urlchecker() && boolval($_POST['checkurl']);
$total = count($pagelist);
$pagelist = $this->pagemanager->pagelistbyid($pagelist);
$count = 0;
Expand Down
6 changes: 4 additions & 2 deletions app/class/Controllerpage.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ public function render(string $page): void

if ($this->importpage() && $this->user->iseditor()) {
try {
$this->page = $this->pagemanager->renderpage($this->page, $this->router, new Serviceurlchecker(8));
$urlchecker = Config::urlchecker() ? new Serviceurlchecker(8) : null;
$this->page = $this->pagemanager->renderpage($this->page, $this->router, $urlchecker);
} catch (RuntimeException $e) {
Logger::errorex($e);
}
Expand Down Expand Up @@ -186,7 +187,8 @@ public function read(string $page): void
$oldlinkto = $this->page->linkto();
}
try {
$this->page = $this->pagemanager->renderpage($this->page, $this->router, new Serviceurlchecker(3));
$urlchecker = Config::urlchecker() ? new Serviceurlchecker(8) : null;
$this->page = $this->pagemanager->renderpage($this->page, $this->router, $urlchecker);
} catch (RuntimeException $e) {
Logger::errorex($e);
}
Expand Down
11 changes: 11 additions & 0 deletions app/view/templates/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,17 @@
<input type="checkbox" name="internallinkblank" id="internallinkblank" value="1" <?= Wcms\Config::internallinkblank() ? 'checked' : '' ?> form="admin">
</p>

<p class="field">
<input type="hidden" name="urlchecker" value="0" form="admin">
<label for="urlchecker">Enalbe URL checker</label>
<input type="checkbox" name="urlchecker" id="urlchecker" value="1" <?= Wcms\Config::urlchecker() ? 'checked' : '' ?> form="admin">
</p>

<p class="info">
URL checker try to reach URLs online to see if they are alives.
This may cause longer render time if recently activated.
</p>

<h3>Markdown Parser</h3>

<p class="field">
Expand Down
3 changes: 2 additions & 1 deletion app/view/templates/home.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
'colors' => $colors,
'queryaddress' => $queryaddress,
'matchedbookmarks' => $matchedbookmarks,
'editablebookmarks' => $editablebookmarks
'editablebookmarks' => $editablebookmarks,
'urlchecker' => $urlchecker,
]);
?>

Expand Down

0 comments on commit abf3add

Please sign in to comment.