From 6e6e26ad260b9e5bf1f622ab6e916be35557c722 Mon Sep 17 00:00:00 2001
From: mmk2410
Date: Sun, 6 Dec 2015 15:19:16 +0100
Subject: [PATCH] Delete Posts Edit Posts Back to blog
---
articles/main/2015-07-24-example.md | 3 +
config.php | 2 +-
rcc/edit/index.php | 112 +++++++++++
rcc/index.php | 283 ++++++++++++++++------------
rcc/res/delete.js | 62 ++++++
rcc/res/delete_post.php | 25 +++
rcc/res/edit.js | 72 +++++++
rcc/res/get_posts.php | 25 +++
rcc/res/rcc.css | 9 +
rcc/res/save.php | 22 +++
res/php/ArticleGenerator.php | 80 +++++++-
11 files changed, 574 insertions(+), 121 deletions(-)
mode change 100644 => 100755 articles/main/2015-07-24-example.md
create mode 100644 rcc/edit/index.php
create mode 100644 rcc/res/delete.js
create mode 100644 rcc/res/delete_post.php
create mode 100644 rcc/res/edit.js
create mode 100644 rcc/res/get_posts.php
create mode 100644 rcc/res/save.php
diff --git a/articles/main/2015-07-24-example.md b/articles/main/2015-07-24-example.md
old mode 100644
new mode 100755
index c9865d0..5a17e74
--- a/articles/main/2015-07-24-example.md
+++ b/articles/main/2015-07-24-example.md
@@ -1,7 +1,10 @@
%TITLE: The Rangitaki logo
%DATE: 24 July 2015
+%AUTHOR: The great testers
%TAGS: design, artwork, logo
+
This is the official Rangitaki logo.
![The Rangitaki logo](media/example.png)
+
\ No newline at end of file
diff --git a/config.php b/config.php
index 041068c..c796691 100644
--- a/config.php
+++ b/config.php
@@ -15,7 +15,7 @@ $bloghome = 'yes';
$bloghomeurl = '../';
// Home name - Set here an individual name for your main page
$bloghomename = 'Home';
-// Main Blog name -> Set a specific name for your name blog
+// Main Blog name -> Set a specific name for your main blog
// This value is empty by default
$blogmainname = '';
// Intro - set yes if you have a blog intro and no if you don't have one
diff --git a/rcc/edit/index.php b/rcc/edit/index.php
new file mode 100644
index 0000000..7875fe5
--- /dev/null
+++ b/rcc/edit/index.php
@@ -0,0 +1,112 @@
+
+
+
+
+
+
+ Rangitaki Control Center
+
+
+
+
+
+
+
+
+
+
+
diff --git a/rcc/index.php b/rcc/index.php
index 198c130..f158887 100644
--- a/rcc/index.php
+++ b/rcc/index.php
@@ -23,136 +23,183 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
-
-
- Rangitaki Control Center
-
-
-
-
-
- The Rangitaki Control Center is disabled. You can enable it in your config file. But please read first the documentation.
+ Please go back and try again.
+
+
+
+
+
diff --git a/rcc/res/delete.js b/rcc/res/delete.js
new file mode 100644
index 0000000..a48d5c3
--- /dev/null
+++ b/rcc/res/delete.js
@@ -0,0 +1,62 @@
+/**
+ * Created by mmk2410 on 12/6/15.
+ *
+ * JavaScript for the functionality to delete blogs
+ */
+
+function main() {
+
+ // listener and function for recieving the posts of the selected blogs
+ $("#delete_get_posts").click(function () {
+ var selectedBlog = $("#delete_selected_blog").val();
+ $.get("res/get_posts.php", {
+ blog: selectedBlog
+ }, function (data) {
+ $("#delete_select_post").remove();
+ $("#delete_select_post_info").remove();
+ $("#delete_post_button").remove();
+ $("#delete_get_posts").after("");
+ $("#delete_get_posts").after("
Now select the post you want to delete. " +
+ "Remember that once a post is deleted it can't be restored.
");
+ $("#delete_select_post").append("");
+ $.each($.parseJSON(data), function (index, value) {
+ var post = value.substring(0, value.length - 3);
+ $("#delete_selected_post").append("");
+ });
+ $("#delete_select_post").after("DELETE POST")
+ });
+ });
+
+}
+
+/**
+ * Delete the selected posts
+ */
+function deletePostButton() {
+
+ var selectedBlog = $("#delete_selected_blog").val();
+ var selectedPost = $("#delete_selected_post").val();
+ $.get("res/delete_post.php", {
+ blog: selectedBlog,
+ post: selectedPost
+ }, function (data) {
+ $("#delete_select_post").remove();
+ $("#delete_select_post_info").remove();
+ $("#delete_post_button").remove();
+ if (data == "901") {
+ alert("ERROR 901: No post as get argument given.");
+ } else if (data == "921") {
+ alert("ERROR 921: No post with given argument available.");
+ } else if (data == "941") {
+ alert("ERROR 941: No blog as get argument given");
+ } else if (data == "961") {
+ alert("ERROR 961: Error while deleting the file. Check if the web server has the permission to do so.");
+ } else if (data == "0") {
+ alert("Post successfully deleted.");
+ }
+ });
+
+}
+
+$(document).ready(main());
\ No newline at end of file
diff --git a/rcc/res/delete_post.php b/rcc/res/delete_post.php
new file mode 100644
index 0000000..3770461
--- /dev/null
+++ b/rcc/res/delete_post.php
@@ -0,0 +1,25 @@
+
");
+ $("#edit_get_posts").after("
Now select the post you want to edit.
");
+ $("#edit_select_post").append("");
+ $.each($.parseJSON(data), function (index, value) {
+ var post = value.substring(0, value.length - 3);
+ $("#edit_selected_post").append("");
+ });
+ $("#edit_select_post").after("EDIT POST")
+ });
+ });
+
+ $("#save_changes").click(function () {
+ var postTitle = $("#title").val();
+ var postDate = $("#date").val();
+ var postAuthor = $("#author").val();
+ var postTags = $("#tags").val();
+ var postText = $("#text").val();
+
+ var file = "../../articles/" + getVariables['blog'] + "/" + getVariables['post'] + ".md";
+ console.log(file);
+
+ $.post("../res/save.php", {
+ title: postTitle,
+ date: postDate,
+ author: postAuthor,
+ tags: postTags,
+ text: postText,
+ file: file
+ }, function (data) {
+ if (data == "0") {
+ alert("File successfully changed.");
+ window.open("../");
+ } else if (data == "1") {
+ alert("Error while saving the changes.");
+ } else if (data == "-1") {
+ alert("file");
+ }
+ });
+ });
+}
+
+/**
+ * Delete the selected posts
+ */
+function editPostButton() {
+
+ var selectedBlog = $("#edit_selected_blog").val();
+ var selectedPost = $("#edit_selected_post").val();
+ var href = "./edit/?blog=" + selectedBlog + "&post=" + selectedPost;
+ window.open(href);
+
+}
+
+$(document).ready(main());
\ No newline at end of file
diff --git a/rcc/res/get_posts.php b/rcc/res/get_posts.php
new file mode 100644
index 0000000..0fd91b2
--- /dev/null
+++ b/rcc/res/get_posts.php
@@ -0,0 +1,25 @@
+ p{
font-size: 14px;
line-height: 24px;
diff --git a/rcc/res/save.php b/rcc/res/save.php
new file mode 100644
index 0000000..bd96296
--- /dev/null
+++ b/rcc/res/save.php
@@ -0,0 +1,22 @@
+