diff --git a/Changelog.md b/Changelog.md index aa4d6e5..1eb6b62 100755 --- a/Changelog.md +++ b/Changelog.md @@ -33,6 +33,7 @@ data# Changelog - Fixed pressing the edit button on pages that have a single quote in their name - Fixed a spelling mistake on the file preview page - I'm sure I fixed that before...! - Fixed an issue whereby the search index wouldn't update if your pages contained special characters + - Fixed an issue with the recent changes list not updating when the number of recently changes reached setings.max_recent_changes (#104) ## v0.12 diff --git a/build/index.php b/build/index.php index 15a2484..34b67e6 100755 --- a/build/index.php +++ b/build/index.php @@ -1875,7 +1875,7 @@ register_module([ $content .= "

None yet! Try making a few changes and then check back here.

\n"; } - echo(page_renderer::render("Recent Changes - $settings->sitename", $content)); + exit(page_renderer::render("Recent Changes - $settings->sitename", $content)); }); register_save_preprocessor(function(&$pageinfo, &$newsource, &$oldsource) { @@ -1920,7 +1920,7 @@ function add_recent_change($rchange) // Limit the number of entries in the recent changes file if we've // been asked to. if(isset($settings->max_recent_changes)) - $recentchanges = array_slice($recentchanges, -$settings->max_recent_changes); + $recentchanges = array_slice($recentchanges, 0, $settings->max_recent_changes); // Save the recent changes file back to disk file_put_contents($paths->recentchanges, json_encode($recentchanges, JSON_PRETTY_PRINT)); @@ -2161,7 +2161,7 @@ register_module([ /** - * @api {get} ?action=idindex-show Show the id index. + * @api {get} ?action=idindex-show Show the id index * @apiDescription Outputs the id index. Useful if you need to verify that it's working as expected. * @apiName SearchShowIdIndex * @apiGroup Search @@ -3760,40 +3760,42 @@ register_module([ } // Check for edit conflicts - $existing_content_hash = sha1_file($env->storage_prefix . $pageindex->{$env->page}->filename); - if(isset($_POST["prev-content-hash"]) and - $existing_content_hash != $_POST["prev-content-hash"]) + if(!empty($pageindex->{$env->page}) && file_exists($env->storage_prefix . $pageindex->{$env->page}->filename)) { - $existingPageData = htmlentities(file_get_contents($env->storage_prefix . $env->storage_prefix . $pageindex->{$env->page}->filename)); - // An edit conflict has occurred! We should get the user to fix it. - $content = "

Resolving edit conflict - $env->page

"; - if(!$env->is_logged_in and $settings->anonedits) + $existing_content_hash = sha1_file($env->storage_prefix . $pageindex->{$env->page}->filename); + if(isset($_POST["prev-content-hash"]) and + $existing_content_hash != $_POST["prev-content-hash"]) { - $content .= "

Warning: You are not logged in! Your IP address may be recorded.

"; - } - $content .= "

An edit conflict has arisen because someone else has saved an edit to $env->page since you started editing it. Both texts are shown below, along the differences between the 2 conflicting revisions. To continue, please merge your changes with the existing content. Note that only the text in the existing content box will be kept when you press the \"Resolve Conflict\" button at the bottom of the page.

- -
-

Existing content

- - -

Differences

-
- - -

Your content

- - -

$settings->editing_message

- -
"; - - // Insert a reference to jsdiff to generate the diffs - $diffScript = <<<'DIFFSCRIPT' + $existingPageData = htmlentities(file_get_contents($env->storage_prefix . $env->storage_prefix . $pageindex->{$env->page}->filename)); + // An edit conflict has occurred! We should get the user to fix it. + $content = "

Resolving edit conflict - $env->page

"; + if(!$env->is_logged_in and $settings->anonedits) + { + $content .= "

Warning: You are not logged in! Your IP address may be recorded.

"; + } + $content .= "

An edit conflict has arisen because someone else has saved an edit to $env->page since you started editing it. Both texts are shown below, along the differences between the 2 conflicting revisions. To continue, please merge your changes with the existing content. Note that only the text in the existing content box will be kept when you press the \"Resolve Conflict\" button at the bottom of the page.

+ +
+

Existing content

+ + +

Differences

+
+ + +

Your content

+ + +

$settings->editing_message

