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.

48 lines
1.4 KiB

  1. const utils = require('../utils/utils.js');
  2. var Promise = require('promise');
  3. var session = require('client-sessions');
  4. module.exports=
  5. {
  6. /**
  7. * Method calls the admin widgets it correct order
  8. *
  9. * @param result
  10. * @param fileName
  11. * @param request
  12. * @return {*|Promise}
  13. */
  14. main: function(result, fileName, request)
  15. {
  16. result.write("<div class=\"w3-row\">");
  17. return new Promise(function(resolve, reject)
  18. {
  19. if(request.session && request.session.user)
  20. {
  21. console.log("user logged in");
  22. utils.getPostData(request).then(function (postData)
  23. {
  24. return require("../admin/newPost.js").main(result, postData);
  25. }).then(function(postData)
  26. {
  27. return require("../admin/addCategory.js").main(result, postData);
  28. }).then(function()
  29. {
  30. result.write("</div>");
  31. resolve();
  32. });
  33. }
  34. else
  35. {
  36. //login page
  37. require("../admin/login.js").main(result, request).then(function()
  38. {
  39. resolve();
  40. }).catch(function(err)
  41. {
  42. console.log(err);
  43. })
  44. }
  45. });
  46. }
  47. };