git.shiar.nl
/
minimedit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
72fc7bd
)
widget/sitemap: order pages hierarchically and alphabetically
author
Mischa POSLAWSKY
<perl@shiar.org>
Sat, 29 Jun 2019 00:22:46 +0000
(
02:22
+0200)
committer
Mischa POSLAWSKY
<perl@shiar.org>
Fri, 12 Jul 2019 02:18:16 +0000
(
04:18
+0200)
widget/sitemap.php
patch
|
blob
|
history
diff --git
a/widget/sitemap.php
b/widget/sitemap.php
index 9b03e2fbee6813d0d42596002276cd1730ae9b5d..a7dbfddf9fe78bc4ea6af91e648ec95eff590d92 100644
(file)
--- a/
widget/sitemap.php
+++ b/
widget/sitemap.php
@@
-1,4
+1,5
@@
<?php
<?php
+# find **/*.html
$search = new RecursiveCallbackFilterIterator(
new RecursiveDirectoryIterator(ltrim($Args, '/') ?: '.'),
function ($current) {
$search = new RecursiveCallbackFilterIterator(
new RecursiveDirectoryIterator(ltrim($Args, '/') ?: '.'),
function ($current) {
@@
-15,8
+16,17
@@
$search = new RecursiveCallbackFilterIterator(
}
);
}
);
+# order alphabetically by link
+$dir = iterator_to_array(new RecursiveIteratorIterator($search));
+array_walk($dir, function (&$row, $name) {
+ # prepare values for sorting (directory index first)
+ $row = preg_replace('{/index\.html$}', '', $name);
+});
+asort($dir);
+
+# list article details
print '<ul class="replies">'."\n";
print '<ul class="replies">'."\n";
-foreach (
new RecursiveIteratorIterator($search) as $filename => $match
) {
+foreach (
$dir as $filename => $sorted
) {
$article = new ArchiveArticle($filename);
printf('<li><a href="%s">%s</a>', $article->link, $article->name);
if ($article->image) {
$article = new ArchiveArticle($filename);
printf('<li><a href="%s">%s</a>', $article->link, $article->name);
if ($article->image) {