diff --git a/admin.js b/admin.js new file mode 100644 index 0000000..ece99b5 --- /dev/null +++ b/admin.js @@ -0,0 +1,85 @@ +/** + * 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. + * + * @author Jeffery Russell 7-21-18 + */ + +const http = require('http'); + +const url = require('url'); + +const express = require("express"); + +const session = require('express-session'); + +const includes = require('./includes/includes.js'); + +const app = express(); + +const utils = require('./utils/utils.js'); + +const port = 8001; + +const cache = require('memory-cache'); + +/** Initializes sessions for login */ +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) +{ + if(request.headers.host.includes("localhost:" + port) || + request.headers.host.includes("jrtechs.net")) + { + const filename = url.parse(request.url, true).pathname; + + //handles image requests + if(filename.includes("/img/") || filename.includes(".jpg") || filename.includes(".png")) + { + require("./img/image.js").main(res, filename, cache); + } + else if(filename.includes("/css/") || filename.includes(".woff2")) + { + includes.sendCSS(res, filename, cache) + } + else if(filename.includes("/js/") || filename.includes(".js")) + { + require("./js/js.js").main(res, filename, cache); + } + else + { + res.writeHead(200, {'Content-Type': 'text/html'}); + + file = "./admin/admin.js"; + + Promise.all([includes.printAdminHeader(), + require(file).main(filename, request), + includes.printFooter()]).then(function(content) + { + res.write(content.join('')); + res.end(); + + }).catch(function(err) + { + console.log(err); + throw err; + }); + } + } + else + { + // utils.printWrongHost(res); + res.writeHead(418, {}); + res.end(); + } +}); + +http.createServer(app).listen(port); + + diff --git a/css/code.css b/css/code.css index bd778a7..6d6afbc 100644 --- a/css/code.css +++ b/css/code.css @@ -127,3 +127,40 @@ pre .chunk { pre .tex .formula { opacity: 0.5; } + + +.hemisu-comment, pre .comment, pre .xml .doctype, pre .html .doctype { + color: #999999; +} + +.hemisu-accent1, pre .number, pre .ruby .keyword { + color: #538192; +} + +.hemisu-accent2, pre .string, pre .regexp, pre .xml .value, pre .html .value { + color: #739200; +} + +.hemisu-accent3, pre .keyword, pre .title, pre .constant, pre .xml .tag, pre .html .tag, pre .css .rules .attribute { + color: #ff0055; +} + +.hemisu-accent4 { + color: #503d15; +} + +pre code { + display: block; + background: white; + color: #111111; + font-family: Menlo, Monaco, Consolas, monospace; + line-height: 1.5; + border: 1px solid #ccc; + padding: 10px; +} +pre .xml .tag .title { + color: #111111; +} +pre .html .tag .title { + color: #111111; +} \ No newline at end of file diff --git a/entries/web-development/media/a6594f978c7925bcf3194a1c97029bd3.png b/entries/web-development/media/a6594f978c7925bcf3194a1c97029bd3.png deleted file mode 100644 index 89a9531..0000000 Binary files a/entries/web-development/media/a6594f978c7925bcf3194a1c97029bd3.png and /dev/null differ diff --git a/entries/web-development/media/websiteOptimization/finalResults.png b/entries/web-development/media/websiteOptimization/finalResults.png new file mode 100644 index 0000000..93f488f Binary files /dev/null and b/entries/web-development/media/websiteOptimization/finalResults.png differ diff --git a/includes/adminHeader.html b/includes/adminHeader.html new file mode 100644 index 0000000..2f0e466 --- /dev/null +++ b/includes/adminHeader.html @@ -0,0 +1,62 @@ + + + + + Jrtechs + + + + + + + + + + + + + + + + + + +




+ +
+
\ No newline at end of file diff --git a/includes/footer.html b/includes/footer.html index bd353d4..d8252ba 100644 --- a/includes/footer.html +++ b/includes/footer.html @@ -53,6 +53,9 @@ + + + \ No newline at end of file diff --git a/includes/header.html b/includes/header.html index 4ae3917..25529b9 100644 --- a/includes/header.html +++ b/includes/header.html @@ -1,6 +1,6 @@ - + Jrtechs @@ -10,6 +10,8 @@ + + diff --git a/includes/includes.js b/includes/includes.js index b9c46b1..0b8cf06 100644 --- a/includes/includes.js +++ b/includes/includes.js @@ -8,6 +8,8 @@ const HEADER_FILE = "includes/header.html"; const FOOTER_FILE = "includes/footer.html"; +const ADMIN_HEADER = "includes/adminHeader.html"; + const Promise = require('promise'); const crypto = require('crypto'); @@ -36,6 +38,16 @@ module.exports = return utils.include(FOOTER_FILE); }, + /** + * Displays the admin header + * + * @returns {*|Promise} + */ + printAdminHeader() + { + return utils.include(ADMIN_HEADER); + }, + /**Sends a css file to the user * diff --git a/optimizeImages.sh b/optimizeImages.sh index c405ffa..042db2b 100644 --- a/optimizeImages.sh +++ b/optimizeImages.sh @@ -15,10 +15,9 @@ for folder in "${folders[@]}"; do jpegoptim --max=80 --strip-all --preserve --totals --all-progressive "$f" done - for f in $(find $folder -name '*.png' -or -name '*.PNG'); do - convert "$f" -resize $WIDTH "$f" optipng -o7 -preserve "$f" done + done \ No newline at end of file diff --git a/sitemap.txt b/sitemap.txt index 9cf19f3..6ce4dc5 100644 --- a/sitemap.txt +++ b/sitemap.txt @@ -5,7 +5,11 @@ http://jrtechs.net/category/test http://jrtechs.net/category/testing-2 http://jrtechs.net/category/testing-three 3 http://jrtechs.net/category/other +http://jrtechs.net/category/web-development +http://jrtechs.net/category/web-development http://jrtechs.net/projects/steam-friends-graph http://jrtechs.net/projects/java-fibonacci-solver http://jrtechs.net/projects/musical-floppy-drive-build-log http://jrtechs.net/java/top-three-recommended-java-ides +http://jrtechs.net/web-development/node-website-optimization +http://jrtechs.net/web-development/node-website-optimization