Updated API

This commit is contained in:
markseu 2024-04-10 10:33:40 +02:00
parent 1ecd5f1f3d
commit beee937102
8 changed files with 63 additions and 60 deletions

View file

@ -1,7 +1,7 @@
<?php
// Core extension, https://github.com/annaesvensson/yellow-core
// 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`
// Please note that the latest core can be found in file "system/workers/core.php"
class YellowCore {
const VERSION = "0.8.134";
@ -40,7 +40,7 @@ class YellowCore {
$fileName = "yellow.php";
$fileData = $fileDataNew = $this->readFile($fileName);
$fileDataNew = str_replace("system/extensions/core.php", "system/workers/core.php", $fileDataNew);
if ($fileData!=$fileDataNew && !$this->createFile($fileName, $fileDataNew)) {
if ($fileData!=$fileDataNew && !$this->writeFile($fileName, $fileDataNew)) {
$statusCode = 500;
header("HTTP/1.0 500 Server error");
echo "Something went wrong during core update: Can't write file '$fileName'! <br/>\n";
@ -68,8 +68,8 @@ class YellowCore {
return $fileData;
}
// Create file
public function createFile($fileName, $fileData, $mkdir = false) {
// Write file
public function writeFile($fileName, $fileData, $mkdir = false) {
$ok = false;
if ($mkdir) {
$path = dirname($fileName);

View file

@ -74,14 +74,14 @@ Status: available
system/workers/breadcrumb.php: breadcrumb.php, create, update
Extension: Bundle
Version: 0.9.2
Version: 0.9.3
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-09 17:07:13
Published: 2024-04-10 10:18:17
Status: available
system/workers/bundle.php: bundle.php, create, update
@ -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.2
Version: 0.9.3
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-09 17:09:52
Published: 2024-04-10 10:17:55
Status: available
system/workers/core.php: core.php, create, update
system/extensions/core.php: coreupdate.txt, update
@ -212,14 +212,14 @@ Status: available
system/workers/dutch.php: dutch.php, create, update
Extension: Edit
Version: 0.9.2
Version: 0.9.3
Description: Edit your website in a web browser.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-edit/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-edit
DocumentationLanguage: en, de, sv
Published: 2024-04-06 21:49:39
Published: 2024-04-10 10:25:08
Status: available
system/workers/edit.php: edit.php, create, update
system/workers/edit.css: edit.css, create, update
@ -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.2
Version: 0.9.3
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-09 18:56:19
Published: 2024-04-10 10:19:17
Status: available
system/workers/generate.php: generate.php, create, update
@ -602,14 +602,14 @@ Status: available
system/workers/private.php: private.php, create, update
Extension: Publish
Version: 0.9.2
Version: 0.9.3
Description: Make and publish extensions.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-publish/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-publish
DocumentationLanguage: en, de, sv
Published: 2024-04-08 19:23:04
Published: 2024-04-10 10:20:07
Status: available
system/workers/publish.php: publish.php, create, update
@ -777,14 +777,14 @@ Status: available
system/workers/turkish.php: turkish.php, create, update
Extension: Update
Version: 0.9.2
Version: 0.9.3
Description: Keep your website up to date.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-update/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-update
DocumentationLanguage: en, de, sv
Published: 2024-04-05 14:41:10
Published: 2024-04-10 10:20:21
Status: available
system/workers/update.php: update.php, create, update
system/workers/updatepatch.bin: updatepatch.php, create, additional

View file

@ -1,14 +1,14 @@
# Datenstrom Yellow extension settings
Extension: Core
Version: 0.9.2
Version: 0.9.3
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-09 17:09:52
Published: 2024-04-10 10:17:55
Status: available
system/workers/core.php: core.php, create, update
system/extensions/core.php: coreupdate.txt, update
@ -20,14 +20,14 @@ system/layouts/navigation.html: navigation.html, create, update, careful
system/layouts/pagination.html: pagination.html, create, update, careful
Extension: Edit
Version: 0.9.2
Version: 0.9.3
Description: Edit your website in a web browser.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-edit/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-edit
DocumentationLanguage: en, de, sv
Published: 2024-04-06 21:49:39
Published: 2024-04-10 10:25:08
Status: available
system/workers/edit.php: edit.php, create, update
system/workers/edit.css: edit.css, create, update
@ -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.2
Version: 0.9.3
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-09 18:56:19
Published: 2024-04-10 10:19:17
Status: available
system/workers/generate.php: generate.php, create, update
@ -62,13 +62,13 @@ media/images/photo.jpg: photo.jpg, create, optional
media/thumbnails/photo-100x40.jpg: photo-100x40.jpg, create, optional
Extension: Install
Version: 0.9.1
Version: 0.9.2
Description: Install a brand new website.
Developer: Anna Svensson
DownloadUrl: https://github.com/annaesvensson/yellow-install/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-install
DocumentationLanguage: en, de, sv
Published: 2024-04-04 14:49:36
Published: 2024-04-10 10:27:08
Status: unassembled
system/workers/install.php: install.php, create
system/workers/install-language.bin: install-language.bin, compress @source/yellow-language/, create
@ -129,14 +129,14 @@ 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.9.2
Version: 0.9.3
Description: Keep your website up to date.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-update/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-update
DocumentationLanguage: en, de, sv
Published: 2024-04-05 14:41:10
Published: 2024-04-10 10:20:21
Status: available
system/workers/update.php: update.php, create, update
system/workers/updatepatch.bin: updatepatch.php, create, additional

View file

@ -2,7 +2,7 @@
// Core extension, https://github.com/annaesvensson/yellow-core
class YellowCore {
const VERSION = "0.9.2";
const VERSION = "0.9.3";
const RELEASE = "0.9";
public $content; // content files
public $media; // media files
@ -659,7 +659,7 @@ class YellowSystem {
}
$fileData = $this->yellow->toolbox->readFile($fileName);
$fileData = $this->yellow->toolbox->setTextSettings($fileData, "", "", $settingsNew);
return $this->yellow->toolbox->createFile($fileName, $fileData);
return $this->yellow->toolbox->writeFile($fileName, $fileData);
}
// Set default system setting
@ -980,7 +980,7 @@ class YellowUser {
}
$fileData = $this->yellow->toolbox->readFile($fileName);
$fileData = $this->yellow->toolbox->setTextSettings($fileData, "email", $email, $settingsNew);
return $this->yellow->toolbox->createFile($fileName, $fileData);
return $this->yellow->toolbox->writeFile($fileName, $fileData);
}
// Remove user settings from file
@ -989,7 +989,7 @@ class YellowUser {
if (isset($this->settings[$email])) unset($this->settings[$email]);
$fileData = $this->yellow->toolbox->readFile($fileName);
$fileData = $this->yellow->toolbox->unsetTextSettings($fileData, "email", $email);
return $this->yellow->toolbox->createFile($fileName, $fileData);
return $this->yellow->toolbox->writeFile($fileName, $fileData);
}
// Set current email
@ -2118,8 +2118,8 @@ class YellowToolbox {
return $fileData;
}
// Create file
public function createFile($fileName, $fileData, $mkdir = false) {
// Write file
public function writeFile($fileName, $fileData, $mkdir = false) {
$ok = false;
if ($mkdir) {
$path = dirname($fileName);
@ -2139,6 +2139,9 @@ class YellowToolbox {
return $ok;
}
// TODO: remove later, for backwards compatibility
public function createFile($fileName, $fileData, $mkdir = false) { return $this->writeFile($fileName, $fileData, $mkdir); }
// Append file
public function appendFile($fileName, $fileData, $mkdir = false) {
$ok = false;

View file

@ -2,7 +2,7 @@
// Edit extension, https://github.com/annaesvensson/yellow-edit
class YellowEdit {
const VERSION = "0.9.2";
const VERSION = "0.9.3";
public $yellow; // access to API
public $response; // web response
public $merge; // text merge
@ -49,7 +49,7 @@ class YellowEdit {
if (!$cleanup) $fileDataNew .= $line;
}
$fileDataNew = rtrim($fileDataNew)."\n";
if ($fileData!=$fileDataNew && !$this->yellow->toolbox->createFile($fileNameUser, $fileDataNew)) {
if ($fileData!=$fileDataNew && !$this->yellow->toolbox->writeFile($fileNameUser, $fileDataNew)) {
$this->yellow->toolbox->log("error", "Can't write file '$fileNameUser'!");
}
}
@ -117,9 +117,9 @@ class YellowEdit {
public function onParsePageExtra($page, $name) {
$output = null;
if ($this->editable && $name=="header") {
$extensionLocation = $this->yellow->system->get("coreServerBase").$this->yellow->system->get("coreExtensionLocation");
$output = "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"{$extensionLocation}edit.css\" />\n";
$output .= "<script type=\"text/javascript\" src=\"{$extensionLocation}edit.js\"></script>\n";
$assetLocation = $this->yellow->system->get("coreServerBase").$this->yellow->system->get("coreAssetLocation");
$output = "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"{$assetLocation}edit.css\" />\n";
$output .= "<script type=\"text/javascript\" src=\"{$assetLocation}edit.js\"></script>\n";
$output .= "<script type=\"text/javascript\">\n";
$output .= "// <![CDATA[\n";
$output .= "yellow.page = ".json_encode($this->response->getPageData($page)).";\n";
@ -723,7 +723,7 @@ class YellowEdit {
$page = $this->response->getPageNew($scheme, $address, $base, $location, $fileName,
$rawData, $this->response->getEndOfLine());
if (!$page->isError()) {
if ($this->yellow->toolbox->createFile($page->fileName, $page->rawData, true)) {
if ($this->yellow->toolbox->writeFile($page->fileName, $page->rawData, true)) {
$location = $this->yellow->lookup->normaliseUrl($scheme, $address, $base, $page->location);
$statusCode = $this->yellow->sendStatus(303, $location);
} else {
@ -751,10 +751,10 @@ class YellowEdit {
if (!$page->isError()) {
if ($this->yellow->lookup->isFileLocation($location)) {
$ok = $this->yellow->toolbox->renameFile($fileName, $page->fileName, true) &&
$this->yellow->toolbox->createFile($page->fileName, $page->rawData);
$this->yellow->toolbox->writeFile($page->fileName, $page->rawData);
} else {
$ok = $this->yellow->toolbox->renameDirectory(dirname($fileName), dirname($page->fileName), true) &&
$this->yellow->toolbox->createFile($page->fileName, $page->rawData);
$this->yellow->toolbox->writeFile($page->fileName, $page->rawData);
}
if ($ok) {
$location = $this->yellow->lookup->normaliseUrl($scheme, $address, $base, $page->location);
@ -1182,7 +1182,7 @@ class YellowEditResponse {
if ($file->get("type")=="html" || $file->get("type")=="svg") {
$fileData = $this->yellow->toolbox->readFile($fileNameTemp);
$fileData = $this->yellow->lookup->normaliseData($fileData, $file->get("type"));
if (is_string_empty($fileData) || !$this->yellow->toolbox->createFile($fileNameTemp, $fileData)) {
if (is_string_empty($fileData) || !$this->yellow->toolbox->writeFile($fileNameTemp, $fileData)) {
$file->error(500, "Can't write file '$fileNameTemp'!");
}
}
@ -1744,7 +1744,7 @@ class YellowEditResponse {
$rawData = $this->yellow->toolbox->readFile($fileName);
$rawData = $this->yellow->toolbox->setMetaData($rawData, "pageOriginalLocation", $location);
$rawData = $this->yellow->toolbox->setMetaData($rawData, "pageOriginalFileName", $fileName);
return $this->yellow->toolbox->createFile($fileName, $rawData) &&
return $this->yellow->toolbox->writeFile($fileName, $rawData) &&
$this->yellow->toolbox->deleteFile($fileName, $this->yellow->system->get("coreTrashDirectory"));
}
@ -1753,7 +1753,7 @@ class YellowEditResponse {
$rawData = $this->yellow->toolbox->readFile($fileName);
$rawData = $this->yellow->toolbox->setMetaData($rawData, "pageOriginalLocation", $location);
$rawData = $this->yellow->toolbox->setMetaData($rawData, "pageOriginalFileName", $fileName);
return $this->yellow->toolbox->createFile($fileName, $rawData) &&
return $this->yellow->toolbox->writeFile($fileName, $rawData) &&
$this->yellow->toolbox->deleteDirectory(dirname($fileName), $this->yellow->system->get("coreTrashDirectory"));
}
@ -1779,7 +1779,7 @@ class YellowEditResponse {
}
return !is_string_empty($fileNameDeleted) && $this->yellow->lookup->isContentFile($fileNameRestored) &&
$this->yellow->toolbox->renameFile($fileNameDeleted, $fileNameRestored, true) &&
$this->yellow->toolbox->createFile($fileNameRestored, $rawDataRestored);
$this->yellow->toolbox->writeFile($fileNameRestored, $rawDataRestored);
}
// Restore deleted directory from trash
@ -1805,7 +1805,7 @@ class YellowEditResponse {
}
return !is_string_empty($pathDeleted) && $this->yellow->lookup->isContentFile($fileNameRestored) &&
$this->yellow->toolbox->renameDirectory($pathDeleted, dirname($fileNameRestored), true) &&
$this->yellow->toolbox->createFile($fileNameRestored, $rawDataRestored);
$this->yellow->toolbox->writeFile($fileNameRestored, $rawDataRestored);
}
// Check if location has been deleted

View file

@ -2,7 +2,7 @@
// Generate extension, https://github.com/annaesvensson/yellow-generate
class YellowGenerate {
const VERSION = "0.9.2";
const VERSION = "0.9.3";
public $yellow; // access to API
public $files; // number of files
public $errors; // number of errors
@ -195,7 +195,7 @@ class YellowGenerate {
}
$fileName = $this->getStaticFile($path, $location, $statusCode);
if (is_file($fileName)) $this->yellow->toolbox->deleteFile($fileName);
if (!$this->yellow->toolbox->createFile($fileName, $fileData, true) ||
if (!$this->yellow->toolbox->writeFile($fileName, $fileData, true) ||
!$this->yellow->toolbox->modifyFile($fileName, $modified)) {
$statusCode = 500;
$this->yellow->page->statusCode = $statusCode;

View file

@ -2,7 +2,7 @@
// Install extension, https://github.com/annaesvensson/yellow-install
class YellowInstall {
const VERSION = "0.9.1";
const VERSION = "0.9.2";
const PRIORITY = "1";
public $yellow; // access to API
@ -253,7 +253,7 @@ class YellowInstall {
$textOld = str_replace("\\n", "\n", $this->yellow->language->getText("{$name}Text", "en"));
$textNew = str_replace("\\n", "\n", $this->yellow->language->getText("{$name}Text", $language));
$fileData = str_replace($textOld, $textNew, $fileData);
if (!$this->yellow->toolbox->createFile($fileName, $fileData)) {
if (!$this->yellow->toolbox->writeFile($fileName, $fileData)) {
$statusCode = 500;
$this->yellow->page->error($statusCode, "Can't write file '$fileName'!");
}
@ -276,7 +276,7 @@ class YellowInstall {
if (!is_string_empty($fileData)) $fileData .= "\n";
$fileData .= "Language: $language\n";
$fileData .= "media/images/photo.jpg: ".$this->yellow->language->getText("installExampleImage", $language)."\n";
if (!$this->yellow->toolbox->createFile($fileName, $fileData)) {
if (!$this->yellow->toolbox->writeFile($fileName, $fileData)) {
$statusCode = 500;
$this->yellow->page->error($statusCode, "Can't write file '$fileName'!");
}
@ -304,7 +304,7 @@ class YellowInstall {
$fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreExtensionFile");
$fileData = $this->yellow->toolbox->readFile($fileName);
$fileDataNew = $this->yellow->toolbox->unsetTextSettings($fileData, "extension", "install");
if ($statusCode==200 && !$this->yellow->toolbox->createFile($fileName, $fileDataNew)) {
if ($statusCode==200 && !$this->yellow->toolbox->writeFile($fileName, $fileDataNew)) {
$statusCode = 500;
$this->yellow->page->error($statusCode, "Can't write file '$fileName'!");
}
@ -429,7 +429,7 @@ class YellowInstall {
$statusCode = 500;
$this->yellow->page->error($statusCode, "Can't download file '$url'!");
}
if ($statusCode==200 && !$this->yellow->toolbox->createFile($fileName, $fileData)) {
if ($statusCode==200 && !$this->yellow->toolbox->writeFile($fileName, $fileData)) {
$statusCode = 500;
$this->yellow->page->error($statusCode, "Can't write file '$fileName'!");
}

View file

@ -2,7 +2,7 @@
// Update extension, https://github.com/annaesvensson/yellow-update
class YellowUpdate {
const VERSION = "0.9.2";
const VERSION = "0.9.3";
const PRIORITY = "2";
public $yellow; // access to API
public $extensions; // number of extensions
@ -232,7 +232,7 @@ class YellowUpdate {
foreach ($settings as $key=>$value) {
$fileName = $path.$this->yellow->lookup->normaliseName($key, true, false, true).".zip";
list($statusCode, $fileData) = $this->getExtensionFile($value->get("downloadUrl"));
if ($statusCode==200 && !$this->yellow->toolbox->createFile($fileName.".download", $fileData)) {
if ($statusCode==200 && !$this->yellow->toolbox->writeFile($fileName.".download", $fileData)) {
$statusCode = 500;
$this->yellow->page->error($statusCode, "Can't write file '$fileName'!");
}
@ -325,7 +325,7 @@ class YellowUpdate {
if (preg_match("/optional/i", $flags) && $this->yellow->extension->isExisting($extension)) $create = $update = $delete = false;
if (preg_match("/careful/i", $flags) && is_file($fileName) && $lastModified!=$oldModified) $update = false;
if ($create) {
if (!$this->yellow->toolbox->createFile($fileName, $fileData, true) ||
if (!$this->yellow->toolbox->writeFile($fileName, $fileData, true) ||
!$this->yellow->toolbox->modifyFile($fileName, $newModified)) {
$statusCode = 500;
$this->yellow->page->error($statusCode, "Can't write file '$fileName'!");
@ -333,7 +333,7 @@ class YellowUpdate {
}
if ($update) {
if (!$this->yellow->toolbox->deleteFile($fileName, $this->yellow->system->get("coreTrashDirectory")) ||
!$this->yellow->toolbox->createFile($fileName, $fileData) ||
!$this->yellow->toolbox->writeFile($fileName, $fileData) ||
!$this->yellow->toolbox->modifyFile($fileName, $newModified)) {
$statusCode = 500;
$this->yellow->page->error($statusCode, "Can't write file '$fileName'!");
@ -457,7 +457,7 @@ class YellowUpdate {
} elseif ($action=="uninstall") {
$fileDataNew = $this->yellow->toolbox->unsetTextSettings($fileData, "extension", $extension);
}
if ($fileData!=$fileDataNew && !$this->yellow->toolbox->createFile($fileName, $fileDataNew)) {
if ($fileData!=$fileDataNew && !$this->yellow->toolbox->writeFile($fileName, $fileDataNew)) {
$statusCode = 500;
$this->yellow->page->error($statusCode, "Can't write file '$fileName'!");
}
@ -500,7 +500,7 @@ class YellowUpdate {
}
}
}
if ($fileData!=$fileDataNew && !$this->yellow->toolbox->createFile($fileName, $fileDataNew)) {
if ($fileData!=$fileDataNew && !$this->yellow->toolbox->writeFile($fileName, $fileDataNew)) {
$statusCode = 500;
$this->yellow->page->error($statusCode, "Can't write file '$fileName'!");
}
@ -572,7 +572,7 @@ class YellowUpdate {
}
}
}
if ($fileData!=$fileDataNew && !$this->yellow->toolbox->createFile($fileName, $fileDataNew)) {
if ($fileData!=$fileDataNew && !$this->yellow->toolbox->writeFile($fileName, $fileDataNew)) {
$statusCode = 500;
$this->yellow->page->error($statusCode, "Can't write file '$fileName'!");
}
@ -789,7 +789,7 @@ class YellowUpdate {
$url = $this->yellow->system->get("updateAvailableUrl");
if ($url=="auto") $url = "https://raw.githubusercontent.com/datenstrom/yellow/main/system/extensions/update-available.ini";
list($statusCode, $fileData) = $this->getExtensionFile($url);
if ($statusCode==200 && !$this->yellow->toolbox->createFile($fileNameAvailable, $fileData)) {
if ($statusCode==200 && !$this->yellow->toolbox->writeFile($fileNameAvailable, $fileData)) {
$statusCode = 500;
$this->yellow->page->error($statusCode, "Can't write file '$fileNameAvailable'!");
}