+ +
"; + + // Insert a reference to jsdiff to generate the diffs + $diffScript = <<<'DIFFSCRIPT' window.addEventListener("load", function(event) { var destination = document.getElementById("highlighted-diff"), - diff = JsDiff.diffWords(document.getElementById("original-content").value, document.getElementById("new-content").value), - output = ""; + diff = JsDiff.diffWords(document.getElementById("original-content").value, document.getElementById("new-content").value), + output = ""; diff.forEach(function(change) { var classes = "token"; if(change.added) classes += " diff-added"; @@ -3804,10 +3806,11 @@ window.addEventListener("load", function(event) { }); DIFFSCRIPT; - $content .= "\n - \n"; - - exit(page_renderer::render_main("Edit Conflict - $env->page - $settings->sitename", $content)); + $content .= "\n + \n"; + + exit(page_renderer::render_main("Edit Conflict - $env->page - $settings->sitename", $content)); + } } // -----~~~==~~~----- diff --git a/module_index.json b/module_index.json index 19b6298..6408740 100755 --- a/module_index.json +++ b/module_index.json @@ -50,7 +50,7 @@ "author": "Starbeamrainbowlabs", "description": "Adds recent changes. Access through the 'recent-changes' action.", "id": "feature-recent-changes", - "lastupdate": 1465757910, + "lastupdate": 1472387876, "optional": false }, { @@ -68,7 +68,7 @@ "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.", "id": "feature-search", - "lastupdate": 1472229999, + "lastupdate": 1472230560, "optional": false }, { @@ -77,7 +77,7 @@ "author": "Starbeamrainbowlabs", "description": "Adds the ability to upload files to Pepperminty Wiki. Uploaded files act as pages and have the special 'File\/' prefix.", "id": "feature-upload", - "lastupdate": 1471884345, + "lastupdate": 1472230366, "optional": false }, { @@ -86,7 +86,7 @@ "author": "Starbeamrainbowlabs", "description": "Adds the credits page. You *must* have this module :D", "id": "page-credits", - "lastupdate": 1471632910, + "lastupdate": 1472230366, "optional": false }, { @@ -113,7 +113,7 @@ "author": "Starbeamrainbowlabs", "description": "Allows you to edit pages by adding the edit and save actions. You should probably include this one.", "id": "page-edit", - "lastupdate": 1471809336, + "lastupdate": 1472387737, "optional": false }, { @@ -122,7 +122,7 @@ "author": "Starbeamrainbowlabs", "description": "Adds a page that you can use to export your wiki as a .zip file. Uses $settings->export_only_allow_admins, which controls whether only admins are allowed to export the wiki.", "id": "page-export", - "lastupdate": 1466582751, + "lastupdate": 1472230366, "optional": false }, { @@ -131,7 +131,7 @@ "author": "Starbeamrainbowlabs", "description": "Adds a rather useful help page. Access through the 'help' action. This module also exposes help content added to Pepperminty Wiki's inbuilt invisible help section system.", "id": "page-help", - "lastupdate": 1471697534, + "lastupdate": 1472230366, "optional": false }, { @@ -140,7 +140,7 @@ "author": "Starbeamrainbowlabs", "description": "Adds a page that lists all the pages in the index along with their metadata.", "id": "page-list", - "lastupdate": 1471633011, + "lastupdate": 1472230366, "optional": false }, { @@ -149,7 +149,7 @@ "author": "Starbeamrainbowlabs", "description": "Adds a pair of actions (login and checklogin) that allow users to login. You need this one if you want your users to be able to login.", "id": "page-login", - "lastupdate": 1472061908, + "lastupdate": 1472230366, "optional": false }, { @@ -167,7 +167,7 @@ "author": "Starbeamrainbowlabs", "description": "Adds an action to allow administrators to move pages.", "id": "page-move", - "lastupdate": 1471632807, + "lastupdate": 1472230366, "optional": false }, { @@ -185,7 +185,7 @@ "author": "Starbeamrainbowlabs", "description": "Allows you to view pages. You really should include this one.", "id": "page-view", - "lastupdate": 1471784271, + "lastupdate": 1472230366, "optional": false }, { @@ -203,7 +203,7 @@ "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, and also *requires* write access to the disk on first load.", "id": "parser-parsedown", - "lastupdate": 1471954922, + "lastupdate": 1472230366, "optional": false } ] \ No newline at end of file diff --git a/modules/feature-recent-changes.php b/modules/feature-recent-changes.php index 3138e58..94c3e73 100644 --- a/modules/feature-recent-changes.php +++ b/modules/feature-recent-changes.php @@ -50,7 +50,7 @@ register_module([ $content .= "

