From e3fcecdc1a7a46370b0aec19a657d3ae62889446 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Mon, 3 Jul 2017 18:33:25 +0100 Subject: [PATCH] Fix small bug in new preview function. https://github.com/sbrl/Pepperminty-Wiki/pull/140#issuecomment-31269952 --- build/index.php | 84 +++++++++++++++++++++---------------------- module_index.json | 2 +- modules/page-edit.php | 84 +++++++++++++++++++++---------------------- 3 files changed, 85 insertions(+), 85 deletions(-) diff --git a/build/index.php b/build/index.php index 27a24a7..d04cbcd 100644 --- a/build/index.php +++ b/build/index.php @@ -5119,47 +5119,6 @@ register_module([ "code" => function() { global $settings, $env; - - /** - * @api {post} ?action=preview-edit&page={pageName}[&newpage=yes] Get a preview of the page - * @apiDescription Gets a preview of the current edit state of a given page - * @apiName PreviewPage - * @apiPermission Anonymous - * - * @apiUse PageParameter - * @apiParam {string} newpage Set to 'yes' if a new page is being created. - * @apiParam {string} preview-edit Set to a value to preview an edit of a page. - */ - - /* - * - * ██████ ██████ ███████ ██ ██ ██ ███████ ██ ██ - * ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - * ██████ ██████ █████ ██ ██ ██ █████ ██ █ ██ - * ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ ██ - * ██ ██ ██ ███████ ████ ██ ███████ ███ ███ - * - * ███████ ██████ ██ ████████ - * ██ ██ ██ ██ ██ - * █████ ██ ██ ██ ██ - * ██ ██ ██ ██ ██ - * ███████ ██████ ██ ██ - * - */ - add_action("preview-edit", function() { - global $pageindex, $settings, $env, $actions; - - if(isset($_POST['preview-edit']) && isset($_POST['content'])) { - // preview changes - get_object_vars($actions)['edit'](); - } - else { - // save page - get_object_vars($actions)['save'](); - } - - - }); /** * @api {get} ?action=edit&page={pageName}[&newpage=yes] Get an editing page @@ -5282,7 +5241,7 @@ register_module([ } - $content .= "
+ $content .= "

@@ -5343,6 +5302,47 @@ window.addEventListener("load", function(event) {
 			exit(page_renderer::render_main("$title - $settings->sitename", $content));
 		});
 		
