1
0
mirror of https://github.com/typemill/typemill.git synced 2025-08-05 13:47:37 +02:00

version 1.0.4 changed settings and fixed bug

This commit is contained in:
Sebastian
2017-11-19 17:44:42 +01:00
parent 53aaba7a57
commit e0f4c884ea
6 changed files with 88 additions and 46 deletions

View File

@@ -2,6 +2,11 @@
This is the version history with some release notes.
## Version 1.0.4 (17.11.2017)
- Bugfix: Settings file was generated after a page refresh, this is fixed now.
- Improvement: Cleaned up the load and merge process for settings, managed in a new static class now.
## Version 1.0.3 (14.11.2017)
- Bugfix: Deleted a config-file in the download-version, that broke the setup url.

View File

@@ -49,16 +49,9 @@ class PageController extends Controller
/* update sitemap */
$sitemap = new WriteSitemap();
$sitemap->updateSitemap('cache', 'sitemap.xml', 'lastSitemap.txt', $structure, $uri->getBaseUrl());
$version = new VersionCheck();
$latestVersion = $version->checkVersion($uri->getBaseUrl());
if($latestVersion)
{
$yaml = new WriteYaml();
$yamlContent = $yaml->getYaml('settings', 'settings.yaml');
$yamlContent['latestVersion'] = $latestVersion;
$yaml->updateYaml('settings', 'settings.yaml', $yamlContent);
}
/* check and update the typemill-version in the user settings */
$this->updateVersion($uri->getBaseUrl());
}
}
}
@@ -155,4 +148,28 @@ class PageController extends Controller
return $structure;
}
protected function updateVersion($baseUrl)
{
/* check the latest public typemill version */
$version = new VersionCheck();
$latestVersion = $version->checkVersion($baseUrl);
if($latestVersion)
{
/* check, if user-settings exist */
$yaml = new WriteYaml();
$userSettings = $yaml->getYaml('settings', 'settings.yaml');
if($userSettings)
{
/* if there is no version info in the settings or if the version info is outdated */
if(!isset($userSettings['latestVersion']) || $userSettings['latestVersion'] != $latestVersion)
{
/* write the latest version into the user-settings */
$userSettings['latestVersion'] = $latestVersion;
$yaml->updateYaml('settings', 'settings.yaml', $userSettings);
}
}
}
}
}

View File

@@ -1,22 +1,58 @@
<?php
DEFINE('DS', DIRECTORY_SEPARATOR);
namespace Typemill;
return [
'title' => 'TYPEMILL',
'author' => 'Unknown',
'copyright' => 'Copyright',
'startpage' => true,
'rootPath' => __DIR__ . DS . '..' . DS,
'theme' => ($theme = 'typemill'),
'themeFolder' => ($themeFolder = 'themes'),
'themeBasePath' => __DIR__ . DS . '..' . DS,
'themePath' => __DIR__ . DS . '..' . DS . $themeFolder . DS . $theme,
'settingsPath' => __DIR__ . DS . '..' . DS . 'settings',
'authorPath' => __DIR__ . DS . 'author' . DS,
'contentFolder' => 'content',
'displayErrorDetails' => false,
'version' => '1.0.3'
];
class Settings
{
public static function loadSettings()
{
$settings = self::getDefaultSettings();
$userSettings = self::getUserSettings($settings['settingsPath']);
if($userSettings)
{
$settings = array_merge($settings, $userSettings);
}
$settings['themePath'] = $settings['rootPath'] . $settings['themeFolder'] . DIRECTORY_SEPARATOR . $settings['theme'];
return array('settings' => $settings);
}
private function getDefaultSettings()
{
$rootPath = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
return [
'determineRouteBeforeAppMiddleware' => true,
'displayErrorDetails' => true,
'title' => 'TYPEMILL',
'author' => 'Unknown',
'copyright' => 'Copyright',
'startpage' => true,
'rootPath' => $rootPath,
'theme' => ($theme = 'typemill'),
'themeFolder' => ($themeFolder = 'themes'),
'themeBasePath' => $rootPath,
'themePath' => $rootPath . $themeFolder . DIRECTORY_SEPARATOR . $theme,
'settingsPath' => $rootPath . 'settings',
'authorPath' => __DIR__ . DIRECTORY_SEPARATOR . 'author' . DIRECTORY_SEPARATOR,
'contentFolder' => 'content',
'version' => '1.0.4'
];
}
private function getUserSettings($settingsPath)
{
if(file_exists($settingsPath . DIRECTORY_SEPARATOR . 'settings.yaml'))
{
$yaml = new \Symfony\Component\Yaml\Parser();
?>
try {
$userSettings = $yaml->parse( file_get_contents($settingsPath . DIRECTORY_SEPARATOR . 'settings.yaml' ) );
} catch (ParseException $e) {
printf("Unable to parse the YAML string: %s", $e->getMessage());
}
return $userSettings;
}
return false;
}
}

View File

@@ -10,23 +10,7 @@ session_start();
* LOAD SETTINGS *
************************/
$settings = require_once( __DIR__ . '/settings.php');
if(file_exists($settings['settingsPath'] . DIRECTORY_SEPARATOR . 'settings.yaml'))
{
$yaml = new \Symfony\Component\Yaml\Parser();
try {
$userSettings = $yaml->parse( file_get_contents($settings['settingsPath'] . DIRECTORY_SEPARATOR . 'settings.yaml' ) );
} catch (ParseException $e) {
printf("Unable to parse the YAML string: %s", $e->getMessage());
}
$settings = array_merge($settings, $userSettings);
$settings['themePath'] = $settings['themeBasePath'] . $settings['themeFolder'] . DIRECTORY_SEPARATOR . $settings['theme'];
}
$settings['settings'] = $settings;
$settings = Typemill\Settings::loadSettings();
/************************
* INITIATE SLIM *

Submodule system/vendor/erusev/parsedown updated: 728952b90a...fbe3fe878f

BIN
zips/typemill-1.0.4.zip Normal file

Binary file not shown.