diff --git a/index.php b/index.php
index d1d8693..21c5d58 100644
--- a/index.php
+++ b/index.php
@@ -264,7 +264,7 @@ if(!file_exists("./pageindex.json"))
// Extract the subpage's key
$subpage_relative_key = substr($item, $stem_length, -3);
- // Calculate how many times removed the current subpage is from the current page. 1 = direct descendant.
+ // Calculate how many times removed the current subpage is from the current page. 0 = direct descendant.
$times_removed = substr_count($subpage_relative_key, "/");
$subpage_full_key = substr($item, 0, -3);
// Store the name of the subpage we found in the subpage object of the current page
@@ -700,7 +700,7 @@ register_module([
register_module([
"name" => "Page editor",
- "version" => "0.6",
+ "version" => "0.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",
@@ -708,12 +708,12 @@ register_module([
"code" => function() {
/*
- *
- * ___ __ ___ _____
- * / __|/ _` \ \ / / _ \
- * \__ \ (_| |\ V / __/
- * |___/\__,_| \_/ \___|
- * %save%
+ * _ _ _
+ * ___ __| (_) |_
+ * / _ \/ _` | | __|
+ * | __/ (_| | | |_
+ * \___|\__,_|_|\__|
+ * %edit%
*/
add_action("edit", function() {
global $pageindex, $settings, $page, $isloggedin;
@@ -761,14 +761,13 @@ register_module([
exit(page_renderer::render_main("$title - $settings->sitename", $content));
});
-
/*
- * _ _ _
- * ___ __| (_) |_
- * / _ \/ _` | | __|
- * | __/ (_| | | |_
- * \___|\__,_|_|\__|
- * %edit%
+ *
+ * ___ __ ___ _____
+ * / __|/ _` \ \ / / _ \
+ * \__ \ (_| |\ V / __/
+ * |___/\__,_| \_/ \___|
+ * %save%
*/
add_action("save", function() {
global $pageindex, $settings, $page, $isloggedin, $user;
@@ -789,6 +788,14 @@ register_module([
header("refresh: 5; url=index.php?page=$page");
exit("Bad request: No content specified.");
}
+
+ // Make sure that the directory in which the page needs to be saved exists
+ if(!is_dir(dirname("$page.md")))
+ {
+ // Recursively create the directory if needed
+ mkdir(dirname("$page.md"), null, true);
+ }
+
if(file_put_contents("$page.md", htmlentities($_POST["content"]), ENT_QUOTES) !== false)
{
//update the page index
@@ -907,6 +914,7 @@ register_module([
Last Editor |
Last Edit Time |
\n";
+ // todo list the pages in alphabetical order
foreach($pageindex as $pagename => $pagedetails)
{
$content .= "\t\t
diff --git a/module_index.json b/module_index.json
index 19c88f9..1465c5a 100644
--- a/module_index.json
+++ b/module_index.json
@@ -25,11 +25,11 @@
},
{
"name": "Page editor",
- "version": "0.6",
+ "version": "0.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": 1432497592
+ "lastupdate": 1436797312
},
{
"name": "Help page",
@@ -45,7 +45,7 @@
"author": "Starbeamrainbowlabs",
"description": "Adds a page that lists all the pages in the index along with their metadata.",
"id": "page-list",
- "lastupdate": 1432497592
+ "lastupdate": 1436796812
},
{
"name": "Login",
diff --git a/modules/page-edit.php b/modules/page-edit.php
index 0606e3a..fa37b3f 100644
--- a/modules/page-edit.php
+++ b/modules/page-edit.php
@@ -1,7 +1,7 @@
"Page editor",
- "version" => "0.6",
+ "version" => "0.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",
@@ -9,12 +9,12 @@ register_module([
"code" => function() {
/*
- *
- * ___ __ ___ _____
- * / __|/ _` \ \ / / _ \
- * \__ \ (_| |\ V / __/
- * |___/\__,_| \_/ \___|
- * %save%
+ * _ _ _
+ * ___ __| (_) |_
+ * / _ \/ _` | | __|
+ * | __/ (_| | | |_
+ * \___|\__,_|_|\__|
+ * %edit%
*/
add_action("edit", function() {
global $pageindex, $settings, $page, $isloggedin;
@@ -62,14 +62,13 @@ register_module([
exit(page_renderer::render_main("$title - $settings->sitename", $content));
});
-
/*
- * _ _ _
- * ___ __| (_) |_
- * / _ \/ _` | | __|
- * | __/ (_| | | |_
- * \___|\__,_|_|\__|
- * %edit%
+ *
+ * ___ __ ___ _____
+ * / __|/ _` \ \ / / _ \
+ * \__ \ (_| |\ V / __/
+ * |___/\__,_| \_/ \___|
+ * %save%
*/
add_action("save", function() {
global $pageindex, $settings, $page, $isloggedin, $user;
@@ -90,6 +89,14 @@ register_module([
header("refresh: 5; url=index.php?page=$page");
exit("Bad request: No content specified.");
}
+
+ // Make sure that the directory in which the page needs to be saved exists
+ if(!is_dir(dirname("$page.md")))
+ {
+ // Recursively create the directory if needed
+ mkdir(dirname("$page.md"), null, true);
+ }
+
if(file_put_contents("$page.md", htmlentities($_POST["content"]), ENT_QUOTES) !== false)
{
//update the page index
diff --git a/modules/page-list.php b/modules/page-list.php
index 29e07cd..f0ae22b 100644
--- a/modules/page-list.php
+++ b/modules/page-list.php
@@ -17,6 +17,7 @@ register_module([
Last Editor |
Last Edit Time |
\n";
+ // todo list the pages in alphabetical order
foreach($pageindex as $pagename => $pagedetails)
{
$content .= "\t\t