commit ecf084cc8d733cadba9227185b2114809fce4305
parent 465dfe465ab7170914e32128439a532ab6180686
Author: markseu <mark2011@mayberg.se>
Date: Thu, 26 Nov 2020 11:13:04 +0100
Updated static site generator for bundled files
Diffstat:
3 files changed, 47 insertions(+), 20 deletions(-)
diff --git a/system/extensions/bundle.php b/system/extensions/bundle.php
@@ -2,7 +2,7 @@
// Bundle extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/bundle
class YellowBundle {
- const VERSION = "0.8.18";
+ const VERSION = "0.8.19";
public $yellow; // access to API
// Handle initialisation
@@ -15,7 +15,7 @@ class YellowBundle {
if ($action=="clean" || $action=="daily" || $action=="uninstall") {
$statusCode = 200;
$path = $this->yellow->system->get("coreExtensionDirectory");
- foreach ($this->yellow->toolbox->getDirectoryEntries($path, "/bundle-.*/", false, false) as $entry) {
+ foreach ($this->yellow->toolbox->getDirectoryEntries($path, "/^bundle-(.*)/", false, false) as $entry) {
$cleanup = !$this->isBundleRequired($entry) || $action=="uninstall";
if ($cleanup && !$this->yellow->toolbox->deleteFile($entry)) $statusCode = 500;
}
@@ -145,7 +145,7 @@ class YellowBundle {
// Return bundle information
public function getBundleInformation($fileName) {
- $fileNames = array();
+ $locations = $fileNames = array();
$modified = 0;
$fileData = $this->yellow->toolbox->readFile($fileName);
foreach ($this->yellow->toolbox->getTextLines($fileData) as $line) {
@@ -153,15 +153,17 @@ class YellowBundle {
$fileNameOne = $this->yellow->system->get("coreExtensionDirectory").$matches[1];
$fileNameTwo = $this->yellow->system->get("coreThemeDirectory").$matches[1];
if (is_readable($fileNameOne)) {
+ array_push($locations, $this->yellow->system->get("coreExtensionLocation").$matches[1]);
array_push($fileNames, $fileNameOne);
$modified = max($modified, $this->yellow->toolbox->getFileModified($fileNameOne));
} elseif (is_readable($fileNameTwo)) {
+ array_push($locations, $this->yellow->system->get("coreThemeLocation").$matches[1]);
array_push($fileNames, $fileNameTwo);
$modified = max($modified, $this->yellow->toolbox->getFileModified($fileNameTwo));
}
}
}
- return array($fileNames, $modified);
+ return array($locations, $fileNames, $modified);
}
// Return bundle ID
@@ -173,10 +175,10 @@ class YellowBundle {
// Check if bundle is required
public function isBundleRequired($fileName) {
- list($fileNames, $modified) = $this->getBundleInformation($fileName);
+ list($dummy, $fileNames, $modified) = $this->getBundleInformation($fileName);
$idExpected = $idCurrent = $this->getBundleId($fileNames, $modified);
- if (preg_match("/bundle-(.*)\.min/", $fileName, $matches)) $idCurrent = $matches[1];
- return $idExpected==$idCurrent;
+ if (preg_match("/^bundle-(.*)\.min/", $fileName, $matches)) $idCurrent = $matches[1];
+ return $idExpected==$idCurrent && !defined("DEBUG");
}
}
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.25";
+ const VERSION = "0.8.26";
public $yellow; // access to API
public $files; // number of files
public $links; // number of links
@@ -553,7 +553,8 @@ class YellowCommand {
// Return media locations
public function getMediaLocations() {
$locations = array();
- $fileNames = $this->yellow->toolbox->getDirectoryEntriesRecursive($this->yellow->system->get("coreMediaDirectory"), "/.*/", false, false);
+ $path = $this->yellow->system->get("coreMediaDirectory");
+ $fileNames = $this->yellow->toolbox->getDirectoryEntriesRecursive($path, "/.*/", false, false);
foreach ($fileNames as $fileName) {
array_push($locations, "/".$fileName);
}
@@ -563,20 +564,44 @@ class YellowCommand {
// Return system locations
public function getSystemLocations() {
$locations = array();
- $regex = "/\.(css|gif|ico|js|jpg|png|svg|woff|woff2)$/";
+ $extensionPath = $this->yellow->system->get("coreExtensionDirectory");
$extensionDirectoryLength = strlenu($this->yellow->system->get("coreExtensionDirectory"));
- $fileNames = $this->yellow->toolbox->getDirectoryEntriesRecursive($this->yellow->system->get("coreExtensionDirectory"), $regex, false, false);
+ $regex = "/\.(css|gif|ico|js|jpg|png|svg|woff|woff2)$/";
+ $fileNames = $this->yellow->toolbox->getDirectoryEntriesRecursive($extensionPath, $regex, false, false);
foreach ($fileNames as $fileName) {
- array_push($locations, $this->yellow->system->get("coreExtensionLocation").substru($fileName, $extensionDirectoryLength));
+ $location = $this->yellow->system->get("coreExtensionLocation").substru($fileName, $extensionDirectoryLength);
+ array_push($locations, $location);
}
+ $themePath = $this->yellow->system->get("coreThemeDirectory");
$themeDirectoryLength = strlenu($this->yellow->system->get("coreThemeDirectory"));
- $fileNames = $this->yellow->toolbox->getDirectoryEntriesRecursive($this->yellow->system->get("coreThemeDirectory"), $regex, false, false);
+ $fileNames = $this->yellow->toolbox->getDirectoryEntriesRecursive($themePath, $regex, false, false);
foreach ($fileNames as $fileName) {
- array_push($locations, $this->yellow->system->get("coreThemeLocation").substru($fileName, $themeDirectoryLength));
+ $location = $this->yellow->system->get("coreThemeLocation").substru($fileName, $themeDirectoryLength);
+ array_push($locations, $location);
}
- return $locations;
+ return array_diff($locations, $this->getSystemLocationsIgnore());
}
-
+
+ // Return system locations to ignore
+ public function getSystemLocationsIgnore() {
+ $locations = array();
+ $extensionPath = $this->yellow->system->get("coreExtensionDirectory");
+ $extensionDirectoryLength = strlenu($this->yellow->system->get("coreExtensionDirectory"));
+ if ($this->yellow->extension->isExisting("bundle")) {
+ foreach ($this->yellow->toolbox->getDirectoryEntries($extensionPath, "/^bundle-(.*)/", false, false) as $entry) {
+ list($locationsBundle) = $this->yellow->extension->get("bundle")->getBundleInformation($entry);
+ $locations = array_merge($locations, $locationsBundle);
+ }
+ }
+ if ($this->yellow->extension->isExisting("edit")) {
+ foreach ($this->yellow->toolbox->getDirectoryEntries($extensionPath, "/^edit\.(.*)/", false, false) as $entry) {
+ $location = $this->yellow->system->get("coreExtensionLocation").substru($entry, $extensionDirectoryLength);
+ array_push($locations, $location);
+ }
+ }
+ return array_unique($locations);
+ }
+
// Return extra locations
public function getExtraLocations($path) {
$locations = array();
diff --git a/system/extensions/update-current.ini b/system/extensions/update-current.ini
@@ -1,21 +1,21 @@
# Datenstrom Yellow update settings
Extension: Bundle
-Version: 0.8.18
+Version: 0.8.19
Description: Bundle website files.
HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/bundle
DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/bundle.zip
-Published: 2020-11-20 16:47:03
+Published: 2020-11-26 11:08:05
Developer: Datenstrom
Tag: feature
system/extensions/bundle.php: bundle.php, create, update
Extension: Command
-Version: 0.8.25
+Version: 0.8.26
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: 2020-10-26 14:56:54
+Published: 2020-11-26 10:59:25
Developer: Datenstrom
Tag: feature
system/extensions/command.php: command.php, create, update