None yet! Try making a few changes and then check back here.

\n"; } - echo(page_renderer::render("Recent Changes - $settings->sitename", $content)); + exit(page_renderer::render("Recent Changes - $settings->sitename", $content)); }); register_save_preprocessor(function(&$pageinfo, &$newsource, &$oldsource) { @@ -95,7 +95,7 @@ function add_recent_change($rchange) // Limit the number of entries in the recent changes file if we've // been asked to. if(isset($settings->max_recent_changes)) - $recentchanges = array_slice($recentchanges, -$settings->max_recent_changes); + $recentchanges = array_slice($recentchanges, 0, $settings->max_recent_changes); // Save the recent changes file back to disk file_put_contents($paths->recentchanges, json_encode($recentchanges, JSON_PRETTY_PRINT)); diff --git a/modules/page-edit.php b/modules/page-edit.php index f063a9c..c2b8f03 100755 --- a/modules/page-edit.php +++ b/modules/page-edit.php @@ -183,40 +183,42 @@ register_module([ } // Check for edit conflicts - $existing_content_hash = sha1_file($env->storage_prefix . $pageindex->{$env->page}->filename); - if(isset($_POST["prev-content-hash"]) and - $existing_content_hash != $_POST["prev-content-hash"]) + if(!empty($pageindex->{$env->page}) && file_exists($env->storage_prefix . $pageindex->{$env->page}->filename)) { - $existingPageData = htmlentities(file_get_contents($env->storage_prefix . $env->storage_prefix . $pageindex->{$env->page}->filename)); - // An edit conflict has occurred! We should get the user to fix it. - $content = "

Resolving edit conflict - $env->page

"; - if(!$env->is_logged_in and $settings->anonedits) + $existing_content_hash = sha1_file($env->storage_prefix . $pageindex->{$env->page}->filename); + if(isset($_POST["prev-content-hash"]) and + $existing_content_hash != $_POST["prev-content-hash"]) { - $content .= "

Warning: You are not logged in! Your IP address may be recorded.

"; - } - $content .= "

An edit conflict has arisen because someone else has saved an edit to $env->page since you started editing it. Both texts are shown below, along the differences between the 2 conflicting revisions. To continue, please merge your changes with the existing content. Note that only the text in the existing content box will be kept when you press the \"Resolve Conflict\" button at the bottom of the page.

- -
-

Existing content

- - -

Differences

-
- - -

Your content

- - -

$settings->editing_message

- -
"; - - // Insert a reference to jsdiff to generate the diffs - $diffScript = <<<'DIFFSCRIPT' + $existingPageData = htmlentities(file_get_contents($env->storage_prefix . $env->storage_prefix . $pageindex->{$env->page}->filename)); + // An edit conflict has occurred! We should get the user to fix it. + $content = "

Resolving edit conflict - $env->page

"; + if(!$env->is_logged_in and $settings->anonedits) + { + $content .= "

Warning: You are not logged in! Your IP address may be recorded.

"; + } + $content .= "

An edit conflict has arisen because someone else has saved an edit to $env->page since you started editing it. Both texts are shown below, along the differences between the 2 conflicting revisions. To continue, please merge your changes with the existing content. Note that only the text in the existing content box will be kept when you press the \"Resolve Conflict\" button at the bottom of the page.

+ +
+

Existing content

+ + +

Differences

+
+ + +

Your content

+ + +

$settings->editing_message

+ +
"; + + // Insert a reference to jsdiff to generate the diffs + $diffScript = <<<'DIFFSCRIPT' window.addEventListener("load", function(event) { var destination = document.getElementById("highlighted-diff"), - diff = JsDiff.diffWords(document.getElementById("original-content").value, document.getElementById("new-content").value), - output = ""; + diff = JsDiff.diffWords(document.getElementById("original-content").value, document.getElementById("new-content").value), + output = ""; diff.forEach(function(change) { var classes = "token"; if(change.added) classes += " diff-added"; @@ -227,10 +229,11 @@ window.addEventListener("load", function(event) { }); DIFFSCRIPT; - $content .= "\n - \n"; - - exit(page_renderer::render_main("Edit Conflict - $env->page - $settings->sitename", $content)); + $content .= "\n + \n"; + + exit(page_renderer::render_main("Edit Conflict - $env->page - $settings->sitename", $content)); + } } // -----~~~==~~~-----