Browse Source

Fixed the static content server to dish up static images from the blog posts.

pull/61/head
jrtechs 5 years ago
parent
commit
b0a911d7dc
5 changed files with 10 additions and 10 deletions
  1. +0
    -4
      includes/includes.js
  2. +3
    -1
      includes/staticContentServer.js
  3. +6
    -2
      routes/includes/index.js
  4. +1
    -0
      routes/index.js
  5. +0
    -3
      utils/pageBuilder.js

+ 0
- 4
includes/includes.js View File

@ -7,9 +7,6 @@
* @author Jeffery Russell * @author Jeffery Russell
*/ */
//used for file IO
const utils = require('../utils/utils.js');
const HEADER_KEY = "header"; const HEADER_KEY = "header";
const FOOTER_KEY = "footer"; const FOOTER_KEY = "footer";
@ -112,7 +109,6 @@ module.exports =
{ {
readFile(fileName).then(function(result) readFile(fileName).then(function(result)
{ {
console.log(result);
context[key] = result; context[key] = result;
resolve(); resolve();
}).catch(function(error) }).catch(function(error)

+ 3
- 1
includes/staticContentServer.js View File

@ -12,7 +12,9 @@ module.exports=
serveStaticContent: function(request, result, filename, baseURL) serveStaticContent: function(request, result, filename, baseURL)
{ {
fullPath = baseURL + filename;
var fullPath = baseURL + filename;
if(fullPath.charAt(0) === '/')
fullPath = fullPath.substring(1,);
if (filename.includes(".svg") || filename.includes(".svg")) if (filename.includes(".svg") || filename.includes(".svg"))
{ {
includes.sendSVG(result, fullPath); includes.sendSVG(result, fullPath);

+ 6
- 2
routes/includes/index.js View File

@ -10,9 +10,13 @@ const contentLoader = require('../../includes/staticContentServer.js');
routes.get('*', (request, result) => routes.get('*', (request, result) =>
{ {
var filename = url.parse(request.url, true).pathname; var filename = url.parse(request.url, true).pathname;
if(!contentLoader.serveStaticContent(request, result, filename, "includes"))
console.log(request.originalURL);
console.log(request.url.path);
if(!contentLoader.serveStaticContent(request, result, request.originalUrl, ""))
{ {
//missing content //missing content
} }
}); });

+ 1
- 0
routes/index.js View File

@ -19,6 +19,7 @@ routes.use('/downloads', downloads);
/** static content like css, js, and images */ /** static content like css, js, and images */
const includes = require('./includes'); const includes = require('./includes');
routes.use('/includes', includes); routes.use('/includes', includes);
routes.use('/blogContent', includes);
/** category pages */ /** category pages */

+ 0
- 3
utils/pageBuilder.js View File

@ -149,15 +149,12 @@ module.exports =
require("../blog/sidebar.js").main(templateContext)]) require("../blog/sidebar.js").main(templateContext)])
.then(function (content) .then(function (content)
{ {
console.log(JSON.stringify(content));
const html = whiskers.render(content[0], templateContext); const html = whiskers.render(content[0], templateContext);
result.write(html); result.write(html);
result.end(); result.end();
cache.put(filename + "?page=" + page, html); cache.put(filename + "?page=" + page, html);
}).catch(function (err) }).catch(function (err)
{ {
console.log("dewie");
console.log(err);
cache.del(filename + "?page=" + page); cache.del(filename + "?page=" + page);
module.exports.print404(result) module.exports.print404(result)

Loading…
Cancel
Save