Core update (spring remix)

This commit is contained in:
markseu 2015-04-29 09:26:48 +02:00
parent 13dad7f106
commit e885d5f321
24 changed files with 1366 additions and 1151 deletions

View file

@ -13,5 +13,5 @@ RewriteRule ^(cache|content|system)/ error [L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^[^\.]+$ - [T=text/html,L]
ErrorDocument 404 /error404.html
ErrorDocument 404 /error.html
</IfModule>

View file

@ -1,4 +1,4 @@
Yellow 0.5.2
Yellow 0.5.3
============
[![Yellow](https://raw.githubusercontent.com/wiki/datenstrom/yellow/images/yellow.jpg)](http://datenstrom.se/yellow)
@ -9,11 +9,8 @@ How do I install this?
1. [Download Yellow and unzip it](https://github.com/datenstrom/yellow/archive/master.zip).
2. Copy all files to your web hosting.
3. Open your website in a web browser.
How do I get started?
---------------------
Start by editing your website. Just give it a try.
For more information see [Yellow documentation](https://github.com/datenstrom/yellow/wiki).
Installing is unzipping one file and you are ready to go. [Learn more](https://github.com/datenstrom/yellow/wiki).
License
-------

View file

@ -3,8 +3,7 @@
sitename = Yellow
author = Yellow
language = en
theme = default
template = default
theme = flatsite
// timeZone = UTC
// serverScheme = http
@ -18,14 +17,14 @@ systemDir = system/
configDir = system/config/
coreDir = system/core/
pluginDir = system/plugins/
snippetDir = system/snippets/
templateDir = system/templates/
themeDir = system/themes/
snippetDir = system/themes/snippets/
templateDir = system/themes/templates/
mediaDir = media/
imageDir = media/images/
staticDir = cache/
staticDefaultFile = index.html
staticErrorFile = error404.html
staticErrorFile = error.html
contentDir = content/
contentRootDir = default/
contentHomeDir = home/
@ -33,18 +32,19 @@ contentDefaultFile = page.txt
contentPagination = page
contentExtension = .txt
configExtension = .ini
errorPageFile = error(.*).txt
newPageFile = new(.*).txt
textStringFile = language(.*).ini
textFile = language-(.*).ini
errorFile = page-error-(.*).txt
robotsTextFile = robots.txt
parser = markdownextra
template = default
parser = markdown
parserSafeMode = 0
multiLanguageMode = 0
commandlineIgnoreLocation =
commandlineSystemFile = .htaccess
webinterfaceLocation = /edit/
webinterfaceServerScheme = http
webinterfaceUserHashAlgorithm = bcrypt
webinterfaceUserHashCost = 10
webinterfaceUserFile = user.ini
webinterfaceFilePrefix = published
commandlineIgnoreLocation =
commandlineSystemFile = .htaccess
webinterfaceNewFile = page-new-(.*).txt
webinterfaceMetaFilePrefix = published

View file

@ -1,20 +1,20 @@
<?php
// Copyright (c) 2013-2014 Datenstrom, http://datenstrom.se
// Copyright (c) 2013-2015 Datenstrom, http://datenstrom.se
// This file may be used and distributed under the terms of the public license.
// Command line core plugin
class YellowCommandline
{
const Version = "0.5.1";
var $yellow; //access to API
var $content; //number of content pages
var $media; //number of media files
var $system; //number of system files
var $error; //number of build errors
var $locationsArguments; //locations with arguments detected
var $locationsPagination; //locations with pagination detected
const Version = "0.5.3";
var $yellow; //access to API
var $content; //number of content pages
var $media; //number of media files
var $system; //number of system files
var $error; //number of build errors
var $locationsArgs; //locations with location arguments detected
var $locationsArgsPagination; //locations with pagination arguments detected
// Handle plugin initialisation
// Handle initialisation
function onLoad($yellow)
{
$this->yellow = $yellow;
@ -22,15 +22,6 @@ class YellowCommandline
$this->yellow->config->setDefault("commandlineSystemFile", ".htaccess");
}
// Handle command help
function onCommandHelp()
{
$help .= "version\n";
$help .= "build [DIRECTORY LOCATION]\n";
$help .= "clean [DIRECTORY LOCATION]\n";
return $help;
}
// Handle command
function onCommand($args)
{
@ -51,6 +42,15 @@ class YellowCommandline
return $statusCode;
}
// Handle command help
function onCommandHelp()
{
$help .= "version\n";
$help .= "build [DIRECTORY LOCATION]\n";
$help .= "clean [DIRECTORY LOCATION]\n";
return $help;
}
// Show available commands
function helpCommand()
{
@ -93,34 +93,38 @@ class YellowCommandline
return $statusCode;
}
// Build static directories and files
// Build static pages and files
function buildStatic($path, $location)
{
$this->yellow->toolbox->timerStart($time);
$path = rtrim(empty($path) ? $this->yellow->config->get("staticDir") : $path, '/');
$this->content = $this->media = $this->system = $this->error = $statusCode = 0;
$this->locationsArguments = $this->locationsPagination = array();
$this->locationsArgs = $this->locationsArgsPagination = array();
if(empty($location))
{
$statusCode = $this->cleanStatic($path, $location);
foreach($this->getStaticLocations() as $location)
{
$statusCode = max($statusCode, $this->buildStaticRequest($path, $location, true));
$statusCode = max($statusCode, $this->buildStaticPage($path, $location, true));
}
foreach($this->locationsArguments as $location)
foreach($this->locationsArgs as $location)
{
$statusCode = max($statusCode, $this->buildStaticRequest($path, $location, true));
$statusCode = max($statusCode, $this->buildStaticPage($path, $location, true));
}
foreach($this->locationsPagination as $location)
foreach($this->locationsArgsPagination as $location)
{
if(substru($location, -1) != ':')
{
$statusCode = max($statusCode, $this->buildStaticPage($path, $location, false, true));
}
for($pageNumber=2; $pageNumber<=999; ++$pageNumber)
{
$statusCodeLocation = $this->buildStaticRequest($path, $location.$pageNumber, false, true);
$statusCodeLocation = $this->buildStaticPage($path, $location.$pageNumber, false, true);
$statusCode = max($statusCode, $statusCodeLocation);
if($statusCodeLocation == 0) break;
}
}
$statusCode = max($statusCode, $this->buildStaticError($path, 404));
$statusCode = max($statusCode, $this->buildStaticPage($path, "/error", false, false, true));
foreach($this->getStaticFilesMedia($path) as $fileNameSource=>$fileNameDest)
{
$statusCode = max($statusCode, $this->buildStaticFile($fileNameSource, $fileNameDest, true));
@ -130,66 +134,33 @@ class YellowCommandline
$statusCode = max($statusCode, $this->buildStaticFile($fileNameSource, $fileNameDest, false));
}
} else {
$statusCode = $this->buildStaticRequest($path, $location);
$statusCode = $this->buildStaticPage($path, $location);
}
$this->yellow->toolbox->timerStop($time);
if(defined("DEBUG") && DEBUG>=1) echo "YellowCommandline::buildStatic time:$time ms\n";
return $statusCode;
}
// Build static request
function buildStaticRequest($path, $location, $analyse = false, $probe = false)
// Build static page
function buildStaticPage($path, $location, $analyse = false, $probe = false, $error = false)
{
ob_start();
$_SERVER["SERVER_PROTOCOL"] = "HTTP/1.1";
$_SERVER["SERVER_NAME"] = $this->yellow->config->get("serverName");
$_SERVER["REQUEST_URI"] = $this->yellow->config->get("serverBase").$location;
$_SERVER["SCRIPT_NAME"] = $this->yellow->config->get("serverBase")."yellow.php";
$_SERVER["SCRIPT_NAME"] = $this->yellow->config->get("serverBase")."/yellow.php";
$_REQUEST = array();
$statusCode = $this->yellow->request();
if($statusCode < 400)
if($statusCode<400 || $error)
{
$fileName = $this->yellow->toolbox->findStaticFileFromLocation($location, $path,
$this->yellow->config->get("staticDefaultFile"));
$fileData = ob_get_contents();
$modified = strtotime($this->yellow->page->getHeader("Last-Modified"));
if(!$this->yellow->toolbox->createFile($fileName, $fileData, true) ||
!$this->yellow->toolbox->modifyFile($fileName, $modified))
if($statusCode>=301 && $statusCode<=303)
{
$statusCode = 500;
$this->yellow->page->error($statusCode, "Can't write file '$fileName'!");
$fileData = $this->getStaticRedirect($this->yellow->page->getHeader("Location"));
$modified = time();
}
}
ob_end_clean();
if($statusCode==200 && $analyse) $this->analyseStaticContent($fileData);
if($statusCode==404 && $probe) $statusCode = 0;
if($statusCode != 0) ++$this->content;
if($statusCode >= 400)
{
++$this->error;
echo "ERROR building content location '$location', ".$this->yellow->page->getStatusCode(true)."\n";
}
if(defined("DEBUG") && DEBUG>=3) echo $fileData;
if(defined("DEBUG") && DEBUG>=1) echo "YellowCommandline::buildStaticRequest status:$statusCode location:$location\n";
return $statusCode;
}
// Build static error
function buildStaticError($path, $statusCodeRequest)
{
ob_start();
$_SERVER["SERVER_PROTOCOL"] = "HTTP/1.1";
$_SERVER["SERVER_NAME"] = $this->yellow->config->get("serverName");
$_SERVER["REQUEST_URI"] = $this->yellow->config->get("serverBase")."/";
$_SERVER["SCRIPT_NAME"] = $this->yellow->config->get("serverBase")."yellow.php";
$_REQUEST = array();
$fileName = "$path/".$this->yellow->config->get("staticErrorFile");
$statusCode = $this->yellow->request($statusCodeRequest);
if($statusCode == $statusCodeRequest)
{
$statusCode = 200;
$fileData = ob_get_contents();
$modified = strtotime($this->yellow->page->getHeader("Last-Modified"));
$fileName = $this->getStaticFile($path, $location, $statusCode);
if(!$this->yellow->toolbox->createFile($fileName, $fileData, true) ||
!$this->yellow->toolbox->modifyFile($fileName, $modified))
{
@ -199,13 +170,17 @@ class YellowCommandline
}
}
ob_end_clean();
++$this->system;
if($statusCode==200 && $analyse) $this->analyseStaticPage($fileData);
if($statusCode==404 && $error) $statusCode = 200;
if($statusCode==404 && $probe) $statusCode = 0;
if($statusCode != 0) ++$this->content;
if($statusCode >= 400)
{
++$this->error;
echo "ERROR building error file, ".$this->yellow->page->getStatusCode(true)."\n";
echo "ERROR building content location '$location', ".$this->yellow->page->getStatusCode(true)."\n";
}
if(defined("DEBUG") && DEBUG>=1) echo "YellowCommandline::buildStaticError status:$statusCode file:$fileName\n";
if(defined("DEBUG") && DEBUG>=3) echo $fileData;
if(defined("DEBUG") && DEBUG>=1) echo "YellowCommandline::buildStaticPage status:$statusCode location:$location\n";
return $statusCode;
}
@ -226,8 +201,8 @@ class YellowCommandline
return $statusCode;
}
// Analyse static content, detect locations with arguments and pagination
function analyseStaticContent($text)
// Analyse static page, detect locations with arguments
function analyseStaticPage($text)
{
$serverName = $this->yellow->config->get("serverName");
$serverBase = $this->yellow->config->get("serverBase");
@ -243,20 +218,20 @@ class YellowCommandline
if(!$this->yellow->toolbox->isLocationArgs($match)) continue;
if(substru($match, 0, strlenu($serverBase)) != $serverBase) continue;
$location = rawurldecode(substru($match, strlenu($serverBase)));
if(!$this->yellow->toolbox->isPaginationLocation($location, $pagination))
if(!$this->yellow->toolbox->isLocationArgsPagination($location, $pagination))
{
$location = rtrim($location, '/').'/';
if(is_null($this->locationsArguments[$location]))
if(is_null($this->locationsArgs[$location]))
{
$this->locationsArguments[$location] = $location;
if(defined("DEBUG") && DEBUG>=2) echo "YellowCommandline::analyseStaticContent type:arguments location:$location\n";
$this->locationsArgs[$location] = $location;
if(defined("DEBUG") && DEBUG>=2) echo "YellowCommandline::analyseStaticPage detected location:$location\n";
}
} else {
$location = rtrim($location, "0..9");
if(is_null($this->locationsPagination[$location]))
if(is_null($this->locationsArgsPagination[$location]))
{
$this->locationsPagination[$location] = $location;
if(defined("DEBUG") && DEBUG>=2) echo "YellowCommandline::analyseStaticContent type:pagination location:$location\n";
$this->locationsArgsPagination[$location] = $location;
if(defined("DEBUG") && DEBUG>=2) echo "YellowCommandline::analyseStaticPage detected location:$location\n";
}
}
}
@ -297,9 +272,9 @@ class YellowCommandline
function cleanStaticDirectory($path)
{
$statusCode = 200;
if($this->isYellowDirectory($path))
if(is_dir($path))
{
if(is_file("$path/yellow.php") || $path=="/" || !$this->yellow->toolbox->deleteDirectory($path, true))
if(!$this->checkStaticDirectory($path) || !$this->yellow->toolbox->deleteDirectory($path, true))
{
$statusCode = 500;
echo "ERROR cleaning pages: Can't delete directory '$path'!\n";
@ -312,18 +287,13 @@ class YellowCommandline
function cleanStaticFile($path, $location)
{
$statusCode = 200;
$fileName = $this->yellow->toolbox->findStaticFileFromLocation($location, $path,
$this->yellow->config->get("staticDefaultFile"));
if($this->isYellowDirectory($path) && is_file($fileName))
$fileName = $this->getStaticFile($path, $location, $statusCode);
if(is_file($fileName))
{
$entry = basename($fileName);
if($entry!="yellow.php" && substru($entry, 0, 1)!=".")
if(!$this->checkStaticDirectory($path) || !$this->yellow->toolbox->deleteFile($fileName))
{
if(!$this->yellow->toolbox->deleteFile($fileName))
{
$statusCode = 500;
echo "ERROR cleaning pages: Can't delete file '$fileName'!\n";
}
$statusCode = 500;
echo "ERROR cleaning pages: Can't delete file '$fileName'!\n";
}
}
return $statusCode;
@ -352,7 +322,20 @@ class YellowCommandline
$serverName = $this->yellow->config->get("serverName");
$serverBase = $this->yellow->config->get("serverBase");
return !empty($serverScheme) && !empty($serverName) &&
$this->yellow->toolbox->isValidLocation($serverBase) && $serverBase!="/";
$this->yellow->lookup->isValidLocation($serverBase) && $serverBase!="/";
}
// Check static directory
function checkStaticDirectory($path)
{
$ok = false;
if(!empty($path))
{
if($path == rtrim($this->yellow->config->get("staticDir"), '/')) $ok = true;
if(is_file("$path/".$this->yellow->config->get("commandlineSystemFile"))) $ok = true;
if(is_file("$path/yellow.php")) $ok = false;
}
return $ok;
}
// Return static locations from file system
@ -409,6 +392,29 @@ class YellowCommandline
return $files;
}
// Return static file
function getStaticFile($path, $location, $statusCode)
{
if($statusCode < 400)
{
$fileName = $path.$location;
if(!$this->yellow->lookup->isFileLocation($location)) $fileName .= $this->yellow->config->get("staticDefaultFile");
} else if($statusCode == 404) {
$fileName = $path."/".$this->yellow->config->get("staticErrorFile");
}
return $fileName;
}
// Return static redirect
function getStaticRedirect($location)
{
$output = "<!DOCTYPE html><html>\n<head>\n";
$output .= "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />\n";
$output .= "<meta http-equiv=\"refresh\" content=\"0;url=".htmlspecialchars($location)."\" />\n";
$output .= "</head>\n</html>";
return $output;
}
// Return command help
function getCommandHelp()
{
@ -436,12 +442,6 @@ class YellowCommandline
usort($data, strnatcasecmp);
return $data;
}
// Check if directory contains Yellow files
function isYellowDirectory($path)
{
return is_file("$path/yellow.php") || is_file("$path/".$this->yellow->config->get("commandlineSystemFile"));
}
}
$yellow->plugins->register("commandline", "YellowCommandline", YellowCommandline::Version);

View file

@ -1,4 +1,4 @@
/* Yellow web interface 0.5.1 */
/* Yellow web interface 0.5.3 */
.yellow-bar { position:relative; overflow:hidden; line-height:2em; margin-bottom:10px; }
.yellow-bar-left { display:block; float:left; }

View file

@ -4,7 +4,7 @@
// Yellow main API
var yellow =
{
version: "0.5.1",
version: "0.5.3",
action: function(text) { yellow.webinterface.action(text); },
onClick: function(e) { yellow.webinterface.hidePanesOnClick(yellow.toolbox.getEventElement(e)); },
onKeydown: function(e) { yellow.webinterface.hidePanesOnKeydown(yellow.toolbox.getEventKeycode(e)); },

View file

@ -5,7 +5,7 @@
// Web interface core plugin
class YellowWebinterface
{
const Version = "0.5.1";
const Version = "0.5.3";
var $yellow; //access to API
var $active; //web interface is active? (boolean)
var $userLoginFailed; //web interface login failed? (boolean)
@ -15,7 +15,7 @@ class YellowWebinterface
var $rawDataSource; //raw data of page for comparison
var $rawDataEdit; //raw data of page for editing
// Handle plugin initialisation
// Handle initialisation
function onLoad($yellow)
{
$this->yellow = $yellow;
@ -27,7 +27,8 @@ class YellowWebinterface
$this->yellow->config->setDefault("webinterfaceUserHashAlgorithm", "bcrypt");
$this->yellow->config->setDefault("webinterfaceUserHashCost", "10");
$this->yellow->config->setDefault("webinterfaceUserFile", "user.ini");
$this->yellow->config->setDefault("webinterfaceFilePrefix", "published");
$this->yellow->config->setDefault("webinterfaceNewFile", "page-new-(.*).txt");
$this->yellow->config->setDefault("webinterfaceMetaFilePrefix", "published");
$this->users->load($this->yellow->config->get("configDir").$this->yellow->config->get("webinterfaceUserFile"));
}
@ -44,17 +45,17 @@ class YellowWebinterface
if(rtrim($location, '/') == rtrim($activeLocation, '/'))
{
$statusCode = 301;
$locationHeader = $this->yellow->toolbox->getLocationHeader(
$location = $this->yellow->lookup->normaliseUrl(
$this->yellow->config->get("webinterfaceServerScheme"),
$this->yellow->config->get("webinterfaceServerName"), $base, $activeLocation);
$this->yellow->sendStatus($statusCode, $locationHeader, false);
$this->yellow->sendStatus($statusCode, $location);
}
}
return $statusCode;
}
// Handle page meta data parsing
function onParseMeta($page, $text)
function onParseMeta($page)
{
if($this->isActive() && $this->isUser())
{
@ -71,41 +72,35 @@ class YellowWebinterface
}
}
// Handle page extra header
function onHeaderExtra($page)
// Handle page extra HTML data
function onExtra()
{
$header = "";
$output = "";
if($this->isActive())
{
$location = $this->yellow->config->getHtml("serverBase").$this->yellow->config->getHtml("pluginLocation");
$header .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"{$location}core-webinterface.css\" />\n";
$header .= "<script type=\"text/javascript\" src=\"{$location}core-webinterface.js\"></script>\n";
$header .= "<script type=\"text/javascript\">\n";
$header .= "// <![CDATA[\n";
$output .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"{$location}core-webinterface.css\" />\n";
$output .= "<script type=\"text/javascript\" src=\"{$location}core-webinterface.js\"></script>\n";
$output .= "<script type=\"text/javascript\">\n";
$output .= "// <![CDATA[\n";
if($this->isUser())
{
$header .= "yellow.page.userPermission = ".json_encode($this->userPermission).";\n";
$header .= "yellow.page.rawDataSource = ".json_encode($this->rawDataSource).";\n";
$header .= "yellow.page.rawDataEdit = ".json_encode($this->rawDataEdit).";\n";
$header .= "yellow.page.rawDataNew = ".json_encode($this->getDataNew()).";\n";
$header .= "yellow.page.parserSafeMode = ".json_encode($page->parserSafeMode).";\n";
$header .= "yellow.page.statusCode = ".json_encode($page->statusCode).";\n";
$output .= "yellow.page.userPermission = ".json_encode($this->userPermission).";\n";
$output .= "yellow.page.rawDataSource = ".json_encode($this->rawDataSource).";\n";
$output .= "yellow.page.rawDataEdit = ".json_encode($this->rawDataEdit).";\n";
$output .= "yellow.page.rawDataNew = ".json_encode($this->getDataNew()).";\n";
$output .= "yellow.page.parserSafeMode = ".json_encode($this->yellow->page->parserSafeMode).";\n";
$output .= "yellow.page.statusCode = ".json_encode($this->yellow->page->statusCode).";\n";
}
$header .= "yellow.config = ".json_encode($this->getDataConfig()).";\n";
$language = $this->isUser() ? $this->users->getLanguage() : $page->get("language");
$output .= "yellow.config = ".json_encode($this->getDataConfig()).";\n";
$language = $this->isUser() ? $this->users->getLanguage() : $this->yellow->page->get("language");
if(!$this->yellow->text->isLanguage($language)) $language = $this->yellow->config->get("language");
$header .= "yellow.text = ".json_encode($this->yellow->text->getData("webinterface", $language)).";\n";
if(defined("DEBUG")) $header .= "yellow.debug = ".json_encode(DEBUG).";\n";
$header .= "// ]]>\n";
$header .= "</script>\n";
$output .= "yellow.text = ".json_encode($this->yellow->text->getData("webinterface", $language)).";\n";
if(defined("DEBUG")) $output .= "yellow.debug = ".json_encode(DEBUG).";\n";
$output .= "// ]]>\n";
$output .= "</script>\n";
}
return $header;
}
// Handle command help
function onCommandHelp()
{
return "user EMAIL PASSWORD [NAME LANGUAGE HOME]\n";
return $output;
}
// Handle command
@ -120,6 +115,12 @@ class YellowWebinterface
return $statusCode;
}
// Handle command help
function onCommandHelp()
{
return "user EMAIL PASSWORD [NAME LANGUAGE HOME]\n";
}
// Create or update user account
function userCommand($args)
{
@ -180,11 +181,12 @@ class YellowWebinterface
{
$statusCode = $this->yellow->processRequest($serverScheme, $serverName, $base, $location, $fileName, false);
} else {
if($this->yellow->toolbox->isFileLocation($location) && $this->yellow->isContentDirectory("$location/"))
if($this->yellow->isRequestContentDirectory($location))
{
$statusCode = 301;
$locationHeader = $this->yellow->toolbox->getLocationHeader($serverScheme, $serverName, $base, "$location/");
$this->yellow->sendStatus($statusCode, $locationHeader, false);
$location = $this->yellow->lookup->isFileLocation($location) ? "$location/" : "/".$this->yellow->getRequestLanguage()."/";
$location = $this->yellow->lookup->normaliseUrl($serverScheme, $serverName, $base, $location);
$this->yellow->sendStatus($statusCode, $location);
} else {
$statusCode = $this->userPermission ? 424 : 404;
$this->yellow->processRequest($serverScheme, $serverName, $base, $location, $fileName, false);
@ -207,8 +209,8 @@ class YellowWebinterface
if($this->yellow->toolbox->createFile($page->fileName, $page->rawData))
{
$statusCode = 303;
$locationHeader = $this->yellow->toolbox->getLocationHeader($serverScheme, $serverName, $base, $page->location);
$this->yellow->sendStatus($statusCode, $locationHeader, false);
$location = $this->yellow->lookup->normaliseUrl($serverScheme, $serverName, $base, $page->location);
$this->yellow->sendStatus($statusCode, $location);
} else {
$statusCode = 500;
$this->yellow->processRequest($serverScheme, $serverName, $base, $location, $fileName, false);
@ -239,8 +241,8 @@ class YellowWebinterface
$this->yellow->toolbox->createFile($page->fileName, $page->rawData))
{
$statusCode = 303;
$locationHeader = $this->yellow->toolbox->getLocationHeader($serverScheme, $serverName, $base, $page->location);
$this->yellow->sendStatus($statusCode, $locationHeader, false);
$location = $this->yellow->lookup->normaliseUrl($serverScheme, $serverName, $base, $page->location);
$this->yellow->sendStatus($statusCode, $location);
} else {
$statusCode = 500;
$this->yellow->processRequest($serverScheme, $serverName, $base, $location, $fileName, false);
@ -265,8 +267,8 @@ class YellowWebinterface
if(!is_file($fileName) || $this->yellow->toolbox->deleteFile($fileName))
{
$statusCode = 303;
$locationHeader = $this->yellow->toolbox->getLocationHeader($serverScheme, $serverName, $base, $location);
$this->yellow->sendStatus($statusCode, $locationHeader, false);
$location = $this->yellow->lookup->normaliseUrl($serverScheme, $serverName, $base, $location);
$this->yellow->sendStatus($statusCode, $location);
} else {
$statusCode = 500;
$this->yellow->processRequest($serverScheme, $serverName, $base, $location, $fileName, false);
@ -284,12 +286,12 @@ class YellowWebinterface
if(substru($location, 0, strlenu($home)) == $home)
{
$statusCode = 303;
$locationHeader = $this->yellow->toolbox->getLocationHeader($serverScheme, $serverName, $base, $location);
$this->yellow->sendStatus($statusCode, $locationHeader, false);
$location = $this->yellow->lookup->normaliseUrl($serverScheme, $serverName, $base, $location);
$this->yellow->sendStatus($statusCode, $location);
} else {
$statusCode = 302;
$locationHeader = $this->yellow->toolbox->getLocationHeader($serverScheme, $serverName, $base, $home);
$this->yellow->sendStatus($statusCode, $locationHeader, false);
$location = $this->yellow->lookup->normaliseUrl($serverScheme, $serverName, $base, $home);
$this->yellow->sendStatus($statusCode, $location);
}
return $statusCode;
}
@ -300,11 +302,11 @@ class YellowWebinterface
$statusCode = 302;
$this->users->destroyCookie("login");
$this->users->email = "";
$locationHeader = $this->yellow->toolbox->getLocationHeader(
$location = $this->yellow->lookup->normaliseUrl(
$this->yellow->config->get("serverScheme"),
$this->yellow->config->get("serverName"),
$this->yellow->config->get("serverBase"), $location);
$this->yellow->sendStatus($statusCode, $locationHeader, false);
$this->yellow->sendStatus($statusCode, $location);
return $statusCode;
}
@ -390,14 +392,11 @@ class YellowWebinterface
{
$page = new YellowPage($this->yellow);
$page->setRequestInformation($serverScheme, $serverName, $base, $location, $fileName);
$page->parseData($rawData, false);
$page->fileName = $this->yellow->toolbox->findFileFromTitle(
$page->get($this->yellow->config->get("webinterfaceFilePrefix")), $page->get("title"), $fileName,
$this->yellow->config->get("contentDefaultFile"), $this->yellow->config->get("contentExtension"));
$page->location = $this->yellow->toolbox->findLocationFromFile(
$page->fileName, $this->yellow->config->get("contentDir"),
$this->yellow->config->get("contentRootDir"), $this->yellow->config->get("contentHomeDir"),
$page->parseData($rawData, false, 0);
$page->fileName = $this->yellow->lookup->findFileFromTitle(
$page->get($this->yellow->config->get("webinterfaceMetaFilePrefix")), $page->get("title"), $fileName,
$this->yellow->config->get("contentDefaultFile"), $this->yellow->config->get("contentExtension"));
$page->location = $this->yellow->lookup->findLocationFromFile($page->fileName);
if($this->yellow->pages->find($page->location))
{
preg_match("/^(.*?)(\d*)$/", $page->get("title"), $matches);
@ -407,13 +406,10 @@ class YellowWebinterface
for(; $titleNumber<=999; ++$titleNumber)
{
$page->rawData = $this->updateDataTitle($rawData, $titleText.$titleNumber);
$page->fileName = $this->yellow->toolbox->findFileFromTitle(
$page->get($this->yellow->config->get("webinterfaceFilePrefix")), $titleText.$titleNumber, $fileName,
$this->yellow->config->get("contentDefaultFile"), $this->yellow->config->get("contentExtension"));
$page->location = $this->yellow->toolbox->findLocationFromFile(
$page->fileName, $this->yellow->config->get("contentDir"),
$this->yellow->config->get("contentRootDir"), $this->yellow->config->get("contentHomeDir"),
$page->fileName = $this->yellow->lookup->findFileFromTitle(
$page->get($this->yellow->config->get("webinterfaceMetaFilePrefix")), $titleText.$titleNumber, $fileName,
$this->yellow->config->get("contentDefaultFile"), $this->yellow->config->get("contentExtension"));
$page->location = $this->yellow->lookup->findLocationFromFile($page->fileName);
if(!$this->yellow->pages->find($page->location)) { $ok = true; break; }
}
if(!$ok) $page->error(500, "Page '".$page->get("title")."' can not be created!");
@ -427,23 +423,20 @@ class YellowWebinterface
{
$page = new YellowPage($this->yellow);
$page->setRequestInformation($serverScheme, $serverName, $base, $location, $fileName);
$page->parseData($this->merge->merge($rawDataSource, $rawDataEdit, $rawDataFile), false);
$page->parseData($this->merge->merge($rawDataSource, $rawDataEdit, $rawDataFile), false, 0);
if(empty($page->rawData)) $page->error(500, "Page has been modified by someone else!");
if($this->yellow->toolbox->isFileLocation($location) && !$page->isError())
if($this->yellow->lookup->isFileLocation($location) && !$page->isError())
{
$pageSource = new YellowPage($this->yellow);
$pageSource->setRequestInformation($serverScheme, $serverName, $base, $location, $fileName);
$pageSource->parseData($rawDataSource, false);
$prefix = $this->yellow->config->get("webinterfaceFilePrefix");
$pageSource->parseData($rawDataSource, false, 0);
$prefix = $this->yellow->config->get("webinterfaceMetaFilePrefix");
if($pageSource->get($prefix)!=$page->get($prefix) || $pageSource->get("title")!=$page->get("title"))
{
$page->fileName = $this->yellow->toolbox->findFileFromTitle(
$page->fileName = $this->yellow->lookup->findFileFromTitle(
$page->get($prefix), $page->get("title"), $fileName,
$this->yellow->config->get("contentDefaultFile"), $this->yellow->config->get("contentExtension"));
$page->location = $this->yellow->toolbox->findLocationFromFile(
$page->fileName, $this->yellow->config->get("contentDir"),
$this->yellow->config->get("contentRootDir"), $this->yellow->config->get("contentHomeDir"),
$this->yellow->config->get("contentDefaultFile"), $this->yellow->config->get("contentExtension"));
$page->location = $this->yellow->lookup->findLocationFromFile($page->fileName);
if($pageSource->location!=$page->location && $this->yellow->pages->find($page->location))
{
$page->error(500, "Page '".$page->get("title")."' already exists!");
@ -457,12 +450,9 @@ class YellowWebinterface
// Return content data for new page
function getDataNew($title = "")
{
$fileName = $this->yellow->toolbox->findFileFromLocation(
$this->yellow->page->location, $this->yellow->config->get("contentDir"),
$this->yellow->config->get("contentRootDir"), $this->yellow->config->get("contentHomeDir"),
$this->yellow->config->get("contentDefaultFile"), $this->yellow->config->get("contentExtension"));
$fileName = $this->yellow->toolbox->findFileNew($fileName,
$this->yellow->config->get("configDir"), $this->yellow->config->get("newPageFile"),
$fileName = $this->yellow->lookup->findFileFromLocation($this->yellow->page->location);
$fileName = $this->yellow->lookup->findFileNew($fileName,
$this->yellow->config->get("configDir"), $this->yellow->config->get("webinterfaceNewFile"),
$this->yellow->config->get("contentDefaultFile"));
$fileData = $this->yellow->toolbox->getFileData($fileName);
$fileData = preg_replace("/@datetime/i", date("Y-m-d H:i:s"), $fileData);

File diff suppressed because it is too large Load diff

View file

@ -2,28 +2,28 @@
// Copyright (c) 2013-2015 Datenstrom, http://datenstrom.se
// This file may be used and distributed under the terms of the public license.
// Markdown extra plugin
class YellowMarkdownExtra
// Markdown plugin
class YellowMarkdown
{
const Version = "0.1.6";
const Version = "0.5.1";
var $yellow; //access to API
// Handle plugin initialisation
// Handle initialisation
function onLoad($yellow)
{
$this->yellow = $yellow;
}
// Handle page content parsing of raw format
function onParseContentText($page, $text)
function onParseContentRaw($page, $text)
{
$markdown = new YellowMarkdownExtraParser($this->yellow, $page);
$markdown = new YellowMarkdownParser($this->yellow, $page);
return $markdown->transform($text);
}
}
// Markdown extra parser
class YellowMarkdownExtraParser extends MarkdownExtraParser
// Markdown parser
class YellowMarkdownParser extends MarkdownExtraParser
{
var $yellow; //access to API
var $page; //access to page
@ -38,7 +38,7 @@ class YellowMarkdownExtraParser extends MarkdownExtraParser
$this->no_entities = $page->parserSafeMode;
$this->url_filter_func = function($url) use ($yellow, $page)
{
return $yellow->toolbox->normaliseLocation($url, $page->base, $page->location,
return $yellow->lookup->normaliseLocation($url, $page->base, $page->location,
$yellow->config->get("serverBase").$yellow->config->get("imageLocation"),
$page->parserSafeMode && $page->statusCode==200);
};
@ -57,7 +57,7 @@ class YellowMarkdownExtraParser extends MarkdownExtraParser
// Return unique id attribute
function getIdAttribute($text)
{
$text = $this->yellow->toolbox->normaliseName($text, true, false, true);
$text = $this->yellow->lookup->normaliseName($text, true, false, true);
$text = trim(preg_replace("/-+/", "-", $text), "-");
if(is_null($this->idAttributes[$text]))
{
@ -83,9 +83,9 @@ class YellowMarkdownExtraParser extends MarkdownExtraParser
function _doAutoLinks_shortcut_callback($matches)
{
$text = preg_replace("/\s+/s", " ", $matches[2]);
$output = $this->page->parseType($matches[1], $text, true);
$output = $this->page->parseContentBlock($matches[1], $text, true);
if(is_null($output)) $output = htmlspecialchars($matches[0], ENT_NOQUOTES);
return $this->hashBlock($output);
return substr($output, 0, 4)=="<div" ? $this->hashBlock($output) : $this->hashPart($output);
}
// Handle comments
@ -101,7 +101,7 @@ class YellowMarkdownExtraParser extends MarkdownExtraParser
function _doFencedCodeBlocks_callback($matches)
{
$text = $matches[4];
$output = $this->page->parseType($matches[2], $text, false);
$output = $this->page->parseContentBlock($matches[2], $text, false);
if(is_null($output))
{
$attr = $this->doExtraAttributes("pre", $dummy =& $matches[3]);
@ -3325,5 +3325,5 @@ class MarkdownExtraParser extends MarkdownParser {
}
$yellow->plugins->register("markdownextra", "YellowMarkdownExtra", YellowMarkdownExtra::Version);
$yellow->plugins->register("markdown", "YellowMarkdown", YellowMarkdown::Version);
?>

View file

@ -1,11 +0,0 @@
<?php list($name, $pages) = $yellow->getSnippetArgs() ?>
<?php if($pages->isPagination()): ?>
<div class="pagination">
<?php if($pages->getLocationPrevious()): ?>
<a class="previous" href="<?php echo $pages->getLocationPrevious() ?>"><?php echo $yellow->text->getHtml("paginationPrevious") ?></a>
<?php endif ?>
<?php if($pages->getLocationNext()): ?>
<a class="next" href="<?php echo $pages->getLocationNext() ?>"><?php echo $yellow->text->getHtml("paginationNext") ?></a>
<?php endif ?>
</div>
<?php endif ?>

View file

@ -1,59 +0,0 @@
/* Default theme 0.5.2 */
/* Designer: Datenstrom Sweden */
html, body, div, form, pre, span, tr, th, td { margin:0; padding:0; border:0; vertical-align:baseline; }
body {
margin:1em;
background-color:#fff; color:#717171;
font-family:"Helvetica Neue",Helvetica,sans-serif;
font-size:1.0em;
font-weight:200;
line-height:1.5;
}
h1, h2, h3, h4, h5, h6 { color:#07d; font-weight:normal; }
hr { height:1px; background:#ddd; border:0; }
strong { font-weight:bold; }
code { font-size:1.1em; }
a { color:#07d; }
a:hover { color:#07d; text-decoration:underline; }
a, img { border:none; text-decoration:none; }
.sitename h1 { margin-top:0.5em; margin-bottom:0em; font-size:2.2em; font-weight:500; }
.sitename h1 a { color:#111; text-decoration:none; }
.navigation { margin-bottom:1em; line-height:2em; }
.navigation a { color:#111; padding:0 0.3em; display:inline-block; }
.navigation a:hover { color:#07d; }
.navigation ul { margin:0 -0.3em; padding:0; list-style:none; }
.navigation li { display:inline; }
.content h1 a:hover { text-decoration:none; }
.content img { max-width:100%; height:auto; }
.content form { margin:1em 0; }
.content table { border-spacing:0; border-collapse:collapse; }
.content th { text-align:left; padding:0.3em; border-bottom:1px solid #ddd;}
.content td { text-align:left; padding:0.3em; border-top:1px solid #ddd;}
.content .flexible { position:relative; padding-bottom:56.25%; padding-top:30px; }
.content .flexible iframe { position:absolute; top:0; left:0; width:100%; height:100%; }
.content .toc { margin:0; padding:0; list-style:none; }
.pagination { margin:1em 0; }
.footer { margin-top:1em; }
.footer a { color:#717171; }
.footer a:hover { color:#07d; text-decoration:underline; }
.left { float:left; margin:0 1em 0 0; }
.center { display:block; margin:0 auto; }
.right { float:right; margin:0 0 0 1em; }
/* Responsive and print */
.page { margin:0 auto; max-width:62em; }
@media screen and (min-width:62em) {
body { width:60em; margin:1em auto; }
}
@media screen and (max-width:30em) {
body { margin:0.5em; font-size:0.9em; }
.sitename h1, h1, h2 { font-size:1.3em; }
.sitename h1, .sitename, .navigation, .footer, .page { margin:0; padding:0; border:0; }
}
@media print {
body, h1, h2, h3, h4, h5, h6 { background-color:white; color:black; }
.page { border:none !important; }
}

101
system/themes/flatsite.css Normal file
View file

@ -0,0 +1,101 @@
/* Flatsite theme 0.1.7 */
/* Designer: Mark Mayberg */
@import url(https://fonts.googleapis.com/css?family=Open+Sans:300,400,700);
html, body, div, form, pre, span, tr, th, td { margin:0; padding:0; border:0; vertical-align:baseline; }
body {
margin:1em;
background-color:#fff; color:#717171;
font-family:'Open Sans',sans-serif;
font-size:1.0em;
font-weight:300;
line-height:1.5;
}
h1, h2, h3, h4, h5, h6 { color:#07d; font-weight:normal; }
h1 { font-size:2.0em; }
hr { height:1px; background:#ddd; border:0; }
strong { font-weight:bold; }
code { font-size:1.1em; }
a { color:#07d; }
a:hover { color:#07d; text-decoration:underline; }
a, img { border:none; text-decoration:none; }
.sitename { display:block; float:left; }
.sitename h1 { margin:0; }
.sitename h1 a { color:#111; text-decoration:none; }
.navigation { display:block; float:right; }
.navigation { margin-top:0.9em; margin-bottom:0.9em; line-height:2em; }
.navigation a { padding:0 0.3em; display:inline-block; }
.navigation ul { margin:0 -0.3em; padding:0; list-style:none; }
.navigation li { display:inline; }
.content { clear:both; }
.content h1 a:hover { text-decoration:none; }
.content img { max-width:100%; height:auto; }
.content form { margin:1em 0; }
.content table { border-spacing:0; border-collapse:collapse; }
.content th { text-align:left; padding:0.3em; border-bottom:1px solid #ddd;}
.content td { text-align:left; padding:0.3em; border-top:1px solid #ddd;}
.content .flexible { position:relative; padding-bottom:56.25%; padding-top:30px; }
.content .flexible iframe { position:absolute; top:0; left:0; width:100%; height:100%; }
.content .toc { margin:0; padding:0; list-style:none; }
.content code { border:1px solid #ddd; border-radius:3px; padding:0 0.5em; }
.content pre>code { border:none; padding:0; }
.content pre { border:1px solid #ddd; border-radius:3px; padding:1em; overflow:hidden; }
.content .imagelist { margin:0; padding:0; list-style:none; }
.content .themes { margin:0; padding:0; list-style:none; width:100%; }
.content .themes li { padding-bottom:1em; text-align:center; white-space:nowrap; display:inline-block; width:24%; }
.pagination { margin:1em 0; }
.footer { margin-top:2em; }
.footer a { color:#07d; }
.footer a:hover { color:#07d; text-decoration:underline; }
.left { float:left; margin:0 1em 0 0; }
.center { display:block; margin:0 auto; }
.right { float:right; margin:0 0 0 1em; }
/* Forms and buttons */
.form-control {
margin:0; padding:2px 4px;
display:inline-block;
background-color:#fff; color:#555;
background-image:linear-gradient(to bottom, #fff, #fff);
border:1px solid #bbb;
border-radius:4px;
font-size:0.9em; font-family:inherit; font-weight:normal; line-height:1;
}
.btn {
margin:0; padding:4px 22px;
display:inline-block; min-width:8em;
background-color:#eaeaea; color:#333333;
background-image:linear-gradient(to bottom, #f8f8f8, #e1e1e1);
border:1px solid #bbb;
border-color:#c1c1c1 #c1c1c1 #aaaaaa;
border-radius:4px;
outline-offset:-2px;
font-size:0.9em; font-family:inherit; font-weight:normal; line-height:1;
text-align:center; text-decoration:none;
}
.btn:hover, .btn:focus, .btn:active {
color:#333333;
background-image:none;
text-decoration:none;
}
.btn:active { box-shadow:inset 0 2px 4px rgba(0, 0, 0, 0.1); }
/* Responsive and print */
.page { margin:0 auto; max-width:1000px; }
@media screen and (min-width:62em) {
body { width:60em; margin:1em auto; }
.page{ margin:0; max-width:none; }
}
@media screen and (max-width:30em) {
body { margin:0.5em; font-size:0.9em; }
.sitename h1, h1, h2 { font-size:1.2em; }
.sitename h1, .header, .navigation, .footer, .page { margin:0; padding:0; }
.sitename, .navigation { float:none; }
}
@media print {
body, h1, h2, h3, h4, h5, h6 { background-color:white; color:black; }
.page { border:none !important; }
}

View file

@ -11,7 +11,7 @@
<title><?php echo $yellow->page->getHtml("titleHeader") ?></title>
<link rel="shortcut icon" href="<?php echo $yellow->config->get("serverBase").$yellow->config->get("imageLocation")."icon.png" ?>" />
<link rel="stylesheet" type="text/css" media="all" href="<?php echo $yellow->config->get("serverBase").$yellow->config->get("themeLocation").$yellow->page->get("theme").".css" ?>" />
<?php echo $yellow->page->getHeaderExtra() ?>
<?php echo $yellow->page->getExtra() ?>
</head>
<body>
<div class="page">

View file

@ -0,0 +1,11 @@
<?php list($name, $pages) = $yellow->getSnippetArgs() ?>
<?php if($pages->isPagination()): ?>
<div class="pagination">
<?php if($pages->getPaginationPrevious()): ?>
<a class="previous" href="<?php echo $pages->getPaginationPrevious() ?>"><?php echo $yellow->text->getHtml("paginationPrevious") ?></a>
<?php endif ?>
<?php if($pages->getPaginationNext()): ?>
<a class="next" href="<?php echo $pages->getPaginationNext() ?>"><?php echo $yellow->text->getHtml("paginationNext") ?></a>
<?php endif ?>
</div>
<?php endif ?>

View file

@ -1,4 +1,3 @@
<?php /* Default template */ ?>
<?php $yellow->snippet("header") ?>
<?php $yellow->snippet("sitename") ?>
<?php $yellow->snippet("navigation") ?>