1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-18 10:51:21 +02:00

feat(core): Decouple settings for system plugins from the engine core. #368

BREAKING CHANGE:

this settings will be stored in the **registry.plugin.site.***

```

# The title of the website
title: Flextype

# The description of the website
description: Build fast, flexible, easier to manage websites with Flextype.

# The keywords of the website
keywords: flextype, php, cms, flat-file cms, flat cms, flatfile cms, html

# The robots of the website
robots: index, follow

# The name and email address of the website author
author:
  email: ''
  name: ''
```

this settings will be stored in the **registry.plugin.admin.***

```

# entries settings
entries:
  items_view_default: list
  media:
    upload_images_quality: 70
    upload_images_width: 1600
    upload_images_height: 0
    accept_file_types: gif, jpg, jpeg, png, ico, zip, tgz, txt, md, doc, docx, pdf, epub, xls, xlsx, ppt, pptx, mp3, ogg, wav, m4a, mp4, m4v, ogv, wmv, avi, webm, svg
```
This commit is contained in:
Awilum
2020-02-14 01:49:58 +03:00
parent 5a055d9435
commit 130795d812
5 changed files with 80 additions and 60 deletions

View File

@@ -1,20 +1,3 @@
# The title of the website
title: Flextype
# The description of the website
description: Build fast, flexible, easier to manage websites with Flextype.
# The keywords of the website
keywords: flextype, php, cms, flat-file cms, flat cms, flatfile cms, html
# The robots of the website
robots: index, follow
# The name and email address of the website author
author:
email: ''
name: ''
# Set the timezone to be used on the website.
# For a list of valid timezone settings, see:
# http://php.net/manual/en/timezones.php
@@ -52,15 +35,7 @@ date_display_format: 'd-m-y G:i'
# - media.upload_images_quality: Image quality
# - media.accept_file_types: Define the file types (extensions to be exact) that are acceptable for upload.
entries:
items_view_default: list
main: home
media:
upload_images_quality: 70
upload_images_width: 1600
upload_images_height: 0
accept_file_types: gif, jpg, jpeg, png, ico, zip, tgz, txt, md, doc, docx, pdf,
epub, xls, xlsx, ppt, pptx, mp3, ogg, wav, m4a, mp4, m4v, ogv, wmv, avi, webm,
svg
error404:
title: Error 404
description: We're sorry but the page you are looking for doesn't appear to exist!

View File

