Browse Source

Got the project sites working and fixed bug with pagination bar.

pull/61/head
jrtechs 5 years ago
parent
commit
4963cbe0aa
7 changed files with 32 additions and 76 deletions
  1. +5
    -3
      blog/renderNextBar.js
  2. +1
    -1
      includes/includes.js
  3. +0
    -10
      routes/includes/index.js
  4. +3
    -1
      routes/index.js
  5. +23
    -1
      routes/projects/index.js
  6. +0
    -59
      server.js
  7. +0
    -1
      sites/projects.js

+ 5
- 3
blog/renderNextBar.js View File

@ -40,14 +40,16 @@ module.exports=
var nextPage = currentPage + 1;
var previousPage = currentPage - 1;
var strippedURL = baseURL.split("?page=")[0];
if (isValidPage(previousPage, postsPerPage, totalPosts))
{
paginationObject.previous = {url: baseURL + "?page=" + previousPage};
paginationObject.previous = {url: strippedURL + "?page=" + previousPage};
}
if (isValidPage(nextPage, postsPerPage, totalPosts))
{
paginationObject.next = {url: baseURL + "?page=" + nextPage};
paginationObject.next = {url: strippedURL + "?page=" + nextPage};
}
var page = 1;
@ -60,7 +62,7 @@ module.exports=
}
else
{
pages.push({number: page, url: baseURL + "?page=" + page})
pages.push({number: page, url: strippedURL + "?page=" + page})
}
page = page + 1;
}

+ 1
- 1
includes/includes.js View File

@ -201,7 +201,7 @@ module.exports =
*/
sendHTML: function(result, fileName)
{
readFile("." + fileName).then(function(content)
readFile(fileName).then(function(content)
{
result.writeHead(200, {'Content-Type': 'text/html'});
result.write(content);

+ 0
- 10
routes/includes/index.js View File

@ -1,22 +1,12 @@
const routes = require('express').Router();
/** used to parse the request URL */
const url = require('url');
const contentLoader = require('../../includes/staticContentServer.js');
routes.get('*', (request, result) =>
{
var filename = url.parse(request.url, true).pathname;
console.log(request.originalURL);
console.log(request.url.path);
if(!contentLoader.serveStaticContent(request, result, request.originalUrl, ""))
{
//missing content
}
});

+ 3
- 1
routes/index.js View File

@ -28,7 +28,9 @@ routes.use('/category', category);
const pageBuilder = require('../utils/pageBuilder');
const projects = ["/steam/"];
const project = require('./projects');
routes.use('/steam', project);
//blog home page

+ 23
- 1
routes/projects/index.js View File

@ -1,8 +1,30 @@
const routes = require('express').Router();
routes.get('/', (request, result) =>
const url = require('url');
const contentLoader = require('../../includes/staticContentServer.js');
routes.get('*', (request, result) =>
{
var filename = url.parse(request.url, true).pathname;
var extra = '';
if(filename === '/')
{
if(request.originalUrl.charAt(request.originalUrl.length -1) !== '/')
{
result.redirect(request.originalUrl + "/");
}
else
{
extra = "/index.html";
}
}
if(!contentLoader.serveStaticContent(request, result,
request.originalUrl + extra, "blogContent/projects"))
{
}
});
module.exports = routes;

+ 0
- 59
server.js View File

@ -17,13 +17,9 @@ const express = require("express");
/** express app */
const app = express();
/** server side logging */
const sql = require('./utils/sql');
/** Used for gzip compression */
const compression = require('compression');
/**Updates the site map whenever the server is started */
const map = require('./utils/generateSiteMap.js');
map.main();
@ -35,64 +31,9 @@ const session = require('express-session');
/**Initializes sessions for login */
app.use(session({ secret: config.SESSION_SECRET, cookie: { maxAge: 6000000 }}));
const routes = require('./routes');
app.use('/', routes);
// /**
// * Parses the request url and calls correct JS files
// */
// app.use(function(request, result)
// {
// //prevents people from pointing their dns at my IP:port for my site
// if(request.headers.host.includes("localhost:" + port) ||
// request.headers.host.includes("jrtechs.net"))
// {
// const filename = url.parse(request.url, true).pathname;
//
// var project = false;
// projects.forEach(function(projectName)
// {
// if(filename.startsWith(projectName))
// {
// require("./sites/projects.js").main(request, result, projectName);
// project = true;
// }
// });
//
// if(filename.startsWith("/admin"))
// {
// require("./sites/admin.js").main(request, result, filename);
// project = true;
// }
//
// if(!project)
// {
// require("./sites/blog.js").main(request, result, filename);
// }
//
// try
// {
// const getClientAddress = (request.headers['x-forwarded-for'] || '').split(',')[0]
// || request.connection.remoteAddress;
// console.log(getClientAddress);
//
// sql.logTraffic(getClientAddress, filename);
// }
// catch (e)
// { }
// }
// else
// {
// // utils.printWrongHost(result);
// result.writeHead(418, {});
// result.end();
// }
// });
//enables gzip compression for the site
app.use(compression());

+ 0
- 1
sites/projects.js View File

@ -29,7 +29,6 @@ module.exports=
filename = baseURL + "index.html";
}
if (!contentLoader.serveStaticContent(request, result, filename, "/blogContent/projects"))
{
console.log(filename);

Loading…
Cancel
Save