Browse Source

Updated documentation

pull/4/head
Jeffery R 6 years ago
parent
commit
9dfd7b0ba7
12 changed files with 80 additions and 27 deletions
  1. +1
    -0
      admin/addCategory.js
  2. +7
    -0
      downloads/downloads.js
  3. +7
    -1
      posts/category.js
  4. +5
    -1
      posts/homePage.js
  5. +5
    -12
      server.js
  6. +0
    -1
      sidebar/categoriesSideBar.js
  7. +10
    -5
      sidebar/popularPosts.js
  8. +9
    -3
      sidebar/recentPosts.js
  9. +8
    -1
      sidebar/sidebar.js
  10. +0
    -1
      utils/generateSiteMap.js
  11. +22
    -2
      utils/sql.js
  12. +6
    -0
      utils/utils.js

+ 1
- 0
admin/addCategory.js View File

@ -71,6 +71,7 @@ var processPost = function(res, postData)
});
};
module.exports=
{
main: function(res, postData)

+ 7
- 0
downloads/downloads.js View File

@ -13,6 +13,13 @@ const sql = require('../utils/sql');
module.exports=
{
/**
* TODO
* @param res
* @param requestURL
* @param request
* @returns {*|Promise}
*/
main: function(res, requestURL, request)
{
res.setHeader('Content-disposition', 'attachment; filename=dramaticpenguin.MOV');

+ 7
- 1
posts/category.js View File

@ -3,7 +3,13 @@ const sql = require('../utils/sql');
const utils = require('../utils/utils.js');
/**
* Renders all posts in a single category
*
* @param result
* @param resultURL
* @returns {*}
*/
var renderPosts = function(result, resultURL)
{
var splitURL = resultURL.split("/");

+ 5
- 1
posts/homePage.js View File

@ -6,7 +6,11 @@ const Promise = require('promise');
const postRenderer = require('../posts/singlePost.js');
/**Renders each recent post for the homepage of the website
*
* @param result
* @returns {*|Promise}
*/
var renderRecentPosts = function(result)
{
return new Promise(function(resolve, reject)

+ 5
- 12
server.js View File

@ -14,10 +14,8 @@ var express = require("express");
var session = require('express-session');
const includes = require('./includes/includes.js');
//
const utils = require('./utils/utils.js');
//
// var forceSsl = require('express-force-ssl');
var map = require('./utils/generateSiteMap.js');
map.main();
@ -26,6 +24,10 @@ var app = express();
app.use(session({ secret: utils.getFileLine('../session_secret'), cookie: { maxAge: 6000000 }}));
/**
* Parses the request url and calls correct JS files
*/
app.use(function(request, res)
{
var q = url.parse(request.url, true);
@ -40,10 +42,6 @@ app.use(function(request, res)
{
includes.sendCSS(res, filename)
}
// else if(filename.includes(/download/))
// {
// require("./downloads/downloads.js").main(res, filename, request);
// }
else
{
var file = "";
@ -78,9 +76,4 @@ app.use(function(request, res)
})
}
});
//https.createServer(options, app).listen(443);
http.createServer(app).listen(8080);
//app.use(forceSsl);

+ 0
- 1
sidebar/categoriesSideBar.js View File

@ -30,7 +30,6 @@ module.exports=
res.write("</div></div>");
resolve();
})
});
}
};

+ 10
- 5
sidebar/popularPosts.js View File

@ -3,15 +3,20 @@ const sql = require('../utils/sql');
module.exports=
{
/**Renders the popular posts sidebar.
*
* @param res
* @returns {*|Promise}
*/
main: function(res)
{
console.log("sidebar called");
return new Promise(function(resolve, reject)
{
res.write("<div class=\"w3-card w3-margin\">");
res.write("<div class=\"w3-container w3-padding\"><h4>Popular Posts</h4></div>");
res.write("<div class=\"w3-container w3-padding\">" +
"<h4>Popular Posts</h4></div>");
res.write("<div class=\"w3-sidebar w3-bar-block\">");
@ -21,12 +26,12 @@ module.exports=
{
console.log(cat);
res.write("<a class=\"w3-bar-item w3-button\" href='" + url + "'>" + p.name + "<br></a>");
res.write("<a class=\"w3-bar-item w3-button\" href='"
+ url + "'>" + p.name + "<br></a>");
});
res.write("</div></div>");
resolve();
})
});
});
}
};

