Updated extensions, better command line
This commit is contained in:
parent
1391af1d31
commit
7cebfa7ba7
|
@ -2,7 +2,7 @@
|
|||
// Serve extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/serve
|
||||
|
||||
class YellowServe {
|
||||
const VERSION = "0.8.15";
|
||||
const VERSION = "0.8.16";
|
||||
public $yellow; // access to API
|
||||
|
||||
// Handle initialisation
|
||||
|
@ -30,19 +30,25 @@ class YellowServe {
|
|||
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);
|
||||
if ($this->checkDynamicSettings($path, $url)) {
|
||||
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 ($this->isDynamicPath($path)) {
|
||||
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 {
|
||||
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";
|
||||
$statusCode = 400;
|
||||
$fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreSystemFile");
|
||||
echo "ERROR starting web server: Please configure `CoreServerUrl: auto` in file '$fileName'!\n";
|
||||
}
|
||||
} else {
|
||||
$statusCode = 400;
|
||||
|
@ -50,4 +56,14 @@ class YellowServe {
|
|||
}
|
||||
return $statusCode;
|
||||
}
|
||||
|
||||
// Check dynamic settings
|
||||
public function checkDynamicSettings($path, $url) {
|
||||
return $this->yellow->system->get("coreServerUrl")=="auto" || !$this->isDynamicPath($path);
|
||||
}
|
||||
|
||||
// Check if dynamic path
|
||||
public function isDynamicPath($path) {
|
||||
return empty($path) || $path=="dynamic";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,11 +101,11 @@ Tag: feature
|
|||
system/extensions/meta.php: meta.php, create, update
|
||||
|
||||
Extension: Serve
|
||||
Version: 0.8.15
|
||||
Version: 0.8.16
|
||||
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
|
||||
Published: 2021-08-23 12:46:25
|
||||
Developer: Datenstrom
|
||||
Tag: feature
|
||||
system/extensions/serve.php: serve.php, create, update
|
||||
|
@ -126,11 +126,11 @@ system/themes/stockholm-opensans-light.woff: stockholm-opensans-light.woff, crea
|
|||
system/themes/stockholm-opensans-regular.woff: stockholm-opensans-regular.woff, create, update, careful
|
||||
|
||||
Extension: Update
|
||||
Version: 0.8.55
|
||||
Version: 0.8.56
|
||||
Description: Keep your website up to date.
|
||||
HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/update
|
||||
DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/update.zip
|
||||
Published: 2021-08-20 12:49:04
|
||||
Published: 2021-08-23 11:57:26
|
||||
Developer: Datenstrom
|
||||
Tag: feature
|
||||
system/extensions/update.php: update.php, create, update
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Update extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/update
|
||||
|
||||
class YellowUpdate {
|
||||
const VERSION = "0.8.55";
|
||||
const VERSION = "0.8.56";
|
||||
const PRIORITY = "2";
|
||||
public $yellow; // access to API
|
||||
public $updates; // number of updates
|
||||
|
@ -86,6 +86,19 @@ class YellowUpdate {
|
|||
}
|
||||
}
|
||||
}
|
||||
if ($action=="update") { // TODO: remove later, convert extension settings
|
||||
$fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreSystemFile");
|
||||
if ($this->yellow->system->get("galleryStyle")=="photoswipe") {
|
||||
if (!$this->yellow->system->save($fileName, array("galleryStyle" => "zoom"))) {
|
||||
$this->yellow->log("error", "Can't write file '$fileName'!");
|
||||
}
|
||||
}
|
||||
if ($this->yellow->system->get("sliderStyle")=="flickity") {
|
||||
if (!$this->yellow->system->save($fileName, array("sliderStyle" => "loop"))) {
|
||||
$this->yellow->log("error", "Can't write file '$fileName'!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handle request
|
||||
|
@ -151,16 +164,28 @@ class YellowUpdate {
|
|||
// Process command to update website
|
||||
public function processCommandUpdate($command, $text) {
|
||||
$extensions = $this->getExtensionsFromText($text);
|
||||
list($statusCode, $settings) = $this->getExtensionUpdateInformation($extensions);
|
||||
if ($statusCode!=200 || !empty($settings)) {
|
||||
$this->updates = 0;
|
||||
if ($statusCode==200) $statusCode = $this->downloadExtensions($settings);
|
||||
if ($statusCode==200) $statusCode = $this->updateExtensions("update");
|
||||
if ($statusCode>=400) echo "ERROR updating files: ".$this->yellow->page->get("pageError")."\n";
|
||||
echo "Yellow $command: Website ".($statusCode!=200 ? "not " : "")."updated";
|
||||
echo ", $this->updates update".($this->updates!=1 ? "s" : "")." installed\n";
|
||||
if (!empty($extensions)) {
|
||||
list($statusCode, $settings) = $this->getExtensionUpdateInformation($extensions);
|
||||
if ($statusCode!=200 || !empty($settings)) {
|
||||
$this->updates = 0;
|
||||
if ($statusCode==200) $statusCode = $this->downloadExtensions($settings);
|
||||
if ($statusCode==200) $statusCode = $this->updateExtensions("update");
|
||||
if ($statusCode>=400) echo "ERROR updating files: ".$this->yellow->page->get("pageError")."\n";
|
||||
echo "Yellow $command: Website ".($statusCode!=200 ? "not " : "")."updated";
|
||||
echo ", $this->updates update".($this->updates!=1 ? "s" : "")." installed\n";
|
||||
} else {
|
||||
echo "Your website is up to date\n";
|
||||
}
|
||||
} else {
|
||||
echo "Your website is up to date\n";
|
||||
list($statusCode, $settings) = $this->getExtensionUpdateInformation(array("all"));
|
||||
if ($statusCode!=200 || !empty($settings)) {
|
||||
if ($statusCode>=400) echo "ERROR updating files: ".$this->yellow->page->get("pageError")."\n";
|
||||
$this->updates = count($settings);
|
||||
echo "Yellow $command: Please type 'php yellow.php update all'";
|
||||
echo ", $this->updates update".($this->updates!=1 ? "s" : "")." available\n";
|
||||
} else {
|
||||
echo "Your website is up to date\n";
|
||||
}
|
||||
}
|
||||
return $statusCode;
|
||||
}
|
||||
|
@ -646,7 +671,7 @@ class YellowUpdate {
|
|||
list($statusCodeCurrent, $settingsCurrent) = $this->getExtensionSettings(false);
|
||||
list($statusCodeLatest, $settingsLatest) = $this->getExtensionSettings(true);
|
||||
$statusCode = max($statusCodeCurrent, $statusCodeLatest);
|
||||
if (empty($extensions)) {
|
||||
if (in_array("all", $extensions)) {
|
||||
foreach ($settingsCurrent as $key=>$value) {
|
||||
if ($settingsLatest->isExisting($key)) {
|
||||
$versionCurrent = $settingsCurrent[$key]->get("version");
|
||||
|
|
Loading…
Reference in a new issue