Personal blog written from scratch using Node.js, Bootstrap, and MySQL. https://jrtechs.net
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.3 KiB

  1. //sending static content
  2. const includes = require('../includes/includes.js');
  3. const whiskers = require('whiskers');
  4. /**
  5. * @author Jeffery Russell 11-3-18
  6. *
  7. * @type {{main: (function(*=, *): Promise)}}
  8. */
  9. module.exports=
  10. {
  11. /**
  12. * Calls blog and sidebar modules to render blog contents in order
  13. *
  14. * @param requestURL
  15. * @returns {Promise|*}
  16. */
  17. main: function(request, result, filename)
  18. {
  19. const clientAddress = (request.headers['x-forwarded-for'] || '').split(',')[0]
  20. || request.connection.remoteAddress;
  21. result.writeHead(200, {'Content-Type': 'text/html'});
  22. const file = "../admin/admin.js";
  23. var templateContext = Object();
  24. Promise.all([includes.fetchTemplate("admin/adminMain.html"),
  25. includes.printAdminHeader(templateContext),
  26. require(file).main(request, clientAddress, templateContext, filename),
  27. includes.printFooter(templateContext),
  28. ]).then(function(content)
  29. {
  30. result.write(whiskers.render(content[0], templateContext));
  31. result.end();
  32. }).catch(function(err)
  33. {
  34. console.log(err);
  35. throw err;
  36. });
  37. }
  38. };