From 75e68e3f532652d9d6e0c1d6bde66d335c322d64 Mon Sep 17 00:00:00 2001
From: Starbeamrainbowlabs <sbrl@starbeamrainbowlabs.com>
Date: Wed, 7 Dec 2016 20:40:16 +0000
Subject: [PATCH] Create random action

---
 build/index.php           | 33 +++++++++++++++++++++++++++++++++
 module_index.json         |  9 +++++++++
 modules/action-random.php | 31 +++++++++++++++++++++++++++++++
 3 files changed, 73 insertions(+)
 create mode 100644 modules/action-random.php

diff --git a/build/index.php b/build/index.php
index 88233e0..1368cf4 100644
--- a/build/index.php
+++ b/build/index.php
@@ -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",
diff --git a/module_index.json b/module_index.json
index ce1bf9b..cd35050 100755
--- a/module_index.json
+++ b/module_index.json
@@ -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",
diff --git a/modules/action-random.php b/modules/action-random.php
new file mode 100644
index 0000000..485081b
--- /dev/null
+++ b/modules/action-random.php
@@ -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>");
+	}
+]);
+
+?>
