diff --git a/content/00-welcome/00-setup-your-website.yaml b/content/00-welcome/00-setup-your-website.yaml index 44887da..4e77138 100644 --- a/content/00-welcome/00-setup-your-website.yaml +++ b/content/00-welcome/00-setup-your-website.yaml @@ -1,15 +1,15 @@ meta: title: 'Setup Your Website' description: 'Typemill provides detailed settings, and you have access to nearly all settings in the author panel. Learn the basics in this short video:' - heroimage: '' + heroimage: media/live/1528492471.svg heroimagealt: null owner: trendschau author: 'Sebastian Schürmanns' + allowedrole: null + alloweduser: null manualdate: null - modified: '2021-05-27' + modified: '2021-09-02' created: '2021-05-27' time: 21-02-24 navtitle: 'setup your website' hide: false - allowedrole: null - alloweduser: null diff --git a/system/Controllers/MediaApiController.php b/system/Controllers/MediaApiController.php index a837a17..005eac7 100644 --- a/system/Controllers/MediaApiController.php +++ b/system/Controllers/MediaApiController.php @@ -99,24 +99,57 @@ class MediaApiController extends ContentController $this->params = $request->getParams(); $this->uri = $request->getUri()->withUserInfo(''); - $imageProcessor = new ProcessImage($this->settings['images']); - + $imageProcessor = new ProcessImage($this->settings['images']); + if(!$imageProcessor->checkFolders('images')) { - return $response->withJson(['errors' => 'Please check if your media-folder exists and all folders inside are writable.'], 500); - } + return $response->withJson(['errors' => ['message' => 'Please check if your media-folder exists and all folders inside are writable.']], 500); + } - if($imageProcessor->createImage($this->params['image'], $this->params['name'], $this->settings['images'])) + $imageParts = explode(";base64,", $this->params['image']); + $imageType = explode("/", $imageParts[0]); + + if(!isset($imageType[1])) { + return $response->withJson(['errors' => ['message' => 'We did not find an image type, the file might be corrupted.']], 422); + } + + $acceptedTypes = [ + 'png' => true, + 'jpg' => true, + 'jpeg' => true, + 'gif' => true, + 'webp' => true, + ]; + + if(isset($this->settings['svg']) && $this->settings['svg']) + { + $acceptedTypes['svg+xml'] = true; + } + + if(!isset($acceptedTypes[$imageType[1]])) + { + return $response->withJson(['errors' => ['message' => 'The image type is not supported.']], 422); + } + + $imageResult = $imageProcessor->createImage($this->params['image'], $this->params['name'], $this->settings['images']); + + if($imageResult) + { + if(is_array($imageResult) && isset($imageResult['errors'])) + { + return $response->withJson($imageResult,422); + } + # publish image directly, used for example by image field for meta-tabs if($this->params['publish']) { $imageProcessor->publishImage(); } - return $response->withJson(['name' => 'media/live/' . $imageProcessor->getFullName(),'errors' => false]); + return $response->withJson(['name' => 'media/live/' . $imageProcessor->getFullName(),'errors' => false]); } - return $response->withJson(['errors' => 'could not store image to temporary folder']); + return $response->withJson(['errors' => 'could not store image to temporary folder'],422); } public function uploadFile(Request $request, Response $response, $args) diff --git a/system/Controllers/SettingsController.php b/system/Controllers/SettingsController.php index 7a02ab4..ae417b0 100644 --- a/system/Controllers/SettingsController.php +++ b/system/Controllers/SettingsController.php @@ -111,6 +111,7 @@ class SettingsController extends Controller 'trustedproxies' => $newSettings['trustedproxies'], 'headersoff' => isset($newSettings['headersoff']) ? true : null, 'urlschemes' => $newSettings['urlschemes'], + 'svg' => isset($newSettings['svg']) ? true : null, ); # https://www.slimframework.com/docs/v3/cookbook/uploading-files.html; diff --git a/system/Models/ProcessImage.php b/system/Models/ProcessImage.php index d0638ff..8254792 100644 --- a/system/Models/ProcessImage.php +++ b/system/Models/ProcessImage.php @@ -22,6 +22,19 @@ class ProcessImage extends ProcessAssets $imageData = $imageDecoded["image"]; $imageType = $imageDecoded["type"]; + if($imageType == 'svg+xml') + { + # store the original name as txt-file + $tmpname = fopen($this->tmpFolder . $this->getName() . ".svg.txt", "w"); + + # store the same svg file for original, live and thumb. + $this->saveOriginal($this->tmpFolder, $imageData, $name = 'original', 'svg'); + $this->saveOriginal($this->tmpFolder, $imageData, $name = 'live', 'svg'); + $this->saveOriginal($this->tmpFolder, $imageData, $name = 'thumbs', 'svg'); + + return true; + } + $this->setExtension($imageType); # transform image-stream into image @@ -325,17 +338,34 @@ class ProcessImage extends ProcessAssets { $imageinfo = getimagesize($this->liveFolder . $name); - $imagedetails = [ - 'name' => $name, - 'timestamp' => filemtime($this->liveFolder . $name), - 'bytes' => filesize($this->liveFolder . $name), - 'width' => $imageinfo[0], - 'height' => $imageinfo[1], - 'type' => $imageinfo['mime'], - 'src_thumb' => 'media/thumbs/' . $name, - 'src_live' => 'media/live/' . $name, - 'pages' => $this->findPagesWithUrl($structure, $name, $result = []) - ]; + if(!$imageinfo && pathinfo($this->liveFolder . $name, PATHINFO_EXTENSION) == 'svg') + { + $imagedetails = [ + 'name' => $name, + 'timestamp' => filemtime($this->liveFolder . $name), + 'bytes' => filesize($this->liveFolder . $name), + 'width' => '---', + 'height' => '---', + 'type' => 'svg', + 'src_thumb' => 'media/thumbs/' . $name, + 'src_live' => 'media/live/' . $name, + 'pages' => $this->findPagesWithUrl($structure, $name, $result = []) + ]; + } + else + { + $imagedetails = [ + 'name' => $name, + 'timestamp' => filemtime($this->liveFolder . $name), + 'bytes' => filesize($this->liveFolder . $name), + 'width' => $imageinfo[0], + 'height' => $imageinfo[1], + 'type' => $imageinfo['mime'], + 'src_thumb' => 'media/thumbs/' . $name, + 'src_live' => 'media/live/' . $name, + 'pages' => $this->findPagesWithUrl($structure, $name, $result = []) + ]; + } return $imagedetails; } diff --git a/system/Models/Validation.php b/system/Models/Validation.php index 5689510..0cde6be 100644 --- a/system/Models/Validation.php +++ b/system/Models/Validation.php @@ -29,12 +29,12 @@ class Validation Validator::addRule('image_types', function($field, $value, array $params, array $fields) use ($user) { - $allowed = ['jpg', 'jpeg', 'png', 'webp']; + $allowed = ['jpg', 'jpeg', 'png', 'webp', 'svg']; $pathinfo = pathinfo($value); $extension = strtolower($pathinfo['extension']); if(in_array($extension, $allowed)){ return true; } return false; - }, 'only jpg, jpeg, png, webp, allowed'); + }, 'only jpg, jpeg, png, webp, svg allowed'); # checks if email is available if user is created Validator::addRule('emailAvailable', function($field, $value, array $params, array $fields) use ($user) diff --git a/system/Settings.php b/system/Settings.php index 7598a6e..554f961 100644 --- a/system/Settings.php +++ b/system/Settings.php @@ -84,7 +84,7 @@ class Settings 'editor' => 'visual', 'formats' => ['markdown', 'headline', 'ulist', 'olist', 'table', 'quote', 'notice', 'image', 'video', 'file', 'toc', 'hr', 'definition', 'code'], 'contentFolder' => 'content', - 'version' => '1.4.8', + 'version' => '1.4.8.2', 'setup' => true, 'welcome' => true, 'images' => ['live' => ['width' => 820], 'thumbs' => ['width' => 250, 'height' => 150]], @@ -185,6 +185,7 @@ class Settings 'trustedproxies' => true, 'headersoff' => true, 'urlschemes' => true, + 'svg' => true, ]; # cleanup the existing usersettings diff --git a/system/author/css/style.css b/system/author/css/style.css index 3a70c20..785d4cf 100644 --- a/system/author/css/style.css +++ b/system/author/css/style.css @@ -2151,12 +2151,14 @@ button.post-button:hover{ padding: 0 0 0 20px; font-size: 0.9em; line-height: 30px; + height: 30px; background: #66b0a1; margin-bottom: 2px; color: #fff; } .newblock-close{ line-height: 30px; + height: 30px; border: 0px; color: #fff; background: #e0474c; diff --git a/system/author/js/vue-shared.js b/system/author/js/vue-shared.js index 1c9639b..bfaae98 100644 --- a/system/author/js/vue-shared.js +++ b/system/author/js/vue-shared.js @@ -618,7 +618,7 @@ Vue.component('component-image', { if(result.errors) { - publishController.errors.message = result.errors; + publishController.errors.message = result.errors.message; } else { @@ -837,8 +837,8 @@ const medialib = Vue.component('medialib', { }); } return filteredFiles; - } - }, + } + }, methods: { isImagesActive: function() { diff --git a/system/author/layouts/layout.twig b/system/author/layouts/layout.twig index 143fc8c..dc79cec 100644 --- a/system/author/layouts/layout.twig +++ b/system/author/layouts/layout.twig @@ -16,8 +16,8 @@ - - + + {{ assets.renderCSS() }} @@ -39,16 +39,16 @@ - + - - - - - + + + + + diff --git a/system/author/layouts/layoutAuth.twig b/system/author/layouts/layoutAuth.twig index 7af1fa2..8e502ef 100644 --- a/system/author/layouts/layoutAuth.twig +++ b/system/author/layouts/layoutAuth.twig @@ -17,7 +17,7 @@ - + {{ assets.renderCSS() }} diff --git a/system/author/layouts/layoutBlank.twig b/system/author/layouts/layoutBlank.twig index ff49dc2..5f2c7d1 100644 --- a/system/author/layouts/layoutBlank.twig +++ b/system/author/layouts/layoutBlank.twig @@ -16,7 +16,7 @@ - +
diff --git a/system/author/layouts/layoutBlox.twig b/system/author/layouts/layoutBlox.twig index 6d74171..4799e89 100644 --- a/system/author/layouts/layoutBlox.twig +++ b/system/author/layouts/layoutBlox.twig @@ -16,8 +16,8 @@ - - + + {{ assets.renderCSS() }} @@ -41,17 +41,17 @@ - + - - - - - - + + + + + + - - - - - - + + + + + + + {{ assets.renderJS() }} diff --git a/system/author/layouts/layoutEditor.twig b/system/author/layouts/layoutEditor.twig index a512df9..92b7322 100644 --- a/system/author/layouts/layoutEditor.twig +++ b/system/author/layouts/layoutEditor.twig @@ -16,8 +16,8 @@ - - + + {{ assets.renderCSS() }} @@ -41,15 +41,15 @@ - + - - - - + + + + - - - - - - + + + + + + + {{ assets.renderJS() }} diff --git a/system/author/settings/system.twig b/system/author/settings/system.twig index 215b846..188bd62 100644 --- a/system/author/settings/system.twig +++ b/system/author/settings/system.twig @@ -220,6 +220,13 @@ {{ errors.settings.images.live.height | first }} {% endif %} +