+ 9
- 3
sidebar/recentPosts.js View File

@ -3,6 +3,11 @@ const sql = require('../utils/sql');
module.exports=
{
/** Renders the the recent post sidebar.
*
* @param res
* @returns {*|Promise}
*/
main: function(res)
{
return new Promise(function(resolve, reject)
@ -10,7 +15,8 @@ module.exports=
res.write("<div class=\"w3-card w3-margin\">");
res.write("<div class=\"w3-container w3-padding w3-gray\"><h4>Recent Posts</h4></div>");
res.write("<div class=\"w3-container w3-padding w3-gray\">" +
"<h4>Recent Posts</h4></div>");
res.write("<div class=\"w3-bar-block w3-white\">");
@ -19,12 +25,12 @@ module.exports=
posts.forEach(function(p)
{
var url = '/' + p.category + '/' + p.url;
res.write("<a class=\"w3-bar-item w3-button\" href='" + url + "'>" + p.name + "<br></a>");
res.write("<a class=\"w3-bar-item w3-button\" href='"
+ url + "'>" + p.name + "<br></a>");
});
res.write("</div></div>");
resolve();
})
});
}
};

+ 8
- 1
sidebar/sidebar.js View File

@ -3,6 +3,12 @@ var Promise = require('promise');
module.exports=
{
/** Method which renders the entire sidebar through calling
* appropriate widget js files.
*
* @param res
* @returns {*|Promise}
*/
main: function(res)
{
return new Promise(function(resolve, reject)
@ -14,7 +20,8 @@ module.exports=
return require("../sidebar/recentPosts.js").main(res);
}).then(function()
{
return require("../sidebar/categoriesSideBar.js").main(res);
return require("../sidebar/categoriesSideBar.js")
.main(res);
}).then(function()
{
res.write("</div>");

+ 0
- 1
utils/generateSiteMap.js View File

@ -4,7 +4,6 @@ const sql = require('../utils/sql');
module.exports=
{
main: function()
{
sql.getSiteMap().then(function(result)

+ 22
- 2
utils/sql.js View File

@ -81,7 +81,8 @@ module.exports=
return new Promise(function(resolve, reject)
{
fetch("select * from posts where post_id='" + id + "' limit 1").then(function(post)
fetch("select * from posts where post_id='" + id + "' limit 1")
.then(function(post)
{
resolve(post[0]);
}).catch(function(error)
@ -174,6 +175,10 @@ module.exports=
},
/**
* Fetches the recent posts from the database.
* @returns {Array}
*/
getRecentPostSQL: function()
{
return fetch("select * from posts order by post_id desc limit 10");
@ -221,7 +226,10 @@ module.exports=
},
/**
* TODO
* @returns {*|Promise}
*/
getPopularPosts: function()
{
return new Promise(function(resolve, reject)
@ -311,6 +319,12 @@ module.exports=
+ categoryId + "'");
},
/**TODO work on website downloads
*
* @param downloadURL
* @returns {Array}
*/
getDownload: function(downloadURL)
{
var cleanD = sanitizer.sanitize(downloadURL);
@ -318,6 +332,12 @@ module.exports=
return fetch(q);
},
/**
* Based on the post data submitted by the user this function updates
* the information on the post in the database
* @param postData
* @returns {*|the}
*/
editPost: function(postData)
{
var url = postData.edit_name_new.split(" ").join("-").toLowerCase();

+ 6
- 0
utils/utils.js View File

@ -108,6 +108,12 @@ module.exports=
});
},
/**
* Displays 404 error to user
*
* @param result
* @returns {*}
*/
print404: function(result)
{
return this.include(result, "includes/404.html");

Loading…
Cancel
Save