mikuli.cz

:)
git clone https://git.sr.ht/~ashymad/mikuli.cz
Log | Files | Refs

commit df164f1c5abf0b57965ae477b93bc0b0bce9f2e7
parent c4a5ea5d00105a47c5fb651347bf9f7cba160241
Author: markseu <mark2011@mayberg.se>
Date:   Mon,  4 Dec 2023 22:06:29 +0100

Updated installer for testing extensions

Diffstat:
Msystem/extensions/install.php | 26+++++++++++++++++++++++---
Msystem/extensions/update-current.ini | 4++--
2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/system/extensions/install.php b/system/extensions/install.php @@ -2,7 +2,7 @@ // Install extension, https://github.com/annaesvensson/yellow-install class YellowInstall { - const VERSION = "0.8.92"; + const VERSION = "0.8.93"; const PRIORITY = "1"; public $yellow; // access to API @@ -91,7 +91,7 @@ class YellowInstall { echo "ERROR installing files: ".$this->yellow->page->errorMessage."\n"; echo "The installation has not been completed. Please run command again.\n"; } else { - $extensions = count($this->yellow->extension->data); + $extensions = $this->getExtensionsCount(); echo "Yellow $command: $extensions extension".($extensions!=1 ? "s" : "").", 0 errors\n"; } } else { @@ -398,12 +398,15 @@ class YellowInstall { $path = $this->yellow->system->get("coreExtensionDirectory"); $fileData = $this->yellow->toolbox->readFile($path.$this->yellow->system->get("updateLatestFile")); $settings = $this->yellow->toolbox->getTextSettings($fileData, "extension"); + $extensionsNow = 0; + $extensionsEstimated = count($settings) - substr_count(strtoloweru($fileData), "tag: language"); $curlHandle = curl_init(); foreach ($settings as $key=>$value) { $fileName = $path."install-".$this->yellow->lookup->normaliseName($key, true, false, true).".bin"; if (is_file($fileName)) continue; - $url = $value->get("downloadUrl"); if (preg_match("/language/i", $value->get("tag"))) continue; + echo "\rDownloading latest extensions ".$this->getProgressPercent(++$extensionsNow, $extensionsEstimated, 5, 95)."%... "; + $url = $value->get("downloadUrl"); curl_setopt($curlHandle, CURLOPT_URL, $this->yellow->extension->get("update")->getExtensionDownloadUrl($url)); curl_setopt($curlHandle, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; YellowInstall/".YellowInstall::VERSION).")"; curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1); @@ -432,6 +435,7 @@ class YellowInstall { if ($statusCode!=200) break; } curl_close($curlHandle); + echo "\rDownloading latest extensions 100%... done\n"; } return $statusCode; } @@ -469,6 +473,14 @@ class YellowInstall { return $extensions; } + // Return extensions installed + public function getExtensionsCount() { + $fileNameCurrent = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("updateCurrentFile"); + $fileData = $this->yellow->toolbox->readFile($fileNameCurrent); + $settings = $this->yellow->toolbox->getTextSettings($fileData, "extension"); + return count($settings); + } + // Return system languages public function getSystemLanguages($languagesDefault) { $languages = array(); @@ -527,6 +539,14 @@ class YellowInstall { return $rawData; } + // Return progress in percent + public function getProgressPercent($now, $total, $increments, $max) { + $max = intval($max/$increments) * $increments; + $percent = intval(($max/$total) * $now); + if ($increments>1) $percent = intval($percent/$increments) * $increments; + return min($max, $percent); + } + // Check if running built-in web server public function isServerBuiltin() { list($name) = $this->yellow->toolbox->detectServerInformation(); diff --git a/system/extensions/update-current.ini b/system/extensions/update-current.ini @@ -54,11 +54,11 @@ media/images/photo.jpg: photo.jpg, create, optional media/thumbnails/photo-100x40.jpg: photo-100x40.jpg, create, optional Extension: Install -Version: 0.8.92 +Version: 0.8.93 Description: Install a brand new website. DocumentationUrl: https://github.com/annaesvensson/yellow-install DownloadUrl: https://github.com/annaesvensson/yellow-install/archive/refs/heads/main.zip -Published: 2023-12-03 03:23:42 +Published: 2023-12-04 20:53:04 Developer: Anna Svensson Status: unlisted system/extensions/install.php: install.php, create