mirror of
https://github.com/typemill/typemill.git
synced 2025-08-11 16:44:21 +02:00
Favicon, captcha, and raw editor improvements
This commit is contained in:
@@ -50,6 +50,19 @@ abstract class Controller
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function hasChanged($input, $stored, $field)
|
||||
{
|
||||
if(isset($input[$field]) && isset($stored[$field]) && $input[$field] == $stored[$field])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(!isset($input[$field]) && !isset($input[$field]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function getItem($navigation, $url, $urlinfo)
|
||||
{
|
||||
$url = $this->removeEditorFromUrl($url);
|
||||
|
@@ -328,7 +328,6 @@ class ControllerApiAuthorMeta extends Controller
|
||||
return $response->withHeader('Content-Type', 'application/json')->withStatus(500);
|
||||
}
|
||||
|
||||
|
||||
# we have to flatten field definitions for tabs if there are fieldsets in it
|
||||
public function flattenTabFields($tabfields, $flattab, $fieldset = null)
|
||||
{
|
||||
@@ -350,17 +349,4 @@ class ControllerApiAuthorMeta extends Controller
|
||||
}
|
||||
return $flattab;
|
||||
}
|
||||
|
||||
protected function hasChanged($input, $page, $field)
|
||||
{
|
||||
if(isset($input[$field]) && isset($page[$field]) && $input[$field] == $page[$field])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(!isset($input[$field]) && !isset($input[$field]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -14,7 +14,6 @@ class ControllerApiImage extends Controller
|
||||
|
||||
# MISSING
|
||||
#
|
||||
# solution for logo
|
||||
# return error messages and display in image component
|
||||
# check if resized is bigger than original, then use original
|
||||
|
||||
|
@@ -6,6 +6,7 @@ use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Typemill\Models\Validation;
|
||||
use Typemill\Models\Extension;
|
||||
use Typemill\Models\Media;
|
||||
use Typemill\Models\User;
|
||||
use Typemill\Models\Settings;
|
||||
use Typemill\Static\Translations;
|
||||
@@ -43,6 +44,26 @@ class ControllerApiSystemSettings extends Controller
|
||||
return $response->withHeader('Content-Type', 'application/json')->withStatus(400);
|
||||
}
|
||||
|
||||
# if everything is fine, create customsizes for favicon
|
||||
if(isset($validatedOutput['favicon']) && $validatedOutput['favicon'] != '' && ($validatedOutput['favicon'] != $this->settings['favicon']))
|
||||
{
|
||||
$media = new Media();
|
||||
|
||||
$sizes = [
|
||||
'16' => ['width' => 16, 'height' => 16],
|
||||
'32' => ['width' => 32, 'height' => 32],
|
||||
'72' => ['width' => 72, 'height' => 72],
|
||||
'114' => ['width' => 114, 'height' => 114],
|
||||
'144' => ['width' => 144, 'height' => 144],
|
||||
'180' => ['width' => 180, 'height' => 180],
|
||||
];
|
||||
|
||||
foreach ($sizes as $size)
|
||||
{
|
||||
$favicon = $media->createCustomSize($validatedOutput['favicon'], $size['width'], $size['height'], 'favicon');
|
||||
}
|
||||
}
|
||||
|
||||
# store updated settings here
|
||||
$updatedSettings = $settingsModel->updateSettings($validatedOutput);
|
||||
|
||||
|
@@ -178,13 +178,13 @@ class ControllerWebFrontend extends Controller
|
||||
{
|
||||
$favicon = true;
|
||||
$assets->addMeta('tilecolor','<meta name="msapplication-TileColor" content="#F9F8F6" />');
|
||||
$assets->addMeta('tileimage','<meta name="msapplication-TileImage" content="' . $urlinfo['baseurl'] . '/media/files/favicon-144.png" />');
|
||||
$assets->addMeta('icon16','<link rel="icon" type="image/png" href="' . $urlinfo['baseurl'] . '/media/files/favicon-16.png" sizes="16x16" />');
|
||||
$assets->addMeta('icon32','<link rel="icon" type="image/png" href="' . $urlinfo['baseurl'] . '/media/files/favicon-32.png" sizes="32x32" />');
|
||||
$assets->addMeta('icon72','<link rel="apple-touch-icon" sizes="72x72" href="' . $urlinfo['baseurl'] . '/media/files/favicon-72.png" />');
|
||||
$assets->addMeta('icon114','<link rel="apple-touch-icon" sizes="114x114" href="' . $urlinfo['baseurl'] . '/media/files/favicon-114.png" />');
|
||||
$assets->addMeta('icon144','<link rel="apple-touch-icon" sizes="144x144" href="' . $urlinfo['baseurl'] . '/media/files/favicon-144.png" />');
|
||||
$assets->addMeta('icon180','<link rel="apple-touch-icon" sizes="180x180" href="' . $urlinfo['baseurl'] . '/media/files/favicon-180.png" />');
|
||||
$assets->addMeta('tileimage','<meta name="msapplication-TileImage" content="' . $urlinfo['baseurl'] . '/media/custom/favicon-144x144.png" />');
|
||||
$assets->addMeta('icon16','<link rel="icon" type="image/png" href="' . $urlinfo['baseurl'] . '/media/custom/favicon-16x16.png" sizes="16x16" />');
|
||||
$assets->addMeta('icon32','<link rel="icon" type="image/png" href="' . $urlinfo['baseurl'] . '/media/custom/favicon-32x32.png" sizes="32x32" />');
|
||||
$assets->addMeta('icon72','<link rel="apple-touch-icon" sizes="72x72" href="' . $urlinfo['baseurl'] . '/media/custom/favicon-72x72.png" />');
|
||||
$assets->addMeta('icon114','<link rel="apple-touch-icon" sizes="114x114" href="' . $urlinfo['baseurl'] . '/media/custom/favicon-114x114.png" />');
|
||||
$assets->addMeta('icon144','<link rel="apple-touch-icon" sizes="144x144" href="' . $urlinfo['baseurl'] . '/media/custom/favicon-144x144.png" />');
|
||||
$assets->addMeta('icon180','<link rel="apple-touch-icon" sizes="180x180" href="' . $urlinfo['baseurl'] . '/media/custom/favicon-180x180.png" />');
|
||||
}
|
||||
|
||||
|
||||
|
@@ -486,7 +486,7 @@ class Media
|
||||
return true;
|
||||
}
|
||||
|
||||
public function createCustomSize($imageUrl, $width = NULL, $height = NULL)
|
||||
public function createCustomSize($imageUrl, $width = NULL, $height = NULL, $forcename = NULL)
|
||||
{
|
||||
$this->setPathInfo($imageUrl);
|
||||
|
||||
@@ -506,19 +506,18 @@ class Media
|
||||
$extension = $this->getExtension();
|
||||
$originalName = $this->getFilename();
|
||||
$originalFile = $originalName . '.' . $extension;
|
||||
$customName = $originalName . $resizeName;
|
||||
$customName = $forcename ? $forcename . $resizeName : $originalName . $resizeName;
|
||||
$customFile = $customName . '.' . $extension;
|
||||
|
||||
$storage = new StorageWrapper('\Typemill\Models\Storage');
|
||||
|
||||
if($storage->checkFile('customFolder', '', $customFile))
|
||||
if(!$forcename && $storage->checkFile('customFolder', '', $customFile))
|
||||
{
|
||||
# we should get the custom folder url dynamically from storage class
|
||||
return '/media/custom/' . $customFile;
|
||||
}
|
||||
|
||||
# if name is in customfolder (resized already)
|
||||
if($storage->checkFile('customFolder', '', $originalFile))
|
||||
if(!$forcename && $storage->checkFile('customFolder', '', $originalFile))
|
||||
{
|
||||
$imagePath = $storage->getFolderPath('customFolder') . $originalFile;
|
||||
}
|
||||
@@ -536,7 +535,7 @@ class Media
|
||||
$originalSize = $this->getImageSize($image);
|
||||
$resizedImage = $this->resizeImage($image, $desiredSize, $originalSize);
|
||||
|
||||
if($resizedImage && $storage->storeCustomImage($image, $extension, $customName))
|
||||
if($resizedImage && $storage->storeCustomImage($resizedImage, $extension, $customName))
|
||||
{
|
||||
return '/media/custom/' . $customFile;
|
||||
}
|
||||
|
@@ -31,6 +31,16 @@
|
||||
<input type="text" name="personal-honey-mail">
|
||||
</div>
|
||||
|
||||
{% if captcha == 'standard' %}
|
||||
|
||||
{{ captcha(true) }}
|
||||
|
||||
{% elseif captcha == 'aftererror' %}
|
||||
|
||||
{{ captcha(old) }}
|
||||
|
||||
{% endif %}
|
||||
|
||||
<input
|
||||
type="submit"
|
||||
value="{{ translate('Recover password') }}"
|
||||
|
@@ -14,7 +14,7 @@
|
||||
<fieldset class="">
|
||||
|
||||
<div class="my-2 {{ errors.password ? ' errors' : '' }}">
|
||||
<label for="password">{{ translate('Password') }} <abbr title="{{ translate('required') }}">*</abbr></label>
|
||||
<label for="password">{{ translate('New password') }} <abbr title="{{ translate('required') }}">*</abbr></label>
|
||||
<input
|
||||
type="password"
|
||||
name="password"
|
||||
|
@@ -113,4 +113,6 @@ let typemillUtilities = {
|
||||
this.listenToClick();
|
||||
this.listenToChange();
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
typemillUtilities.start();
|
@@ -17,6 +17,7 @@ const raweditor = Vue.createApp({
|
||||
<label for="raweditor" class="block mb-1 font-medium">{{ $filters.translate('Markdown') }}</label>
|
||||
<div class="codearea">
|
||||
<textarea
|
||||
id="rawcontent"
|
||||
name="raweditor"
|
||||
data-el="editor"
|
||||
class="editor"
|
||||
@@ -38,7 +39,8 @@ const raweditor = Vue.createApp({
|
||||
highlighted: '',
|
||||
errors: false,
|
||||
freeze: false,
|
||||
showraw: true,
|
||||
showraw: true,
|
||||
editorsize: false,
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
@@ -51,6 +53,7 @@ const raweditor = Vue.createApp({
|
||||
eventBus.$on('content', content => {
|
||||
this.initializeContent(content);
|
||||
});
|
||||
|
||||
},
|
||||
methods: {
|
||||
showEditor()
|
||||
@@ -62,10 +65,10 @@ const raweditor = Vue.createApp({
|
||||
},
|
||||
hideEditor()
|
||||
{
|
||||
this.showraw =false;
|
||||
this.showraw = false;
|
||||
},
|
||||
initializeContent(contentArray)
|
||||
{
|
||||
{
|
||||
let markdown = '';
|
||||
let title = contentArray.shift();
|
||||
|
||||
@@ -87,18 +90,27 @@ const raweditor = Vue.createApp({
|
||||
{
|
||||
this.highlight(this.content);
|
||||
this.resizeCodearea();
|
||||
|
||||
eventBus.$emit('editdraft');
|
||||
},
|
||||
resizeCodearea()
|
||||
{
|
||||
let codeeditor = this.$refs["raweditor"];
|
||||
let codeeditor = this.$refs["raweditor"];
|
||||
|
||||
window.requestAnimationFrame(() => {
|
||||
codeeditor.style.height = '200px';
|
||||
if (codeeditor.scrollHeight > 200)
|
||||
|
||||
autosize(codeeditor);
|
||||
|
||||
if(codeeditor.style.height > this.editorsize)
|
||||
{
|
||||
codeeditor.style.height = `${codeeditor.scrollHeight + 2}px`;
|
||||
window.scrollBy({
|
||||
top: 18,
|
||||
left: 0,
|
||||
behavior: "smooth",
|
||||
});
|
||||
}
|
||||
|
||||
this.editorsize = codeeditor.style.height;
|
||||
});
|
||||
},
|
||||
highlight(code)
|
||||
|
@@ -63,6 +63,7 @@ fieldsetmedia:
|
||||
favicon:
|
||||
type: image
|
||||
label: Favicon
|
||||
description: Only PNG format will work.
|
||||
liveimagewidth:
|
||||
type: number
|
||||
label: Standard width for live pictures
|
||||
|
Reference in New Issue
Block a user