Browse Source

Started working on admin's post entry page

pull/4/head
jrtechs 7 years ago
parent
commit
bf8512006f
8 changed files with 85 additions and 295 deletions
  1. +0
    -2
      README.md
  2. +12
    -9
      admin/addCategory.html
  3. +10
    -2
      admin/addCategory.js
  4. +6
    -1
      admin/admin.js
  5. +29
    -0
      admin/newPost.html
  6. +27
    -0
      admin/newPost.js
  7. +0
    -280
      admin/test.html
  8. +1
    -1
      posts/singlePost.js

+ 0
- 2
README.md View File

@ -29,10 +29,8 @@ primary key(category_id)
create table posts(
post_id mediumint unsigned not null AUTO_INCREMENT,
category_id mediumint unsigned not null,
user_id mediumint unsigned not null,
picture_url varchar(100) not null,
published datetime not null,
url varchar(100) not null,
name varchar(100) not null,
primary key(post_id)
);

+ 12
- 9
admin/addCategory.html View File

@ -1,10 +1,13 @@
<h1 class="w3-text-teal w3-center">Add Category</h1>
<div class="w3-third w3-container">
<form action="/admin/" method ="post" class="w3-container w3-card-4">
<div class="w3-group w3-padding-16">
<input class="w3-input" type="text" name="add_category" required>
<label class="w3-label w3-validate">Category</label>
</div>
<p><input type="submit" name="submit" value="Add"
class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align"/></p>
</form>
<h1 class="w3-text-teal w3-center">Add Category</h1>
<form action="/admin/" method ="post" class="w3-container w3-card-4">
<div class="w3-group w3-padding-16">
<input class="w3-input" type="text" name="add_category" required>
<label class="w3-label w3-validate">Category</label>
</div>
<p><input type="submit" name="submit" value="Add"
class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align"/></p>
</form>
</div>

+ 10
- 2
admin/addCategory.js View File

@ -5,7 +5,6 @@ const qs = require('querystring');
var Promise = require('promise');
module.exports=
{
main: function(res, postData)
@ -13,6 +12,15 @@ module.exports=
utils.include(res, "./admin/addCategory.html");
return this.processPost(res, postData);
},
/**
* Checks for post data regarding adding a new category.
* If a post is made with add_category, it parses the url-- replaces spaces
* with dashes -- and calls a insert method on the database
*
* @param res
* @param postData
* @return {*|Promise}
*/
processPost: function(res, postData)
{
return new Promise(function(resolve, reject)
@ -34,7 +42,7 @@ module.exports=
}
}
resolve();
resolve(postData);
});
}
};

+ 6
- 1
admin/admin.js View File

@ -15,14 +15,19 @@ module.exports=
{
return new Promise(function(resolve, reject)
{
result.write("<div class=\"w3-row\">");
utils.getPostData(request).then(function (postData)
{
return require("../admin/newPost.js").main(result, postData);
}).then(function(postData)
{
return require("../admin/addCategory.js").main(result, postData);
}).then(function()
{
console.log("admin page ended");
resolve();
});
})
result.write("</div>");
});
}
};

+ 29
- 0
admin/newPost.html View File

@ -0,0 +1,29 @@
<div class="w3-twothird w3-container">
<h1 class="w3-text-teal w3-center">New Post</h1>
<form action="/admin/" method ="post" class="w3-container w3-card-4">
<!-- Post category -->
<div class="w3-group w3-padding-16">
<input class="w3-input" type="text" name="add_post_category" required>
<label class="w3-label w3-validate">Category</label>
</div>
<!-- Post name -->
<div class="w3-group w3-padding-16">
<input class="w3-input" type="text" name="add_post_name" required>
<label class="w3-label w3-validate">Name</label>
</div>
<!-- Post header picture -->
<div class="w3-group w3-padding-16">
<input class="w3-input" type="text" name="add_post_picture" required>
<label class="w3-label w3-validate">Picture</label>
</div>
<!-- Post date -->
<div class="w3-group w3-padding-16">
<input class="w3-input" type="date" name="add_post_date" required>
<label class="w3-label w3-validate">Date</label>
</div>
<p><input type="submit" name="submit" value="Add"
class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align"/></p>
</form>
</div>

