toolbox->getDirectoryEntries($yellow->config->get("pluginDir"), "/.*\.php/", true, false) as $entry)
diff --git a/system/core/core_commandline.php b/system/core/core_commandline.php
index b9359cc..b781afc 100755
--- a/system/core/core_commandline.php
+++ b/system/core/core_commandline.php
@@ -5,7 +5,7 @@
// Command line core plugin
class Yellow_Commandline
{
- const Version = "0.1.3";
+ const Version = "0.1.4";
var $yellow; //access to API
// Initialise plugin
@@ -141,31 +141,34 @@ class Yellow_Commandline
$statusCode = $this->yellow->request();
if($statusCode != 404)
{
- $ok = false;
+ $fileOk = true;
$modified = strtotime($this->yellow->page->getHeader("Last-Modified"));
- if(preg_match("/^(\w+)\/(\w+)/", $this->yellow->page->getHeader("Content-Type"), $matches))
- {
- $contentType = "$matches[1]/$matches[2]";
- $locationExtension = $this->getStaticLocation($location, ".$matches[2]");
- }
- if(empty($contentType) || $contentType=="text/html")
+ list($contentType, $contentEncoding) = explode(';', $this->yellow->page->getHeader("Content-Type"), 2);
+ $staticLocation = $this->getStaticLocation($location, $contentType);
+ if($location == $staticLocation)
{
$fileName = $this->getStaticFileName($location, $path);
$fileData = ob_get_contents();
if($statusCode == 301) $fileData = $this->getStaticRedirect($this->yellow->page->getHeader("Location"));
- $ok = $this->makeStaticFile($fileName, $fileData, $modified);
+ $fileOk = $this->makeStaticFile($fileName, $fileData, $modified);
} else {
- $fileName = $this->getStaticFileName($location, $path);
- $fileData = $this->getStaticRedirect("http://$serverName$serverBase$locationExtension");
- $ok = $this->makeStaticFile($fileName, $fileData, $modified);
- if($ok)
+ if(!$this->yellow->toolbox->isFileLocation($location))
{
- $fileName = $this->getStaticFileName($locationExtension, $path);
- $fileData = ob_get_contents();
- $ok = $this->makeStaticFile($fileName, $fileData, $modified);
+ $fileName = $this->getStaticFileName($location, $path);
+ $fileData = $this->getStaticRedirect("http://$serverName$serverBase$staticLocation");
+ $fileOk = $this->makeStaticFile($fileName, $fileData, $modified);
+ if($fileOk)
+ {
+ $fileName = $this->getStaticFileName($staticLocation, $path);
+ $fileData = ob_get_contents();
+ $fileOk = $this->makeStaticFile($fileName, $fileData, $modified);
+ }
+ } else {
+ $statusCode = 500;
+ $this->yellow->page->error($statusCode, "Invalid file name for type '$contentType'!");
}
}
- if(!$ok)
+ if(!$fileOk)
{
$statusCode = 500;
$this->yellow->page->error($statusCode, "Can't write file '$fileName'!");
@@ -186,10 +189,8 @@ class Yellow_Commandline
$statusCode = $this->yellow->request($statusCodeRequest);
if($statusCode == $statusCodeRequest)
{
- $fileData = ob_get_contents();
$modified = strtotime($this->yellow->page->getHeader("Last-Modified"));
- $ok = $this->makeStaticFile($fileName, $fileData, $modified);
- if(!$ok)
+ if(!$this->makeStaticFile($fileName, ob_get_contents(), $modified))
{
$statusCode = 500;
$this->yellow->page->error($statusCode, "Can't write file '$fileName'!");
@@ -213,6 +214,28 @@ class Yellow_Commandline
$this->yellow->toolbox->modifyFile($fileNameDest, filemtime($fileNameSource));
}
+ // Return static location corresponding to content type
+ function getStaticLocation($location, $contentType)
+ {
+ $extension = ($pos = strrposu($location, '.')) ? substru($location, $pos) : "";
+ if($contentType == "text/html")
+ {
+ if($this->yellow->toolbox->isFileLocation($location))
+ {
+ if(!empty($extension) && $extension!=".html") $location .= ".html";
+ }
+ } else {
+ if($this->yellow->toolbox->isFileLocation($location))
+ {
+ if(empty($extension)) $location .= ".unknown";
+ } else {
+ if(preg_match("/^(\w+)\/(\w+)/", $contentType, $matches)) $extension = ".$matches[2]";
+ $location .= "index$extension";
+ }
+ }
+ return $location;
+ }
+
// Return static file name from location
function getStaticFileName($location, $path)
{
@@ -224,13 +247,6 @@ class Yellow_Commandline
return $fileName;
}
- // Return static location with file extension
- function getStaticLocation($location, $extension)
- {
- if(!$this->yellow->toolbox->isFileLocation($location)) $location .= "index";
- return $location.$extension;
- }
-
// Return static redirect data
function getStaticRedirect($url)
{
diff --git a/system/core/core_markdown.php b/system/core/core_markdown.php
index 6b78901..15713e7 100755
--- a/system/core/core_markdown.php
+++ b/system/core/core_markdown.php
@@ -7,7 +7,7 @@ class Yellow_Markdown
{
const Version = "0.1.5";
var $markdown; //markdown parser
- var $html; //generated HTML
+ var $textHtml; //generated text (HTML format)
// Initialise plugin
function initPlugin($yellow)
@@ -18,7 +18,7 @@ class Yellow_Markdown
// Parse text
function parse($text)
{
- return $this->html = $this->markdown->transform($text);
+ return $this->textHtml = $this->markdown->transform($text);
}
}
diff --git a/system/core/core_plaintext.php b/system/core/core_plaintext.php
new file mode 100755
index 0000000..6128964
--- /dev/null
+++ b/system/core/core_plaintext.php
@@ -0,0 +1,21 @@
+text = $text;
+ return $textHtml;
+ }
+}
+
+$yellow->registerPlugin("plaintext", "Yellow_Plaintext", Yellow_Plaintext::Version);
+?>
\ No newline at end of file
diff --git a/system/core/core_rawhtml.php b/system/core/core_rawhtml.php
deleted file mode 100755
index b47d248..0000000
--- a/system/core/core_rawhtml.php
+++ /dev/null
@@ -1,19 +0,0 @@
-html = $text;
- }
-}
-
-$yellow->registerPlugin("rawhtml", "Yellow_RawHtml", Yellow_RawHtml::Version);
-?>
\ No newline at end of file
diff --git a/system/core/core_webinterface.php b/system/core/core_webinterface.php
index 692209e..b42dda1 100755
--- a/system/core/core_webinterface.php
+++ b/system/core/core_webinterface.php
@@ -5,7 +5,7 @@
// Web interface core plugin
class Yellow_Webinterface
{
- const Version = "0.1.6";
+ const Version = "0.1.7";
var $yellow; //access to API
var $users; //web interface users
var $activeLocation; //web interface location? (boolean)
@@ -182,7 +182,7 @@ class Yellow_Webinterface
function checkUserPermissions($location, $fileName)
{
$path = dirname($fileName);
- return is_dir($path);
+ return is_dir($path) && strlenu(basename($fileName))<128;
}
// Check if web interface location
diff --git a/system/snippets/content.php b/system/snippets/content.php
new file mode 100755
index 0000000..3b4f688
--- /dev/null
+++ b/system/snippets/content.php
@@ -0,0 +1,5 @@
+getSnippetArgs(); ?>
+
+
+
+
diff --git a/system/templates/default.php b/system/templates/default.php
index 13f962c..61703f0 100755
--- a/system/templates/default.php
+++ b/system/templates/default.php
@@ -1,7 +1,4 @@
snippet("header") ?>
snippet("navigation") ?>
-
-
page->getTitle() ?>
-page->getContent() ?>
-
+snippet("content", $yellow->page->getTitle(), $yellow->page->getContent()) ?>
snippet("footer") ?>
\ No newline at end of file