Updated API, spring remix

This commit is contained in:
markseu 2023-05-19 13:49:25 +02:00
parent ab67f1407b
commit aacd46c273
9 changed files with 87 additions and 83 deletions

View file

@ -2,7 +2,7 @@
// Core extension, https://github.com/annaesvensson/yellow-core // Core extension, https://github.com/annaesvensson/yellow-core
class YellowCore { class YellowCore {
const VERSION = "0.8.113"; const VERSION = "0.8.114";
const RELEASE = "0.8.22"; const RELEASE = "0.8.22";
public $content; // content files public $content; // content files
public $media; // media files public $media; // media files
@ -98,7 +98,7 @@ class YellowCore {
$statusCode = 0; $statusCode = 0;
$this->toolbox->timerStart($time); $this->toolbox->timerStart($time);
ob_start(); ob_start();
list($scheme, $address, $base, $location, $fileName) = $this->getRequestInformation(); list($scheme, $address, $base, $location, $fileName) = $this->lookup->getRequestInformation();
$this->page->setRequestInformation($scheme, $address, $base, $location, $fileName, true); $this->page->setRequestInformation($scheme, $address, $base, $location, $fileName, true);
foreach ($this->extension->data as $key=>$value) { foreach ($this->extension->data as $key=>$value) {
if (method_exists($value["object"], "onRequest")) { if (method_exists($value["object"], "onRequest")) {
@ -253,7 +253,7 @@ class YellowCore {
public function command($line = "") { public function command($line = "") {
$statusCode = 0; $statusCode = 0;
$this->toolbox->timerStart($time); $this->toolbox->timerStart($time);
list($command, $text) = $this->getCommandInformation($line); list($command, $text) = $this->lookup->getCommandInformation($line);
foreach ($this->extension->data as $key=>$value) { foreach ($this->extension->data as $key=>$value) {
if (method_exists($value["object"], "onCommand")) { if (method_exists($value["object"], "onCommand")) {
$this->lookup->commandHandler = $key; $this->lookup->commandHandler = $key;
@ -310,42 +310,6 @@ class YellowCore {
return array_pad($this->lookup->layoutArguments, $sizeMin, null); return array_pad($this->lookup->layoutArguments, $sizeMin, null);
} }
// Return troubleshooting URL
public function getTroubleshootingUrl() {
return "https://datenstrom.se/yellow/help/troubleshooting";
}
// Return request information
public function getRequestInformation($scheme = "", $address = "", $base = "") {
if (is_string_empty($scheme) && is_string_empty($address) && is_string_empty($base)) {
$url = $this->system->get("coreServerUrl");
if ($url=="auto" || $this->lookup->isCommandLine()) $url = $this->toolbox->detectServerUrl();
list($scheme, $address, $base) = $this->lookup->getUrlInformation($url);
$this->system->set("coreServerScheme", $scheme);
$this->system->set("coreServerAddress", $address);
$this->system->set("coreServerBase", $base);
if ($this->system->get("coreDebugMode")>=3) {
echo "YellowCore::getRequestInformation $scheme://$address$base<br/>\n";
}
}
$location = substru($this->toolbox->detectServerLocation(), strlenu($base));
$fileName = "";
if (is_string_empty($fileName)) $fileName = $this->lookup->findFileFromMediaLocation($location);
if (is_string_empty($fileName)) $fileName = $this->lookup->findFileFromContentLocation($location);
return array($scheme, $address, $base, $location, $fileName);
}
// Return command information
public function getCommandInformation($line = "") {
if (is_string_empty($line)) {
$line = $this->toolbox->getTextString(array_slice($this->toolbox->getServer("argv"), 1));
if ($this->system->get("coreDebugMode")>=3) {
echo "YellowCore::getCommandInformation $line<br/>\n";
}
}
return $this->toolbox->getTextList($line, " ", 2);
}
// Return command help // Return command help
public function getCommandHelp() { public function getCommandHelp() {
$data = array(); $data = array();
@ -363,14 +327,9 @@ class YellowCore {
return $data; return $data;
} }
// Return request handler // Return troubleshooting URL
public function getRequestHandler() { public function getTroubleshootingUrl() {
return $this->lookup->requestHandler; return "https://datenstrom.se/yellow/help/troubleshooting";
}
// Return command handler
public function getCommandHandler() {
return $this->lookup->commandHandler;
} }
// TODO: remove later, for backwards compatibility // TODO: remove later, for backwards compatibility
@ -448,7 +407,7 @@ class YellowContent {
$address = $this->yellow->page->address; $address = $this->yellow->page->address;
$base = $this->yellow->page->base; $base = $this->yellow->page->base;
$one = ($pages->offsetGet(0)->location!=$this->yellow->page->location) ? $pages->offsetGet(0) : $this->yellow->page; $one = ($pages->offsetGet(0)->location!=$this->yellow->page->location) ? $pages->offsetGet(0) : $this->yellow->page;
preg_match_all("/<h(\d) id=\"([^\"]+)\">(.*?)<\/h\d>/i", $one->getContent(), $matches, PREG_SET_ORDER); preg_match_all("/<h(\d) id=\"([^\"]+)\">(.*?)<\/h\d>/i", $one->getContentHtml(), $matches, PREG_SET_ORDER);
foreach ($matches as $match) { foreach ($matches as $match) {
if ($match[1]==2) { if ($match[1]==2) {
$page = new YellowPage($this->yellow); $page = new YellowPage($this->yellow);
@ -1657,6 +1616,47 @@ class YellowLookup {
return array($scheme, $address, $base); return array($scheme, $address, $base);
} }
// Return request information
public function getRequestInformation($scheme = "", $address = "", $base = "") {
if (is_string_empty($scheme) && is_string_empty($address) && is_string_empty($base)) {
$url = $this->yellow->system->get("coreServerUrl");
if ($url=="auto" || $this->isCommandLine()) $url = $this->yellow->toolbox->detectServerUrl();
list($scheme, $address, $base) = $this->getUrlInformation($url);
$this->yellow->system->set("coreServerScheme", $scheme);
$this->yellow->system->set("coreServerAddress", $address);
$this->yellow->system->set("coreServerBase", $base);
if ($this->yellow->system->get("coreDebugMode")>=3) {
echo "YellowLookup::getRequestInformation $scheme://$address$base<br/>\n";
}
}
$location = substru($this->yellow->toolbox->detectServerLocation(), strlenu($base));
$fileName = "";
if (is_string_empty($fileName)) $fileName = $this->findFileFromMediaLocation($location);
if (is_string_empty($fileName)) $fileName = $this->findFileFromContentLocation($location);
return array($scheme, $address, $base, $location, $fileName);
}
// Return command information
public function getCommandInformation($line = "") {
if (is_string_empty($line)) {
$line = $this->yellow->toolbox->getTextString(array_slice($this->yellow->toolbox->getServer("argv"), 1));
if ($this->yellow->system->get("coreDebugMode")>=3) {
echo "YellowLookup::getCommandInformation $line<br/>\n";
}
}
return $this->yellow->toolbox->getTextList($line, " ", 2);
}
// Return request handler
public function getRequestHandler() {
return $this->requestHandler;
}
// Return command handler
public function getCommandHandler() {
return $this->commandHandler;
}
// Return attributes from text // Return attributes from text
public function getTextAttributes($text, $attributesAllowEmptyString) { public function getTextAttributes($text, $attributesAllowEmptyString) {
$tokens = array(); $tokens = array();
@ -3063,7 +3063,7 @@ class YellowPage {
$value = $this->yellow->extension->data[$this->get("parser")]; $value = $this->yellow->extension->data[$this->get("parser")];
if (method_exists($value["object"], "onParseContentRaw")) { if (method_exists($value["object"], "onParseContentRaw")) {
$this->parser = $value["object"]; $this->parser = $value["object"];
$this->parserData = $this->getContent(true); $this->parserData = $this->getContentRaw();
$this->parserData = $this->parser->onParseContentRaw($this, $this->parserData); $this->parserData = $this->parser->onParseContentRaw($this, $this->parserData);
foreach ($this->yellow->extension->data as $key=>$value) { foreach ($this->yellow->extension->data as $key=>$value) {
if (method_exists($value["object"], "onParseContentHtml")) { if (method_exists($value["object"], "onParseContentHtml")) {
@ -3073,7 +3073,7 @@ class YellowPage {
} }
} }
} else { } else {
$this->parserData = $this->getContent(true); $this->parserData = $this->getContentRaw();
$this->parserData = preg_replace("/\[yellow error\]/i", $this->errorMessage, $this->parserData); $this->parserData = preg_replace("/\[yellow error\]/i", $this->errorMessage, $this->parserData);
} }
if (!$this->isExisting("description")) { if (!$this->isExisting("description")) {
@ -3126,12 +3126,12 @@ class YellowPage {
if ($this->yellow->lookup->isNestedLocation($this->location, $this->fileName, true)) { if ($this->yellow->lookup->isNestedLocation($this->location, $this->fileName, true)) {
$this->error(500, "Folder '".dirname($this->fileName)."' may not contain subfolders!"); $this->error(500, "Folder '".dirname($this->fileName)."' may not contain subfolders!");
} }
if ($this->yellow->getRequestHandler()=="core" && $this->isExisting("redirect") && $this->statusCode==200) { if ($this->yellow->lookup->getRequestHandler()=="core" && $this->isExisting("redirect") && $this->statusCode==200) {
$location = $this->yellow->lookup->normaliseLocation($this->get("redirect"), $this->location); $location = $this->yellow->lookup->normaliseLocation($this->get("redirect"), $this->location);
$location = $this->yellow->lookup->normaliseUrl($this->scheme, $this->address, "", $location); $location = $this->yellow->lookup->normaliseUrl($this->scheme, $this->address, "", $location);
$this->status(301, $location); $this->status(301, $location);
} }
if ($this->yellow->getRequestHandler()=="core" && !$this->isAvailable() && $this->statusCode==200) { if ($this->yellow->lookup->getRequestHandler()=="core" && !$this->isAvailable() && $this->statusCode==200) {
$this->error(404); $this->error(404);
} }
if ($this->isExisting("pageClean")) $this->outputData = null; if ($this->isExisting("pageClean")) $this->outputData = null;
@ -3237,20 +3237,20 @@ class YellowPage {
return htmlspecialchars($this->getDateFormatted($key, $format)); return htmlspecialchars($this->getDateFormatted($key, $format));
} }
// Return page content data, HTML encoded or raw format // Return page content data, raw format
public function getContent($rawFormat = false) { public function getContentRaw() {
if ($rawFormat) {
$this->parseMetaUpdate(); $this->parseMetaUpdate();
$text = substrb($this->rawData, $this->metaDataOffsetBytes); return substrb($this->rawData, $this->metaDataOffsetBytes);
} else {
$this->parseContent();
$text = $this->parserData;
} }
return $text;
// Return page content data, HTML encoded or raw format
public function getContentHtml() {
$this->parseContent();
return $this->parserData;
} }
// Return page extra data, HTML encoded // Return page extra data, HTML encoded
public function getExtra($name) { public function getExtraHtml($name) {
$output = ""; $output = "";
foreach ($this->yellow->extension->data as $key=>$value) { foreach ($this->yellow->extension->data as $key=>$value) {
if (method_exists($value["object"], "onParsePageExtra")) { if (method_exists($value["object"], "onParsePageExtra")) {
@ -3492,6 +3492,10 @@ class YellowPage {
public function isPage($key) { public function isPage($key) {
return isset($this->sharedPages[$key]); return isset($this->sharedPages[$key]);
} }
// TODO: remove later, for backwards compatibility
public function getContent($rawFormat = false) { return $rawFormat ? $this->getContentRaw() : $this->getContentHtml(); }
public function getExtra($name) { return $this->getExtraHtml($name); }
} }
class YellowPageCollection extends ArrayObject { class YellowPageCollection extends ArrayObject {

View file

@ -2,7 +2,7 @@
// Edit extension, https://github.com/annaesvensson/yellow-edit // Edit extension, https://github.com/annaesvensson/yellow-edit
class YellowEdit { class YellowEdit {
const VERSION = "0.8.74"; const VERSION = "0.8.75";
public $yellow; // access to API public $yellow; // access to API
public $response; // web response public $response; // web response
public $merge; // text merge public $merge; // text merge
@ -63,7 +63,7 @@ class YellowEdit {
$scheme = $this->yellow->system->get("coreServerScheme"); $scheme = $this->yellow->system->get("coreServerScheme");
$address = $this->yellow->system->get("coreServerAddress"); $address = $this->yellow->system->get("coreServerAddress");
$base = rtrim($this->yellow->system->get("coreServerBase").$this->yellow->system->get("editLocation"), "/"); $base = rtrim($this->yellow->system->get("coreServerBase").$this->yellow->system->get("editLocation"), "/");
list($scheme, $address, $base, $location, $fileName) = $this->yellow->getRequestInformation($scheme, $address, $base); list($scheme, $address, $base, $location, $fileName) = $this->yellow->lookup->getRequestInformation($scheme, $address, $base);
$this->yellow->page->setRequestInformation($scheme, $address, $base, $location, $fileName, false); $this->yellow->page->setRequestInformation($scheme, $address, $base, $location, $fileName, false);
$statusCode = $this->processRequest($scheme, $address, $base, $location, $fileName); $statusCode = $this->processRequest($scheme, $address, $base, $location, $fileName);
} }
@ -1165,7 +1165,7 @@ class YellowEditResponse {
$class = "page-preview layout-".$page->get("layout"); $class = "page-preview layout-".$page->get("layout");
$output = "<div class=\"".htmlspecialchars($class)."\"><div class=\"content\"><div class=\"main\">"; $output = "<div class=\"".htmlspecialchars($class)."\"><div class=\"content\"><div class=\"main\">";
if ($this->yellow->system->get("editToolbarButtons")!="none") $output .= "<h1>".$page->getHtml("titleContent")."</h1>\n"; if ($this->yellow->system->get("editToolbarButtons")!="none") $output .= "<h1>".$page->getHtml("titleContent")."</h1>\n";
$output .= $page->getContent(); $output .= $page->getContentHtml();
$output .= "</div></div></div>"; $output .= "</div></div></div>";
$page->statusCode = 200; $page->statusCode = 200;
$page->outputData = $output; $page->outputData = $output;

View file

@ -2,7 +2,7 @@
// Install extension, https://github.com/annaesvensson/yellow-install // Install extension, https://github.com/annaesvensson/yellow-install
class YellowInstall { class YellowInstall {
const VERSION = "0.8.88"; const VERSION = "0.8.89";
const PRIORITY = "1"; const PRIORITY = "1";
public $yellow; // access to API public $yellow; // access to API
@ -346,7 +346,7 @@ class YellowInstall {
$rewrite = true; $rewrite = true;
if (!$this->isServerBuiltin()) { if (!$this->isServerBuiltin()) {
$curlHandle = curl_init(); $curlHandle = curl_init();
list($scheme, $address, $base) = $this->yellow->getRequestInformation(); list($scheme, $address, $base) = $this->yellow->lookup->getRequestInformation();
$location = $this->yellow->system->get("coreThemeLocation").$this->yellow->lookup->normaliseName($this->yellow->system->get("theme")).".css"; $location = $this->yellow->system->get("coreThemeLocation").$this->yellow->lookup->normaliseName($this->yellow->system->get("theme")).".css";
$url = $this->yellow->lookup->normaliseUrl($scheme, $address, $base, $location); $url = $this->yellow->lookup->normaliseUrl($scheme, $address, $base, $location);
curl_setopt($curlHandle, CURLOPT_URL, $url); curl_setopt($curlHandle, CURLOPT_URL, $url);

View file

@ -2,7 +2,7 @@
// Meta extension, https://github.com/annaesvensson/yellow-meta // Meta extension, https://github.com/annaesvensson/yellow-meta
class YellowMeta { class YellowMeta {
const VERSION = "0.8.16"; const VERSION = "0.8.17";
public $yellow; // access to API public $yellow; // access to API
// Handle initialisation // Handle initialisation
@ -43,7 +43,7 @@ class YellowMeta {
if ($page->isExisting("image")) { if ($page->isExisting("image")) {
$name = $page->get("image"); $name = $page->get("image");
$alt = $page->isExisting("imageAlt") ? $page->get("imageAlt") : $page->get("title"); $alt = $page->isExisting("imageAlt") ? $page->get("imageAlt") : $page->get("title");
} elseif (preg_match("/\[image(\s.*?)\]/", $page->getContent(true), $matches)) { } elseif (preg_match("/\[image(\s.*?)\]/", $page->getContentRaw(), $matches)) {
list($name, $alt) = $this->yellow->toolbox->getTextArguments(trim($matches[1])); list($name, $alt) = $this->yellow->toolbox->getTextArguments(trim($matches[1]));
if (is_string_empty($alt)) $alt = $page->get("title"); if (is_string_empty($alt)) $alt = $page->get("title");
} else { } else {

View file

@ -1,11 +1,11 @@
# Datenstrom Yellow update settings # Datenstrom Yellow update settings
Extension: Core Extension: Core
Version: 0.8.113 Version: 0.8.114
Description: Core functionality of the website. Description: Core functionality of the website.
DocumentationUrl: https://github.com/annaesvensson/yellow-core DocumentationUrl: https://github.com/annaesvensson/yellow-core
DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/main/downloads/core.zip DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/main/downloads/core.zip
Published: 2023-05-18 17:55:38 Published: 2023-05-19 13:37:00
Developer: Mark Seuffert, David Fehrmann Developer: Mark Seuffert, David Fehrmann
Tag: feature Tag: feature
system/extensions/core.php: core.php, create, update system/extensions/core.php: core.php, create, update
@ -17,11 +17,11 @@ system/layouts/navigation.html: navigation.html, create, update, careful
system/layouts/pagination.html: pagination.html, create, update, careful system/layouts/pagination.html: pagination.html, create, update, careful
Extension: Edit Extension: Edit
Version: 0.8.74 Version: 0.8.75
Description: Edit your website in a web browser. Description: Edit your website in a web browser.
DocumentationUrl: https://github.com/annaesvensson/yellow-edit DocumentationUrl: https://github.com/annaesvensson/yellow-edit
DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/main/downloads/edit.zip DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/main/downloads/edit.zip
Published: 2023-05-18 18:03:30 Published: 2023-05-19 00:50:31
Developer: Anna Svensson Developer: Anna Svensson
Tag: feature Tag: feature
system/extensions/edit.php: edit.php, create, update system/extensions/edit.php: edit.php, create, update
@ -44,11 +44,11 @@ media/images/photo.jpg: photo.jpg, create, optional
media/thumbnails/photo-100x40.jpg: photo-100x40.jpg, create, optional media/thumbnails/photo-100x40.jpg: photo-100x40.jpg, create, optional
Extension: Install Extension: Install
Version: 0.8.88 Version: 0.8.89
Description: Install a brand new, shiny website. Description: Install a brand new, shiny website.
DocumentationUrl: https://github.com/annaesvensson/yellow-install DocumentationUrl: https://github.com/annaesvensson/yellow-install
DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/main/downloads/install.zip DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/main/downloads/install.zip
Published: 2023-04-16 23:55:50 Published: 2023-05-19 13:29:22
Developer: Anna Svensson Developer: Anna Svensson
Status: unlisted Status: unlisted
system/extensions/install.php: install.php, create system/extensions/install.php: install.php, create
@ -76,11 +76,11 @@ Tag: feature
system/extensions/markdown.php: markdown.php, create, update system/extensions/markdown.php: markdown.php, create, update
Extension: Meta Extension: Meta
Version: 0.8.16 Version: 0.8.17
Description: Meta data for humans and machines. Description: Meta data for humans and machines.
DocumentationUrl: https://github.com/annaesvensson/yellow-meta DocumentationUrl: https://github.com/annaesvensson/yellow-meta
DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/main/downloads/meta.zip DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/main/downloads/meta.zip
Published: 2022-11-03 18:23:11 Published: 2023-05-19 00:58:40
Developer: Anna Svensson, Steffen Schultz Developer: Anna Svensson, Steffen Schultz
Tag: feature Tag: feature
system/extensions/meta.php: meta.php, create, update system/extensions/meta.php: meta.php, create, update

View file

@ -2,7 +2,7 @@
<div class="content"> <div class="content">
<div class="main" role="main"> <div class="main" role="main">
<h1><?php echo $this->yellow->page->getHtml("titleContent") ?></h1> <h1><?php echo $this->yellow->page->getHtml("titleContent") ?></h1>
<?php echo $this->yellow->page->getContent() ?> <?php echo $this->yellow->page->getContentHtml() ?>
</div> </div>
</div> </div>
<?php $this->yellow->layout("footer") ?> <?php $this->yellow->layout("footer") ?>

View file

@ -2,7 +2,7 @@
<div class="content"> <div class="content">
<div class="main" role="main"> <div class="main" role="main">
<h1><?php echo $this->yellow->page->getHtml("titleContent") ?></h1> <h1><?php echo $this->yellow->page->getHtml("titleContent") ?></h1>
<?php echo $this->yellow->page->getContent() ?> <?php echo $this->yellow->page->getContentHtml() ?>
</div> </div>
</div> </div>
<?php $this->yellow->layout("footer") ?> <?php $this->yellow->layout("footer") ?>

View file

@ -1,10 +1,10 @@
<div class="footer" role="contentinfo"> <div class="footer" role="contentinfo">
<div class="siteinfo"> <div class="siteinfo">
<?php echo $this->yellow->page->getPage("footer")->getContent() ?> <?php echo $this->yellow->page->getPage("footer")->getContentHtml() ?>
</div> </div>
<div class="siteinfo-banner"></div> <div class="siteinfo-banner"></div>
</div> </div>
</div> </div>
<?php echo $this->yellow->page->getExtra("footer") ?> <?php echo $this->yellow->page->getExtraHtml("footer") ?>
</body> </body>
</html> </html>

View file

@ -7,14 +7,14 @@
<meta name="author" content="<?php echo $this->yellow->page->getHtml("author") ?>" /> <meta name="author" content="<?php echo $this->yellow->page->getHtml("author") ?>" />
<meta name="generator" content="Datenstrom Yellow" /> <meta name="generator" content="Datenstrom Yellow" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<?php echo $this->yellow->page->getExtra("header") ?> <?php echo $this->yellow->page->getExtraHtml("header") ?>
</head> </head>
<body> <body>
<div class="<?php echo "page layout-".$this->yellow->page->getHtml("layout") ?>"> <div class="<?php echo "page layout-".$this->yellow->page->getHtml("layout") ?>">
<div class="header" role="banner"> <div class="header" role="banner">
<div class="sitename"> <div class="sitename">
<h1><a href="<?php echo $this->yellow->page->getBase(true)."/" ?>"><i class="sitename-logo"></i><?php echo $this->yellow->page->getHtml("sitename") ?></a></h1> <h1><a href="<?php echo $this->yellow->page->getBase(true)."/" ?>"><i class="sitename-logo"></i><?php echo $this->yellow->page->getHtml("sitename") ?></a></h1>
<?php echo $this->yellow->page->getPage("header")->getContent() ?> <?php echo $this->yellow->page->getPage("header")->getContentHtml() ?>
</div> </div>
<div class="sitename-banner"></div> <div class="sitename-banner"></div>
<?php $this->yellow->layout("navigation") ?> <?php $this->yellow->layout("navigation") ?>