Browse Source

Created admin server and fixed code highlighting.

pull/4/head
jrtechs 6 years ago
parent
commit
8161f86c5f
10 changed files with 207 additions and 3 deletions
  1. +85
    -0
      admin.js
  2. +37
    -0
      css/code.css
  3. BIN
      entries/web-development/media/a6594f978c7925bcf3194a1c97029bd3.png
  4. BIN
      entries/web-development/media/websiteOptimization/finalResults.png
  5. +62
    -0
      includes/adminHeader.html
  6. +3
    -0
      includes/footer.html
  7. +3
    -1
      includes/header.html
  8. +12
    -0
      includes/includes.js
  9. +1
    -2
      optimizeImages.sh
  10. +4
    -0
      sitemap.txt

+ 85
- 0
admin.js View File

@ -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);

+ 37
- 0
css/code.css View File

@ -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;
}

BIN
entries/web-development/media/a6594f978c7925bcf3194a1c97029bd3.png View File

Before After
Width: 1230  |  Height: 744  |  Size: 140 KiB

BIN
entries/web-development/media/websiteOptimization/finalResults.png View File

Before After
Width: 966  |  Height: 285  |  Size: 82 KiB

+ 62
- 0
includes/adminHeader.html View File

@ -0,0 +1,62 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Jrtechs</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/css/code.css" media="screen">
<link rel="stylesheet" href="/css/bootstrap.css" media="screen">
<meta name="description" content="Blog of Jeffery Russell, featuring technical guides, and projects.">
<meta name="author" content="Jeffery Russell">
<style>
html, body, h1, h2, h3, h4, h5, h6 {
font-family: 'Open Sans', sans-serif;
}
p{font-size:18px;}
</style>
</head>
<body>
<div class="navbar navbar-expand-lg navbar-dark fixed-top bg-primary" id="mainNav">
<div class="container">
<a class="navbar-brand" href="#">Jrtechs</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="https://jrtechs.net">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://jrtechs.me/#contact">Contact</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="nav-item">
<a class="nav-link" href="https://jrtechs.me">Resume</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://github.com/jrtechs">Github</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://www.youtube.com/c/JrtechsNet">Youtube</a>
</li>
</ul>
</div>
</div>
</div>
<br><br><br><br><br>
<div class="container">
<div class="row">

+ 3
- 0
includes/footer.html View File

@ -53,6 +53,9 @@
<script src="/js/navBar.min.js" async></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.9.1/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</body>
</html>

+ 3
- 1
includes/header.html View File

@ -1,6 +1,6 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<title>Jrtechs</title>
@ -10,6 +10,8 @@
<link rel="stylesheet" href="/css/purge.css" media="screen">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.2.0/styles/default.min.css">
<meta name="description" content="Blog of Jeffery Russell, featuring technical guides, and projects.">
<meta name="author" content="Jeffery Russell">

+ 12
- 0
includes/includes.js View File

@ -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
*

+ 1
- 2
optimizeImages.sh View File

@ -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

+ 4
- 0
sitemap.txt View File

@ -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

Loading…
Cancel
Save