Parcourir la source

Core update (blåbär remix)

markseu il y a 10 ans
Parent
commit
f56a59c8c1

+ 2 - 4
README.md

@@ -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)
 [![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).  
 1. [Download Yellow and unzip it](https://github.com/datenstrom/yellow/archive/master.zip).  
 2. Copy all files to your web hosting.  
 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
 License
 -------
 -------

+ 2 - 1
system/config/config.ini

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

+ 2 - 2
system/core/core-commandline.php

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

+ 1 - 1
system/core/core-webinterface.css

@@ -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 { position:relative; overflow:hidden; height:2em; margin-bottom:10px; }
 .yellow-bar-left { display:block; float:left; }
 .yellow-bar-left { display:block; float:left; }

+ 1 - 1
system/core/core-webinterface.js

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

+ 16 - 4
system/core/core-webinterface.php

@@ -5,7 +5,7 @@
 // Web interface core plugin
 // Web interface core plugin
 class YellowWebinterface
 class YellowWebinterface
 {
 {
-	const Version = "0.5.19";
+	const Version = "0.5.20";
 	var $yellow;				//access to API
 	var $yellow;				//access to API
 	var $active;				//web interface is active? (boolean)
 	var $active;				//web interface is active? (boolean)
 	var $userLoginFailed;		//web interface login failed? (boolean)
 	var $userLoginFailed;		//web interface login failed? (boolean)
@@ -82,6 +82,18 @@ class YellowWebinterface
 			if(substru($text, 0, 2)=="- ") $editText = trim(substru($text, 2));
 			if(substru($text, 0, 2)=="- ") $editText = trim(substru($text, 2));
 			$output = "<a href=\"".$page->get("pageEdit")."\">".htmlspecialchars($editText)."</a>";
 			$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;
 		return $output;
 	}
 	}
 	
 	
@@ -91,11 +103,11 @@ class YellowWebinterface
 		$output = NULL;
 		$output = NULL;
 		if($this->isActive() && $name=="header")
 		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())
 			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 .= "<script type=\"text/javascript\">\n";
 				$output .= "// <![CDATA[\n";
 				$output .= "// <![CDATA[\n";
 				if($this->isUser())
 				if($this->isUser())

+ 62 - 10
system/core/core.php

@@ -5,7 +5,7 @@
 // Yellow main class
 // Yellow main class
 class Yellow
 class Yellow
 {
 {
-	const Version = "0.5.26";
+	const Version = "0.5.27";
 	var $page;				//current page
 	var $page;				//current page
 	var $pages;				//pages from file system
 	var $pages;				//pages from file system
 	var $files;				//files from file system
 	var $files;				//files from file system
@@ -58,7 +58,8 @@ class Yellow
 		$this->config->setDefault("configFile", "config.ini");
 		$this->config->setDefault("configFile", "config.ini");
 		$this->config->setDefault("textFile", "language-(.*).ini");
 		$this->config->setDefault("textFile", "language-(.*).ini");
 		$this->config->setDefault("errorFile", "page-error-(.*).txt");
 		$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("template", "default");
 		$this->config->setDefault("navigation", "navigation");
 		$this->config->setDefault("navigation", "navigation");
 		$this->config->setDefault("parser", "markdown");
 		$this->config->setDefault("parser", "markdown");
@@ -249,8 +250,8 @@ class Yellow
 				$fileName = $this->config->get("pluginDir").substru($location, $pluginLocationLength);
 				$fileName = $this->config->get("pluginDir").substru($location, $pluginLocationLength);
 			} else if(substru($location, 0, $themeLocationLength) == $this->config->get("themeLocation")) {
 			} else if(substru($location, 0, $themeLocationLength) == $this->config->get("themeLocation")) {
 				$fileName = $this->config->get("themeDir").substru($location, $themeLocationLength);
 				$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);
 		if(empty($fileName)) $fileName = $this->lookup->findFileFromLocation($location);
@@ -737,6 +738,22 @@ class YellowPage
 	function getExtra($name)
 	function getExtra($name)
 	{
 	{
 		$output = "";
 		$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)
 		foreach($this->yellow->plugins->plugins as $key=>$value)
 		{
 		{
 			if(method_exists($value["obj"], "onExtra"))
 			if(method_exists($value["obj"], "onExtra"))
@@ -745,7 +762,33 @@ class YellowPage
 				if(!is_null($outputPlugin)) $output .= $outputPlugin;
 				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
 	// Set page response output
@@ -1333,7 +1376,7 @@ class YellowFiles
 			$this->files[$location] = array();
 			$this->files[$location] = array();
 			$serverScheme = $this->yellow->page->serverScheme;
 			$serverScheme = $this->yellow->page->serverScheme;
 			$serverName = $this->yellow->page->serverName;
 			$serverName = $this->yellow->page->serverName;
-			$base = $this->yellow->page->base;
+			$base = $this->yellow->config->get("serverBase");
 			if(empty($location))
 			if(empty($location))
 			{
 			{
 				$fileNames = array($this->yellow->config->get("mediaDir"));
 				$fileNames = array($this->yellow->config->get("mediaDir"));
@@ -1586,9 +1629,9 @@ class YellowConfig
 		$config = array();
 		$config = array();
 		if(empty($filterStart) && empty($filterEnd))
 		if(empty($filterStart) && empty($filterEnd))
 		{
 		{
-			$config = $this->config;
+			$config = array_merge($this->configDefaults, $this->config);
 		} else {
 		} 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($filterStart) && substru($key, 0, strlenu($filterStart))==$filterStart) $config[$key] = $value;
 				if(!empty($filterEnd) && substru($key, -strlenu($filterEnd))==$filterEnd) $config[$key] = $value;
 				if(!empty($filterEnd) && substru($key, -strlenu($filterEnd))==$filterEnd) $config[$key] = $value;
@@ -2162,6 +2205,14 @@ class YellowLookup
 // Yellow toolbox with helpers
 // Yellow toolbox with helpers
 class YellowToolbox
 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
 	// Return server scheme from current HTTP request
 	function getServerScheme()
 	function getServerScheme()
 	{
 	{
@@ -2377,6 +2428,7 @@ class YellowToolbox
 	{
 	{
 		$mimeTypes = array(
 		$mimeTypes = array(
 			"css" => "text/css",
 			"css" => "text/css",
+			"ico" => "image/x-icon",
 			"js" => "application/javascript",
 			"js" => "application/javascript",
 			"jpg" => "image/jpeg",
 			"jpg" => "image/jpeg",
 			"png" => "image/png",
 			"png" => "image/png",
@@ -2551,7 +2603,7 @@ class YellowToolbox
 	// Create description from text string
 	// Create description from text string
 	function createTextDescription($text, $lengthMax, $removeHtml = true, $endMarker = "", $endMarkerText = "")
 	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)
 		if($removeHtml)
 		{
 		{
 			while(true)
 			while(true)
@@ -2618,7 +2670,7 @@ class YellowToolbox
 	// Create keywords from text string
 	// Create keywords from text string
 	function createTextKeywords($text, $keywordsMax = 0)
 	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]);
 		foreach($tokens as $key=>$value) if(strlenu($value) < 3) unset($tokens[$key]);
 		if($keywordsMax) $tokens = array_slice($tokens, 0, $keywordsMax);
 		if($keywordsMax) $tokens = array_slice($tokens, 0, $keywordsMax);
 		return implode(", ", $tokens);
 		return implode(", ", $tokens);

+ 0 - 2
system/themes/snippets/header.php

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