diff --git a/README.md b/README.md index 21d1967..88e168b 100644 --- a/README.md +++ b/README.md @@ -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"; + +''' diff --git a/includes.js b/includes/includes.js similarity index 80% rename from includes.js rename to includes/includes.js index e3ecf43..6cccef8 100644 --- a/includes.js +++ b/includes/includes.js @@ -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
"); }, printFooter: function(res) { - //res.write("footer"); utils.include(res, FOOTER_FILE); res.end(); } diff --git a/category.js b/posts/category.js similarity index 100% rename from category.js rename to posts/category.js diff --git a/server.js b/server.js index dd5410a..910a8e6 100644 --- a/server.js +++ b/server.js @@ -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); \ No newline at end of file diff --git a/utils.js b/utils/utils.js similarity index 100% rename from utils.js rename to utils/utils.js