Updated config and plugins

This commit is contained in:
markseu 2018-09-28 14:07:09 +02:00
parent c27eb45c24
commit f1b7201290
6 changed files with 39 additions and 28 deletions

View file

@ -10,7 +10,8 @@ Theme: flatsite
StaticUrl:
StaticDefaultFile: index.html
StaticErrorFile: 404.html
StaticDir: cache/
StaticDir: public/
CacheDir: cache/
MediaLocation: /media/
DownloadLocation: /media/downloads/
ImageLocation: /media/images/
@ -50,8 +51,8 @@ Sidebar: sidebar
Siteicon: icon
Tagline:
Parser: markdown
ParserSafeMode: 0
MultiLanguageMode: 0
SafeMode: 0
SetupMode: 1
BundleAndMinify: 1
EditLocation: /edit/

View file

@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowCore {
const VERSION = "0.7.6";
const VERSION = "0.7.7";
public $page; //current page
public $pages; //pages from file system
public $files; //files from file system
@ -34,7 +34,8 @@ class YellowCore {
$this->config->setDefault("staticUrl", "");
$this->config->setDefault("staticDefaultFile", "index.html");
$this->config->setDefault("staticErrorFile", "404.html");
$this->config->setDefault("staticDir", "cache/");
$this->config->setDefault("staticDir", "public/");
$this->config->setDefault("cacheDir", "cache/");
$this->config->setDefault("mediaLocation", "/media/");
$this->config->setDefault("downloadLocation", "/media/downloads/");
$this->config->setDefault("imageLocation", "/media/images/");
@ -75,8 +76,8 @@ class YellowCore {
$this->config->setDefault("siteicon", "icon");
$this->config->setDefault("tagline", "");
$this->config->setDefault("parser", "markdown");
$this->config->setDefault("parserSafeMode", "0");
$this->config->setDefault("multiLanguageMode", "0");
$this->config->setDefault("safeMode", "0");
$this->config->setDefault("setupMode", "0");
}
@ -152,7 +153,7 @@ class YellowCore {
}
}
if ($statusCode==0) {
$fileName = $this->lookup->findFileStatic($location, $fileName, $cacheable && !$this->isCommandLine());
$fileName = $this->lookup->findFileFromCache($location, $fileName, $cacheable && !$this->isCommandLine());
if ($this->lookup->isContentFile($fileName) || !is_readable($fileName)) {
$fileName = $this->readPage($scheme, $address, $base, $location, $fileName, $cacheable,
max(is_readable($fileName) ? 200 : 404, $this->page->statusCode), $this->page->get("pageError"));
@ -386,7 +387,7 @@ class YellowPage {
public $outputData; //response output
public $parser; //content parser
public $parserData; //content data of page
public $parserSafeMode; //page is parsed in safe mode? (boolean)
public $safeMode; //page is parsed in safe mode? (boolean)
public $available; //page is available? (boolean)
public $visible; //page is visible location? (boolean)
public $active; //page is active location? (boolean)
@ -416,7 +417,7 @@ class YellowPage {
$this->rawData = $rawData;
$this->parser = null;
$this->parserData = "";
$this->parserSafeMode = intval($this->yellow->config->get("parserSafeMode"));
$this->safeMode = intval($this->yellow->config->get("safeMode"));
$this->available = true;
$this->visible = $this->yellow->lookup->isVisibleLocation($this->location, $this->fileName);
$this->active = $this->yellow->lookup->isActiveLocation($this->location, $this->yellow->page->location);
@ -541,7 +542,7 @@ class YellowPage {
$output .= htmlspecialchars("$key $value")."<br />\n";
}
$output .= "</span>\n";
if ($this->parserSafeMode) $this->error(500, "Yellow '$text' is not available in safe mode!");
if ($this->safeMode) $this->error(500, "Yellow '$text' is not available in safe mode!");
}
}
}
@ -2086,17 +2087,6 @@ class YellowLookup {
return $fileName;
}
// Return static file if possible
public function findFileStatic($location, $fileName, $cacheable) {
if ($cacheable) {
$location .= $this->yellow->toolbox->getLocationArgs();
$fileNameStatic = rtrim($this->yellow->config->get("staticDir"), "/").$location;
if (!$this->isFileLocation($location)) $fileNameStatic .= $this->yellow->config->get("staticDefaultFile");
if (is_readable($fileNameStatic)) $fileName = $fileNameStatic;
}
return $fileName;
}
// Return children from location
public function findChildrenFromLocation($location) {
$fileNames = array();
@ -2163,6 +2153,17 @@ class YellowLookup {
return $fileName;
}
// Return file path from cache if possible
public function findFileFromCache($location, $fileName, $cacheable) {
if ($cacheable) {
$location .= $this->yellow->toolbox->getLocationArgs();
$fileNameStatic = rtrim($this->yellow->config->get("cacheDir"), "/").$location;
if (!$this->isFileLocation($location)) $fileNameStatic .= $this->yellow->config->get("staticDefaultFile");
if (is_readable($fileNameStatic)) $fileName = $fileNameStatic;
}
return $fileName;
}
// Normalise file/directory token
public function normaliseToken($text, $fileExtension = "", $removeExtension = false) {
if (!empty($fileExtension)) $text = ($pos = strrposu($text, ".")) ? substru($text, 0, $pos) : $text;

View file

@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowEdit {
const VERSION = "0.7.30";
const VERSION = "0.7.31";
public $yellow; //access to API
public $response; //web response
public $users; //user accounts
@ -1055,7 +1055,7 @@ class YellowResponse {
$data["address"] = $this->yellow->page->address;
$data["base"] = $this->yellow->page->base;
$data["location"] = $this->yellow->page->location;
$data["parserSafeMode"] = $this->yellow->page->parserSafeMode;
$data["safeMode"] = $this->yellow->page->safeMode;
}
if ($this->action!="none") $data = array_merge($data, $this->getRequestData());
$data["action"] = $this->action;

View file

@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowMarkdown {
const VERSION = "0.7.1";
const VERSION = "0.7.2";
public $yellow; //access to API
// Handle initialisation
@ -3744,10 +3744,10 @@ class YellowMarkdownExtraParser extends MarkdownExtraParser {
$this->yellow = $yellow;
$this->page = $page;
$this->idAttributes = array();
$this->no_markup = $page->parserSafeMode;
$this->no_markup = $page->safeMode;
$this->url_filter_func = function($url) use ($yellow, $page) {
return $yellow->lookup->normaliseLocation($url, $page->location,
$page->parserSafeMode && $page->statusCode==200);
$page->safeMode && $page->statusCode==200);
};
parent::__construct();
}

View file

@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowSetup {
const VERSION = "0.7.2";
const VERSION = "0.7.3";
public $yellow; //access to API
// Handle initialisation
@ -59,7 +59,7 @@ class YellowSetup {
$statusCode = $this->updateLanguage();
$this->yellow->page->setRequestInformation($scheme, $address, $base, $location, $fileName);
$this->yellow->page->parseData($this->getRawDataSetup(), false, $statusCode, $this->yellow->page->get("pageError"));
$this->yellow->page->parserSafeMode = false;
$this->yellow->page->safeMode = false;
if ($status=="setup") $status = $this->updateUser($email, $password, $name, $language)==200 ? "ok" : "error";
if ($status=="ok") $status = $this->updateFeature($feature)==200 ? "ok" : "error";
if ($status=="ok") $status = $this->updateContent($language, "Home", "/")==200 ? "ok" : "error";

View file

@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowUpdate {
const VERSION = "0.7.21";
const VERSION = "0.7.22";
public $yellow; //access to API
public $updates; //number of updates
@ -20,6 +20,15 @@ class YellowUpdate {
// Handle startup
public function onStartup($update) {
if ($update) { //TODO: remove later, converts old config
$fileNameConfig = $this->yellow->config->get("configDir").$this->yellow->config->get("configFile");
if ($this->yellow->config->isExisting("parserSafeMode") {
$this->yellow->config->save($fileNameConfig, array("safeMode" => $this->yellow->config->get("parserSafeMode"));
}
if ($this->yellow->config->get("staticDir")=="cache/" {
$this->yellow->config->save($fileNameConfig, array("staticDir" => "public/");
}
}
if ($update) {
$fileNameConfig = $this->yellow->config->get("configDir").$this->yellow->config->get("configFile");
$fileData = $this->yellow->toolbox->readFile($fileNameConfig);