Skip to content

Commit

Permalink
Updated core
Browse files Browse the repository at this point in the history
  • Loading branch information
markseuffert committed Apr 9, 2024
1 parent 3d8f06a commit 1aea895
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 76 deletions.
2 changes: 1 addition & 1 deletion system/extensions/core.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
// Core extension, https://github.com/annaesvensson/yellow-core
// This file is only needed for backwards compatibility with Datenstrom Yellow 0.8.23
// This file is only needed for backwards compatibility with Datenstrom Yellow 0.8
// Please note that the latest core can be found in file `system/workers/core.php`

class YellowCore {
Expand Down
16 changes: 8 additions & 8 deletions system/extensions/update-available.ini
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ Status: available
system/workers/breadcrumb.php: breadcrumb.php, create, update

Extension: Bundle
Version: 0.9.1
Version: 0.9.2
Description: Bundle website files.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-bundle/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-bundle
DocumentationLanguage: en, de, sv
Published: 2024-04-04 16:35:34
Published: 2024-04-09 17:07:13
Status: available
system/workers/bundle.php: bundle.php, create, update

Expand Down Expand Up @@ -148,14 +148,14 @@ system/themes/copenhagen.css: copenhagen.css, create, update, careful
system/themes/copenhagen.png: copenhagen.png, create

Extension: Core
Version: 0.9.1
Version: 0.9.2
Description: Core functionality of your website.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-core/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-core
DocumentationLanguage: en, de, sv
Published: 2024-04-04 14:38:12
Published: 2024-04-09 17:09:52
Status: available
system/workers/core.php: core.php, create, update
system/extensions/core.php: coreupdate.txt, update
Expand Down Expand Up @@ -304,14 +304,14 @@ system/workers/gallery-default-skin.svg: gallery-default-skin.svg, create, updat
system/workers/gallery-preloader.gif: gallery-preloader.gif, create, update

Extension: Generate
Version: 0.9.1
Version: 0.9.2
Description: Generate a static website.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-generate/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-generate
DocumentationLanguage: en, de, sv
Published: 2024-04-04 14:55:02
Published: 2024-04-09 18:56:19
Status: available
system/workers/generate.php: generate.php, create, update

Expand Down Expand Up @@ -513,14 +513,14 @@ Status: available
system/workers/markdown.php: markdown.php, create, update

Extension: Meta
Version: 0.9.1
Version: 0.9.2
Description: Meta data for humans and machines.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-meta/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-meta
DocumentationLanguage: en, de, sv
Published: 2024-04-04 20:54:52
Published: 2024-04-09 15:39:39
Status: available
system/workers/meta.php: meta.php, create, update

Expand Down
8 changes: 4 additions & 4 deletions system/extensions/yellow-extension.ini
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Datenstrom Yellow extension settings

Extension: Core
Version: 0.9.1
Version: 0.9.2
Description: Core functionality of your website.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-core/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-core
DocumentationLanguage: en, de, sv
Published: 2024-04-04 14:38:12
Published: 2024-04-09 17:09:52
Status: available
system/workers/core.php: core.php, create, update
system/extensions/core.php: coreupdate.txt, update
Expand Down Expand Up @@ -36,14 +36,14 @@ system/workers/edit-stack.svg: edit-stack.svg, create, update
content/shared/page-new-default.md: page-new-default.md, create, optional

Extension: Generate
Version: 0.9.1
Version: 0.9.2
Description: Generate a static website.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-generate/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-generate
DocumentationLanguage: en, de, sv
Published: 2024-04-04 14:55:02
Published: 2024-04-09 18:56:19
Status: available
system/workers/generate.php: generate.php, create, update

Expand Down
80 changes: 54 additions & 26 deletions system/workers/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Core extension, https://github.com/annaesvensson/yellow-core

class YellowCore {
const VERSION = "0.9.1";
const VERSION = "0.9.2";
const RELEASE = "0.9";
public $content; // content files
public $media; // media files
Expand Down Expand Up @@ -42,11 +42,11 @@ public function __construct() {
$this->system->setDefault("coreUserFile", "yellow-user.ini");
$this->system->setDefault("coreExtensionFile", "yellow-extension.ini");
$this->system->setDefault("coreWebsiteFile", "yellow-website.log");
$this->system->setDefault("coreAssetLocation", "/assets/");
$this->system->setDefault("coreMediaLocation", "/media/");
$this->system->setDefault("coreDownloadLocation", "/media/downloads/");
$this->system->setDefault("coreImageLocation", "/media/images/");
$this->system->setDefault("coreThumbnailLocation", "/media/thumbnails/");
$this->system->setDefault("coreExtensionLocation", "/media/extensions/");
$this->system->setDefault("coreMultiLanguageMode", "0");
$this->system->setDefault("coreDebugMode", "0");
}
Expand Down Expand Up @@ -82,7 +82,8 @@ public function load() {
$this->system->set("coreServerInstallDirectory", $pathInstall);
$this->system->set("coreServerRootDirectory", $pathRoot);
$this->system->set("coreServerHomeDirectory", $pathHome);
$this->system->set("coreThemeLocation", "/media/extensions/"); // TODO: remove later, for backwards compatibility
$this->system->set("coreExtensionLocation", "/assets/"); // TODO: remove later, for backwards compatibility
$this->system->set("coreThemeLocation", "/assets/"); // TODO: remove later, for backwards compatibility
register_shutdown_function(array($this, "processFatalError"));
if ($this->system->get("coreDebugMode")>=1) {
ini_set("display_errors", 1);
Expand Down Expand Up @@ -1289,18 +1290,8 @@ public function findChildrenFromContentLocation($location) {
// Return media location from file path
public function findMediaLocationFromFile($fileName) {
$location = "";
$themeDirectoryLength = strlenu($this->yellow->system->get("coreThemeDirectory"));
$workerDirectoryLength = strlenu($this->yellow->system->get("coreWorkerDirectory"));
$mediaDirectoryLength = strlenu($this->yellow->system->get("coreMediaDirectory"));
if (substru($fileName, 0, $themeDirectoryLength)==$this->yellow->system->get("coreThemeDirectory")) {
if ($this->isSafeFile($fileName)) {
$location = $this->yellow->system->get("coreExtensionLocation").substru($fileName, $themeDirectoryLength);
}
} elseif (substru($fileName, 0, $workerDirectoryLength)==$this->yellow->system->get("coreWorkerDirectory")) {
if ($this->isSafeFile($fileName)) {
$location = $this->yellow->system->get("coreExtensionLocation").substru($fileName, $workerDirectoryLength);
}
} elseif (substru($fileName, 0, $mediaDirectoryLength)==$this->yellow->system->get("coreMediaDirectory")) {
if (substru($fileName, 0, $mediaDirectoryLength)==$this->yellow->system->get("coreMediaDirectory")) {
$location = "/".$fileName;
}
return $location;
Expand All @@ -1309,15 +1300,8 @@ public function findMediaLocationFromFile($fileName) {
// Return file path from media location
public function findFileFromMediaLocation($location) {
$fileName = "";
$extensionLocationLength = strlenu($this->yellow->system->get("coreExtensionLocation"));
$mediaLocationLength = strlenu($this->yellow->system->get("coreMediaLocation"));
if (substru($location, 0, $extensionLocationLength)==$this->yellow->system->get("coreExtensionLocation")) {
if ($this->isSafeFile($location)) {
$fileNameOne = $this->yellow->system->get("coreThemeDirectory").substru($location, $extensionLocationLength);
$fileNameTwo = $this->yellow->system->get("coreWorkerDirectory").substru($location, $extensionLocationLength);
$fileName = is_file($fileNameOne) ? $fileNameOne : $fileNameTwo;
}
} elseif (substru($location, 0, $mediaLocationLength)==$this->yellow->system->get("coreMediaLocation")) {
if (substru($location, 0, $mediaLocationLength)==$this->yellow->system->get("coreMediaLocation")) {
$fileName = substru($location, 1);
}
return $fileName;
Expand All @@ -1343,6 +1327,49 @@ public function findMediaDirectory($key) {
return substru($key, -8, 8)=="Location" ? $this->findFileFromMediaLocation($this->yellow->system->get($key)) : "";
}

// Return media location from file path
public function findSystemLocationFromFile($fileName) {
$location = "";
$layoutDirectoryLength = strlenu($this->yellow->system->get("coreLayoutDirectory"));
$themeDirectoryLength = strlenu($this->yellow->system->get("coreThemeDirectory"));
$workerDirectoryLength = strlenu($this->yellow->system->get("coreWorkerDirectory"));
if (substru($fileName, 0, $layoutDirectoryLength)==$this->yellow->system->get("coreLayoutDirectory")) {
if ($this->isSafeFile($fileName)) {
$location = $this->yellow->system->get("coreAssetLocation").substru($fileName, $layoutDirectoryLength);
}
} elseif (substru($fileName, 0, $themeDirectoryLength)==$this->yellow->system->get("coreThemeDirectory")) {
if ($this->isSafeFile($fileName)) {
$location = $this->yellow->system->get("coreAssetLocation").substru($fileName, $themeDirectoryLength);
}
} elseif (substru($fileName, 0, $workerDirectoryLength)==$this->yellow->system->get("coreWorkerDirectory")) {
if ($this->isSafeFile($fileName)) {
$location = $this->yellow->system->get("coreAssetLocation").substru($fileName, $workerDirectoryLength);
}
}
return $location;
}

// Return file path from media location
public function findFileFromSystemLocation($location) {
$fileName = "";
$assetLocationLength = strlenu($this->yellow->system->get("coreAssetLocation"));
if (substru($location, 0, $assetLocationLength)==$this->yellow->system->get("coreAssetLocation")) {
if ($this->isSafeFile($location)) {
$fileNameLayout = $this->yellow->system->get("coreLayoutDirectory").substru($location, $assetLocationLength);
$fileNameTheme = $this->yellow->system->get("coreThemeDirectory").substru($location, $assetLocationLength);
$fileNameWorker = $this->yellow->system->get("coreWorkerDirectory").substru($location, $assetLocationLength);
if (is_file($fileNameLayout)) {
$fileName = $fileNameLayout;
} elseif (is_file($fileNameTheme)) {
$fileName = $fileNameTheme;
} elseif (is_file($fileNameWorker)) {
$fileName = $fileNameWorker;
}
}
}
return $fileName;
}

// Return file or directory that matches token
public function findFileDirectory($path, $token, $fileExtension, $directory, $default, &$found, &$invalid) {
if ($this->normaliseToken($token, $fileExtension)!=$token) $invalid = true;
Expand Down Expand Up @@ -1613,6 +1640,7 @@ public function getRequestInformation($scheme = "", $address = "", $base = "") {
}
$location = substru($this->yellow->toolbox->detectServerLocation(), strlenu($base));
$fileName = "";
if (is_string_empty($fileName)) $fileName = $this->findFileFromSystemLocation($location);
if (is_string_empty($fileName)) $fileName = $this->findFileFromMediaLocation($location);
if (is_string_empty($fileName)) $fileName = $this->findFileFromContentLocation($location);
return array($scheme, $address, $base, $location, $fileName);
Expand Down Expand Up @@ -3305,20 +3333,20 @@ public function getExtraHtml($name) {
}
}
if ($name=="header") {
$extensionLocation = $this->yellow->system->get("coreServerBase").$this->yellow->system->get("coreExtensionLocation");
$assetLocation = $this->yellow->system->get("coreServerBase").$this->yellow->system->get("coreAssetLocation");
$fileNameTheme = $this->yellow->system->get("coreThemeDirectory").$this->yellow->lookup->normaliseName($this->get("theme")).".css";
if (is_file($fileNameTheme)) {
$fileLocation = $extensionLocation.$this->yellow->lookup->normaliseName($this->get("theme")).".css";
$fileLocation = $assetLocation.$this->yellow->lookup->normaliseName($this->get("theme")).".css";
$output .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"$fileLocation\" />\n";
}
$fileNameScript = $this->yellow->system->get("coreThemeDirectory").$this->yellow->lookup->normaliseName($this->get("theme")).".js";
if (is_file($fileNameScript)) {
$fileLocation = $extensionLocation.$this->yellow->lookup->normaliseName($this->get("theme")).".js";
$fileLocation = $assetLocation.$this->yellow->lookup->normaliseName($this->get("theme")).".js";
$output .= "<script type=\"text/javascript\" src=\"$fileLocation\"></script>\n";
}
$fileNameFavicon = $this->yellow->system->get("coreThemeDirectory").$this->yellow->lookup->normaliseName($this->get("theme")).".png";
if (is_file($fileNameFavicon)) {
$fileLocation = $extensionLocation.$this->yellow->lookup->normaliseName($this->get("theme")).".png";
$fileLocation = $assetLocation.$this->yellow->lookup->normaliseName($this->get("theme")).".png";
$output .= "<link rel=\"icon\" type=\"image/png\" href=\"$fileLocation\" />\n";
}
}
Expand Down
Loading

0 comments on commit 1aea895

Please sign in to comment.