Skip to content

Commit

Permalink
Updated core, image formats
Browse files Browse the repository at this point in the history
  • Loading branch information
markseuffert committed Apr 20, 2024
1 parent e73b6a3 commit 123ec7d
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 124 deletions.
12 changes: 6 additions & 6 deletions system/extensions/update-available.ini
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.3
Version: 0.9.4
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-10 10:17:55
Published: 2024-04-20 15:24:55
Status: available
system/workers/core.php: core.php, create, update
system/extensions/core.php: coreupdate.txt, update
Expand Down Expand Up @@ -212,14 +212,14 @@ Status: available
system/workers/dutch.php: dutch.php, create, update

Extension: Edit
Version: 0.9.3
Version: 0.9.4
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-10 10:25:08
Published: 2024-04-20 15:10:16
Status: available
system/workers/edit.php: edit.php, create, update
system/workers/edit.css: edit.css, create, update
Expand Down Expand Up @@ -431,14 +431,14 @@ system/workers/icon.css: icon.css, create, update
system/workers/icon.woff: icon.woff, create, update

Extension: Image
Version: 0.9.1
Version: 0.9.2
Description: Add images and thumbnails.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-image/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-image
DocumentationLanguage: en, de, sv
Published: 2024-04-04 14:56:26
Published: 2024-04-20 15:25:01
Status: available
system/workers/image.php: image.php, create, update
media/images/photo.jpg: photo.jpg, create, optional
Expand Down
12 changes: 6 additions & 6 deletions system/extensions/yellow-extension.ini
@@ -1,14 +1,14 @@
# Datenstrom Yellow extension settings

Extension: Core
Version: 0.9.3
Version: 0.9.4
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-10 10:17:55
Published: 2024-04-20 15:24:55
Status: available
system/workers/core.php: core.php, create, update
system/extensions/core.php: coreupdate.txt, update
Expand All @@ -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.3
Version: 0.9.4
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-10 10:25:08
Published: 2024-04-20 15:10:16
Status: available
system/workers/edit.php: edit.php, create, update
system/workers/edit.css: edit.css, create, update
Expand All @@ -48,14 +48,14 @@ Status: available
system/workers/generate.php: generate.php, create, update

Extension: Image
Version: 0.9.1
Version: 0.9.2
Description: Add images and thumbnails.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-image/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-image
DocumentationLanguage: en, de, sv
Published: 2024-04-04 14:56:26
Published: 2024-04-20 15:25:01
Status: available
system/workers/image.php: image.php, create, update
media/images/photo.jpg: photo.jpg, create, optional
Expand Down
31 changes: 5 additions & 26 deletions system/workers/core.php
Expand Up @@ -2,7 +2,7 @@
// Core extension, https://github.com/annaesvensson/yellow-core

