Skip to content

Commit

Permalink
Updated API
Browse files Browse the repository at this point in the history
  • Loading branch information
markseuffert committed Apr 1, 2024
1 parent c5358c4 commit 8d60be0
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 81 deletions.
55 changes: 14 additions & 41 deletions system/extensions/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Core extension, https://github.com/annaesvensson/yellow-core

class YellowCore {
const VERSION = "0.8.128";
const VERSION = "0.8.129";
const RELEASE = "0.8.23";
public $content; // content files
public $media; // media files
Expand Down Expand Up @@ -385,25 +385,9 @@ public function index($showInvisible = false, $multiLanguage = false) {
}

// Return page collection with top-level navigation
public function top($showInvisible = false, $showOnePager = true) {
public function top($showInvisible = false) {
$rootLocation = $this->getRootLocation($this->yellow->page->location);
$pages = $this->getChildren($rootLocation, $showInvisible);
if (count($pages)==1 && $showOnePager) {
$scheme = $this->yellow->page->scheme;
$address = $this->yellow->page->address;
$base = $this->yellow->page->base;
$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->getContentHtml(), $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
if ($match[1]==2) {
$page = new YellowPage($this->yellow);
$page->setRequestInformation($scheme, $address, $base, $one->location."#".$match[2], $one->fileName, false);
$page->parseMeta("---\nTitle: $match[3]\n---\n");
$pages->append($page);
}
}
}
return $pages;
return $this->getChildren($rootLocation, $showInvisible);
}

// Return page collection with path ancestry
Expand Down Expand Up @@ -2013,8 +1997,13 @@ public function getDirectoryEntriesRecursive($path, $regex = "/.*/", $sort = tru
}
return $entries;
}

// Return directory information, modification date and file count
public function getDirectoryInformation($path) {
return $this->getDirectoryInformationRecursive($path, 1);
}

