mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-22 04:23:01 +00:00
Add initial jump to comments link, but it doesn't work yet.
This commit is contained in:
parent
94378d8c31
commit
6835c77384
4 changed files with 29 additions and 6 deletions
|
@ -729,6 +729,20 @@ function endsWith($whole, $end)
|
||||||
{
|
{
|
||||||
return (strpos($whole, $end, strlen($whole) - strlen($end)) !== false);
|
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
|
* Returns the system's mime type mappings, considering the first extension
|
||||||
|
@ -2210,7 +2224,7 @@ register_module([
|
||||||
|
|
||||||
|
|
||||||
$comments_html = "<aside class='comments'>" .
|
$comments_html = "<aside class='comments'>" .
|
||||||
"<h2>Comments</h2>\n";
|
"<h2 id='comments'>Comments</h2>\n";
|
||||||
|
|
||||||
if($env->is_logged_in) {
|
if($env->is_logged_in) {
|
||||||
$comments_html .= "<form class='comment-reply-form' method='post' action='?action=comment&page=" . rawurlencode($env->page) . "'>\n" .
|
$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";
|
$comments_html .= "</aside>\n";
|
||||||
|
|
||||||
|
$to_comments_link = "<a href='#comments'>Jump to comments</a>";
|
||||||
|
|
||||||
$parts["{extra}"] = $comments_html . $parts["{extra}"];
|
$parts["{extra}"] = $comments_html . $parts["{extra}"];
|
||||||
|
|
||||||
|
// fixme
|
||||||
|
$parts["{content}"] = str_replace_once("</h1>", "</h1>\n$to_comments_link", $parts["{content}"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
$reply_js_snippet = <<<'REPLYJS'
|
$reply_js_snippet = <<<'REPLYJS'
|
||||||
|
@ -6098,7 +6117,7 @@ register_module([
|
||||||
$page = $env->page;
|
$page = $env->page;
|
||||||
if(!isset($pageindex->$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)
|
if($settings->editing)
|
||||||
{
|
{
|
||||||
// Editing is enabled, redirect to the editing page
|
// Editing is enabled, redirect to the editing page
|
||||||
|
|
|
@ -50,7 +50,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": 1495289583,
|
"lastupdate": 1495292573,
|
||||||
"optional": false
|
"optional": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -230,7 +230,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": 1482008539,
|
"lastupdate": 1495291771,
|
||||||
"optional": false
|
"optional": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -137,7 +137,7 @@ register_module([
|
||||||
|
|
||||||
|
|
||||||
$comments_html = "<aside class='comments'>" .
|
$comments_html = "<aside class='comments'>" .
|
||||||
"<h2>Comments</h2>\n";
|
"<h2 id='comments'>Comments</h2>\n";
|
||||||
|
|
||||||
if($env->is_logged_in) {
|
if($env->is_logged_in) {
|
||||||
$comments_html .= "<form class='comment-reply-form' method='post' action='?action=comment&page=" . rawurlencode($env->page) . "'>\n" .
|
$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";
|
$comments_html .= "</aside>\n";
|
||||||
|
|
||||||
|
$to_comments_link = "<a href='#comments'>Jump to comments</a>";
|
||||||
|
|
||||||
$parts["{extra}"] = $comments_html . $parts["{extra}"];
|
$parts["{extra}"] = $comments_html . $parts["{extra}"];
|
||||||
|
|
||||||
|
$parts["{content}"] = str_replace_once("</h1>", "</h1>\n$to_comments_link", $parts["{content}"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
$reply_js_snippet = <<<'REPLYJS'
|
$reply_js_snippet = <<<'REPLYJS'
|
||||||
|
|
|
@ -34,7 +34,7 @@ register_module([
|
||||||
$page = $env->page;
|
$page = $env->page;
|
||||||
if(!isset($pageindex->$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)
|
if($settings->editing)
|
||||||
{
|
{
|
||||||
// Editing is enabled, redirect to the editing page
|
// Editing is enabled, redirect to the editing page
|
||||||
|
|
Loading…
Reference in a new issue