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.

46 lines
1.4 KiB

  1. /**
  2. * Handler for contact page
  3. * @author Jeffery Russell 8-19-18
  4. */
  5. /** used for file IO */
  6. const utils = require('../utils/utils.js');
  7. /** used for static files */
  8. const includes = require('../includes/includes');
  9. const TEMPLATE_FILE = "blog/contact.html";
  10. const whiskers = require('whiskers');
  11. module.exports =
  12. {
  13. /**
  14. * Displays the contact page along with the header, sidebar, and footer.
  15. * This uses the admin header because it doesn't need any minified css
  16. * which has been purged of some css classes which are not used in any
  17. * of the blog blog.
  18. *
  19. * @param request -- main express request
  20. * @param result -- renders the html of the contact page
  21. */
  22. main: function(request, result)
  23. {
  24. result.writeHead(200, {'Content-Type': 'text/html'});
  25. var templateContext = Object();
  26. Promise.all([includes.fetchTemplate(TEMPLATE_FILE),
  27. includes.printHeader(templateContext),
  28. includes.printFooter(templateContext),
  29. require("./sidebar.js").main(templateContext)])
  30. .then(function (content)
  31. {
  32. const html = whiskers.render(content[0], templateContext);
  33. result.write(html);
  34. result.end();
  35. }).catch(function(err)
  36. {
  37. console.log(err);
  38. });
  39. }
  40. };