@@ -94,7 +94,7 @@ class EntriesController extends Controller
if (isset($entry_current['items_view'])) {
$items_view = $entry_current['items_view'];
} else {
$items_view = $this->registry->get('settings.entries.items_view_default');
$items_view = $this->registry->get('plugins.admin.entries.items_view_default');
}
return $this->view->render(
@@ -892,31 +892,31 @@ class EntriesController extends Controller
$files_directory = PATH['entries'] . '/' . $id . '/';
$file = $this->_uploadFile($_FILES['file'], $files_directory, $this->registry->get('settings.entries.media.accept_file_types'), 27000000);
$file = $this->_uploadFile($_FILES['file'], $files_directory, $this->registry->get('plugins.admin.entries.media.accept_file_types'), 27000000);
if ($file !== false) {
if (in_array(pathinfo($file)['extension'], ['jpg', 'jpeg', 'png', 'gif'])) {
// open an image file
$img = Image::make($file);
// now you are able to resize the instance
if ($this->registry->get('settings.entries.media.upload_images_width') > 0 && $this->registry->get('settings.entries.media.upload_images_height') > 0) {
$img->resize($this->registry->get('settings.entries.media.upload_images_width'), $this->registry->get('settings.entries.media.upload_images_height'), function($constraint) {
if ($this->registry->get('plugins.admin.entries.media.upload_images_width') > 0 && $this->registry->get('plugins.admin.entries.media.upload_images_height') > 0) {
$img->resize($this->registry->get('plugins.admin.entries.media.upload_images_width'), $this->registry->get('plugins.admin.entries.media.upload_images_height'), function($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
} elseif ($this->registry->get('settings.entries.media.upload_images_width') > 0) {
$img->resize($this->registry->get('settings.entries.media.upload_images_width'), null, function($constraint) {
} elseif ($this->registry->get('plugins.admin.entries.media.upload_images_width') > 0) {
$img->resize($this->registry->get('plugins.admin.entries.media.upload_images_width'), null, function($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
} elseif ($this->registry->get('settings.entries.media.upload_images_height') > 0) {
$img->resize(null, $this->registry->get('settings.entries.media.upload_images_height'), function($constraint) {
} elseif ($this->registry->get('plugins.admin.entries.media.upload_images_height') > 0) {
$img->resize(null, $this->registry->get('plugins.admin.entries.media.upload_images_height'), function($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
}
// finally we save the image as a new file
$img->save($file, $this->registry->get('settings.entries.media.upload_images_quality'));
$img->save($file, $this->registry->get('plugins.admin.entries.media.upload_images_quality'));
// destroy
$img->destroy();
@@ -1066,7 +1066,7 @@ class EntriesController extends Controller
$base_url = \Slim\Http\Uri::createFromEnvironment(new \Slim\Http\Environment($_SERVER))->getBaseUrl();
$files = [];
foreach (array_diff(scandir(PATH['entries'] . '/' . $id), ['..', '.']) as $file) {
if (strpos($this->registry->get('settings.entries.media.accept_file_types'), $file_ext = substr(strrchr($file, '.'), 1)) !== false) {
if (strpos($this->registry->get('plugins.admin.entries.media.accept_file_types'), $file_ext = substr(strrchr($file, '.'), 1)) !== false) {
if (strpos($file, strtolower($file_ext), 1)) {
if ($file !== 'entry.md') {
if ($path) {

View File

@@ -1,2 +1,14 @@
# enabled: true or false to disable the plugin
enabled: true
# custom admin pane route
route: admin
# entries settings
entries:
items_view_default: list
media:
upload_images_quality: 70
upload_images_width: 1600
upload_images_height: 0
accept_file_types: gif, jpg, jpeg, png, ico, zip, tgz, txt, md, doc, docx, pdf, epub, xls, xlsx, ppt, pptx, mp3, ogg, wav, m4a, mp4, m4v, ogv, wmv, avi, webm, svg

View File

@@ -1,2 +1,22 @@
# enabled: true or false to disable the plugin
enabled: true
# Site plugin priority
priority: -1000000
# The title of the website
title: Flextype
# The description of the website
description: Build fast, flexible, easier to manage websites with Flextype.
# The keywords of the website
keywords: flextype, php, cms, flat-file cms, flat cms, flatfile cms, html
# The robots of the website
robots: index, follow
# The name and email address of the website author
author:
email: ''
name: ''

View File

@@ -4,43 +4,55 @@
{% block head %}
<meta charset="{{ registry.settings.charset|lower }}">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="{% if entry.description %}{{ entry.description }}{% else %}{{ registry.settings.description }}{% endif %}">
<meta name="keywords" content="{% if entry.keywords %}{{ entry.keywords }}{% else %}{{ registry.settings.keywords }}{% endif %}">
<meta name="robots" content="{% if entry.robots %}{{ entry.robots }}{% else %}{{ registry.settings.robots }}{% endif %}">
<meta name="generator" content="Powered by Flextype {{ FLEXTYPE_VERSION }}" />
<meta name="description" content="{% if entry.description %}{{ entry.description }}{% else %}{{ registry.plugins.site.description }}{% endif %}">
<meta name="keywords" content="{% if entry.keywords %}{{ entry.keywords }}{% else %}{{ registry.plugins.site.keywords }}{% endif %}">
<meta name="robots" content="{% if entry.robots %}{{ entry.robots }}{% else %}{{ registry.plugins.site.robots }}{% endif %}">
<meta name="generator" content="Powered by Flextype {{ FLEXTYPE_VERSION }}"/>
{% do emitter.emit('onThemeMeta') %}
{% do
emitter.emit('onThemeMeta') %}
<title>{% if entry.title %}{{ entry.title|e('html') }} | {% endif %}{{ registry.settings.title|e('html') }}</title>
<title>
{% if entry.title %}{{ entry.title|e('html') }}
|
{% endif %}{{ registry.settings.title|e('html') }}</title>
<link href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,500,500i,700,700i,900,900i&display=swap&subset=cyrillic,cyrillic-ext,latin-ext" rel="stylesheet">
{% set build_css = base_url() ~ '/site/themes/' ~ registry.settings.theme ~ '/assets/dist/css/build.min.css' %}
{% do assets.add('css', build_css, 'site', 1) %}
{% do
assets.add('css', build_css, 'site', 1) %}
{% for assets_site in assets.get('css', 'site') %}
{% for assets_by_priorities in assets_site %}
<link href="{{ assets_by_priorities.asset }}" rel="stylesheet">
{% endfor %}
{% endfor %}
{% do emitter.emit('onThemeHeader') %}
{% do
emitter.emit('onThemeHeader') %}
{{ snippets.exec('google-analytics')|raw }}
{% endblock %}
</head>
<body>
<nav class="bg-black text-white">
<div class="container mx-auto pl-16 pr-16 pt-6 pb-6 clearfix">
<div class="w-full lg:w-2/12
<div class="w-full lg:w-2/12
text-center lg:text-left
float-left text-white py-2 uppercase tracking-wide">
<a href="{{ base_url() }}" class="w-full lg:w-2/12 text-center text-base no-underline">{{ registry.settings.title|e('html') }}</a>
</div>
<div class="w-full float-right lg:w-9/12 font-noirpro-semibold">
<div class="text-right p-2">
{% for item in entries.fetch('', {'order_by': {'field': 'menu_item_order', 'direction': 'asc'}}) %}
{% if item.menu_item_title %}
<a href="{{ base_url() }}/{{ item.menu_item_url }}"
class="uppercase
<a href="{{ base_url() }}" class="w-full lg:w-2/12 text-center text-base no-underline">{{ registry.plugins.site.title|e('html') }}</a>
</div>
<div class="w-full float-right lg:w-9/12 font-noirpro-semibold">
<div class="text-right p-2">
{% for item in entries.fetch('', {
'order_by': {
'field': 'menu_item_order',
'direction': 'asc'
}
}) %}
{% if item.menu_item_title %}
<a
href="{{ base_url() }}/{{ item.menu_item_url }}"
class="uppercase
relative
block
text-white
@@ -53,13 +65,13 @@
lg:inline-block
{% if loop.last %}lg:mr-0{% else %}lg:mr-4{% endif %}
{% if item.menu_item_url in entry.slug %}border-white{% endif %}">
{{ item.menu_item_title }}
</a>
{% endif %}
{% endfor %}
{{ item.menu_item_title }}
</a>
{% endif %}
{% endfor %}
</div>
</div>
</div>
</div>
</div>
</nav>
<main class="container">
@@ -75,6 +87,7 @@
</footer>
</main>
{% do emitter.emit('onThemeTail') %}
{% do
emitter.emit('onThemeTail') %}
</body>
</html>
</html>