From e10cdbcd4ef06194adeb69cadd93704f215e3888 Mon Sep 17 00:00:00 2001 From: jrtechs Date: Sat, 8 Dec 2018 17:47:02 -0500 Subject: [PATCH] Added server controls to the admin page for clear cache and pull from git. --- admin/posts/newPost.html | 77 ++++++++++++++++++++++++++-------------- admin/posts/newPost.js | 10 ++++++ includes/includes.js | 9 +++++ sites/blog.js | 9 +++++ 4 files changed, 78 insertions(+), 27 deletions(-) diff --git a/admin/posts/newPost.html b/admin/posts/newPost.html index c11065a..35f1333 100644 --- a/admin/posts/newPost.html +++ b/admin/posts/newPost.html @@ -1,31 +1,54 @@ -
-

New Post

- -
- -
- - -
- -
- - -
- -
- - -
+
+
+

Server Controls

- -
- - -
- + + + + + + +
+ +
+ + +
+
- + +
+
+
+

New Post

+ +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ + +
+ + +
+
+ +
+
+
\ No newline at end of file diff --git a/admin/posts/newPost.js b/admin/posts/newPost.js index f0d2cc5..f7e3ac8 100644 --- a/admin/posts/newPost.js +++ b/admin/posts/newPost.js @@ -36,6 +36,16 @@ const processPost = function(postData) reject(error); }) } + else if(post.clear_cache) + { + require("../../sites/blog.js").clearCache(); + require("../../includes/includes.js").clearCache(); + } + else if(post.git_pull) + { + const execSync = require('child_process').execSync; + code = execSync('git pull') + } else { resolve(""); diff --git a/includes/includes.js b/includes/includes.js index cb816d7..33cb075 100644 --- a/includes/includes.js +++ b/includes/includes.js @@ -166,5 +166,14 @@ module.exports = sendSVG: function(result, fileName) { sendCachedContent(fileName, 'image/svg+xml', result); + }, + + /** + * Clears the cache + */ + clearCache: function() + { + console.log("Includes cache cleared"); + cache.clear(); } }; \ No newline at end of file diff --git a/sites/blog.js b/sites/blog.js index b0b20c3..38ca2c0 100644 --- a/sites/blog.js +++ b/sites/blog.js @@ -79,5 +79,14 @@ module.exports= result.end(); } } + }, + + /** + * Clears the memory cache. + */ + clearCache: function() + { + console.log("Blog cache cleared"); + cache.clear(); } }; \ No newline at end of file