class YellowCore {
const VERSION = "0.9.3";
const VERSION = "0.9.4";
const RELEASE = "0.9";
public $content; // content files
public $media; // media files
Expand Down Expand Up @@ -82,8 +82,6 @@ public function load() {
$this->system->set("coreServerInstallDirectory", $pathInstall);
$this->system->set("coreServerRootDirectory", $pathRoot);
$this->system->set("coreServerHomeDirectory", $pathHome);
$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 @@ -730,7 +728,6 @@ public function getAvailable($key) {
}
return !is_array_empty($values) ? $values : array($valueDefault);
}
public function getValues($key) { return $this->getAvailable($key); } //TODO: remove later, for backwards compatibility

// Return system settings
public function getSettings($filterStart = "", $filterEnd = "") {
Expand Down Expand Up @@ -1861,7 +1858,7 @@ public function isSafeUrl($url) {

// Check if file is a well-known file type
public function isSafeFile($fileName) {
return preg_match("/\.(css|gif|ico|js|jpg|map|png|scss|svg|woff|woff2)$/", $fileName);
return preg_match("/\.(css|gif|ico|js|jpeg|jpg|map|png|scss|svg|woff|woff2)$/", $fileName);
}

// Check if file is valid
Expand Down Expand Up @@ -2013,6 +2010,7 @@ public function getMimeContentType($fileName) {
"ico" => "image/x-icon",
"js" => "application/javascript",
"json" => "application/json",
"jpeg" => "image/jpeg",
"jpg" => "image/jpeg",
"md" => "text/markdown",
"png" => "image/png",
Expand Down Expand Up @@ -2139,9 +2137,6 @@ public function writeFile($fileName, $fileData, $mkdir = false) {
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;
Expand Down Expand Up @@ -2788,7 +2783,7 @@ public function detectTerminalInformation() {
return array($width, $height);
}

// Detect image width, height, orientation and type for GIF/JPG/PNG/SVG
// Detect image width, height, orientation and type for GIF/JPEG/PNG/SVG
public function detectImageInformation($fileName, $fileType = "") {
$width = $height = $orientation = 0;
$type = "";
Expand All @@ -2803,7 +2798,7 @@ public function detectImageInformation($fileName, $fileType = "") {
$height = (ord($dataHeader[3])<<8) + ord($dataHeader[2]);
$type = $fileType;
}
} elseif ($fileType=="jpg") {
} elseif ($fileType=="jpeg" || $fileType=="jpg") {
$dataBufferSizeMax = filesize($fileName);
$dataBufferSize = min($dataBufferSizeMax, 4096);
if ($dataBufferSize) $dataBuffer = fread($fileHandle, $dataBufferSize);
Expand Down Expand Up @@ -2987,10 +2982,6 @@ public function isLocationArgumentsPagination($location) {
public function isNotModified($lastModifiedFormatted) {
return $this->getServer("HTTP_IF_MODIFIED_SINCE")==$lastModifiedFormatted;
}

// TODO: remove later, for backwards compatibility
public function normaliseArguments($text, $appendSlash = true, $filterStrict = true) { return $this->yellow->lookup->normaliseArguments($text, $appendSlash, $filterStrict); }
public function normalisePath($text) { return $this->yellow->lookup->normalisePath($text); }
}

class YellowPage {
Expand Down Expand Up @@ -3164,10 +3155,6 @@ public function parseContentElement($name, $text, $attrributes, $type) {
$output = $value["object"]->onParseContentElement($this, $name, $text, $attrributes, $type);
if (!is_null($output)) break;
}
if (method_exists($value["object"], "onParseContentShortcut")) { //TODO: remove later, for backwards compatibility
$output = $value["object"]->onParseContentShortcut($this, $name, $text, $type);
if (!is_null($output)) break;
}
}
if (is_null($output)) {
if ($name=="yellow" && $type=="inline" && $text=="error") {
Expand All @@ -3180,9 +3167,6 @@ public function parseContentElement($name, $text, $attrributes, $type) {
return $output;
}

// TODO: remove later, for backwards compatibility
public function parseContentShortcut($name, $text, $type) { return $this->parseContentElement($name, $text, "", $type); }

// Parse page
public function parsePage() {
$this->parsePageLayout($this->get("layout"));
Expand Down Expand Up @@ -3567,10 +3551,6 @@ public function isHeader($key) {
public function isPage($key) {
return isset($this->sharedPages[$key]);
}

// TODO: remove later, for backwards compatibility
public function getContent($rawFormat = false) { return $rawFormat ? $this->getContentRaw() : $this->getContentHtml(); }
public function getExtra($name) { return $this->getExtraHtml($name); }
}

class YellowPageCollection extends ArrayObject {
Expand Down Expand Up @@ -3984,7 +3964,6 @@ function substrb() {
function is_string_empty($string) {
return is_null($string) || $string==="";
}
function strempty($string) { return is_null($string) || $string===""; } //TODO: remove later, for backwards compatibility

// Check if array is empty
function is_array_empty($array) {
Expand Down
6 changes: 3 additions & 3 deletions system/workers/edit.php
Expand Up @@ -2,7 +2,7 @@
// Edit extension, https://github.com/annaesvensson/yellow-edit

class YellowEdit {
const VERSION = "0.9.3";
const VERSION = "0.9.4";
public $yellow; // access to API
public $response; // web response
public $merge; // text merge
Expand All @@ -16,7 +16,7 @@ public function onLoad($yellow) {
$this->yellow->system->setDefault("editSiteEmail", "noreply");
$this->yellow->system->setDefault("editLocation", "/edit/");
$this->yellow->system->setDefault("editUploadNewLocation", "/media/@group/@filename");
$this->yellow->system->setDefault("editUploadExtensions", ".gif, .jpg, .mp3, .ogg, .pdf, .png, .svg, .zip");
$this->yellow->system->setDefault("editUploadExtensions", ".gif, .jpeg, .jpg, .mp3, .ogg, .pdf, .png, .svg, .zip");
$this->yellow->system->setDefault("editKeyboardShortcuts", "ctrl+b bold, ctrl+i italic, ctrl+k strikethrough, ctrl+e code, ctrl+s save, ctrl+alt+p preview");
$this->yellow->system->setDefault("editToolbarButtons", "auto");
$this->yellow->system->setDefault("editEndOfLine", "auto");
Expand Down Expand Up @@ -1535,7 +1535,7 @@ public function getFileNewGroup($fileNameShort) {
$fileType = $this->yellow->toolbox->getFileType($fileNameShort);
$locationMedia = $this->yellow->system->get("coreMediaLocation");
$locationGroup = $this->yellow->system->get("coreDownloadLocation");
if (preg_match("/(gif|jpg|png|svg)$/", $fileType)) {
if (preg_match("/(gif|jpeg|jpg|png|svg)$/", $fileType)) {
$locationGroup = $this->yellow->system->get("coreImageLocation");
}
if (preg_match("#^$locationMedia(.+?)\/#", $locationGroup, $matches)) {
Expand Down
26 changes: 13 additions & 13 deletions system/workers/image.php
Expand Up @@ -2,16 +2,16 @@
// Image extension, https://github.com/annaesvensson/yellow-image

class YellowImage {
const VERSION = "0.9.1";
const VERSION = "0.9.2";
public $yellow; // access to API

// Handle initialisation
public function onLoad($yellow) {
$this->yellow = $yellow;
$this->yellow->system->setDefault("imageUploadWidthMax", "1280");
$this->yellow->system->setDefault("imageUploadHeightMax", "1280");
$this->yellow->system->setDefault("imageUploadJpgQuality", "80");
$this->yellow->system->setDefault("imageThumbnailJpgQuality", "80");
$this->yellow->system->setDefault("imageUploadJpegQuality", "80");
$this->yellow->system->setDefault("imageThumbnailJpegQuality", "80");
}

// Handle update
Expand Down Expand Up @@ -59,19 +59,19 @@ public function onEditMediaFile($file, $action, $email) {
$this->yellow->toolbox->detectImageInformation($fileName, $file->get("type"));
$widthMax = $this->yellow->system->get("imageUploadWidthMax");
$heightMax = $this->yellow->system->get("imageUploadHeightMax");
if ($type=="gif" || $type=="jpg" || $type=="png") {
if ($type=="gif" || $type=="jpeg" || $type=="png") {
if ($widthInput>$widthMax || $heightInput>$heightMax) {
list($widthOutput, $heightOutput) = $this->getImageDimensionsFit($widthInput, $heightInput, $widthMax, $heightMax);
$image = $this->loadImage($fileName, $type);
$image = $this->resizeImage($image, $widthInput, $heightInput, $widthOutput, $heightOutput);
$image = $this->orientImage($image, $orientation);
if (!$this->saveImage($image, $fileName, $type, $this->yellow->system->get("imageUploadJpgQuality"))) {
if (!$this->saveImage($image, $fileName, $type, $this->yellow->system->get("imageUploadJpegQuality"))) {
$file->error(500, "Can't write file '$fileName'!");
}
} elseif ($orientation>1) {
$image = $this->loadImage($fileName, $type);
$image = $this->orientImage($image, $orientation);
if (!$this->saveImage($image, $fileName, $type, $this->yellow->system->get("imageUploadJpgQuality"))) {
if (!$this->saveImage($image, $fileName, $type, $this->yellow->system->get("imageUploadJpegQuality"))) {
$file->error(500, "Can't write file '$fileName'!");
}
}
Expand Down Expand Up @@ -100,7 +100,7 @@ public function getImageInformation($fileName, $widthOutput, $heightOutput) {
$image = $this->resizeImage($image, $widthInput, $heightInput, $widthOutput, $heightOutput);
$image = $this->orientImage($image, $orientation);
if (is_file($fileNameOutput)) $this->yellow->toolbox->deleteFile($fileNameOutput);
if (!$this->saveImage($image, $fileNameOutput, $type, $this->yellow->system->get("imageThumbnailJpgQuality")) ||
if (!$this->saveImage($image, $fileNameOutput, $type, $this->yellow->system->get("imageThumbnailJpegQuality")) ||
!$this->yellow->toolbox->modifyFile($fileNameOutput, $this->yellow->toolbox->getFileModified($fileName))) {
$this->yellow->page->error(500, "Can't write file '$fileNameOutput'!");
}
Expand All @@ -126,9 +126,9 @@ public function getImageDimensionsFit($widthInput, $heightInput, $widthMax, $hei
public function loadImage($fileName, $type) {
$image = false;
switch ($type) {
case "gif": $image = @imagecreatefromgif($fileName); break;
case "jpg": $image = @imagecreatefromjpeg($fileName); break;
case "png": $image = @imagecreatefrompng($fileName); break;
case "gif": $image = @imagecreatefromgif($fileName); break;
case "jpeg": $image = @imagecreatefromjpeg($fileName); break;
case "png": $image = @imagecreatefrompng($fileName); break;
}
return $image;
}
Expand All @@ -137,9 +137,9 @@ public function loadImage($fileName, $type) {
public function saveImage($image, $fileName, $type, $quality) {
$ok = false;
switch ($type) {
case "gif": $ok = @imagegif($image, $fileName); break;
case "jpg": $ok = @imagejpeg($image, $fileName, $quality); break;
case "png": $ok = @imagepng($image, $fileName); break;
case "gif": $ok = @imagegif($image, $fileName); break;
case "jpeg": $ok = @imagejpeg($image, $fileName, $quality); break;
case "png": $ok = @imagepng($image, $fileName); break;
}
return $ok;
}
Expand Down
2 changes: 1 addition & 1 deletion system/workers/install.php
Expand Up @@ -381,7 +381,7 @@ public function checkServerRewrite() {
if (!$this->isServerBuiltin()) {
$curlHandle = curl_init();
list($scheme, $address, $base) = $this->yellow->lookup->getRequestInformation();
$location = $this->yellow->system->get("coreThemeLocation").$this->yellow->lookup->normaliseName($this->yellow->system->get("theme")).".css";
$location = $this->yellow->system->get("coreAssetLocation").$this->yellow->lookup->normaliseName($this->yellow->system->get("theme")).".css";
$url = $this->yellow->lookup->normaliseUrl($scheme, $address, $base, $location);
curl_setopt($curlHandle, CURLOPT_URL, $url);
curl_setopt($curlHandle, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; YellowInstall/".YellowInstall::VERSION).")";
Expand Down

0 comments on commit 123ec7d

Please sign in to comment.