Browse Source

Made the SQL structures in a markdown file.

pull/4/head
jrtechs 7 years ago
parent
commit
c5abcd8c94
5 changed files with 66 additions and 16 deletions
  1. +45
    -0
      README.md
  2. +1
    -3
      includes/includes.js
  3. +0
    -0
      posts/category.js
  4. +20
    -13
      server.js
  5. +0
    -0
      utils/utils.js

+ 45
- 0
README.md View File

@ -1,2 +1,47 @@
# NodeJSBlog
Recreating my wordpress blog in node JS.
##MYSQL Information
'''sql
create database blog_name;
use blog_name;
create table users(
user_id mediumint unsigned not null AUTO_INCREMENT,
first_name varchar(20) not null,
last_name varchar(40) not null,
user_name varchar(60) not null,
pass char(40) not null,
registration_date datetime not null,
admin boolean not null,
primary key(user_id)
);
create table categories(
category_id mediumint unsigned not null AUTO_INCREMENT,
name varchar(60) not null,
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)
);
create table popular_posts(
popular_post_id mediumint unsigned not null AUTO_INCREMENT,
post_id mediumint unsigned not null,
primary key(popular_post_id)
);
grant all on blog_name.* to blog_user@localhost identified by "password";
'''

includes.js → includes/includes.js View File

@ -2,7 +2,7 @@
Includes.js
File used for getting the header and footer
*/
const utils = require('./utils.js');
const utils = require('../utils/utils.js');
const HEADER_FILE = "includes/header.html";
@ -14,11 +14,9 @@ module.exports =
{
res.writeHead(200, {'Content-Type': 'text/html'});
utils.include(res, HEADER_FILE);
//res.write("Header<br>");
},
printFooter: function(res)
{
//res.write("footer");
utils.include(res, FOOTER_FILE);
res.end();
}

category.js → posts/category.js View File


+ 20
- 13
server.js View File

@ -1,8 +1,14 @@
var http = require('http');
/**
* Main server file for the blog. This file is responsible for
* creating the server and listening for clients. The main run
* function parses the url and calls a sub module to make the
* appropriate pages.
*/
const http = require('http');
const url = require('url');
const fs = require('fs');
const utils = require('./utils.js');
const includes = require('./includes.js');
const includes = require('./includes/includes.js');
http.createServer(function (req, res)
{
@ -12,24 +18,25 @@ http.createServer(function (req, res)
//prints header
includes.printHeader(res);
utils.include(res, "README.md");
if(filename.includes("/category"))
{
console.log("categories");
test();
//categories or view a category page
}
else if(filename.includes("/posts/"))
else if(filename.includes("/downloads/"))
{
console.log("posts");
//downloads page
//probably will be implemented later
}
else if(filename.includes("/downloads/"))
else if(filename.includes("/admin"))
{
console.log("downloads");
//admin page
}
else
{
console.log("default");
//normal blog entry
}
//includes footer file
includes.printFooter(res);
}).listen(8080);

utils.js → utils/utils.js View File


Loading…
Cancel
Save