mikuli.cz

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

commit 5b36a087a7082c1de13445b4efb2a4b33816064a
parent adfca2f1a7420118eaf7e1608c216372a7161d4f
Author: markseu <mark2011@mayberg.se>
Date:   Tue, 17 Aug 2021 16:21:07 +0200

Updated command line, moved built-in web server into own extension

Diffstat:
Msystem/extensions/command.php | 34+---------------------------------
Asystem/extensions/serve.php | 53+++++++++++++++++++++++++++++++++++++++++++++++++++++
Msystem/extensions/update-current.ini | 14++++++++++++--
3 files changed, 66 insertions(+), 35 deletions(-)

diff --git a/system/extensions/command.php b/system/extensions/command.php @@ -2,7 +2,7 @@ // Command extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/command class YellowCommand { - const VERSION = "0.8.28"; + const VERSION = "0.8.29"; public $yellow; // access to API public $files; // number of files public $links; // number of links @@ -29,7 +29,6 @@ class YellowCommand { case "build": $statusCode = $this->processCommandBuild($command, $text); break; case "check": $statusCode = $this->processCommandCheck($command, $text); break; case "clean": $statusCode = $this->processCommandClean($command, $text); break; - case "serve": $statusCode = $this->processCommandServe($command, $text); break; default: $statusCode = 0; } return $statusCode; @@ -40,7 +39,6 @@ class YellowCommand { $help = "build [directory location]\n"; $help .= "check [directory location]\n"; $help .= "clean [directory location]\n"; - $help .= "serve [directory url]\n"; return $help; } @@ -431,36 +429,6 @@ class YellowCommand { } return $statusCode; } - - // 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("commandStaticBuildDirectory"))) { - $path = $this->yellow->system->get("commandStaticBuildDirectory"); - } - if (empty($url)) $url = "http://localhost:8000"; - list($scheme, $address, $base) = $this->yellow->lookup->getUrlInformation($url); - if ($scheme=="http" && !empty($address)) { - if (!preg_match("/\:\d+$/", $address)) $address .= ":8000"; - echo "Starting built-in web server on $scheme://$address/\n"; - echo "Press Ctrl+C to quit...\n"; - if (empty($path) || $path=="dynamic") { - exec("php -S $address yellow.php 2>&1", $outputLines, $returnStatus); - } else { - exec("php -S $address -t $path 2>&1", $outputLines, $returnStatus); - } - $statusCode = $returnStatus!=0 ? 500 : 200; - if ($statusCode!=200) { - $output = !empty($outputLines) ? end($outputLines) : "Please check arguments!"; - if (preg_match("/^\[(.*?)\]\s*(.*)$/", $output, $matches)) $output = $matches[2]; - echo "ERROR starting web server: $output\n"; - } - } else { - $statusCode = 400; - echo "Yellow $command: Invalid arguments\n"; - } - return $statusCode; - } // Process request for cached files public function processRequestCache($scheme, $address, $base, $location, $fileName) { diff --git a/system/extensions/serve.php b/system/extensions/serve.php @@ -0,0 +1,53 @@ +<?php +// Serve extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/serve + +class YellowServe { + const VERSION = "0.8.15"; + public $yellow; // access to API + + // Handle initialisation + public function onLoad($yellow) { + $this->yellow = $yellow; + } + + // Handle command + public function onCommand($command, $text) { + switch ($command) { + case "serve": $statusCode = $this->processCommandServe($command, $text); break; + default: $statusCode = 0; + } + return $statusCode; + } + + // Handle command help + public function onCommandHelp() { + return "serve [directory url]\n"; + } + + // Process command to start built-in web server + public function processCommandServe($command, $text) { + list($path, $url) = $this->yellow->toolbox->getTextArguments($text); + if (empty($url)) $url = "http://localhost:8000"; + list($scheme, $address, $base) = $this->yellow->lookup->getUrlInformation($url); + if ($scheme=="http" && !empty($address)) { + if (!preg_match("/\:\d+$/", $address)) $address .= ":8000"; + echo "Starting built-in web server on $scheme://$address/\n"; + echo "Press Ctrl+C to quit...\n"; + if (empty($path) || $path=="dynamic") { + exec("php -S $address yellow.php 2>&1", $outputLines, $returnStatus); + } else { + exec("php -S $address -t $path 2>&1", $outputLines, $returnStatus); + } + $statusCode = $returnStatus!=0 ? 500 : 200; + if ($statusCode!=200) { + $output = !empty($outputLines) ? end($outputLines) : "Please check arguments!"; + if (preg_match("/^\[(.*?)\]\s*(.*)$/", $output, $matches)) $output = $matches[2]; + echo "ERROR starting web server: $output\n"; + } + } else { + $statusCode = 400; + echo "Yellow $command: Invalid arguments\n"; + } + return $statusCode; + } +} diff --git a/system/extensions/update-current.ini b/system/extensions/update-current.ini @@ -11,11 +11,11 @@ Tag: feature system/extensions/bundle.php: bundle.php, create, update Extension: Command -Version: 0.8.28 +Version: 0.8.29 Description: Command line of the website. HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/command DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/command.zip -Published: 2021-04-01 13:17:15 +Published: 2021-08-17 14:50:39 Developer: Datenstrom Tag: feature system/extensions/command.php: command.php, create, update @@ -100,6 +100,16 @@ Developer: Datenstrom, Steffen Schultz Tag: feature system/extensions/meta.php: meta.php, create, update +Extension: Serve +Version: 0.8.15 +Description: Built-in web server. +HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/serve +DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/serve.zip +Published: 2021-08-17 14:50:39 +Developer: Datenstrom +Tag: feature +system/extensions/serve.php: serve.php, create, update + Extension: Stockholm Version: 0.8.11 Description: Stockholm is a clean theme.