+		/**
+		 * @api {post} ?action=preview-edit&page={pageName}[&newpage=yes]	Get a preview of the page
+		 * @apiDescription	Gets a preview of the current edit state of a given page
+		 * @apiName 		PreviewPage
+		 * @apiPermission	Anonymous
+		 * 
+		 * @apiUse	PageParameter
+		 * @apiParam	{string}	newpage 	Set to 'yes' if a new page is being created.
+		 * @apiParam	{string}	preview-edit 	Set to a value to preview an edit of a page.
+		 */
+
+		/*
+		 *
+		 * ██████  ██████  ███████ ██    ██ ██ ███████ ██     ██
+		 * ██   ██ ██   ██ ██      ██    ██ ██ ██      ██     ██
+		 * ██████  ██████  █████   ██    ██ ██ █████   ██  █  ██
+		 * ██      ██   ██ ██       ██  ██  ██ ██      ██ ███ ██
+		 * ██      ██   ██ ███████   ████   ██ ███████  ███ ███
+		 *
+		 * ███████ ██████  ██ ████████ 
+		 * ██      ██   ██ ██    ██    
+		 * █████   ██   ██ ██    ██    
+		 * ██      ██   ██ ██    ██    
+		 * ███████ ██████  ██    ██    
+		 *
+		 */
+		add_action("preview-edit", function() {
+			global $pageindex, $settings, $env, $actions;
+
+			if(isset($_POST['preview-edit']) && isset($_POST['content'])) {
+				// preview changes
+				get_object_vars($actions)['edit']();
+			}
+			else {
+				// save page
+				get_object_vars($actions)['save']();
+			}
+
+			
+		});
+		
 		/**
 		 * @api {post} ?action=save&page={pageName}	Save an edit to a page.
 		 * @apiDescription	Saves an edit to a page. If an edit conflict is encountered, then a conflict resolution page is returned instead.
diff --git a/module_index.json b/module_index.json
index b228b7a..20ecfa4 100755
--- a/module_index.json
+++ b/module_index.json
@@ -158,7 +158,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": 1499102583,
+        "lastupdate": 1499103162,
         "optional": false
     },
     {
diff --git a/modules/page-edit.php b/modules/page-edit.php
index d230e90..adba60b 100644
--- a/modules/page-edit.php
+++ b/modules/page-edit.php
@@ -8,47 +8,6 @@ register_module([
 	
 	"code" => function() {
 		global $settings, $env;
-		
-		/**
-		 * @api {post} ?action=preview-edit&page={pageName}[&newpage=yes]	Get a preview of the page
-		 * @apiDescription	Gets a preview of the current edit state of a given page
-		 * @apiName 		PreviewPage
-		 * @apiPermission	Anonymous
-		 * 
-		 * @apiUse	PageParameter
-		 * @apiParam	{string}	newpage 	Set to 'yes' if a new page is being created.
-		 * @apiParam	{string}	preview-edit 	Set to a value to preview an edit of a page.
-		 */
-
-		/*
-		 *
-		 * ██████  ██████  ███████ ██    ██ ██ ███████ ██     ██
-		 * ██   ██ ██   ██ ██      ██    ██ ██ ██      ██     ██
-		 * ██████  ██████  █████   ██    ██ ██ █████   ██  █  ██
-		 * ██      ██   ██ ██       ██  ██  ██ ██      ██ ███ ██
-		 * ██      ██   ██ ███████   ████   ██ ███████  ███ ███
-		 *
-		 * ███████ ██████  ██ ████████ 
-		 * ██      ██   ██ ██    ██    
-		 * █████   ██   ██ ██    ██    
-		 * ██      ██   ██ ██    ██    
-		 * ███████ ██████  ██    ██    
-		 *
-		 */
-		add_action("preview-edit", function() {
-			global $pageindex, $settings, $env, $actions;
-
-			if(isset($_POST['preview-edit']) && isset($_POST['content'])) {
-				// preview changes
-				get_object_vars($actions)['edit']();
-			}
-			else {
-				// save page
-				get_object_vars($actions)['save']();
-			}
-
-			
-		});
 
 		/**
 		 * @api {get} ?action=edit&page={pageName}[&newpage=yes]	Get an editing page
@@ -171,7 +130,7 @@ register_module([
 
 			}
 
-			$content .= "
+			$content .= "
 					
 					
 					

@@ -232,6 +191,47 @@ window.addEventListener("load", function(event) {
 			exit(page_renderer::render_main("$title - $settings->sitename", $content));
 		});
 		
+		/**
+		 * @api {post} ?action=preview-edit&page={pageName}[&newpage=yes]	Get a preview of the page
+		 * @apiDescription	Gets a preview of the current edit state of a given page
+		 * @apiName 		PreviewPage
+		 * @apiPermission	Anonymous
+		 * 
+		 * @apiUse	PageParameter
+		 * @apiParam	{string}	newpage 	Set to 'yes' if a new page is being created.
+		 * @apiParam	{string}	preview-edit 	Set to a value to preview an edit of a page.
+		 */
+
+		/*
+		 *
+		 * ██████  ██████  ███████ ██    ██ ██ ███████ ██     ██
+		 * ██   ██ ██   ██ ██      ██    ██ ██ ██      ██     ██
+		 * ██████  ██████  █████   ██    ██ ██ █████   ██  █  ██
+		 * ██      ██   ██ ██       ██  ██  ██ ██      ██ ███ ██
+		 * ██      ██   ██ ███████   ████   ██ ███████  ███ ███
+		 *
+		 * ███████ ██████  ██ ████████ 
+		 * ██      ██   ██ ██    ██    
+		 * █████   ██   ██ ██    ██    
+		 * ██      ██   ██ ██    ██    
+		 * ███████ ██████  ██    ██    
+		 *
+		 */
+		add_action("preview-edit", function() {
+			global $pageindex, $settings, $env, $actions;
+
+			if(isset($_POST['preview-edit']) && isset($_POST['content'])) {
+				// preview changes
+				get_object_vars($actions)['edit']();
+			}
+			else {
+				// save page
+				get_object_vars($actions)['save']();
+			}
+
+			
+		});
+		
 		/**
 		 * @api {post} ?action=save&page={pageName}	Save an edit to a page.
 		 * @apiDescription	Saves an edit to a page. If an edit conflict is encountered, then a conflict resolution page is returned instead.