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 Oct 20, 2024
1 parent d5acc25 commit 354085e
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 12 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 @@ -279,6 +280,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 @@ -498,6 +504,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 @@ -229,6 +229,17 @@
<label for="internallinkblank">Open internal links in new tab</label>
</div>

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

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

<h4>Markdown Parser</h4>

<div class="checkbox">
Expand Down
15 changes: 9 additions & 6 deletions 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 Expand Up @@ -321,11 +322,13 @@ class="redirection"
<?php } if ($columns['externallinks']) { ?>
<td class="linkto" title="<?= $item->externallinkstitle() ?>">
<?= $item->externallinks('sort') ?>
<?php $deadlinkcount = $item->deadlinkcount(); if (!empty($deadlinkcount)) { ?>
<span class="deadlinkcount"><?= $deadlinkcount ?></span>
<?php } ?>
<?php $uncheckedlinkcount = $item->uncheckedlinkcount(); if (!empty($uncheckedlinkcount)) { ?>
<span class="uncheckedlinkcount"><?= $uncheckedlinkcount ?></span>
<?php if ($urlchecker) { ?>
<?php $deadlinkcount = $item->deadlinkcount(); if (!empty($deadlinkcount)) { ?>
<span class="deadlinkcount"><?= $deadlinkcount ?></span>
<?php } ?>
<?php $uncheckedlinkcount = $item->uncheckedlinkcount(); if (!empty($uncheckedlinkcount)) { ?>
<span class="uncheckedlinkcount"><?= $uncheckedlinkcount ?></span>
<?php } ?>
<?php } ?>
</td>
<?php } if ($columns['geolocalisation']) { ?>
Expand Down
9 changes: 6 additions & 3 deletions app/view/templates/homemenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,12 @@
<input type="submit" name="action" value="edit">

<h2>Render</h2>
<input type="hidden" name="checkurl" value="0">
<input type="checkbox" name="checkurl" id="checkurl" value="1">
<label for="checkurl">check external links if necessary</label>
<?php if($urlchecker) { ?>
<input type="hidden" name="checkurl" value="0">
<input type="checkbox" name="checkurl" id="checkurl" value="1">
<label for="checkurl">check external links if necessary</label>
<?php } ?>

<input type="submit" name="action" value="render">

<h2>Delete</h2>
Expand Down

0 comments on commit 354085e

Please sign in to comment.