+ 27
- 0
admin/newPost.js View File

@ -0,0 +1,27 @@
const utils = require('../utils/utils.js');
const sql = require('../utils/sql');
const qs = require('querystring');
var Promise = require('promise');
module.exports=
{
main: function(res, postData)
{
utils.include(res, "./admin/newPost.html");
return this.processPost(res, postData);
},
processPost: function(res, postData)
{
return new Promise(function(resolve, reject)
{
var post = qs.parse(postData);
if(post.add_post_name)
{
}
resolve(postData);
});
}
};

+ 0
- 280
admin/test.html View File

@ -1,280 +0,0 @@
<!DOCTYPE html>
<html>
<title>W3.CSS Template</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway">
<style>
body,h1,h2,h3,h4,h5 {font-family: "Raleway", sans-serif}
</style>
<body class="w3-light-grey">
<!-- w3-content defines a container for fixed size centered content,
and is wrapped around the whole page content, except for the footer in this example -->
<div class="w3-content" style="max-width:1400px">
<!-- Header -->
<header class="w3-container w3-center w3-padding-32">
<h1><b>MY BLOG</b></h1>
<p>Welcome to the blog of <span class="w3-tag">unknown</span></p>
</header>
<!-- Grid -->
<div class="w3-row">
<!-- Blog entries -->
<div class="w3-col l8 s12">
<!-- Blog entry -->
<div class="w3-card-4 w3-margin w3-white">
<img src="/w3images/woods.jpg" alt="Nature" style="width:100%">
<div class="w3-container">
<h3><b>TITLE HEADING</b></h3>
<h5>Title description, <span class="w3-opacity">April 7, 2014</span></h5>
</div>
<div class="w3-container">
<p>Mauris neque quam, fermentum ut nisl vitae, convallis maximus nisl. Sed mattis nunc id lorem euismod placerat. Vivamus porttitor magna enim, ac accumsan tortor cursus at. Phasellus sed ultricies mi non congue ullam corper. Praesent tincidunt sed
tellus ut rutrum. Sed vitae justo condimentum, porta lectus vitae, ultricies congue gravida diam non fringilla.</p>
</div>
</div>
<hr>
<!-- Blog entry -->
<div class="w3-card-4 w3-margin w3-white">
<img src="/w3images/bridge.jpg" alt="Norway" style="width:100%">
<div class="w3-container">
<h3><b>BLOG ENTRY</b></h3>
<h5>Title description, <span class="w3-opacity">April 2, 2014</span></h5>
</div>
<div class="w3-container">
<p>Mauris neque quam, fermentum ut nisl vitae, convallis maximus nisl. Sed mattis nunc id lorem euismod placerat. Vivamus porttitor magna enim, ac accumsan tortor cursus at. Phasellus sed ultricies mi non congue ullam corper. Praesent tincidunt sed
tellus ut rutrum. Sed vitae justo condimentum, porta lectus vitae, ultricies congue gravida diam non fringilla.</p>
<div class="w3-row">
<div class="w3-col m8 s12">
<p><button class="w3-button w3-padding-large w3-white w3-border"><b>READ MORE &raquo;</b></button></p>
</div>
<div class="w3-col m4 w3-hide-small">
<p><span class="w3-padding-large w3-right"><b>Comments &nbsp;</b> <span class="w3-badge">2</span></span></p>
</div>
</div>
</div>
</div>
<!-- END BLOG ENTRIES -->
</div>
<!-- Introduction menu -->
<div class="w3-col l4">
<!-- About Card -->
<div class="w3-card w3-margin w3-margin-top">
<img src="/w3images/avatar_g.jpg" style="width:100%">
<div class="w3-container w3-white">
<h4><b>My Name</b></h4>
<p>Just me, myself and I, exploring the universe of uknownment. I have a heart of love and a interest of lorem ipsum and mauris neque quam blog. I want to share my world with you.</p>
</div>
</div><hr>
<!-- Posts -->
<div class="w3-card w3-margin">
<div class="w3-container w3-padding">
<h4>Popular Posts</h4>
</div>
<ul class="w3-ul w3-hoverable w3-white">
<li class="w3-padding-16">
<img src="/w3images/workshop.jpg" alt="Image" class="w3-left w3-margin-right" style="width:50px">
<span class="w3-large">Lorem</span><br>
<span>Sed mattis nunc</span>
</li>
<li class="w3-padding-16">
<img src="/w3images/gondol.jpg" alt="Image" class="w3-left w3-margin-right" style="width:50px">
<span class="w3-large">Ipsum</span><br>
<span>Praes tinci sed</span>
</li>
<li class="w3-padding-16">
<img src="/w3images/skies.jpg" alt="Image" class="w3-left w3-margin-right" style="width:50px">
<span class="w3-large">Dorum</span><br>
<span>Ultricies congue</span>
</li>
<li class="w3-padding-16 w3-hide-medium w3-hide-small">
<img src="/w3images/rock.jpg" alt="Image" class="w3-left w3-margin-right" style="width:50px">
<span class="w3-large">Mingsum</span><br>
<span>Lorem ipsum dipsum</span>
</li>
</ul>
</div>
<hr>
<!-- Labels / tags -->
<div class="w3-card w3-margin">
<div class="w3-container w3-padding">
<h4>Tags</h4>
</div>
<div class="w3-container w3-white">
<p><span class="w3-tag w3-black w3-margin-bottom">Travel</span> <span class="w3-tag w3-light-grey w3-small w3-margin-bottom">New York</span> <span class="w3-tag w3-light-grey w3-small w3-margin-bottom">London</span>
<span class="w3-tag w3-light-grey w3-small w3-margin-bottom">IKEA</span> <span class="w3-tag w3-light-grey w3-small w3-margin-bottom">NORWAY</span> <span class="w3-tag w3-light-grey w3-small w3-margin-bottom">DIY</span>
<span class="w3-tag w3-light-grey w3-small w3-margin-bottom">Ideas</span> <span class="w3-tag w3-light-grey w3-small w3-margin-bottom">Baby</span> <span class="w3-tag w3-light-grey w3-small w3-margin-bottom">Family</span>
<span class="w3-tag w3-light-grey w3-small w3-margin-bottom">News</span> <span class="w3-tag w3-light-grey w3-small w3-margin-bottom">Clothing</span> <span class="w3-tag w3-light-grey w3-small w3-margin-bottom">Shopping</span>
<span class="w3-tag w3-light-grey w3-small w3-margin-bottom">Sports</span> <span class="w3-tag w3-light-grey w3-small w3-margin-bottom">Games</span>
</p>
</div>
</div>
<!-- END Introduction Menu -->
</div>
<!-- END GRID -->
</div>
<!-- END w3-content -->
</div>
<!-- Footer -->
<footer class="w3-container w3-dark-grey w3-padding-32 w3-margin-top">
<button class="w3-button w3-black w3-disabled w3-padding-large w3-margin-bottom">Previous</button>
<button class="w3-button w3-black w3-padding-large w3-margin-bottom">Next &raquo;</button>
<p>Powered by <a href="https://www.w3schools.com/w3css/default.asp" target="_blank">w3.css</a></p>
</footer>
</body>
</html>

+ 1
- 1
posts/singlePost.js View File

@ -26,7 +26,7 @@ module.exports=
res.write("<div class=\"w3-container\">");
//include page content
utils.include(res, "../entries/" + post.url).then(function (value) {
utils.include(res, "../entries/" + post.url + ".html").then(function (value) {
res.write("</div></div>");
resolve();
});

Loading…
Cancel
Save