1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-22 04:23:01 +00:00

If it's a list of strings, then it should be sorted correctly.

This commit is contained in:
Starbeamrainbowlabs 2019-09-03 18:16:01 +01:00
parent 29c62c4bbf
commit 157c6dabdd
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
9 changed files with 42 additions and 25 deletions

View file

@ -19,7 +19,7 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t
- Added aria label to user preferences button - Added aria label to user preferences button
- Hide site logo from screen readers - Hide site logo from screen readers
- Lists of pages that have a specific tag will now be sorted alphabetically (unicode characters should be handled correctly too) - Lists of pages that have a specific tag will now be sorted alphabetically (unicode characters should be handled correctly too)
- Support Unicode characters when sorting the list of all tags - Support Unicode characters when sorting. If it's a list of something, then it's now sorted correctly (e.g. includes pages, tags, etc).
### Changed ### Changed
- Made `build.sh` build script more robust, especially when generating the documentation. - Made `build.sh` build script more robust, especially when generating the documentation.

View file

@ -521,7 +521,10 @@ class page_renderer
public static function generate_all_pages_datalist() { public static function generate_all_pages_datalist() {
global $settings, $pageindex; global $settings, $pageindex;
$arrayPageIndex = get_object_vars($pageindex); $arrayPageIndex = get_object_vars($pageindex);
ksort($arrayPageIndex); $sorter = new Collator("");
uksort($arrayPageIndex, function($a, $b) use($sorter) : int {
return $sorter->compare($a, $b);
});
$result = "<datalist id='allpages'>\n"; $result = "<datalist id='allpages'>\n";
// If dynamic page sugggestions are enabled, then we should send a loading message instead. // If dynamic page sugggestions are enabled, then we should send a loading message instead.

View file

@ -52,10 +52,10 @@
{ {
"id": "extra-sidebar", "id": "extra-sidebar",
"name": "Sidebar", "name": "Sidebar",
"version": "0.3.1", "version": "0.3.2",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds a sidebar to the left hand side of every page. Add '$settings->sidebar_show = true;' to your configuration, or append '&sidebar=yes' to the url to enable. Adding to the url sets a cookie to remember your setting.", "description": "Adds a sidebar to the left hand side of every page. Add '$settings->sidebar_show = true;' to your configuration, or append '&sidebar=yes' to the url to enable. Adding to the url sets a cookie to remember your setting.",
"lastupdate": 1505768813, "lastupdate": 1567528758,
"optional": false, "optional": false,
"extra_data": [] "extra_data": []
}, },
@ -132,30 +132,30 @@
{ {
"id": "feature-search", "id": "feature-search",
"name": "Search", "name": "Search",
"version": "0.10", "version": "0.10.1",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds proper search functionality to Pepperminty Wiki using an inverted index to provide a full text search engine. If pages don't show up, then you might have hit a stop word. If not, try requesting the `invindex-rebuild` action to rebuild the inverted index from scratch.", "description": "Adds proper search functionality to Pepperminty Wiki using an inverted index to provide a full text search engine. If pages don't show up, then you might have hit a stop word. If not, try requesting the `invindex-rebuild` action to rebuild the inverted index from scratch.",
"lastupdate": 1567107944, "lastupdate": 1567528763,
"optional": false, "optional": false,
"extra_data": [] "extra_data": []
}, },
{ {
"id": "feature-stats", "id": "feature-stats",
"name": "Statistics", "name": "Statistics",
"version": "0.2.1", "version": "0.2.2",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "An extensible statistics calculation system. Comes with a range of built-in statistics, but can be extended by other modules too.", "description": "An extensible statistics calculation system. Comes with a range of built-in statistics, but can be extended by other modules too.",
"lastupdate": 1567107944, "lastupdate": 1567528768,
"optional": false, "optional": false,
"extra_data": [] "extra_data": []
}, },
{ {
"id": "feature-theme-gallery", "id": "feature-theme-gallery",
"name": "Theme Gallery", "name": "Theme Gallery",
"version": "0.1", "version": "0.3",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds a theme gallery page and optional automatic theme updates. Contacts a remote server, where IP addresses are stored in automatic server logs for security and attack mitigation purposes.", "description": "Adds a theme gallery page and optional automatic theme updates. Contacts a remote server, where IP addresses are stored in automatic server logs for security and attack mitigation purposes.",
"lastupdate": 1567369192, "lastupdate": 1567528753,
"optional": false, "optional": false,
"extra_data": [] "extra_data": []
}, },
@ -254,10 +254,10 @@
{ {
"id": "page-list", "id": "page-list",
"name": "Page list", "name": "Page list",
"version": "0.11.2", "version": "0.11.3",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds a page that lists all the pages in the index along with their metadata.", "description": "Adds a page that lists all the pages in the index along with their metadata.",
"lastupdate": 1567513003, "lastupdate": 1567530955,
"optional": false, "optional": false,
"extra_data": [] "extra_data": []
}, },
@ -337,7 +337,7 @@
"version": "0.10", "version": "0.10",
"author": "Emanuil Rusev & Starbeamrainbowlabs", "author": "Emanuil Rusev & Starbeamrainbowlabs",
"description": "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https:\/\/github.com\/erusev\/parsedown-extra), which is licensed MIT. Please be careful, as this module adds some weight to your installation.", "description": "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https:\/\/github.com\/erusev\/parsedown-extra), which is licensed MIT. Please be careful, as this module adds some weight to your installation.",
"lastupdate": 1567168168, "lastupdate": 1567530862,
"optional": false, "optional": false,
"extra_data": { "extra_data": {
"Parsedown.php": "https:\/\/raw.githubusercontent.com\/erusev\/parsedown\/fe7a50eceb4a3c867cc9fa9c0aa906b1067d1955\/Parsedown.php", "Parsedown.php": "https:\/\/raw.githubusercontent.com\/erusev\/parsedown\/fe7a50eceb4a3c867cc9fa9c0aa906b1067d1955\/Parsedown.php",

View file

@ -1,7 +1,7 @@
<?php <?php
register_module([ register_module([
"name" => "Sidebar", "name" => "Sidebar",
"version" => "0.3.1", "version" => "0.3.2",
"author" => "Starbeamrainbowlabs", "author" => "Starbeamrainbowlabs",
"description" => "Adds a sidebar to the left hand side of every page. Add '\$settings->sidebar_show = true;' to your configuration, or append '&sidebar=yes' to the url to enable. Adding to the url sets a cookie to remember your setting.", "description" => "Adds a sidebar to the left hand side of every page. Add '\$settings->sidebar_show = true;' to your configuration, or append '&sidebar=yes' to the url to enable. Adding to the url sets a cookie to remember your setting.",
"id" => "extra-sidebar", "id" => "extra-sidebar",
@ -51,7 +51,11 @@ register_module([
// Sort the pageindex // Sort the pageindex
$sorted_pageindex = get_object_vars($pageindex); $sorted_pageindex = get_object_vars($pageindex);
ksort($sorted_pageindex, SORT_NATURAL);
$sorter = new Collator("");
uksort($sorted_pageindex, function($a, $b) use($sorter) : int {
return $sorter->compare($a, $b);
});
$sidebar_contents = ""; $sidebar_contents = "";
$sidebar_contents .= render_sidebar($sorted_pageindex); $sidebar_contents .= render_sidebar($sorted_pageindex);

View file

@ -1,7 +1,7 @@
<?php <?php
register_module([ register_module([
"name" => "Search", "name" => "Search",
"version" => "0.10", "version" => "0.10.1",
"author" => "Starbeamrainbowlabs", "author" => "Starbeamrainbowlabs",
"description" => "Adds proper search functionality to Pepperminty Wiki using an inverted index to provide a full text search engine. If pages don't show up, then you might have hit a stop word. If not, try requesting the `invindex-rebuild` action to rebuild the inverted index from scratch.", "description" => "Adds proper search functionality to Pepperminty Wiki using an inverted index to provide a full text search engine. If pages don't show up, then you might have hit a stop word. If not, try requesting the `invindex-rebuild` action to rebuild the inverted index from scratch.",
"id" => "feature-search", "id" => "feature-search",
@ -891,12 +891,17 @@ class search
} }
/** /**
* Sorts an index alphabetically. Will also sort an inverted index. * Sorts an index alphabetically.
* This allows us to do a binary search instead of a regular * This allows us to do a binary search instead of a regular
* sequential search. * sequential search.
* @param array $index The index to sort. * @param array $index The index to sort.
*/ */
public static function index_sort(&$index) { ksort($index, SORT_NATURAL); } public static function index_sort(&$index) {
$sorter = new Collator("");
uksort($index, function($a, $b) use($sorter) : int {
return $sorter->compare($a, $b);
});
}
/** /**
* Compares two *regular* indexes to find the differences between them. * Compares two *regular* indexes to find the differences between them.

View file

@ -1,7 +1,7 @@
<?php <?php
register_module([ register_module([
"name" => "Statistics", "name" => "Statistics",
"version" => "0.2.1", "version" => "0.2.2",
"author" => "Starbeamrainbowlabs", "author" => "Starbeamrainbowlabs",
"description" => "An extensible statistics calculation system. Comes with a range of built-in statistics, but can be extended by other modules too.", "description" => "An extensible statistics calculation system. Comes with a range of built-in statistics, but can be extended by other modules too.",
"id" => "feature-stats", "id" => "feature-stats",

View file

@ -1,7 +1,7 @@
<?php <?php
register_module([ register_module([
"name" => "Theme Gallery", "name" => "Theme Gallery",
"version" => "0.1", "version" => "0.3",
"author" => "Starbeamrainbowlabs", "author" => "Starbeamrainbowlabs",
"description" => "Adds a theme gallery page and optional automatic theme updates. Contacts a remote server, where IP addresses are stored in automatic server logs for security and attack mitigation purposes.", "description" => "Adds a theme gallery page and optional automatic theme updates. Contacts a remote server, where IP addresses are stored in automatic server logs for security and attack mitigation purposes.",
"id" => "feature-theme-gallery", "id" => "feature-theme-gallery",
@ -46,8 +46,9 @@ register_module([
} }
} }
usort($themes_available, function($a, $b) { $sorter = new Collator("");
return strcmp($a->name, $b->name); usort($themes_available, function($a, $b) use ($sorter) : int {
return $sorter->compare($a->name, $b->name);
}); });
$content = "<h1>Theme Gallery</h1> $content = "<h1>Theme Gallery</h1>

View file

@ -1,7 +1,7 @@
<?php <?php
register_module([ register_module([
"name" => "Page list", "name" => "Page list",
"version" => "0.11.2", "version" => "0.11.3",
"author" => "Starbeamrainbowlabs", "author" => "Starbeamrainbowlabs",
"description" => "Adds a page that lists all the pages in the index along with their metadata.", "description" => "Adds a page that lists all the pages in the index along with their metadata.",
"id" => "page-list", "id" => "page-list",
@ -32,7 +32,10 @@ register_module([
$format = $_GET["format"] ?? "html"; $format = $_GET["format"] ?? "html";
$sorted_pageindex = get_object_vars($pageindex); $sorted_pageindex = get_object_vars($pageindex);
ksort($sorted_pageindex, SORT_NATURAL); $sorter = new Collator("");
uksort($sorted_pageindex, function($a, $b) use($sorter) : int {
return $sorter->compare($a, $b);
});
switch($format) { switch($format) {
case "html": case "html":

View file

@ -132,7 +132,8 @@ register_module([
$orphaned_pages[] = $pagename; $orphaned_pages[] = $pagename;
} }
sort($orphaned_pages); $sorter = new Collator("");
$sorter->sort($orphaned_pages);
$result->value = $orphaned_pages; $result->value = $orphaned_pages;
$result->completed = true; $result->completed = true;