diff --git a/Changelog.md b/Changelog.md index d074ada..2edbf81 100644 --- a/Changelog.md +++ b/Changelog.md @@ -18,6 +18,7 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t - Optimisation: Don't load the statistics index if it's not needed (also esp. noticeable on wikis with lots of pages) - Optimisation: Refactor `stas_split()` to be faster (informal testing shows ~18% → 4% total time) - [Module Api] Optimisation: Remove `search::transliterate` because it has a huge overhead. Use `search::$literator->transliterate()` instead. + - [Module Api] Add new `absolute` and `html` optional boolean arguments to `render_timestamp()` ## v0.20 _Just 1 change since the previous beta release._ diff --git a/modules/feature-watchlist.php b/modules/feature-watchlist.php index cfb5755..13d64f5 100644 --- a/modules/feature-watchlist.php +++ b/modules/feature-watchlist.php @@ -214,6 +214,52 @@ register_module([ $message .= " Go back to your previous page, or review your watchlist."; exit(page_renderer::render_main("Watchlist update successful", "

$message

")); }); + + if(!module_exists("edit")) { + error_log("[module/feature-watchlist] Note: Without the page-edit module, the feature-watchlist module doesn't make much sense. If you don't want anonymous people to edit your wiki, try the 'anonedits' setting."); + return false; + } + + register_save_preprocessor(function($indexentry, $new_data, $old_data) { + global $version, $commit, $env, $settings; + + $usernames = []; + foreach($settings->users as $username => $user_data) { + if(empty($user_data->watchlist)) + continue; + + if(!in_array($env->page, $user_data->watchlist)) + continue; + + $usernames[] = $username; + } + + $chars_changed = strlen($new_data) - strlen($old_data); + $chars_changed_text = ($chars_changed < 0 ? "removes " : "adds ") . "$chars_changed characters"; + + // Calculate the stem from the current full URL by stripping everything after the question mark ('?') + $url_stem = full_url(); + if(mb_strrpos($url_stem, "?") !== false) $url_steam = mb_substr($url_stem, mb_strrpos($url_stem, "?")); + + email_users( + $usernames, + "{$env->page} was updated by {$env->user} - $settings->sitename", + "Hey there! + +{$env->page} was updated by {$env->user} at ".render_timestamp(time(), true, false).", which $chars_changed_text. + +View the latest revision here: {$url_stem}?page=".rawurlencode($env->page)." + +---------- New page text ---------- +$new_data +----------------------------------- + +--$settings->sitename, powered by Pepperminty Wiki $version-".substr($commit, 0, 7)." + +(P.S. Don't reply to this email, because it may not recieve a reply. Instead try contacting $settings->admindetails_name at $settings->admindetails_email, who is $settings->sitename's administrator if you have any issues.) +" + ); + }); } ]);