Better location handling (September update)
This commit is contained in:
parent
39c04c43fa
commit
569de49b98
4 changed files with 39 additions and 15 deletions
|
@ -23,7 +23,7 @@ mediaDir = media/
|
|||
styleDir = media/styles/
|
||||
imageDir = media/images/
|
||||
contentDir = content/
|
||||
contentHomeDir = 1-home/
|
||||
contentHomeDir = home/
|
||||
contentDefaultFile = page.txt
|
||||
contentExtension = .txt
|
||||
configExtension = .ini
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// Yellow main class
|
||||
class Yellow
|
||||
{
|
||||
const Version = "0.1.17";
|
||||
const Version = "0.1.18";
|
||||
var $page; //current page data
|
||||
var $pages; //current page tree from file system
|
||||
var $toolbox; //toolbox with helpers
|
||||
|
@ -369,9 +369,7 @@ class Yellow_Page
|
|||
$this->set("template", $this->yellow->config->get("template"));
|
||||
$this->set("style", $this->yellow->config->get("style"));
|
||||
$this->set("parser", $this->yellow->config->get("parser"));
|
||||
$location = $this->yellow->config->get("serverBase").rtrim($this->yellow->config->get("webinterfaceLocation"), '/').$this->location;
|
||||
$this->set("pageEdit", $location);
|
||||
|
||||
|
||||
if(preg_match("/^(\-\-\-[\r\n]+)(.+?)([\r\n]+\-\-\-[\r\n]+)/s", $this->rawData, $parsed))
|
||||
{
|
||||
$this->metaDataOffsetBytes = strlenb($parsed[0]);
|
||||
|
@ -384,9 +382,13 @@ class Yellow_Page
|
|||
$this->metaDataOffsetBytes = strlenb($parsed[0]);
|
||||
$this->set("title", $parsed[1]);
|
||||
}
|
||||
|
||||
$titleHeader = $this->location!="/" ? $this->get("title")." - ".$this->get("sitename") : $this->get("sitename");
|
||||
if(!$this->isExisting("titleHeader")) $this->set("titleHeader", $titleHeader);
|
||||
if(!$this->isExisting("titleNavigation")) $this->set("titleNavigation", $this->get("title"));
|
||||
$this->set("pageRead", $this->yellow->config->get("serverBase").$this->location);
|
||||
$this->set("pageEdit", $this->yellow->config->get("serverBase").
|
||||
rtrim($this->yellow->config->get("webinterfaceLocation"), '/').$this->location);
|
||||
foreach($this->yellow->plugins->plugins as $key=>$value)
|
||||
{
|
||||
if(method_exists($value["obj"], "onParseMeta"))
|
||||
|
@ -414,6 +416,10 @@ class Yellow_Page
|
|||
{
|
||||
$this->parser = $this->yellow->plugins->plugins[$this->get("parser")]["obj"];
|
||||
$this->parser->parse(substrb($this->rawData, $this->metaDataOffsetBytes));
|
||||
$baseLocation = $this->yellow->pages->serverBase.$this->location;
|
||||
$baseLocation = ($pos = strrposu($baseLocation, '/')) ? substru($baseLocation, 0, $pos) : $baseLocation;
|
||||
$this->parser->textHtml = preg_replace("#<a(.*?)href=\"([^\/\"]+)\"(.*?)>#",
|
||||
"<a$1href=\"$baseLocation/$2\"$3>", $this->parser->textHtml);
|
||||
}
|
||||
foreach($this->yellow->plugins->plugins as $key=>$value)
|
||||
{
|
||||
|
@ -506,8 +512,8 @@ class Yellow_Page
|
|||
// Return page modification time, Unix time
|
||||
function getModified($httpFormat = false)
|
||||
{
|
||||
$modified = strtotime($this->get("modified"));
|
||||
return $httpFormat ? $this->yellow->toolbox->getHttpTimeFormatted($modified) : $modified;
|
||||
$modified = strtotime($this->get("modified"));
|
||||
return $httpFormat ? $this->yellow->toolbox->getHttpTimeFormatted($modified) : $modified;
|
||||
}
|
||||
|
||||
// Return page status code
|
||||
|
@ -891,7 +897,10 @@ class Yellow_Pages
|
|||
function getParentLocation($location)
|
||||
{
|
||||
$parentLocation = "";
|
||||
if(preg_match("/^(.*\/)(.+?)$/", $location, $matches)) $parentLocation = $matches[1]!="/" ? $matches[1] : "";
|
||||
if(preg_match("/^(.*\/).+?$/", $location, $matches))
|
||||
{
|
||||
if($matches[1]!="/" || $this->yellow->toolbox->isFileLocation($location)) $parentLocation = $matches[1];
|
||||
}
|
||||
return $parentLocation;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// Markdown parser core plugin
|
||||
class Yellow_Markdown
|
||||
{
|
||||
const Version = "0.1.6";
|
||||
const Version = "0.1.7";
|
||||
var $yellow; //access to API
|
||||
var $textHtml; //generated text (HTML format)
|
||||
|
||||
|
@ -38,6 +38,7 @@ class Yellow_MarkdownExtraParser extends MarkdownExtra_Parser
|
|||
// Transform text
|
||||
function transform($text)
|
||||
{
|
||||
$text = preg_replace("/@pageRead/i", $this->yellow->page->get("pageRead"), $text);
|
||||
$text = preg_replace("/@pageEdit/i", $this->yellow->page->get("pageEdit"), $text);
|
||||
$text = preg_replace("/@pageError/i", $this->yellow->page->get("pageError"), $text);
|
||||
return parent::transform($text);
|
||||
|
@ -58,7 +59,7 @@ class Yellow_MarkdownExtraParser extends MarkdownExtra_Parser
|
|||
$text = preg_replace("/\s+/s", " ", $matches[2]);
|
||||
$output = $this->yellow->page->parseType($matches[1], $text, true);
|
||||
if(is_null($output)) $output = $matches[0];
|
||||
return $this->hashBlock($output);
|
||||
return $this->hashBlock($output);
|
||||
}
|
||||
|
||||
// Handle fenced code blocks
|
||||
|
@ -72,9 +73,23 @@ class Yellow_MarkdownExtraParser extends MarkdownExtra_Parser
|
|||
$output = "<pre$attr><code>".htmlspecialchars($text, ENT_NOQUOTES)."</code></pre>";
|
||||
}
|
||||
return "\n\n".$this->hashBlock($output)."\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Handle images
|
||||
// Handle inline links
|
||||
function _doAnchors_inline_callback($matches)
|
||||
{
|
||||
$url = $matches[3]=="" ? $matches[4] : $matches[3];
|
||||
$text = $matches[2];
|
||||
$title = $matches[7];
|
||||
$attr = $this->doExtraAttributes("a", $dummy =& $matches[8]);
|
||||
$output = "<a href=\"".$this->encodeAttribute($url)."\"";
|
||||
if(!empty($title)) $output .= " title=\"".$this->encodeAttribute($title)."\"";
|
||||
$output .= $attr;
|
||||
$output .= ">".$this->runSpanGamut($text)."</a>";
|
||||
return $this->hashPart($output);
|
||||
}
|
||||
|
||||
// Handle inline images
|
||||
function _doImages_inline_callback($matches)
|
||||
{
|
||||
$path = $matches[3]=="" ? $matches[4] : $matches[3];
|
||||
|
@ -82,7 +97,7 @@ class Yellow_MarkdownExtraParser extends MarkdownExtra_Parser
|
|||
list($width, $height) = $this->yellow->toolbox->detectImageDimensions($this->yellow->config->get("imageDir").$path);
|
||||
$alt = $matches[2];
|
||||
$title = $matches[7];
|
||||
$attr = $this->doExtraAttributes("img", $dummy =& $matches[8]);
|
||||
$attr = $this->doExtraAttributes("img", $dummy =& $matches[8]);
|
||||
$output = "<img src=\"".$this->encodeAttribute($src)."\"";
|
||||
if($width && $height) $output .= " width=\"$width\" height=\"$height\"";
|
||||
if(!empty($alt)) $output .= " alt=\"".$this->encodeAttribute($alt)."\"";
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// Web interface core plugin
|
||||
class Yellow_Webinterface
|
||||
{
|
||||
const Version = "0.1.9";
|
||||
const Version = "0.1.10";
|
||||
var $yellow; //access to API
|
||||
var $users; //web interface users
|
||||
var $activeLocation; //web interface location? (boolean)
|
||||
|
@ -55,7 +55,7 @@ class Yellow_Webinterface
|
|||
$serverBase = $this->yellow->config->get("serverBase");
|
||||
$webinterfaceLocation = trim($this->yellow->config->get("webinterfaceLocation"), '/');
|
||||
$output = preg_replace("#<a(.*?)href=\"$serverBase/(?!$webinterfaceLocation)(.*?)\"(.*?)>#",
|
||||
"<a$1href=\"$serverBase/$webinterfaceLocation/$2\"$3>", $text);
|
||||
"<a$1href=\"$serverBase/$webinterfaceLocation/$2\"$3>", $text);
|
||||
if($page == $this->yellow->page)
|
||||
{
|
||||
switch($page->statusCode)
|
||||
|
|
Loading…
Add table
Reference in a new issue