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

Create random action

This commit is contained in:
Starbeamrainbowlabs 2016-12-07 20:40:16 +00:00
parent ac3f946442
commit 75e68e3f53
3 changed files with 73 additions and 0 deletions

View file

@ -250,6 +250,7 @@ a.redlink:visited { color: rgb(130, 15, 15); /*#8b1a1a*/ }
.search-context { max-height: 20em; overflow: hidden; }
.search-context::after { content: ""; position: absolute; bottom: 0; width: 100%; height: 3em; display: block; background: linear-gradient(to bottom, transparent, #faf8fb); pointer-events: none; }
textarea[name=content] { height: 30em; }
label:not(.link-display-label) { display: inline-block; min-width: 16rem; }
input[type=text]:not(.link-display), input[type=password], input[type=url], input[type=email], input[type=number], textarea { margin: 0.5rem 0; }
input[type=text], input[type=password], input[type=url], input[type=email], input[type=number], textarea, #search-box { padding: 0.5rem 0.8rem; background: #d5cbf9; border: 0; border-radius: 0.3rem; font-size: 1rem; color: #442772; }
@ -1716,6 +1717,38 @@ register_module([
register_module([
"name" => "Random Page",
"version" => "0.1",
"author" => "Starbeamrainbowlabs",
"description" => "Adds an action called 'random' that redirects you to a random page.",
"id" => "action-random",
"code" => function() {
global $settings;
/**
* @api {get} ?action=random Redirects to a random page.
* @apiName RawSource
* @apiGroup Page
* @apiPermission Anonymous
*/
add_action("random", function() {
global $pageindex;
$pageNames = array_keys(get_object_vars($pageindex));
$randomPageName = $pageNames[array_rand($pageNames)];
http_response_code(307);
header("location: ?page=" . rawurlencode($randomPageName));
});
add_help_section("26-random-redirect", "Jumping to a random page", "<p>$settings->sitename has a function that can send you to a random page. To use it, click <a href='?action=random'>here</a>.</p>");
}
]);
register_module([
"name" => "Raw page source",
"version" => "0.7",

View file

@ -17,6 +17,15 @@
"lastupdate": 1465751051,
"optional": false
},
{
"name": "Random Page",
"version": "0.1",
"author": "Starbeamrainbowlabs",
"description": "Adds an action called 'random' that redirects you to a random page.",
"id": "action-random",
"lastupdate": 1481143095,
"optional": false
},
{
"name": "Raw page source",
"version": "0.7",

31
modules/action-random.php Normal file
View file

@ -0,0 +1,31 @@
<?php
register_module([
"name" => "Random Page",
"version" => "0.1",
"author" => "Starbeamrainbowlabs",
"description" => "Adds an action called 'random' that redirects you to a random page.",
"id" => "action-random",
"code" => function() {
global $settings;
/**
* @api {get} ?action=random Redirects to a random page.
* @apiName RawSource
* @apiGroup Page
* @apiPermission Anonymous
*/
add_action("random", function() {
global $pageindex;
$pageNames = array_keys(get_object_vars($pageindex));
$randomPageName = $pageNames[array_rand($pageNames)];
http_response_code(307);
header("location: ?page=" . rawurlencode($randomPageName));
});
add_help_section("26-random-redirect", "Jumping to a random page", "<p>$settings->sitename has a function that can send you to a random page. To use it, click <a href='?action=random'>here</a>.</p>");
}
]);
?>