mikuli.cz

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

commit 0e3c7e65ffc2dcdd76aadb0a138c05101686b1ff
parent 7b726979547c242b7fcf7aa78b085334e8f3cdb0
Author: markseu <mark2011@mayberg.se>
Date:   Sat,  8 Aug 2020 17:40:16 +0200

Updated extensions, sunshine remix

Diffstat:
Msystem/extensions/command.php | 73++++++++++++++++++++++++++-----------------------------------------------
Msystem/extensions/core.php | 45+++++++++++++++++++++++++++++++++------------
Msystem/extensions/update.php | 8+++++---
Msystem/settings/language.ini | 1-
Msystem/settings/system.ini | 16+++++++++-------
Msystem/settings/user.ini | 1-
6 files changed, 73 insertions(+), 71 deletions(-)

diff --git a/system/extensions/command.php b/system/extensions/command.php @@ -2,8 +2,7 @@ // Command extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/command class YellowCommand { - const VERSION = "0.8.20"; - const PRIORITY = "3"; + const VERSION = "0.8.21"; public $yellow; // access to API public $files; // number of files public $links; // number of links @@ -14,6 +13,10 @@ class YellowCommand { // Handle initialisation public function onLoad($yellow) { $this->yellow = $yellow; + $this->yellow->system->setDefault("commandStaticBuildDirectory", "public/"); + $this->yellow->system->setDefault("commandStaticCacheDirectory", "cache/"); + $this->yellow->system->setDefault("commandStaticDefaultFile", "index.html"); + $this->yellow->system->setDefault("commandStaticErrorFile", "404.html"); } // Handle request @@ -24,7 +27,6 @@ class YellowCommand { // Handle command public function onCommand($command, $text) { switch ($command) { - case "": $statusCode = $this->processCommandHelp(); break; case "build": $statusCode = $this->processCommandBuild($command, $text); break; case "check": $statusCode = $this->processCommandCheck($command, $text); break; case "clean": $statusCode = $this->processCommandClean($command, $text); break; @@ -43,16 +45,6 @@ class YellowCommand { return $help; } - // Process command to show available commands - public function processCommandHelp() { - echo "Datenstrom Yellow is for people who make small websites.\n"; - $lineCounter = 0; - foreach ($this->getCommandHelp() as $line) { - echo(++$lineCounter>1 ? " " : "Syntax: ")."php yellow.php $line\n"; - } - return 200; - } - // Process command to build static website public function processCommandBuild($command, $text) { $statusCode = 0; @@ -78,7 +70,7 @@ class YellowCommand { // Build static files public function buildStaticFiles($path, $locationFilter) { - $path = rtrim(empty($path) ? $this->yellow->system->get("coreStaticBuildDirectory") : $path, "/"); + $path = rtrim(empty($path) ? $this->yellow->system->get("commandStaticBuildDirectory") : $path, "/"); $this->files = $this->errors = 0; $this->locationsArguments = $this->locationsArgumentsPagination = array(); $statusCode = empty($locationFilter) ? $this->cleanStaticFiles($path, $locationFilter) : 200; @@ -260,9 +252,9 @@ class YellowCommand { // Check static files for broken links public function checkStaticFiles($path, $locationFilter) { - $path = rtrim(empty($path) ? $this->yellow->system->get("coreStaticBuildDirectory") : $path, "/"); + $path = rtrim(empty($path) ? $this->yellow->system->get("commandStaticBuildDirectory") : $path, "/"); $this->links = $this->errors = 0; - $regex = "/^[^.]+$|".$this->yellow->system->get("coreStaticDefaultFile")."$/"; + $regex = "/^[^.]+$|".$this->yellow->system->get("commandStaticDefaultFile")."$/"; $fileNames = $this->yellow->toolbox->getDirectoryEntriesRecursive($path, $regex, false, false); list($statusCodeFiles, $links) = $this->analyseLinks($path, $locationFilter, $fileNames); list($statusCodeLinks, $broken, $redirect) = $this->analyseStatus($path, $links); @@ -399,7 +391,7 @@ class YellowCommand { // Clean static files and directories public function cleanStaticFiles($path, $location) { $statusCode = 200; - $path = rtrim(empty($path) ? $this->yellow->system->get("coreStaticBuildDirectory") : $path, "/"); + $path = rtrim(empty($path) ? $this->yellow->system->get("commandStaticBuildDirectory") : $path, "/"); if (empty($location)) { $statusCode = max($statusCode, $this->broadcastCommand("clean", "all")); $statusCode = max($statusCode, $this->cleanStaticDirectory($path)); @@ -452,8 +444,8 @@ class YellowCommand { // Process command to start built-in web server public function processCommandServe($command, $text) { list($path, $url) = $this->yellow->toolbox->getTextArguments($text); - if (empty($path) && is_dir($this->yellow->system->get("coreStaticBuildDirectory"))) { - $path = $this->yellow->system->get("coreStaticBuildDirectory"); + if (empty($path) && is_dir($this->yellow->system->get("commandStaticBuildDirectory"))) { + $path = $this->yellow->system->get("commandStaticBuildDirectory"); } if (empty($url)) $url = "http://localhost:8000"; list($scheme, $address, $base) = $this->yellow->lookup->getUrlInformation($url); @@ -478,11 +470,13 @@ class YellowCommand { // Process request for cached files public function processRequestCache($scheme, $address, $base, $location, $fileName) { $statusCode = 0; - $location .= $this->yellow->toolbox->getLocationArguments(); - $fileName = rtrim($this->yellow->system->get("coreStaticCacheDirectory"), "/").$location; - if (!$this->yellow->lookup->isFileLocation($location)) $fileName .= $this->yellow->system->get("coreStaticDefaultFile"); - if (is_file($fileName) && is_readable($fileName) && !$this->yellow->isCommandLine()) { - $statusCode = $this->yellow->sendFile(200, $fileName, true); + if (is_dir($this->yellow->system->get("commandStaticCacheDirectory"))) { + $location .= $this->yellow->toolbox->getLocationArguments(); + $fileName = rtrim($this->yellow->system->get("commandStaticCacheDirectory"), "/").$location; + if (!$this->yellow->lookup->isFileLocation($location)) $fileName .= $this->yellow->system->get("commandStaticDefaultFile"); + if (is_file($fileName) && is_readable($fileName) && !$this->yellow->isCommandLine()) { + $statusCode = $this->yellow->sendFile(200, $fileName, true); + } } return $statusCode; } @@ -496,29 +490,14 @@ class YellowCommand { public function checkStaticDirectory($path) { $ok = false; if (!empty($path)) { - if ($path==rtrim($this->yellow->system->get("coreStaticBuildDirectory"), "/")) $ok = true; + if ($path==rtrim($this->yellow->system->get("commandStaticBuildDirectory"), "/")) $ok = true; if ($path==rtrim($this->yellow->system->get("coreTrashDirectory"), "/")) $ok = true; - if (is_file("$path/".$this->yellow->system->get("coreStaticDefaultFile"))) $ok = true; + if (is_file("$path/".$this->yellow->system->get("commandStaticDefaultFile"))) $ok = true; if (is_file("$path/yellow.php")) $ok = false; } return $ok; } - // Return command help - public function getCommandHelp() { - $data = array(); - foreach ($this->yellow->extension->data as $key=>$value) { - if (method_exists($value["object"], "onCommandHelp")) { - foreach (preg_split("/[\r\n]+/", $value["object"]->onCommandHelp()) as $line) { - list($command, $dummy) = $this->yellow->toolbox->getTextList($line, " ", 2); - if (!empty($command) && !isset($data[$command])) $data[$command] = $line; - } - } - } - uksort($data, "strnatcasecmp"); - return $data; - } - // Return human readable status public function getStatusFormatted($statusCode) { return $this->yellow->toolbox->getHttpStatusFormatted($statusCode, true); @@ -536,9 +515,9 @@ class YellowCommand { public function getStaticFile($path, $location, $statusCode) { if ($statusCode<400) { $fileName = $path.$location; - if (!$this->yellow->lookup->isFileLocation($location)) $fileName .= $this->yellow->system->get("coreStaticDefaultFile"); + if (!$this->yellow->lookup->isFileLocation($location)) $fileName .= $this->yellow->system->get("commandStaticDefaultFile"); } elseif ($statusCode==404) { - $fileName = $path."/".$this->yellow->system->get("coreStaticErrorFile"); + $fileName = $path."/".$this->yellow->system->get("commandStaticErrorFile"); } return $fileName; } @@ -546,8 +525,8 @@ class YellowCommand { // Return static location public function getStaticLocation($path, $fileName) { $location = substru($fileName, strlenu($path)); - if (basename($location)==$this->yellow->system->get("coreStaticDefaultFile")) { - $defaultFileLength = strlenu($this->yellow->system->get("coreStaticDefaultFile")); + if (basename($location)==$this->yellow->system->get("commandStaticDefaultFile")) { + $defaultFileLength = strlenu($this->yellow->system->get("commandStaticDefaultFile")); $location = substru($location, 0, -$defaultFileLength); } return $location; @@ -608,8 +587,8 @@ class YellowCommand { public function getExtraLocations($path) { $locations = array(); $pathIgnore = "($path/|". - $this->yellow->system->get("coreStaticBuildDirectory")."|". - $this->yellow->system->get("coreStaticCacheDirectory")."|". + $this->yellow->system->get("commandStaticBuildDirectory")."|". + $this->yellow->system->get("commandStaticCacheDirectory")."|". $this->yellow->system->get("coreContentDirectory")."|". $this->yellow->system->get("coreMediaDirectory")."|". $this->yellow->system->get("coreSystemDirectory").")"; diff --git a/system/extensions/core.php b/system/extensions/core.php @@ -2,7 +2,7 @@ // Core extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/core class YellowCore { - const VERSION = "0.8.16"; + const VERSION = "0.8.17"; const RELEASE = "0.8.15"; public $page; // current page public $content; // content files @@ -38,11 +38,6 @@ class YellowCore { $this->system->setDefault("parser", "markdown"); $this->system->setDefault("status", "public"); $this->system->setDefault("coreStaticUrl", ""); - $this->system->setDefault("coreStaticDefaultFile", "index.html"); - $this->system->setDefault("coreStaticErrorFile", "404.html"); - $this->system->setDefault("coreStaticBuildDirectory", "public/"); - $this->system->setDefault("coreStaticCacheDirectory", "cache/"); - $this->system->setDefault("coreTrashDirectory", "system/trash/"); $this->system->setDefault("coreServerUrl", "auto"); $this->system->setDefault("coreServerTimezone", "UTC"); $this->system->setDefault("coreMultiLanguageMode", "0"); @@ -56,9 +51,10 @@ class YellowCore { $this->system->setDefault("coreImageDirectory", "media/images/"); $this->system->setDefault("coreSystemDirectory", "system/"); $this->system->setDefault("coreExtensionDirectory", "system/extensions/"); + $this->system->setDefault("coreSettingDirectory", "system/settings/"); $this->system->setDefault("coreLayoutDirectory", "system/layouts/"); $this->system->setDefault("coreThemeDirectory", "system/themes/"); - $this->system->setDefault("coreSettingDirectory", "system/settings/"); + $this->system->setDefault("coreTrashDirectory", "system/trash/"); $this->system->setDefault("coreContentDirectory", "content/"); $this->system->setDefault("coreContentRootDirectory", "default/"); $this->system->setDefault("coreContentHomeDirectory", "home/"); @@ -283,6 +279,14 @@ class YellowCore { if ($statusCode!=0) break; } } + if ($statusCode==0 && empty($text)) { + $lineCounter = 0; + echo "Datenstrom Yellow is for people who make small websites.\n"; + foreach ($this->getCommandHelp() as $line) { + echo(++$lineCounter>1 ? " " : "Syntax: ")."php yellow.php $line\n"; + } + $statusCode = 200; + } if ($statusCode==0) { $this->lookup->commandHandler = "core"; $statusCode = 400; @@ -373,6 +377,21 @@ class YellowCore { return $this->toolbox->getTextList($line, " ", 2); } + // Return command help + public function getCommandHelp() { + $data = array(); + foreach ($this->extension->data as $key=>$value) { + if (method_exists($value["object"], "onCommandHelp")) { + foreach (preg_split("/[\r\n]+/", $value["object"]->onCommandHelp()) as $line) { + list($command, $dummy) = $this->toolbox->getTextList($line, " ", 2); + if (!empty($command) && !isset($data[$command])) $data[$command] = $line; + } + } + } + uksort($data, "strnatcasecmp"); + return $data; + } + // Return request handler public function getRequestHandler() { return $this->lookup->requestHandler; @@ -1741,12 +1760,14 @@ class YellowUser { foreach ($settingsNew as $key=>$value) { $fileDataSettings .= ucfirst($key).": $value\n"; } - if (!empty($fileDataSettings)) { - $fileDataSettings = preg_replace("/\n+/", "\n", $fileDataSettings); - if (!empty($fileDataStart) && substr($fileDataStart, -2)!="\n\n") $fileDataSettings = "\n".$fileDataSettings; - if (!empty($fileDataEnd)) $fileDataSettings .= "\n"; + if (!empty($fileDataMiddle)) { + $fileDataMiddle = rtrim($fileDataSettings)."\n"; + if (!empty($fileDataEnd)) $fileDataMiddle .= "\n"; + } else { + if (!empty($fileDataStart)) $fileDataEnd .= "\n"; + $fileDataEnd .= $fileDataSettings; } - $fileDataNew = $fileDataStart.$fileDataSettings.$fileDataEnd; + $fileDataNew = $fileDataStart.$fileDataMiddle.$fileDataEnd; return $this->yellow->toolbox->createFile($fileName, $fileDataNew); } diff --git a/system/extensions/update.php b/system/extensions/update.php @@ -2,7 +2,7 @@ // Update extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/update class YellowUpdate { - const VERSION = "0.8.28"; + const VERSION = "0.8.29"; const PRIORITY = "2"; public $yellow; // access to API public $updates; // number of updates @@ -10,9 +10,11 @@ class YellowUpdate { // Handle initialisation public function onLoad($yellow) { $this->yellow = $yellow; + $this->yellow->system->setDefault("updateSourceCodeDirectory", "/Users/yourname/Documents/GitHub/"); $this->yellow->system->setDefault("updateExtensionUrl", "https://github.com/datenstrom/yellow-extensions"); - $this->yellow->system->setDefault("updateExtensionDirectory", "/Users/yourname/Documents/GitHub/"); $this->yellow->system->setDefault("updateExtensionFile", "extension.ini"); + $this->yellow->system->setDefault("updateCurrentFile", "update-current.ini"); + $this->yellow->system->setDefault("updateLatestFile", "update-latest.ini"); $this->yellow->system->setDefault("updateVersionFile", "version.ini"); $this->yellow->system->setDefault("updateWaffleFile", "waffle.ini"); $this->yellow->system->setDefault("updateNotification", "none"); @@ -341,7 +343,7 @@ class YellowUpdate { $extensions = $this->getExtensions($text); if (!empty($extensions)) { $this->updates = 0; - list($statusCode, $data) = $this->getUninstallInformation($extensions, "core, command, update"); + list($statusCode, $data) = $this->getUninstallInformation($extensions, "core, update"); if ($statusCode==200) $statusCode = $this->removeExtensions($data); if ($statusCode>=400) echo "ERROR uninstalling files: ".$this->yellow->page->get("pageError")."\n"; echo "Yellow $command: Website ".($statusCode!=200 ? "not " : "")."updated"; diff --git a/system/settings/language.ini b/system/settings/language.ini @@ -1,2 +1 @@ # Datenstrom Yellow language settings - diff --git a/system/settings/system.ini b/system/settings/system.ini @@ -9,11 +9,6 @@ Theme: stockholm Parser: markdown Status: public CoreStaticUrl: -CoreStaticDefaultFile: index.html -CoreStaticErrorFile: 404.html -CoreStaticBuildDirectory: public/ -CoreStaticCacheDirectory: cache/ -CoreTrashDirectory: system/trash/ CoreServerUrl: auto CoreServerTimezone: UTC CoreMultiLanguageMode: 0 @@ -27,9 +22,10 @@ CoreDownloadDirectory: media/downloads/ CoreImageDirectory: media/images/ CoreSystemDirectory: system/ CoreExtensionDirectory: system/extensions/ +CoreSettingDirectory: system/settings/ CoreLayoutDirectory: system/layouts/ CoreThemeDirectory: system/themes/ -CoreSettingDirectory: system/settings/ +CoreTrashDirectory: system/trash/ CoreContentDirectory: content/ CoreContentRootDirectory: default/ CoreContentHomeDirectory: home/ @@ -41,12 +37,18 @@ CoreDownloadExtension: .download CoreUserFile: user.ini CoreLanguageFile: language.ini CoreLogFile: yellow.log +UpdateSourceCodeDirectory: /Users/yourname/Documents/GitHub/ UpdateExtensionUrl: https://github.com/datenstrom/yellow-extensions -UpdateExtensionDirectory: /Users/yourname/Documents/GitHub/ UpdateExtensionFile: extension.ini +UpdateCurrentFile: update-current.ini +UpdateLatestFile: update-latest.ini UpdateVersionFile: version.ini UpdateWaffleFile: waffle.ini UpdateNotification: none +CommandStaticBuildDirectory: public/ +CommandStaticCacheDirectory: cache/ +CommandStaticDefaultFile: index.html +CommandStaticErrorFile: 404.html EditLocation: /edit/ EditUploadNewLocation: /media/@group/@filename EditUploadExtensions: .gif, .jpg, .pdf, .png, .svg, .zip diff --git a/system/settings/user.ini b/system/settings/user.ini @@ -1,2 +1 @@ # Datenstrom Yellow user settings -