Core update (blåbär remix)

This commit is contained in:
markseu 2015-08-01 19:28:20 +02:00
parent 0e09a87fcd
commit f56a59c8c1
8 changed files with 86 additions and 25 deletions

View file

@ -1,4 +1,4 @@
Yellow 0.5.26
Yellow 0.5.27
=============
[![Yellow](https://raw.githubusercontent.com/wiki/datenstrom/yellow/images/yellow.jpg)](http://datenstrom.se/yellow)
@ -8,9 +8,7 @@ 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.
Installing is unzipping one file and you are ready to go. [Learn more](https://github.com/datenstrom/yellow/wiki).
3. Open your website in a web browser. [Learn more](https://github.com/datenstrom/yellow/wiki).
License
-------

View file

@ -34,7 +34,8 @@ contentExtension = .txt
configExtension = .ini
textFile = language-(.*).ini
errorFile = page-error-(.*).txt
robotsTextFile = robots.txt
robotsFile = robots.txt
iconFile = icon.png
template = default
navigation = navigation
parser = markdown

View file

@ -5,7 +5,7 @@
// Command line core plugin
class YellowCommandline
{
const Version = "0.5.3";
const Version = "0.5.4";
var $yellow; //access to API
var $content; //number of content pages
var $media; //number of media files
@ -387,7 +387,7 @@ class YellowCommandline
}
$fileNames = array();
array_push($fileNames, $this->yellow->config->get("commandlineSystemFile"));
array_push($fileNames, $this->yellow->config->get("configDir").$this->yellow->config->get("robotsTextFile"));
array_push($fileNames, $this->yellow->config->get("configDir").$this->yellow->config->get("robotsFile"));
foreach($fileNames as $fileName) $files[$fileName] = "$path/".basename($fileName);
return $files;
}

View file

@ -1,4 +1,4 @@
/* Yellow web interface 0.5.17 */
/* Yellow web interface 0.5.20 */
.yellow-bar { position:relative; overflow:hidden; 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.17",
version: "0.5.20",
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.19";
const Version = "0.5.20";
var $yellow; //access to API
var $active; //web interface is active? (boolean)
var $userLoginFailed; //web interface login failed? (boolean)
@ -82,6 +82,18 @@ class YellowWebinterface
if(substru($text, 0, 2)=="- ") $editText = trim(substru($text, 2));
$output = "<a href=\"".$page->get("pageEdit")."\">".htmlspecialchars($editText)."</a>";
}
if($name=="debug" && $shortcut)
{
$output = "<div class=\"".htmlspecialchars($name)."\">\n";
if(empty($text))
{
$output .= "Yellow ".Yellow::Version.", PHP ".PHP_VERSION.", ".$this->yellow->toolbox->getServerSoftware().", ".PHP_OS."\n";
} else {
foreach($this->yellow->config->getData($text) as $key=>$value) $output .= htmlspecialchars("$key = $value")."<br />\n";
if($page->parserSafeMode) $page->error(500, "Debug '$text' is not allowed!");
}
$output .= "</div>\n";
}
return $output;
}
@ -91,11 +103,11 @@ class YellowWebinterface
$output = NULL;
if($this->isActive() && $name=="header")
{
$location = $this->yellow->config->getHtml("serverBase").$this->yellow->config->getHtml("pluginLocation");
$output = "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"{$location}core-webinterface.css\" />\n";
if($this->users->getNumber())
{
$output .= "<script type=\"text/javascript\" src=\"{$location}core-webinterface.js\"></script>\n";
$location = $this->yellow->config->get("serverBase").$this->yellow->config->get("pluginLocation")."core-webinterface";
$output = "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"".htmlspecialchars($location).".css\" />\n";
$output .= "<script type=\"text/javascript\" src=\"".htmlspecialchars($location).".js\"></script>\n";
$output .= "<script type=\"text/javascript\">\n";
$output .= "// <![CDATA[\n";
if($this->isUser())

View file

@ -5,7 +5,7 @@
// Yellow main class
class Yellow
{
const Version = "0.5.26";
const Version = "0.5.27";
var $page; //current page
var $pages; //pages from file system
var $files; //files from file system
@ -58,7 +58,8 @@ class Yellow
$this->config->setDefault("configFile", "config.ini");
$this->config->setDefault("textFile", "language-(.*).ini");
$this->config->setDefault("errorFile", "page-error-(.*).txt");
$this->config->setDefault("robotsTextFile", "robots.txt");
$this->config->setDefault("robotsFile", "robots.txt");
$this->config->setDefault("iconFile", "icon.png");
$this->config->setDefault("template", "default");
$this->config->setDefault("navigation", "navigation");
$this->config->setDefault("parser", "markdown");
@ -249,8 +250,8 @@ class Yellow
$fileName = $this->config->get("pluginDir").substru($location, $pluginLocationLength);
} else if(substru($location, 0, $themeLocationLength) == $this->config->get("themeLocation")) {
$fileName = $this->config->get("themeDir").substru($location, $themeLocationLength);
} else if($location == "/".$this->config->get("robotsTextFile")) {
$fileName = $this->config->get("configDir").$this->config->get("robotsTextFile");
} else if($location == "/".$this->config->get("robotsFile")) {
$fileName = $this->config->get("configDir").$this->config->get("robotsFile");
}
}
if(empty($fileName)) $fileName = $this->lookup->findFileFromLocation($location);
@ -737,6 +738,22 @@ class YellowPage
function getExtra($name)
{
$output = "";
if($name == "header")
{
if(is_file($this->yellow->config->get("themeDir").$this->get("theme").".css"))
{
$location = $this->yellow->config->get("serverBase").
$this->yellow->config->get("themeLocation").$this->get("theme").".css";
$output .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"".htmlspecialchars($location)."\" />\n";
}
if(is_file($this->yellow->config->get("imageDir").$this->yellow->config->get("iconFile")))
{
$location = $this->yellow->config->get("serverBase").
$this->yellow->config->get("imageLocation").$this->yellow->config->get("iconFile");
$contentType = $this->yellow->toolbox->getMimeContentType($this->yellow->config->get("iconFile"));
$output .= "<link rel=\"shortcut icon\" type=\"$contentType\" href=\"".htmlspecialchars($location)."\" />\n";
}
}
foreach($this->yellow->plugins->plugins as $key=>$value)
{
if(method_exists($value["obj"], "onExtra"))
@ -745,7 +762,33 @@ class YellowPage
if(!is_null($outputPlugin)) $output .= $outputPlugin;
}
}
return $output;
return $this->normaliseExtra($output);
}
// Normalise page extra HTML data
function normaliseExtra($text)
{
$outputScript = $outputStylesheet = $outputOther = $locations = array();
foreach($this->yellow->toolbox->getTextLines($text) as $line)
{
if(preg_match("/^<script (.*?)src=\"([^\"]+)\"(.*?)><\/script>$/i", $line, $matches))
{
if(is_null($locations[$matches[2]]))
{
$locations[$matches[2]] = $matches[2];
array_push($outputScript, $line);
}
} else if(preg_match("/^<link rel=\"stylesheet\"(.*?)href=\"([^\"]+)\"(.*?)>$/i", $line, $matches)) {
if(is_null($locations[$matches[2]]))
{
$locations[$matches[2]] = $matches[2];
array_push($outputStylesheet, $line);
}
} else {
array_push($outputOther, $line);
}
}
return implode($outputScript).implode($outputStylesheet).implode($outputOther);
}
// Set page response output
@ -1333,7 +1376,7 @@ class YellowFiles
$this->files[$location] = array();
$serverScheme = $this->yellow->page->serverScheme;
$serverName = $this->yellow->page->serverName;
$base = $this->yellow->page->base;
$base = $this->yellow->config->get("serverBase");
if(empty($location))
{
$fileNames = array($this->yellow->config->get("mediaDir"));
@ -1586,9 +1629,9 @@ class YellowConfig
$config = array();
if(empty($filterStart) && empty($filterEnd))
{
$config = $this->config;
$config = array_merge($this->configDefaults, $this->config);
} else {
foreach($this->config as $key=>$value)
foreach(array_merge($this->configDefaults, $this->config) as $key=>$value)
{
if(!empty($filterStart) && substru($key, 0, strlenu($filterStart))==$filterStart) $config[$key] = $value;
if(!empty($filterEnd) && substru($key, -strlenu($filterEnd))==$filterEnd) $config[$key] = $value;
@ -2162,6 +2205,14 @@ class YellowLookup
// Yellow toolbox with helpers
class YellowToolbox
{
// Return server software from current HTTP request
function getServerSoftware()
{
$serverSoftware = PHP_SAPI;
if(preg_match("/^(\S+)/", $_SERVER["SERVER_SOFTWARE"], $matches)) $serverSoftware = $matches[1];
return $serverSoftware;
}
// Return server scheme from current HTTP request
function getServerScheme()
{
@ -2377,6 +2428,7 @@ class YellowToolbox
{
$mimeTypes = array(
"css" => "text/css",
"ico" => "image/x-icon",
"js" => "application/javascript",
"jpg" => "image/jpeg",
"png" => "image/png",
@ -2551,7 +2603,7 @@ class YellowToolbox
// Create description from text string
function createTextDescription($text, $lengthMax, $removeHtml = true, $endMarker = "", $endMarkerText = "")
{
if(preg_match("/<h1>.*<\/h1>(.*)/si", $text, $matches)) $text = $matches[1];
if(preg_match("/^<h1>.*?<\/h1>(.*)$/si", $text, $matches)) $text = $matches[1];
if($removeHtml)
{
while(true)
@ -2618,7 +2670,7 @@ class YellowToolbox
// Create keywords from text string
function createTextKeywords($text, $keywordsMax = 0)
{
$tokens = array_unique(preg_split("/[,\s\(\)]/", strtoloweru($text)));
$tokens = array_unique(preg_split("/[,\s\(\)\+\-]/", strtoloweru($text)));
foreach($tokens as $key=>$value) if(strlenu($value) < 3) unset($tokens[$key]);
if($keywordsMax) $tokens = array_slice($tokens, 0, $keywordsMax);
return implode(", ", $tokens);

View file

@ -9,8 +9,6 @@
<meta name="robots" content="<?php echo $yellow->page->getHtml("robots") ?>" />
<?php endif ?>
<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->getExtra("header") ?>
</head>
<body>