Browse Source

Merge pull request #33 from jrtechs/AdminUpdate

Admin Update
pull/39/head
Jeffery Russell 5 years ago
committed by GitHub
parent
commit
0b86e70056
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 78 additions and 27 deletions
  1. +50
    -27
      admin/posts/newPost.html
  2. +10
    -0
      admin/posts/newPost.js
  3. +9
    -0
      includes/includes.js
  4. +9
    -0
      sites/blog.js

+ 50
- 27
admin/posts/newPost.html View File

@ -1,31 +1,54 @@
<div class="col-md-6 blogPost">
<h1 class="text-center">New Post</h1>
<form action="/admin" method ="post" class="p-2">
<!-- Post category -->
<div class="form-group">
<input class="form-control" type="text" name="add_post_category" required>
<label class="w3-label w3-validate">Category</label>
</div>
<!-- Post name -->
<div class="form-group">
<input class="form-control" type="text" name="add_post_name" required>
<label class="w3-label w3-validate">Name</label>
</div>
<!-- Post header picture -->
<div class="form-group">
<input class="form-control" type="text" name="add_post_picture" value="n/a" required>
<label class="w3-label w3-validate">Picture</label>
</div>
<div class="col-md-6">
<div class="blogPost">
<h1 class="text-center">Server Controls</h1>
<!-- Post date -->
<div class="form-group">
<input class="w3-input" type="date" name="add_post_date" required>
<label class="w3-label w3-validate">Date</label>
</div>
<div class="text-center">
<input type="submit" name="submit" value="Add"
class="btn btn-lg btn-secondary"/>
<form action="/admin" method="post">
<input type="submit" name="clearCache" value="Clear Cache" class="btn btn-lg btn-secondary" />
<input type="hidden" name="clear_cache" value="true">
</form>
<br>
<form action="/admin" method="post">
<input type="submit" name="gitPull" value="Pull from Git" class="btn btn-lg btn-secondary" />
<input type="hidden" name="git_pull" value="true">
</form>
</div>
</form>
</div>
<br>
<div class="blogPost">
<h1 class="text-center">New Post</h1>
<form action="/admin" method ="post" class="p-2">
<!-- Post category -->
<div class="form-group">
<input class="form-control" type="text" name="add_post_category" required>
<label class="w3-label w3-validate">Category</label>
</div>
<!-- Post name -->
<div class="form-group">
<input class="form-control" type="text" name="add_post_name" required>
<label class="w3-label w3-validate">Name</label>
</div>
<!-- Post header picture -->
<div class="form-group">
<input class="form-control" type="text" name="add_post_picture" value="n/a" required>
<label class="w3-label w3-validate">Picture</label>
</div>
<!-- Post date -->
<div class="form-group">
<input class="w3-input" type="date" name="add_post_date" required>
<label class="w3-label w3-validate">Date</label>
</div>
<div class="text-center">
<input type="submit" name="submit" value="Add"
class="btn btn-lg btn-secondary"/>
</div>
</form>
</div>
</div>

+ 10
- 0
admin/posts/newPost.js View File

@ -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("");

+ 9
- 0
includes/includes.js View File

@ -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();
}
};

+ 9
- 0
sites/blog.js View File

@ -79,5 +79,14 @@ module.exports=
result.end();
}
}
},
/**
* Clears the memory cache.
*/
clearCache: function()
{
console.log("Blog cache cleared");
cache.clear();
}
};

Loading…
Cancel
Save