Skip to content

Commit

Permalink
Updated static generator for Carsten
Browse files Browse the repository at this point in the history
  • Loading branch information
markseuffert committed May 9, 2024
1 parent 811de1e commit 8f6fd9a
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 54 deletions.
28 changes: 14 additions & 14 deletions system/extensions/update-available.ini
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,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.9.2
Version: 0.9.4
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: 2024-04-30 18:03:27
Published: 2024-05-09 16:44:32
Status: available
system/workers/blog.php: blog.php, create, update
system/layouts/blog.html: blog.html, create, update, careful
Expand Down Expand Up @@ -149,14 +149,14 @@ system/themes/copenhagen.css: copenhagen.css, create, update, careful
system/themes/copenhagen.png: copenhagen.png, create

Extension: Core
Version: 0.9.9
Version: 0.9.10
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-05-02 16:35:25
Published: 2024-05-09 16:15:59
Status: available
system/workers/core.php: core.php, create, update
system/extensions/core.php: corepatch.txt, update
Expand Down Expand Up @@ -213,14 +213,14 @@ Status: available
system/workers/dutch.php: dutch.php, create, update

Extension: Edit
Version: 0.9.8
Version: 0.9.9
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: 2024-05-07 07:20:40
Published: 2024-05-09 16:45:47
Status: available
system/workers/edit.php: edit.php, create, update
system/workers/edit.css: edit.css, create, update
Expand Down Expand Up @@ -262,14 +262,14 @@ Status: available
system/workers/english.php: english.php, create, update

Extension: Feed
Version: 0.9.2
Version: 0.9.3
Description: Feed with recent changes.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-feed/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-feed
DocumentationLanguage: en, de, sv
Published: 2024-04-25 13:08:57
Published: 2024-05-09 16:28:24
Status: available
system/workers/feed.php: feed.php, create, update
system/layouts/feed.html: feed.html, create, update, careful
Expand Down Expand Up @@ -305,14 +305,14 @@ system/workers/gallery-default-skin.svg: gallery-default-skin.svg, create, updat
system/workers/gallery-preloader.gif: gallery-preloader.gif, create, update

Extension: Generate
Version: 0.9.5
Version: 0.9.6
Description: Generate a static website.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-generate/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-generate
DocumentationLanguage: en, de, sv
Published: 2024-04-25 15:39:34
Published: 2024-05-09 16:39:21
Status: available
system/workers/generate.php: generate.php, create, update

Expand Down Expand Up @@ -665,14 +665,14 @@ Status: available
system/workers/serve.php: serve.php, create, update

Extension: Sitemap
Version: 0.9.2
Version: 0.9.3
Description: Sitemap with all pages.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-sitemap/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-sitemap
DocumentationLanguage: en, de, sv
Published: 2024-04-25 13:09:09
Published: 2024-05-09 16:28:15
Status: available
system/workers/sitemap.php: sitemap.php, create, update
system/layouts/sitemap.html: sitemap.html, create, update, careful
Expand Down Expand Up @@ -792,14 +792,14 @@ system/workers/update.php: update.php, create, update
system/workers/updatepatch.bin: updatepatch.php, create, additional

Extension: Wiki
Version: 0.9.3
Version: 0.9.4
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: 2024-04-30 16:45:31
Published: 2024-05-09 15:43:40
Status: available
system/workers/wiki.php: wiki.php, create, update
system/layouts/wiki.html: wiki.html, create, update, careful
Expand Down
12 changes: 6 additions & 6 deletions system/extensions/yellow-extension.ini
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Datenstrom Yellow extension settings

Extension: Core
Version: 0.9.9
Version: 0.9.10
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-05-02 16:35:25
Published: 2024-05-09 16:15:59
Status: available
system/workers/core.php: core.php, create, update
system/extensions/core.php: corepatch.txt, update
Expand All @@ -20,14 +20,14 @@ system/layouts/navigation.html: navigation.html, create, update, careful
system/layouts/pagination.html: pagination.html, create, update, careful

Extension: Edit
Version: 0.9.8
Version: 0.9.9
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: 2024-05-07 07:20:40
Published: 2024-05-09 16:45:47
Status: available
system/workers/edit.php: edit.php, create, update
system/workers/edit.css: edit.css, create, update
Expand All @@ -36,14 +36,14 @@ system/workers/edit-stack.svg: edit-stack.svg, create, update
content/shared/page-new-default.md: page-new-default.md, create, optional

Extension: Generate
Version: 0.9.5
Version: 0.9.6
Description: Generate a static website.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-generate/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-generate
DocumentationLanguage: en, de, sv
Published: 2024-04-25 15:39:34
Published: 2024-05-09 16:39:21
Status: available
system/workers/generate.php: generate.php, create, update

