Skip to content

Commit

Permalink
feat: remove version number from downloaded uikit folder to prevent p…
Browse files Browse the repository at this point in the history
…rofile exceptions
  • Loading branch information
BernhardBaumrock committed Mar 30, 2023
1 parent f85907a commit 94f8b94
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
17 changes: 5 additions & 12 deletions RockFrontend.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,10 @@ private function downloadUikit()
$tmp = (new WireTempDir());
(new WireHttp())->download($url, $tmp . "uikit.zip");
$this->wire->files->unzip($tmp . "uikit.zip", $tpl);
$this->wire->files->rmdir($tpl . "uikit", true);
foreach (glob($tpl . "uikit-*") as $dir) {
$this->wire->files->rename($dir, $tpl . "uikit");
}
}

public function editLinks($options = null, $list = true, $size = 32)
Expand Down Expand Up @@ -1995,16 +1999,6 @@ public function getModuleConfigInputfields($inputfields)
return $inputfields;
}

private function addUikitNote(InputfieldSelect $f)
{
$note = '';
foreach (scandir($this->wire->config->paths->templates) as $p) {
if (strpos($p, "uikit-") !== 0) continue;
$note .= "\nFound /site/templates/$p";
}
$f->notes .= $note;
}

private function configSettings($inputfields)
{
$fs = new InputfieldFieldset();
Expand Down Expand Up @@ -2127,10 +2121,9 @@ private function configTools(&$inputfields)
$f->name = 'uikit';
$f->label = 'Download UIkit';
$f->collapsed = Inputfield::collapsedYes;
$f->notes = "Will be downloaded to /site/templates/";
$f->notes = "WARNING: This will wipe the folder /site/templates/uikit and then download the selected uikit version into that folder!";
foreach ($this->getUikitVersions() as $k => $v) $f->addOption($k);
$fs->add($f);
$this->addUikitNote($f);

$this->downloadCDN();
$f = new InputfieldMarkup();
Expand Down
4 changes: 2 additions & 2 deletions profiles/rock/files/site/templates/_main.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/** @var RockFrontend $rockfrontend */
$rockfrontend->styles()
->add('/site/templates/uikit-3.15.12/src/less/uikit.theme.less')
->add('/site/templates/uikit/src/less/uikit.theme.less')
->add('/site/modules/RockFrontend/uikit/defaults.less')
// ->add('/site/modules/RockFrontend/uikit/offcanvas.less')
// ->add('/site/modules/RockFrontend/uikit/12-column-grid.less')
Expand All @@ -15,7 +15,7 @@
->add('/site/templates/less/typography.less')
->addDefaultFolders(); // finally autoload styles in sections, partials, etc
$rockfrontend->scripts()
->add('/site/templates/uikit-3.15.12/dist/js/uikit.min.js');
->add('/site/templates/uikit/dist/js/uikit.min.js');
?>
<!DOCTYPE html>
<html lang="de">
Expand Down

0 comments on commit 94f8b94

Please sign in to comment.