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

Add page deletions to the recent changes page.

This commit is contained in:
Starbeamrainbowlabs 2016-04-03 15:43:40 +01:00
parent 8b55263a44
commit 6a2c0dad5c
5 changed files with 74 additions and 24 deletions

View file

@ -349,9 +349,10 @@ textarea ~ input[type=submit] { margin: 0.5rem 0.8rem; padding: 0.5rem; font-wei
.cursor-query { cursor: help; }
.larger { color: rgb(9, 180, 0); }
.smaller { color: rgb(207, 28, 17); }
.smaller, .deletion { color: rgb(207, 28, 17); }
.nochange { color: rgb(132, 123, 199); font-style: italic; }
.significant { font-weight: bolder; font-size: 1.1rem; }
.deletion, .deletion > .editor { text-decoration: line-through; }
.newpage::before { content: \"N\"; margin: 0 0.3em 0 -1em; font-weight: bolder; text-decoration: underline dotted; }
@ -1602,20 +1603,31 @@ register_module([
$content .= "<ul class='page-list'>\n";
foreach($recentchanges as $rchange)
{
// The number (and the sign) of the size difference to display
$size_display = ($rchange->sizediff > 0 ? "+" : "") . $rchange->sizediff;
$size_display_class = $rchange->sizediff > 0 ? "larger" : ($rchange->sizediff < 0 ? "smaller" : "nochange");
if($rchange->sizediff > 500 or $rchange->sizediff < -500)
$size_display_class .= " significant";
$title_display = human_filesize($rchange->newsize - $rchange->sizediff) . " -> " . human_filesize($rchange->newsize);
// Render the page's name
$pageDisplayName = $rchange->page;
if(isset($pageindex->$pageDisplayName) and !empty($pageindex->$pageDisplayName->redirect))
$pageDisplayName = "<em>$pageDisplayName</em>";
$content .= "\t\t\t<li" . (!empty($rchange->newpage) ? " class='newpage'" : "") . "><a href='?page=" . rawurlencode($rchange->page) . "'>$pageDisplayName</a> <span class='editor'>&#9998; $rchange->user</span> <time class='cursor-query' title='" . date("l jS \of F Y \a\\t h:ia T", $rchange->timestamp) . "'>" . human_time_since($rchange->timestamp) . "</time> <span class='$size_display_class' title='$title_display'>($size_display)</span></li>\n";
switch(isset($rchange->type) ? $rchange->type : "edit")
{
case "edit":
// The number (and the sign) of the size difference to display
$size_display = ($rchange->sizediff > 0 ? "+" : "") . $rchange->sizediff;
$size_display_class = $rchange->sizediff > 0 ? "larger" : ($rchange->sizediff < 0 ? "smaller" : "nochange");
if($rchange->sizediff > 500 or $rchange->sizediff < -500)
$size_display_class .= " significant";
$title_display = human_filesize($rchange->newsize - $rchange->sizediff) . " -> " . human_filesize($rchange->newsize);
$content .= "\t\t\t<li" . (!empty($rchange->newpage) ? " class='newpage'" : "") . "><a href='?page=" . rawurlencode($rchange->page) . "'>$pageDisplayName</a> <span class='editor'>&#9998; $rchange->user</span> <time class='cursor-query' title='" . date("l jS \of F Y \a\\t h:ia T", $rchange->timestamp) . "'>" . human_time_since($rchange->timestamp) . "</time> <span class='$size_display_class' title='$title_display'>($size_display)</span></li>\n";
break;
case "deletion":
$content .= "<li class='deletion'>$pageDisplayName <span class='editor'>&#9998; $rchange->user</span> <time class='cursor-query' title='" . date("l jS \of F Y \a\\t h:ia T", $rchange->timestamp) . "'>" . human_time_since($rchange->timestamp) . "</time></li>";
}
}
$content .= "\t\t</ul>";
}
@ -1663,6 +1675,7 @@ register_module([
function add_recent_change($rchange)
{
global $settings, $paths;
$recentchanges = json_decode(file_get_contents($paths->recentchanges), true);
array_unshift($recentchanges, $rchange);
@ -2854,6 +2867,18 @@ register_module([
// Delete the page from the disk
unlink("$env->storage_prefix$env->page.md");
// Add a recent change announcing the deletion if the recent changes
// module is installed
if(module_exists("feature-recent-changes"))
{
add_recent_change([
"type" => "deletion",
"timestamp" => time(),
"page" => $env->page,
"user" => $env->user,
]);
}
exit(page_renderer::render_main("Deleting $env->page - $settings->sitename", "<p>$env->page has been deleted. <a href='index.php'>Go back to the main page</a>.</p>"));
});

View file

@ -41,7 +41,7 @@
"author": "Starbeamrainbowlabs",
"description": "Adds recent changes. Access through the 'recent-changes' action.",
"id": "feature-recent-changes",
"lastupdate": 1459693836,
"lastupdate": 1459694503,
"optional": false
},
{
@ -95,7 +95,7 @@
"author": "Starbeamrainbowlabs",
"description": "Adds an action to allow administrators to delete pages.",
"id": "page-delete",
"lastupdate": 1451133966,
"lastupdate": 1459694163,
"optional": false
},
{

View file

@ -38,20 +38,31 @@ register_module([
$content .= "<ul class='page-list'>\n";
foreach($recentchanges as $rchange)
{
// The number (and the sign) of the size difference to display
$size_display = ($rchange->sizediff > 0 ? "+" : "") . $rchange->sizediff;
$size_display_class = $rchange->sizediff > 0 ? "larger" : ($rchange->sizediff < 0 ? "smaller" : "nochange");
if($rchange->sizediff > 500 or $rchange->sizediff < -500)
$size_display_class .= " significant";
$title_display = human_filesize($rchange->newsize - $rchange->sizediff) . " -> " . human_filesize($rchange->newsize);
// Render the page's name
$pageDisplayName = $rchange->page;
if(isset($pageindex->$pageDisplayName) and !empty($pageindex->$pageDisplayName->redirect))
$pageDisplayName = "<em>$pageDisplayName</em>";
$content .= "\t\t\t<li" . (!empty($rchange->newpage) ? " class='newpage'" : "") . "><a href='?page=" . rawurlencode($rchange->page) . "'>$pageDisplayName</a> <span class='editor'>&#9998; $rchange->user</span> <time class='cursor-query' title='" . date("l jS \of F Y \a\\t h:ia T", $rchange->timestamp) . "'>" . human_time_since($rchange->timestamp) . "</time> <span class='$size_display_class' title='$title_display'>($size_display)</span></li>\n";
switch(isset($rchange->type) ? $rchange->type : "edit")
{
case "edit":
// The number (and the sign) of the size difference to display
$size_display = ($rchange->sizediff > 0 ? "+" : "") . $rchange->sizediff;
$size_display_class = $rchange->sizediff > 0 ? "larger" : ($rchange->sizediff < 0 ? "smaller" : "nochange");
if($rchange->sizediff > 500 or $rchange->sizediff < -500)
$size_display_class .= " significant";
$title_display = human_filesize($rchange->newsize - $rchange->sizediff) . " -> " . human_filesize($rchange->newsize);
$content .= "\t\t\t<li" . (!empty($rchange->newpage) ? " class='newpage'" : "") . "><a href='?page=" . rawurlencode($rchange->page) . "'>$pageDisplayName</a> <span class='editor'>&#9998; $rchange->user</span> <time class='cursor-query' title='" . date("l jS \of F Y \a\\t h:ia T", $rchange->timestamp) . "'>" . human_time_since($rchange->timestamp) . "</time> <span class='$size_display_class' title='$title_display'>($size_display)</span></li>\n";
break;
case "deletion":
$content .= "<li class='deletion'>$pageDisplayName <span class='editor'>&#9998; $rchange->user</span> <time class='cursor-query' title='" . date("l jS \of F Y \a\\t h:ia T", $rchange->timestamp) . "'>" . human_time_since($rchange->timestamp) . "</time></li>";
}
}
$content .= "\t\t</ul>";
}
@ -99,6 +110,7 @@ register_module([
function add_recent_change($rchange)
{
global $settings, $paths;
$recentchanges = json_decode(file_get_contents($paths->recentchanges), true);
array_unshift($recentchanges, $rchange);

View file

@ -63,6 +63,18 @@ register_module([
// Delete the page from the disk
unlink("$env->storage_prefix$env->page.md");
// Add a recent change announcing the deletion if the recent changes
// module is installed
if(module_exists("feature-recent-changes"))
{
add_recent_change([
"type" => "deletion",
"timestamp" => time(),
"page" => $env->page,
"user" => $env->user,
]);
}
exit(page_renderer::render_main("Deleting $env->page - $settings->sitename", "<p>$env->page has been deleted. <a href='index.php'>Go back to the main page</a>.</p>"));
});

View file

@ -346,9 +346,10 @@ textarea ~ input[type=submit] { margin: 0.5rem 0.8rem; padding: 0.5rem; font-wei
.cursor-query { cursor: help; }
.larger { color: rgb(9, 180, 0); }
.smaller { color: rgb(207, 28, 17); }
.smaller, .deletion { color: rgb(207, 28, 17); }
.nochange { color: rgb(132, 123, 199); font-style: italic; }
.significant { font-weight: bolder; font-size: 1.1rem; }
.deletion, .deletion > .editor { text-decoration: line-through; }
.newpage::before { content: \"N\"; margin: 0 0.3em 0 -1em; font-weight: bolder; text-decoration: underline dotted; }