Expand Down
26 changes: 17 additions & 9 deletions system/workers/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.9.9";
const VERSION = "0.9.10";
const RELEASE = "0.9";
public $content; // content files
public $media; // media files
Expand Down Expand Up @@ -1535,6 +1535,11 @@ public function normaliseHeaders($input, $type = "mime", $filterStrict = true) {
return $output;
}

// Normalise CSS class
public function normaliseClass($text) {
return str_replace(array(" ", "_"), array("-", "-"), strtoloweru($text));
}

// Normalise relative path tokens
public function normalisePath($text) {
$textFiltered = "";
Expand Down Expand Up @@ -1593,10 +1598,15 @@ public function normaliseLocation($location, $pageLocation, $filterStrict = true
}

// Normalise location arguments
public function normaliseArguments($text, $appendSlash = true, $filterStrict = true) {
if ($appendSlash) $text .= "/";
public function normaliseArguments($text, $filterStrict = true) {
if ($filterStrict) $text = str_replace(" ", "-", strtoloweru($text));
$text = str_replace(":", $this->yellow->toolbox->getLocationArgumentsSeparator(), $text);
$separator = $this->yellow->toolbox->getLocationArgumentsSeparator();
$text = str_replace(":", $separator, $text);
if (preg_match("/^(.*\/)?page$separator.*$/", $text)) {
$text = rtrim($text, "/");
} else {
$text = rtrim($text, "/")."/";
}
return str_replace(array("%2F","%3A","%3D"), array("/",":","="), rawurlencode($text));
}

Expand Down Expand Up @@ -1940,8 +1950,7 @@ public function getLocationArgumentsNew($key, $value) {
$locationArguments .= "$key:$value";
}
if (!is_string_empty($locationArguments)) {
$locationArguments = $this->yellow->lookup->normaliseArguments($locationArguments, false, false);
if (!$this->isLocationArgumentsPagination($locationArguments)) $locationArguments .= "/";
$locationArguments = $this->yellow->lookup->normaliseArguments($locationArguments);
}
return $locationArguments;
}
Expand All @@ -1958,8 +1967,7 @@ public function getLocationArgumentsCleanUrl() {
}
}
if (!is_string_empty($locationArguments)) {
$locationArguments = $this->yellow->lookup->normaliseArguments($locationArguments, false, false);
if (!$this->isLocationArgumentsPagination($locationArguments)) $locationArguments .= "/";
$locationArguments = $this->yellow->lookup->normaliseArguments($locationArguments);
}
return $locationArguments;
}
Expand Down Expand Up @@ -2982,7 +2990,7 @@ public function isLocationArguments($location = "") {
// Check if there are pagination arguments in current HTTP request
public function isLocationArgumentsPagination($location) {
$separator = $this->getLocationArgumentsSeparator();
return preg_match("/^(.*\/)?page$separator.*$/", $location);
return preg_match("/^(.*\/)?page$separator\d+$/", $location);
}

// Check if unmodified since last HTTP request
Expand Down
4 changes: 2 additions & 2 deletions system/workers/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.9.8";
const VERSION = "0.9.9";
public $yellow; // access to API
public $response; // web response
public $merge; // text merge
Expand Down Expand Up @@ -1594,7 +1594,7 @@ public function sendMail($scheme, $address, $base, $email, $action) {
$expire = time() + 60*60*24;
$actionToken = $this->createActionToken($email, $action, $expire);
$locationArguments = "/action:$action/email:$email/expire:$expire/language:$userLanguage/actiontoken:$actionToken/";
$url = "$scheme://$address$base".$this->yellow->lookup->normaliseArguments($locationArguments, false, false);
$url = "$scheme://$address$base".$this->yellow->lookup->normaliseArguments($locationArguments, false);
}
$prefix = "edit".ucfirst($action);
$message = $this->yellow->language->getText("{$prefix}Message", $userLanguage);
Expand Down
42 changes: 19 additions & 23 deletions system/workers/generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// Generate extension, https://github.com/annaesvensson/yellow-generate

class YellowGenerate {
const VERSION = "0.9.5";
public $yellow; // access to API
public $files; // number of files
public $errors; // number of errors
public $locationsArguments; // locations with location arguments detected
public $locationsArgumentsPagination; // locations with pagination arguments detected
const VERSION = "0.9.6";
public $yellow; // access to API
public $files; // number of files
public $errors; // number of errors
public $locationsWithArguments; // locations with arguments detected
public $locationsWithPagination; // locations with pagination detected

// Handle initialisation
public function onLoad($yellow) {
Expand Down Expand Up @@ -82,7 +82,7 @@ public function generateStatic($path, $location) {
// Generate static content
public function generateStaticContent($path, $locationFilter, $progressText, $increments, $max) {
$statusCode = 200;
$this->locationsArguments = $this->locationsArgumentsPagination = array();
$this->locationsWithArguments = $this->locationsWithPagination = array();
$staticUrl = $this->yellow->system->get("generateStaticUrl");
list($scheme, $address, $base) = $this->yellow->lookup->getUrlInformation($staticUrl);
$locations = $this->getContentLocations();
Expand All @@ -92,18 +92,15 @@ public function generateStaticContent($path, $locationFilter, $progressText, $in
if (!preg_match("#^$base$locationFilter#", "$base$location")) continue;
$statusCode = max($statusCode, $this->generateStaticFile($path, $location, true));
}
foreach ($this->locationsArguments as $location) {
foreach ($this->locationsWithArguments as $location) {
echo "$progressText ".$this->getProgressPercent($this->files, $filesEstimated, $increments, $max/1.5)."%... ";
if (!preg_match("#^$base$locationFilter#", "$base$location")) continue;
$statusCode = max($statusCode, $this->generateStaticFile($path, $location, true));
}
$filesEstimated = $this->files + count($this->locationsArguments) + count($this->locationsArgumentsPagination);
foreach ($this->locationsArgumentsPagination as $location) {
$filesEstimated = $this->files + count($this->locationsWithArguments) + count($this->locationsWithPagination);
foreach ($this->locationsWithPagination as $location) {
echo "$progressText ".$this->getProgressPercent($this->files, $filesEstimated, $increments, $max)."%... ";
if (!preg_match("#^$base$locationFilter#", "$base$location")) continue;
if (substru($location, -1)!=$this->yellow->toolbox->getLocationArgumentsSeparator()) {
$statusCode = max($statusCode, $this->generateStaticFile($path, $location, false, true));
}
for ($pageNumber=2; $pageNumber<=999; ++$pageNumber) {
$statusCodeLocation = $this->generateStaticFile($path, $location.$pageNumber, false, true);
$statusCode = max($statusCode, $statusCodeLocation);
Expand Down Expand Up @@ -155,7 +152,7 @@ public function generateStaticFile($path, $location, $analyse = false, $probe =
} else {
$statusCode = $this->copyStaticFile($path, $location);
}
if ($statusCode==200 && $analyse) $this->analyseLocations($scheme, $address, $base, $fileData);
if ($statusCode==200 && $analyse) $this->analyseStaticLocations($scheme, $address, $base, $fileData);
if ($statusCode==404 && $probe) $statusCode = 100;
if ($statusCode==404 && $error) $statusCode = 200;
if ($statusCode>=200) ++$this->files;
Expand Down Expand Up @@ -219,8 +216,8 @@ public function copyStaticFile($path, $location) {
return $statusCode;
}

// Analyse locations with arguments
public function analyseLocations($scheme, $address, $base, $rawData) {
// Analyse static locations with arguments
public function analyseStaticLocations($scheme, $address, $base, $rawData) {
preg_match_all("/<(.*?)href=\"([^\"]+)\"(.*?)>/i", $rawData, $matches);
foreach ($matches[2] as $match) {
$location = rawurldecode($match);
Expand All @@ -235,19 +232,18 @@ public function analyseLocations($scheme, $address, $base, $rawData) {
$location = substru($location, strlenu($base));
if (!$this->yellow->toolbox->isLocationArguments($location)) continue;
if (!$this->yellow->toolbox->isLocationArgumentsPagination($location)) {
$location = rtrim($location, "/")."/";
if (!isset($this->locationsArguments[$location])) {
$this->locationsArguments[$location] = $location;
if (!isset($this->locationsWithArguments[$location])) {
$this->locationsWithArguments[$location] = $location;
if ($this->yellow->system->get("coreDebugMode")>=2) {
echo "YellowGenerate::analyseLocations detected location:$location<br/>\n";
echo "YellowGenerate::analyseStaticLocations detected location:$location<br/>\n";
}
}
} else {
$location = rtrim($location, "0..9");
if (!isset($this->locationsArgumentsPagination[$location])) {
$this->locationsArgumentsPagination[$location] = $location;
if (!isset($this->locationsWithPagination[$location])) {
$this->locationsWithPagination[$location] = $location;
if ($this->yellow->system->get("coreDebugMode")>=2) {
echo "YellowGenerate::analyseLocations detected location:$location<br/>\n";
echo "YellowGenerate::analyseStaticLocations detected location:$location<br/>\n";
}
}
}
Expand Down
Binary file modified system/workers/install-blog.bin
Binary file not shown.
Binary file modified system/workers/install-wiki.bin
Binary file not shown.

0 comments on commit 8f6fd9a

Please sign in to comment.