1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-12-22 13:45:02 +00:00

Add initial jump to comments link, but it doesn't work yet.

This commit is contained in:
Starbeamrainbowlabs 2017-05-20 16:07:42 +01:00
parent 94378d8c31
commit 6835c77384
4 changed files with 29 additions and 6 deletions

View file

@ -729,6 +729,20 @@ function endsWith($whole, $end)
{
return (strpos($whole, $end, strlen($whole) - strlen($end)) !== false);
}
/**
* Replaces the first occurrence of $find with $replace.
* @param string $find The string to search for.
* @param string $replace The string to replace the search string with.
* @param string $subject The string ot perform the search and replace on.
* @return string The source string after the find and replace has been performed.
*/
function str_replace_once($find, $replace, $subject)
{
$index = strpos($subject, $find);
if($index !== false)
return substr_replace($subject, $replace, $index, strlen($find));
return $subject;
}
/**
* Returns the system's mime type mappings, considering the first extension
@ -2210,7 +2224,7 @@ register_module([
$comments_html = "<aside class='comments'>" .
"<h2>Comments</h2>\n";
"<h2 id='comments'>Comments</h2>\n";
if($env->is_logged_in) {
$comments_html .= "<form class='comment-reply-form' method='post' action='?action=comment&page=" . rawurlencode($env->page) . "'>\n" .
@ -2233,7 +2247,12 @@ register_module([
$comments_html .= "</aside>\n";
$to_comments_link = "<a href='#comments'>Jump to comments</a>";
$parts["{extra}"] = $comments_html . $parts["{extra}"];
// fixme
$parts["{content}"] = str_replace_once("</h1>", "</h1>\n$to_comments_link", $parts["{content}"]);
});
$reply_js_snippet = <<<'REPLYJS'
@ -6098,7 +6117,7 @@ register_module([
$page = $env->page;
if(!isset($pageindex->$page))
{
// todo make this intelligent so we only redirect if the user is acutally able to create the page
// todo make this intelligent so we only redirect if the user is actually able to create the page
if($settings->editing)
{
// Editing is enabled, redirect to the editing page

View file

@ -50,7 +50,7 @@
"author": "Starbeamrainbowlabs",
"description": "Adds threaded comments to the bottom of every page.",
"id": "feature-comments",
"lastupdate": 1495289583,
"lastupdate": 1495292573,
"optional": false
},
{
@ -230,7 +230,7 @@
"author": "Starbeamrainbowlabs",
"description": "Allows you to view pages. You really should include this one.",
"id": "page-view",
"lastupdate": 1482008539,
"lastupdate": 1495291771,
"optional": false
},
{

View file

@ -137,7 +137,7 @@ register_module([
$comments_html = "<aside class='comments'>" .
"<h2>Comments</h2>\n";
"<h2 id='comments'>Comments</h2>\n";
if($env->is_logged_in) {
$comments_html .= "<form class='comment-reply-form' method='post' action='?action=comment&page=" . rawurlencode($env->page) . "'>\n" .
@ -160,7 +160,11 @@ register_module([
$comments_html .= "</aside>\n";
$to_comments_link = "<a href='#comments'>Jump to comments</a>";
$parts["{extra}"] = $comments_html . $parts["{extra}"];
$parts["{content}"] = str_replace_once("</h1>", "</h1>\n$to_comments_link", $parts["{content}"]);
});
$reply_js_snippet = <<<'REPLYJS'

View file

@ -34,7 +34,7 @@ register_module([
$page = $env->page;
if(!isset($pageindex->$page))
{
// todo make this intelligent so we only redirect if the user is acutally able to create the page
// todo make this intelligent so we only redirect if the user is actually able to create the page
if($settings->editing)
{
// Editing is enabled, redirect to the editing page