// Return directory information recursively, Unix time and file count
// Return directory information recursively, modification date and file count
public function getDirectoryInformationRecursive($path, $levelMax = 0) {
--$levelMax;
$modified = $fileCount = 0;
Expand All @@ -2026,8 +2015,8 @@ public function getDirectoryInformationRecursive($path, $levelMax = 0) {
$modified = max($modified, $this->getFileModified("$path/$entry"));
if (is_file("$path/$entry")) ++$fileCount;
}
rewinddir($directoryHandle);
if ($levelMax!=0) {
rewinddir($directoryHandle);
while (($entry = readdir($directoryHandle))!==false) {
if (substru($entry, 0, 1)==".") continue;
if (is_dir("$path/$entry")) {
Expand All @@ -2037,6 +2026,7 @@ public function getDirectoryInformationRecursive($path, $levelMax = 0) {
}
}
}
closedir($directoryHandle);
}
return array($modified, $fileCount);
}
Expand Down Expand Up @@ -3100,7 +3090,7 @@ public function parseContentElement($name, $text, $attrributes, $type) {
$output = $value["object"]->onParseContentElement($this, $name, $text, $attrributes, $type);
if (!is_null($output)) break;
}
if (method_exists($value["object"], "onParseContentShortcut")) {
if (method_exists($value["object"], "onParseContentShortcut")) { //TODO: remove later, for backwards compatibility
$output = $value["object"]->onParseContentShortcut($this, $name, $text, $type);
if (!is_null($output)) break;
}
Expand All @@ -3116,25 +3106,8 @@ public function parseContentElement($name, $text, $attrributes, $type) {
return $output;
}

// Parse page content shortcut
public function parseContentShortcut($name, $text, $type) {
$output = null;
foreach ($this->yellow->extension->data as $key=>$value) {
if (method_exists($value["object"], "onParseContentShortcut")) {
$output = $value["object"]->onParseContentShortcut($this, $name, $text, $type);
if (!is_null($output)) break;
}
}
if (is_null($output)) {
if ($name=="yellow" && $type=="inline" && $text=="error") {
$output = $this->errorMessage;
}
}
if ($this->yellow->system->get("coreDebugMode")>=3 && !is_string_empty($name)) {
echo "YellowPage::parseContentShortcut name:$name type:$type<br/>\n";
}
return $output;
}
// TODO: remove later, for backwards compatibility
public function parseContentShortcut($name, $text, $type) { return $this->parseContentElement($name, $text, "", $type); }

// Parse page
public function parsePage() {
Expand Down
6 changes: 3 additions & 3 deletions system/extensions/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Edit extension, https://github.com/annaesvensson/yellow-edit

class YellowEdit {
const VERSION = "0.8.77";
const VERSION = "0.8.78";
public $yellow; // access to API
public $response; // web response
public $merge; // text merge
Expand Down Expand Up @@ -93,8 +93,8 @@ public function onParseMetaData($page) {
rtrim($this->yellow->system->get("editLocation"), "/").$page->location));
}

// Handle page content of shortcut
public function onParseContentShortcut($page, $name, $text, $type) {
// Handle page content element
public function onParseContentElement($page, $name, $text, $attributes, $type) {
$output = null;
if ($name=="edit" && $type=="inline") {
list($target, $description) = $this->yellow->toolbox->getTextList($text, " ", 2);
Expand Down
6 changes: 3 additions & 3 deletions system/extensions/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Image extension, https://github.com/annaesvensson/yellow-image

class YellowImage {
const VERSION = "0.8.19";
const VERSION = "0.8.20";
public $yellow; // access to API

// Handle initialisation
Expand All @@ -26,8 +26,8 @@ public function onUpdate($action) {
}
}

// Handle page content of shortcut
public function onParseContentShortcut($page, $name, $text, $type) {
// Handle page content element
public function onParseContentElement($page, $name, $text, $attributes, $type) {
$output = null;
if ($name=="image" && $type=="inline") {
list($name, $alt, $style, $width, $height) = $this->yellow->toolbox->getTextArguments($text);
Expand Down
Binary file modified system/extensions/install-blog.bin
Binary file not shown.
Binary file modified system/extensions/install-wiki.bin
Binary file not shown.
10 changes: 5 additions & 5 deletions system/extensions/markdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Markdown extension, https://github.com/annaesvensson/yellow-markdown

class YellowMarkdown {
const VERSION = "0.8.26";
const VERSION = "0.8.27";
public $yellow; // access to API

// Handle initialisation
Expand Down Expand Up @@ -3887,13 +3887,13 @@ public function doAutoLinks($text) {

// Handle shortcuts, block style
public function _doAutoLinks_shortcutBlock_callback($matches) {
$output = $this->page->parseContentShortcut($matches[1], trim($matches[2]), "block");
$output = $this->page->parseContentElement($matches[1], trim($matches[2]), "", "block");
return is_null($output) ? $matches[0] : $this->hashBlock($output);
}

// Handle shortcuts, inline style
public function _doAutoLinks_shortcutInline_callback($matches) {
$output = $this->page->parseContentShortcut($matches[1], trim($matches[2]), "inline");
$output = $this->page->parseContentElement($matches[1], trim($matches[2]), "", "inline");
return is_null($output) ? $matches[0] : $this->hashPart($output);
}

Expand All @@ -3905,15 +3905,15 @@ public function _doAutoLinks_shortcutComment_callback($matches) {

// Handle shortcuts, symbol style
public function _doAutoLinks_shortcutSymbol_callback($matches) {
$output = $this->page->parseContentShortcut("", $matches[1], "symbol");
$output = $this->page->parseContentElement("", $matches[1], "", "symbol");
return is_null($output) ? $matches[0] : $this->hashPart($output);
}

// Handle fenced code blocks
public function _doFencedCodeBlocks_callback($matches) {
$text = $matches[4];
$name = is_string_empty($matches[2]) ? "" : trim("$matches[2] $matches[3]");
$output = $this->page->parseContentShortcut($name, $text, "code");
$output = $this->page->parseContentElement($name, $text, "", "code");
if (is_null($output)) {
$attr = $this->doExtraAttributes("pre", ".$matches[2] $matches[3]");
$output = "<pre$attr><code>".htmlspecialchars($text, ENT_NOQUOTES)."</code></pre>";
Expand Down
32 changes: 16 additions & 16 deletions system/extensions/update-available.ini
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ system/themes/berlin-opensans-light.woff: berlin-opensans-light.woff, create, up
system/themes/berlin-opensans-regular.woff: berlin-opensans-regular.woff, create, update, careful

Extension: Blog
Version: 0.8.30
Version: 0.8.31
Description: Blog for your website.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-blog/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-blog
DocumentationLanguage: en, de, sv
Published: 2023-11-01 17:49:02
Published: 2024-04-01 18:52:01
Status: available
system/extensions/blog.php: blog.php, create, update
system/layouts/blog.html: blog.html, create, update, careful
Expand Down Expand Up @@ -148,14 +148,14 @@ system/themes/copenhagen.css: copenhagen.css, create, update, careful
system/themes/copenhagen.png: copenhagen.png, create

Extension: Core
Version: 0.8.128
Version: 0.8.129
Description: Core functionality of your website.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-core/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-core
DocumentationLanguage: en, de, sv
Published: 2024-03-30 17:29:58
Published: 2024-04-01 18:44:16
Status: available
system/extensions/core.php: core.php, create, update
system/layouts/default.html: default.html, create, update, careful
Expand Down Expand Up @@ -211,14 +211,14 @@ Status: available
system/extensions/dutch.php: dutch.php, create, update

Extension: Edit
Version: 0.8.77
Version: 0.8.78
Description: Edit your website in a web browser.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-edit/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-edit
DocumentationLanguage: en, de, sv
Published: 2023-12-20 23:19:46
Published: 2024-04-01 18:48:05
Status: available
system/extensions/edit.php: edit.php, create, update
system/extensions/edit.css: edit.css, create, update
Expand Down Expand Up @@ -431,14 +431,14 @@ system/extensions/icon.css: icon.css, create, update
system/extensions/icon.woff: icon.woff, create, update

Extension: Image
Version: 0.8.19
Version: 0.8.20
Description: Add images and thumbnails.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-image/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-image
DocumentationLanguage: en, de, sv
Published: 2023-04-16 23:50:53
Published: 2024-04-01 18:49:07
Status: available
system/extensions/image.php: image.php, create, update
media/images/photo.jpg: photo.jpg, create, optional
Expand Down Expand Up @@ -501,14 +501,14 @@ system/themes/karlskrona.css: karlskrona.css, create, update, careful
system/themes/karlskrona.png: karlskrona.png, create

Extension: Markdown
Version: 0.8.26
Version: 0.8.27
Description: Text formatting for humans.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-markdown/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-markdown
DocumentationLanguage: en, de, sv
Published: 2023-09-18 20:49:33
Published: 2024-04-01 18:41:04
Status: available
system/extensions/markdown.php: markdown.php, create, update

Expand Down Expand Up @@ -556,14 +556,14 @@ system/themes/paris-opensans-light.woff: paris-opensans-light.woff, create, upda
system/themes/paris-opensans-regular.woff: paris-opensans-regular.woff, create, update, careful

Extension: Parsedown
Version: 0.8.26
Version: 0.8.27
Description: Text formatting for humans.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-parsedown/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-parsedown
DocumentationLanguage: en, de, sv
Published: 2023-09-18 20:49:49
Published: 2024-04-01 18:41:53
Status: available
system/extensions/parsedown.php: parsedown.php, create, update

Expand Down Expand Up @@ -789,27 +789,27 @@ Status: available
system/extensions/turkish.php: turkish.php, create, update

Extension: Update
Version: 0.8.100
Version: 0.8.101
Description: Keep your website up to date.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-update/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-update
DocumentationLanguage: en, de, sv
Published: 2024-03-29 22:29:25
Published: 2024-04-01 18:50:26
Status: available
system/extensions/update.php: update.php, create, update
system/extensions/updatepatch.bin: updatepatch.php, create, additional

Extension: Wiki
Version: 0.8.30
Version: 0.8.31
Description: Wiki for your website.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-wiki/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-wiki
DocumentationLanguage: en, de, sv
Published: 2023-11-01 17:49:10
Published: 2024-04-01 18:51:50
Status: available
system/extensions/wiki.php: wiki.php, create, update
system/layouts/wiki.html: wiki.html, create, update, careful
Expand Down

0 comments on commit 8d60be0

Please sign in to comment.