From 5eb4fc58756c82c98fcdd0f592f1ec9225805ca0 Mon Sep 17 00:00:00 2001 From: Awilum Date: Tue, 20 Aug 2019 15:47:14 +0300 Subject: [PATCH] feat(core): update Settings #212 #186 We should use YAML files for configuration instead of JSON Because of low readability of JSON files for humans. BREAKING CHANGE: JSON config files should be converted to YAML files - flextype/confing/settings.yaml - site/config/settings.yaml --- flextype/bootstrap.php | 8 ++-- flextype/config/settings.json | 85 ----------------------------------- flextype/config/settings.yaml | 70 +++++++++++++++++++++++++++++ site/config/settings.json | 1 - site/config/settings.yaml | 0 5 files changed, 74 insertions(+), 90 deletions(-) delete mode 100644 flextype/config/settings.json create mode 100644 flextype/config/settings.yaml delete mode 100644 site/config/settings.json create mode 100644 site/config/settings.yaml diff --git a/flextype/bootstrap.php b/flextype/bootstrap.php index 25e48bb6..fa70e4ed 100755 --- a/flextype/bootstrap.php +++ b/flextype/bootstrap.php @@ -49,8 +49,8 @@ $registry = new Registry(); * 3. Merge settings. * 4. Add settings into the registry. */ -$default_settings_file_path = PATH['config']['default'] . '/settings.json'; -$site_settings_file_path = PATH['config']['site'] . '/settings.json'; +$default_settings_file_path = PATH['config']['default'] . '/settings.yaml'; +$site_settings_file_path = PATH['config']['site'] . '/settings.yaml'; // Set settings if Flextype settings and Site settings config files exist if (! Filesystem::has($default_settings_file_path) || ! Filesystem::has($site_settings_file_path)) { @@ -60,13 +60,13 @@ if (! Filesystem::has($default_settings_file_path) || ! Filesystem::has($site_se if (($content = Filesystem::read($default_settings_file_path)) === false) { throw new RuntimeException('Load file: ' . $default_settings_file_path . ' - failed!'); } else { - $default_settings = JsonParser::decode($content); + $default_settings = Parser::decode($content, 'yaml'); } if (($content = Filesystem::read($site_settings_file_path)) === false) { throw new RuntimeException('Load file: ' . $site_settings_file_path . ' - failed!'); } else { - $site_settings = JsonParser::decode($content); + $site_settings = Parser::decode($content, 'yaml'); } // Merge settings diff --git a/flextype/config/settings.json b/flextype/config/settings.json deleted file mode 100644 index 9b5b69c6..00000000 --- a/flextype/config/settings.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "title":"Flextype", - "description":"Build fast, flexible, easier to manage websites with Flextype.", - "keywords":"flextype, php, cms, flat-file cms, flat cms, flatfile cms, html", - "robots":"index, follow", - "author":{ - "email":"", - "name":"" - }, - "timezone":"UTC", - "charset":"UTF-8", - "date_format":"F d Y H:i:s", - "theme":"default", - "locale":"en_US", - "entries":{ - "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!", - "content":"We're sorry but the page you are looking for doesn't appear to exist!", - "template":"default" - } - }, - "errors":{ - "display":false - }, - "cache":{ - "enabled":true, - "prefix":"flextype", - "driver":"auto", - "lifetime":604800, - "memcache":{ - "server":"localhost", - "port":11211 - }, - "memcached":{ - "server":"localhost", - "port":11211 - }, - "redis":{ - "socket":false, - "password":false, - "server":"localhost", - "port":6379 - }, - "sqlite3":{ - "database":"flextype", - "table":"flextype" - } - }, - "admin_panel":{ - "theme":"light" - }, - "whoops" : { - "editor": "atom", - "page_title": "Error!" - }, - "display_error_details": true, - "add_content_length_header": true, - "router_cache_file": false, - "determine_route_before_app_middleware": false, - "output_buffering": "append", - "response_chunk_size": 4096, - "http_version": "1.1", - "twig": { - "auto_reload": true - }, - "slugify": { - "separator": "-", - "lowercase": true, - "trim": true, - "regexp": "/[^A-Za-z0-9]+/", - "lowercase_after_regexp": false, - "strip_tags": false - }, - "image": { - "driver": "gd" - } -} diff --git a/flextype/config/settings.yaml b/flextype/config/settings.yaml new file mode 100644 index 00000000..b4aa4b30 --- /dev/null +++ b/flextype/config/settings.yaml @@ -0,0 +1,70 @@ +title: Flextype +description: Build fast, flexible, easier to manage websites with Flextype. +keywords: flextype, php, cms, flat-file cms, flat cms, flatfile cms, html +robots: index, follow +author: + email: '' + name: '' +timezone: UTC +charset: UTF-8 +date_format: F d Y H:i:s +theme: default +locale: en_US +entries: + 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! + content: We're sorry but the page you are looking for doesn't appear to exist! + template: default +errors: + display: false +cache: + enabled: false + prefix: flextype + driver: auto + lifetime: 604800 + memcache: + server: localhost + port: 11211 + memcached: + server: localhost + port: 11211 + redis: + socket: false + password: false + server: localhost + port: 6379 + sqlite3: + database: flextype + table: flextype +admin_panel: + theme: light +whoops: + editor: atom + page_title: Error! +display_error_details: true +add_content_length_header: true +router_cache_file: false +determine_route_before_app_middleware: false +output_buffering: append +response_chunk_size: 4096 +http_version: '1.1' +twig: + auto_reload: true +slugify: + separator: "-" + lowercase: true + trim: true + regexp: "/[^A-Za-z0-9]+/" + lowercase_after_regexp: false + strip_tags: false +image: + driver: gd diff --git a/site/config/settings.json b/site/config/settings.json deleted file mode 100644 index 0967ef42..00000000 --- a/site/config/settings.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/site/config/settings.yaml b/site/config/settings.yaml new file mode 100644 index 00000000..e69de29b