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

Add « Parent page link to subpages

This commit is contained in:
Starbeamrainbowlabs 2017-09-15 17:15:11 +01:00
parent 8788c1e708
commit 6fd99e5b82
6 changed files with 58 additions and 9 deletions

View file

@ -8,6 +8,8 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t
- Added a new statistics engine, which you can add your own statistic calculators to with `statistic_add` - Added a new statistics engine, which you can add your own statistic calculators to with `statistic_add`
- Added action `stats` to view the calculated statisics - Added action `stats` to view the calculated statisics
- Statistics are automagically recalculated every day - this can be controlled with `stats_update_interval` and `stats_update_processingtime` - Statistics are automagically recalculated every day - this can be controlled with `stats_update_interval` and `stats_update_processingtime`
- Added new "« Parent Page" to subpages so that you can easily visit their parent pages
- Added new `get_page_parent($pagename)` API method.
### Fixed ### Fixed
- Fixed invalid opensearch description. - Fixed invalid opensearch description.

View file

@ -296,7 +296,13 @@ textarea ~ input[type=submit] { margin: 0.5rem 0; padding: 0.5rem; font-weight:
.editform input[type=text] { width: calc(100% - 0.3rem); box-sizing: border-box; } .editform input[type=text] { width: calc(100% - 0.3rem); box-sizing: border-box; }
input.edit-page-button[type='submit'] { width: 49.5%; box-sizing: border-box; } input.edit-page-button[type='submit'] { width: 49.5%; box-sizing: border-box; }
.preview-message { text-align: center; } .preview-message { text-align: center; }
.jump-to-comments { position: relative; top: -2.5em; display: block; text-align: right; pointer-events: none; } @media (min-width: 800px) {
.jump-to-comments { position: absolute; top: 3.5em; right: 2em; display: block; text-align: right; pointer-events: none; }
}
@media (max-width: 799px) {
.jump-to-comments { display: inline-block; }
.link-parent-page { display: inline-block; }
}
.jump-to-comments > a { pointer-events: all; } .jump-to-comments > a { pointer-events: all; }
.file-gallery { margin: 0.5em; padding: 0.5em; list-style-type: none; } .file-gallery { margin: 0.5em; padding: 0.5em; list-style-type: none; }
@ -587,6 +593,18 @@ function glob_recursive($pattern, $flags = 0)
return $files; return $files;
} }
/**
* Gets the name of the parent page to the specified page.
* @param string $pagename The child page to get the parent
* page name for.
* @return string|bool
*/
function get_page_parent($pagename) {
if(mb_strpos($pagename, "/") === false)
return false;
return mb_substr($pagename, 0, mb_strrpos($pagename, "/"));
}
/** /**
* Gets a list of all the sub pages of the current page. * Gets a list of all the sub pages of the current page.
* @param object $pageindex The pageindex to use to search. * @param object $pageindex The pageindex to use to search.
@ -6776,7 +6794,7 @@ register_module([
register_module([ register_module([
"name" => "Page viewer", "name" => "Page viewer",
"version" => "0.16.6", "version" => "0.16.7",
"author" => "Starbeamrainbowlabs", "author" => "Starbeamrainbowlabs",
"description" => "Allows you to view pages. You really should include this one.", "description" => "Allows you to view pages. You really should include this one.",
"id" => "page-view", "id" => "page-view",
@ -6873,9 +6891,14 @@ register_module([
$content .= "<p class='revision-note'><em>(Revision saved by {$env->history->revision_data->editor} " . render_timestamp($env->history->revision_data->timestamp) . ". <a href='?page=" . rawurlencode($env->page) . "'>Jump to the current revision</a> or see a <a href='?action=history&page=" . rawurlencode($env->page) . "'>list of all revisions</a> for this page.)</em></p>\n"; $content .= "<p class='revision-note'><em>(Revision saved by {$env->history->revision_data->editor} " . render_timestamp($env->history->revision_data->timestamp) . ". <a href='?page=" . rawurlencode($env->page) . "'>Jump to the current revision</a> or see a <a href='?action=history&page=" . rawurlencode($env->page) . "'>list of all revisions</a> for this page.)</em></p>\n";
} }
// Add a visit parent page link if we're a subpage
if(get_page_parent($env->page) !== false) {
$content .= "<p class='link-parent-page'><em><a href='?action=view&page=" . rawurlencode(get_page_parent($env->page)) . "'>&laquo; " . htmlentities(get_page_parent($env->page)) . "</a></em></p>\n";
}
// Add an extra message if the requester was redirected from another page // Add an extra message if the requester was redirected from another page
if(isset($_GET["redirected_from"])) if(isset($_GET["redirected_from"]))
$content .= "<p><em>Redirected from <a href='?page=" . rawurlencode($_GET["redirected_from"]) . "&redirect=no'>" . $_GET["redirected_from"] . "</a>.</em></p>"; $content .= "<p><em>Redirected from <a href='?page=" . rawurlencode($_GET["redirected_from"]) . "&redirect=no'>" . $_GET["redirected_from"] . "</a>.</em></p>\n";
$parsing_start = microtime(true); $parsing_start = microtime(true);

View file

@ -226,6 +226,19 @@ function glob_recursive($pattern, $flags = 0)
return $files; return $files;
} }
/**
* Gets the name of the parent page to the specified page.
* @since 0.15
* @param string $pagename The child page to get the parent
* page name for.
* @return string|bool
*/
function get_page_parent($pagename) {
if(mb_strpos($pagename, "/") === false)
return false;
return mb_substr($pagename, 0, mb_strrpos($pagename, "/"));
}
/** /**
* Gets a list of all the sub pages of the current page. * Gets a list of all the sub pages of the current page.
* @param object $pageindex The pageindex to use to search. * @param object $pageindex The pageindex to use to search.

View file

@ -59,7 +59,7 @@
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds threaded comments to the bottom of every page.", "description": "Adds threaded comments to the bottom of every page.",
"id": "feature-comments", "id": "feature-comments",
"lastupdate": 1497799232, "lastupdate": 1505489462,
"optional": false "optional": false
}, },
{ {
@ -244,11 +244,11 @@
}, },
{ {
"name": "Page viewer", "name": "Page viewer",
"version": "0.16.6", "version": "0.16.7",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Allows you to view pages. You really should include this one.", "description": "Allows you to view pages. You really should include this one.",
"id": "page-view", "id": "page-view",
"lastupdate": 1498646088, "lastupdate": 1505491607,
"optional": false "optional": false
}, },
{ {

View file

@ -1,7 +1,7 @@
<?php <?php
register_module([ register_module([
"name" => "Page viewer", "name" => "Page viewer",
"version" => "0.16.6", "version" => "0.16.7",
"author" => "Starbeamrainbowlabs", "author" => "Starbeamrainbowlabs",
"description" => "Allows you to view pages. You really should include this one.", "description" => "Allows you to view pages. You really should include this one.",
"id" => "page-view", "id" => "page-view",
@ -98,9 +98,14 @@ register_module([
$content .= "<p class='revision-note'><em>(Revision saved by {$env->history->revision_data->editor} " . render_timestamp($env->history->revision_data->timestamp) . ". <a href='?page=" . rawurlencode($env->page) . "'>Jump to the current revision</a> or see a <a href='?action=history&page=" . rawurlencode($env->page) . "'>list of all revisions</a> for this page.)</em></p>\n"; $content .= "<p class='revision-note'><em>(Revision saved by {$env->history->revision_data->editor} " . render_timestamp($env->history->revision_data->timestamp) . ". <a href='?page=" . rawurlencode($env->page) . "'>Jump to the current revision</a> or see a <a href='?action=history&page=" . rawurlencode($env->page) . "'>list of all revisions</a> for this page.)</em></p>\n";
} }
// Add a visit parent page link if we're a subpage
if(get_page_parent($env->page) !== false) {
$content .= "<p class='link-parent-page'><em><a href='?action=view&page=" . rawurlencode(get_page_parent($env->page)) . "'>&laquo; " . htmlentities(get_page_parent($env->page)) . "</a></em></p>\n";
}
// Add an extra message if the requester was redirected from another page // Add an extra message if the requester was redirected from another page
if(isset($_GET["redirected_from"])) if(isset($_GET["redirected_from"]))
$content .= "<p><em>Redirected from <a href='?page=" . rawurlencode($_GET["redirected_from"]) . "&redirect=no'>" . $_GET["redirected_from"] . "</a>.</em></p>"; $content .= "<p><em>Redirected from <a href='?page=" . rawurlencode($_GET["redirected_from"]) . "&redirect=no'>" . $_GET["redirected_from"] . "</a>.</em></p>\n";
$parsing_start = microtime(true); $parsing_start = microtime(true);

View file

@ -75,7 +75,13 @@ textarea ~ input[type=submit] { margin: 0.5rem 0; padding: 0.5rem; font-weight:
.editform input[type=text] { width: calc(100% - 0.3rem); box-sizing: border-box; } .editform input[type=text] { width: calc(100% - 0.3rem); box-sizing: border-box; }
input.edit-page-button[type='submit'] { width: 49.5%; box-sizing: border-box; } input.edit-page-button[type='submit'] { width: 49.5%; box-sizing: border-box; }
.preview-message { text-align: center; } .preview-message { text-align: center; }
.jump-to-comments { position: relative; top: -2.5em; display: block; text-align: right; pointer-events: none; } @media (min-width: 800px) {
.jump-to-comments { position: absolute; top: 3.5em; right: 2em; display: block; text-align: right; pointer-events: none; }
}
@media (max-width: 799px) {
.jump-to-comments { display: inline-block; }
.link-parent-page { display: inline-block; }
}
.jump-to-comments > a { pointer-events: all; } .jump-to-comments > a { pointer-events: all; }
.file-gallery { margin: 0.5em; padding: 0.5em; list-style-type: none; } .file-gallery { margin: 0.5em; padding: 0.5em; list-style-type: none; }