mikuli.cz

:)
git clone https://git.sr.ht/~ashymad/mikuli.cz
Log | Files | Refs

commit e7ab8529eac20216f8b15474b33d73d414efb123
parent 1ded03aba073bebdc8b2b71f8acbf39688ad80c0
Author: markseu <mark2011@mayberg.se>
Date:   Sat,  5 Nov 2022 12:26:16 +0100

Updated API, new settings

Diffstat:
Msystem/extensions/command.php | 31++++++++++++++++---------------
Msystem/extensions/core.php | 17++---------------
Msystem/extensions/edit.js | 8+++++++-
Msystem/extensions/edit.php | 33++++++++++++++++++++-------------
Msystem/extensions/install-blog.bin | 0
Msystem/extensions/install-wiki.bin | 0
Msystem/extensions/install.php | 4++--
Msystem/extensions/update-current.ini | 20++++++++++----------
Msystem/extensions/update.php | 2+-
9 files changed, 58 insertions(+), 57 deletions(-)

diff --git a/system/extensions/command.php b/system/extensions/command.php @@ -2,7 +2,7 @@ // Command extension, https://github.com/annaesvensson/yellow-command class YellowCommand { - const VERSION = "0.8.44"; + const VERSION = "0.8.45"; public $yellow; // access to API public $files; // number of files public $links; // number of links @@ -13,7 +13,8 @@ class YellowCommand { // Handle initialisation public function onLoad($yellow) { $this->yellow = $yellow; - $this->yellow->system->setDefault("commandStaticBuildDirectory", "public/"); + $this->yellow->system->setDefault("commandStaticUrl", "auto"); + $this->yellow->system->setDefault("commandStaticDirectory", "public/"); $this->yellow->system->setDefault("commandStaticDefaultFile", "index.html"); $this->yellow->system->setDefault("commandStaticErrorFile", "404.html"); } @@ -51,7 +52,7 @@ class YellowCommand { $this->files = 0; $this->errors = 1; $fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreSystemFile"); - echo "ERROR building files: Please configure CoreStaticUrl in file '$fileName'!\n"; + echo "ERROR building files: Please configure CommandStaticUrl in file '$fileName'!\n"; } echo "Yellow $command: $this->files file".($this->files!=1 ? "s" : ""); echo ", $this->errors error".($this->errors!=1 ? "s" : "")."\n"; @@ -64,11 +65,11 @@ class YellowCommand { // Build static files public function buildStaticFiles($path, $locationFilter) { - $path = rtrim(is_string_empty($path) ? $this->yellow->system->get("commandStaticBuildDirectory") : $path, "/"); + $path = rtrim(is_string_empty($path) ? $this->yellow->system->get("commandStaticDirectory") : $path, "/"); $this->files = $this->errors = 0; $this->locationsArguments = $this->locationsArgumentsPagination = array(); $statusCode = is_string_empty($locationFilter) ? $this->cleanStaticFiles($path, $locationFilter) : 200; - $staticUrl = $this->yellow->system->get("coreStaticUrl"); + $staticUrl = $this->yellow->system->get("commandStaticUrl"); list($scheme, $address, $base) = $this->yellow->lookup->getUrlInformation($staticUrl); $locations = $this->getContentLocations(); $filesEstimated = count($locations); @@ -115,7 +116,7 @@ class YellowCommand { $this->yellow->page->fileName = substru($location, 1); if (!is_readable($this->yellow->page->fileName)) { ob_start(); - $staticUrl = $this->yellow->system->get("coreStaticUrl"); + $staticUrl = $this->yellow->system->get("commandStaticUrl"); list($scheme, $address, $base) = $this->yellow->lookup->getUrlInformation($staticUrl); $statusCode = $this->requestStaticFile($scheme, $address, $base, $location); if ($statusCode<400 || $error) { @@ -237,7 +238,7 @@ class YellowCommand { $this->links = 0; $this->errors = 1; $fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreSystemFile"); - echo "ERROR checking files: Please configure CoreStaticUrl in file '$fileName'!\n"; + echo "ERROR checking files: Please configure CommandStaticUrl in file '$fileName'!\n"; } echo "Yellow $command: $this->links link".($this->links!=1 ? "s" : ""); echo ", $this->errors error".($this->errors!=1 ? "s" : "")."\n"; @@ -250,7 +251,7 @@ class YellowCommand { // Check static files for broken links public function checkStaticFiles($path, $locationFilter) { - $path = rtrim(is_string_empty($path) ? $this->yellow->system->get("commandStaticBuildDirectory") : $path, "/"); + $path = rtrim(is_string_empty($path) ? $this->yellow->system->get("commandStaticDirectory") : $path, "/"); $this->links = $this->errors = 0; $regex = "/^[^.]+$|".$this->yellow->system->get("commandStaticDefaultFile")."$/"; $fileNames = $this->yellow->toolbox->getDirectoryEntriesRecursive($path, $regex, false, false); @@ -268,7 +269,7 @@ class YellowCommand { $statusCode = 200; $links = array(); if (!is_array_empty($fileNames)) { - $staticUrl = $this->yellow->system->get("coreStaticUrl"); + $staticUrl = $this->yellow->system->get("commandStaticUrl"); list($scheme, $address, $base) = $this->yellow->lookup->getUrlInformation($staticUrl); foreach ($fileNames as $fileName) { if (is_readable($fileName)) { @@ -323,7 +324,7 @@ class YellowCommand { public function analyseStatus($path, $links) { $statusCode = 200; $remote = $broken = $redirect = $data = array(); - $staticUrl = $this->yellow->system->get("coreStaticUrl"); + $staticUrl = $this->yellow->system->get("commandStaticUrl"); $staticUrlLength = strlenu(rtrim($staticUrl, "/")); list($scheme, $address, $base) = $this->yellow->lookup->getUrlInformation($staticUrl); $staticLocations = $this->getContentLocations(true); @@ -395,7 +396,7 @@ class YellowCommand { // Clean static files and directories public function cleanStaticFiles($path, $location) { $statusCode = 200; - $path = rtrim(is_string_empty($path) ? $this->yellow->system->get("commandStaticBuildDirectory") : $path, "/"); + $path = rtrim(is_string_empty($path) ? $this->yellow->system->get("commandStaticDirectory") : $path, "/"); if (is_string_empty($location)) { foreach ($this->yellow->extension->data as $key=>$value) { if (method_exists($value["object"], "onUpdate")) $value["object"]->onUpdate("clean"); @@ -452,14 +453,14 @@ class YellowCommand { // Check static settings public function checkStaticSettings() { - return preg_match("/^(http|https):/", $this->yellow->system->get("coreStaticUrl")); + return preg_match("/^(http|https):/", $this->yellow->system->get("commandStaticUrl")); } // Check static directory public function checkStaticDirectory($path) { $ok = false; if (!is_string_empty($path)) { - if ($path==rtrim($this->yellow->system->get("commandStaticBuildDirectory"), "/")) $ok = true; + if ($path==rtrim($this->yellow->system->get("commandStaticDirectory"), "/")) $ok = true; if ($path==rtrim($this->yellow->system->get("coreCacheDirectory"), "/")) $ok = true; if ($path==rtrim($this->yellow->system->get("coreTrashDirectory"), "/")) $ok = true; if (is_file("$path/".$this->yellow->system->get("commandStaticDefaultFile"))) $ok = true; @@ -515,7 +516,7 @@ class YellowCommand { // Return content locations public function getContentLocations($includeAll = false) { $locations = array(); - $staticUrl = $this->yellow->system->get("coreStaticUrl"); + $staticUrl = $this->yellow->system->get("commandStaticUrl"); list($scheme, $address, $base) = $this->yellow->lookup->getUrlInformation($staticUrl); $this->yellow->page->setRequestInformation($scheme, $address, $base, "", "", false); foreach ($this->yellow->content->index(true, true) as $page) { @@ -572,7 +573,7 @@ class YellowCommand { public function getExtraLocations($path) { $locations = array(); $pathIgnore = "($path/|". - $this->yellow->system->get("commandStaticBuildDirectory")."|". + $this->yellow->system->get("commandStaticDirectory")."|". $this->yellow->system->get("coreContentDirectory")."|". $this->yellow->system->get("coreMediaDirectory")."|". $this->yellow->system->get("coreSystemDirectory").")"; diff --git a/system/extensions/core.php b/system/extensions/core.php @@ -2,7 +2,7 @@ // Core extension, https://github.com/annaesvensson/yellow-core class YellowCore { - const VERSION = "0.8.99"; + const VERSION = "0.8.100"; const RELEASE = "0.8.21"; public $page; // current page public $content; // content files @@ -34,13 +34,12 @@ class YellowCore { $this->system->setDefault("parser", "markdown"); $this->system->setDefault("status", "public"); $this->system->setDefault("coreServerUrl", "auto"); - $this->system->setDefault("coreStaticUrl", "auto"); $this->system->setDefault("coreTimezone", "UTC"); $this->system->setDefault("coreContentExtension", ".md"); $this->system->setDefault("coreContentDefaultFile", "page.md"); $this->system->setDefault("coreContentErrorFile", "page-error-(.*).md"); - $this->system->setDefault("coreUserFile", "yellow-user.ini"); $this->system->setDefault("coreLanguageFile", "yellow-language.ini"); + $this->system->setDefault("coreUserFile", "yellow-user.ini"); $this->system->setDefault("coreWebsiteFile", "yellow-website.log"); $this->system->setDefault("coreMediaLocation", "/media/"); $this->system->setDefault("coreDownloadLocation", "/media/downloads/"); @@ -487,16 +486,6 @@ class YellowPage { if (!$this->isExisting("titleHeader")) $this->set("titleHeader", $titleHeader); if ($this->get("status")=="unlisted") $this->visible = false; if ($this->get("status")=="shared") $this->available = false; - $this->set("pageReadUrl", $this->yellow->lookup->normaliseUrl( - $this->yellow->system->get("coreServerScheme"), - $this->yellow->system->get("coreServerAddress"), - $this->yellow->system->get("coreServerBase"), - $this->location)); - $this->set("pageEditUrl", $this->yellow->lookup->normaliseUrl( - $this->yellow->system->get("coreServerScheme"), - $this->yellow->system->get("coreServerAddress"), - $this->yellow->system->get("coreServerBase"), - rtrim($this->yellow->system->get("editLocation"), "/").$this->location)); $this->parseMetaDataShared(); } else { $this->set("size", filesize($this->fileName)); @@ -549,8 +538,6 @@ class YellowPage { if (method_exists($value["object"], "onParseContentRaw")) { $this->parser = $value["object"]; $this->parserData = $this->getContent(true); - $this->parserData = preg_replace("/@pageReadUrl/i", $this->get("pageReadUrl"), $this->parserData); - $this->parserData = preg_replace("/@pageEditUrl/i", $this->get("pageEditUrl"), $this->parserData); $this->parserData = $this->parser->onParseContentRaw($this, $this->parserData); foreach ($this->yellow->extension->data as $key=>$value) { if (method_exists($value["object"], "onParseContentHtml")) { diff --git a/system/extensions/edit.js b/system/extensions/edit.js @@ -693,7 +693,13 @@ yellow.edit = { // Process close processClose: function() { this.hidePane(this.paneId); - if (yellow.page.action=="login") window.open(yellow.page.pageReadUrl, "_self"); + if (yellow.page.action=="login") { + var url = yellow.system.coreServerScheme+"://"+ + yellow.system.coreServerAddress+ + yellow.system.coreServerBase+ + yellow.page.location; + window.open(url, "_self"); + } }, // Create popup diff --git a/system/extensions/edit.php b/system/extensions/edit.php @@ -2,7 +2,7 @@ // Edit extension, https://github.com/annaesvensson/yellow-edit class YellowEdit { - const VERSION = "0.8.67"; + const VERSION = "0.8.68"; public $yellow; // access to API public $response; // web response public $merge; // text merge @@ -84,6 +84,15 @@ class YellowEdit { return "user [option email password]"; } + // Handle page meta data + public function onParseMetaData($page) { + $page->set("editPageUrl", $this->yellow->lookup->normaliseUrl( + $this->yellow->system->get("coreServerScheme"), + $this->yellow->system->get("coreServerAddress"), + $this->yellow->system->get("coreServerBase"), + rtrim($this->yellow->system->get("editLocation"), "/").$page->location)); + } + // Handle page content of shortcut public function onParseContentShortcut($page, $name, $text, $type) { $output = null; @@ -92,7 +101,7 @@ class YellowEdit { if (is_string_empty($target) || $target=="-") $target = "main"; if (is_string_empty($description)) $description = ucfirst($name); $pageTarget = $target=="main" ? $page->getPage("main") : $page->getPage("main")->getPage($target); - $output = "<a href=\"".$pageTarget->get("pageEditUrl")."\">".htmlspecialchars($description)."</a>"; + $output = "<a href=\"".$pageTarget->get("editPageUrl")."\">".htmlspecialchars($description)."</a>"; } return $output; } @@ -1072,12 +1081,12 @@ class YellowEditResponse { $page->parseMeta($rawData); $this->editContentFile($page, "create", $this->userEmail); if ($this->yellow->content->find($page->location)) { - $page->location = $this->getPageNewLocation($page->rawData, $page->location, $page->get("pageNewLocation")); + $page->location = $this->getPageNewLocation($page->rawData, $page->location, $page->get("editNewLocation")); $page->fileName = $this->getPageNewFile($page->location, $page->fileName, $page->get("published")); while ($this->yellow->content->find($page->location) || is_string_empty($page->fileName)) { $page->rawData = $this->yellow->toolbox->setMetaData($page->rawData, "title", $this->getTitleNext($page->rawData)); $page->rawData = $this->yellow->toolbox->normaliseLines($page->rawData, $endOfLine); - $page->location = $this->getPageNewLocation($page->rawData, $page->location, $page->get("pageNewLocation")); + $page->location = $this->getPageNewLocation($page->rawData, $page->location, $page->get("editNewLocation")); $page->fileName = $this->getPageNewFile($page->location, $page->fileName, $page->get("published")); if (++$pageCounter>999) break; } @@ -1107,7 +1116,7 @@ class YellowEditResponse { $pageSource->parseMeta($rawDataSource); $this->editContentFile($page, "edit", $this->userEmail); if ($this->isMetaModified($pageSource, $page) && $page->location!=$this->yellow->content->getHomeLocation($page->location)) { - $page->location = $this->getPageNewLocation($page->rawData, $page->location, $page->get("pageNewLocation"), true); + $page->location = $this->getPageNewLocation($page->rawData, $page->location, $page->get("editNewLocation"), true); $page->fileName = $this->getPageNewFile($page->location, $page->fileName, $page->get("published")); if ($page->location!=$pageSource->location && ($this->yellow->content->find($page->location) || is_string_empty($page->fileName))) { $page->error(500, "Page '".$page->get("title")."' is not possible!"); @@ -1203,6 +1212,10 @@ class YellowEditResponse { // Return page data including status information public function getPageData($page) { $data = array(); + $data["scheme"] = $this->yellow->page->scheme; + $data["address"] = $this->yellow->page->address; + $data["base"] = $this->yellow->page->base; + $data["location"] = $this->yellow->page->location; if ($this->isUser()) { $data["title"] = $this->yellow->toolbox->getMetaData($this->rawDataEdit, "title"); $data["rawDataSource"] = $this->rawDataSource; @@ -1211,13 +1224,7 @@ class YellowEditResponse { $data["rawDataOutput"] = strval($this->rawDataOutput); $data["rawDataReadonly"] = intval($this->rawDataReadonly); $data["rawDataEndOfLine"] = $this->rawDataEndOfLine; - $data["scheme"] = $this->yellow->page->scheme; - $data["address"] = $this->yellow->page->address; - $data["base"] = $this->yellow->page->base; - $data["location"] = $this->yellow->page->location; } - $data["pageReadUrl"] = $this->yellow->page->get("pageReadUrl"); - $data["pageEditUrl"] = $this->yellow->page->get("pageEditUrl"); if ($this->action!="none") $data = array_merge($data, $this->getRequestData()); $data["action"] = $this->action; $data["status"] = $this->status; @@ -1401,8 +1408,8 @@ class YellowEditResponse { } // Return location for new/modified page - public function getPageNewLocation($rawData, $pageLocation, $pageNewLocation, $pageMatchLocation = false) { - $location = is_string_empty($pageNewLocation) ? "@title" : $pageNewLocation; + public function getPageNewLocation($rawData, $pageLocation, $editNewLocation, $pageMatchLocation = false) { + $location = is_string_empty($editNewLocation) ? "@title" : $editNewLocation; $location = preg_replace("/@title/i", $this->getPageNewTitle($rawData), $location); $location = preg_replace("/@timestamp/i", $this->getPageNewData($rawData, "published", true, "U"), $location); $location = preg_replace("/@date/i", $this->getPageNewData($rawData, "published", true, "Y-m-d"), $location); diff --git a/system/extensions/install-blog.bin b/system/extensions/install-blog.bin Binary files differ. diff --git a/system/extensions/install-wiki.bin b/system/extensions/install-wiki.bin Binary files differ. diff --git a/system/extensions/install.php b/system/extensions/install.php @@ -2,7 +2,7 @@ // Install extension, https://github.com/annaesvensson/yellow-install class YellowInstall { - const VERSION = "0.8.84"; + const VERSION = "0.8.85"; const PRIORITY = "1"; public $yellow; // access to API @@ -394,8 +394,8 @@ class YellowInstall { $settings[$key] = trim($value); } if ($this->yellow->system->get("sitename")=="Datenstrom Yellow") $settings["sitename"] = $this->yellow->toolbox->detectServerSitename(); + if ($this->yellow->system->get("commandStaticUrl")=="auto" && getenv("URL")!==false) $settings["commandStaticUrl"] = getenv("URL"); if ($this->yellow->system->get("coreTimezone")=="UTC") $settings["coreTimezone"] = $this->yellow->toolbox->detectServerTimezone(); - if ($this->yellow->system->get("coreStaticUrl")=="auto" && getenv("URL")!==false) $settings["coreStaticUrl"] = getenv("URL"); if ($this->yellow->system->get("updateEventPending")=="none") $settings["updateEventPending"] = "website/install"; $settings["updateCurrentRelease"] = YellowCore::RELEASE; return $settings; diff --git a/system/extensions/update-current.ini b/system/extensions/update-current.ini @@ -1,21 +1,21 @@ # Datenstrom Yellow update settings Extension: Command -Version: 0.8.44 +Version: 0.8.45 Description: Command line of the website. DocumentationUrl: https://github.com/annaesvensson/yellow-command DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/main/downloads/command.zip -Published: 2022-11-03 18:04:20 +Published: 2022-11-05 11:25:18 Developer: Anna Svensson Tag: feature system/extensions/command.php: command.php, create, update Extension: Core -Version: 0.8.99 +Version: 0.8.100 Description: Core functionality of the website. DocumentationUrl: https://github.com/annaesvensson/yellow-core DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/main/downloads/core.zip -Published: 2022-11-03 18:37:24 +Published: 2022-11-05 11:21:33 Developer: Mark Seuffert, David Fehrmann Tag: feature system/extensions/core.php: core.php, create, update @@ -27,11 +27,11 @@ system/layouts/navigation.html: navigation.html, create, update, careful system/layouts/pagination.html: pagination.html, create, update, careful Extension: Edit -Version: 0.8.67 +Version: 0.8.68 Description: Edit your website in a web browser. DocumentationUrl: https://github.com/annaesvensson/yellow-edit DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/main/downloads/edit.zip -Published: 2022-11-03 18:50:28 +Published: 2022-11-04 17:39:21 Developer: Anna Svensson Tag: feature system/extensions/edit.php: edit.php, create, update @@ -54,11 +54,11 @@ media/images/photo.jpg: photo.jpg, create, optional media/thumbnails/photo-100x40.jpg: photo-100x40.jpg, create, optional Extension: Install -Version: 0.8.84 +Version: 0.8.85 Description: Install a brand new, shiny website. DocumentationUrl: https://github.com/annaesvensson/yellow-install DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/main/downloads/install.zip -Published: 2022-11-03 19:08:28 +Published: 2022-11-05 11:49:49 Developer: Anna Svensson Status: unlisted system/extensions/install.php: install.php, create @@ -121,11 +121,11 @@ system/themes/stockholm-opensans-light.woff: stockholm-opensans-light.woff, crea system/themes/stockholm-opensans-regular.woff: stockholm-opensans-regular.woff, create, update, careful Extension: Update -Version: 0.8.89 +Version: 0.8.90 Description: Keep your website up to date. DocumentationUrl: https://github.com/annaesvensson/yellow-update DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/main/downloads/update.zip -Published: 2022-11-03 18:14:57 +Published: 2022-11-05 11:55:13 Developer: Anna Svensson Tag: feature system/extensions/update.php: update.php, create, update diff --git a/system/extensions/update.php b/system/extensions/update.php @@ -2,7 +2,7 @@ // Update extension, https://github.com/annaesvensson/yellow-update class YellowUpdate { - const VERSION = "0.8.89"; + const VERSION = "0.8.90"; const PRIORITY = "2"; public $yellow; // access to API public $extensions; // number of extensions