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.

55 lines
1.6 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(postData)
  29. {
  30. result.write("</div>");
  31. console.log("hmmm");
  32. return require("../admin/editPost.js").main(result, postData);
  33. }).then(function()
  34. {
  35. resolve();
  36. }).catch(function(error)
  37. {
  38. throw error;
  39. });
  40. }
  41. else
  42. {
  43. //login page
  44. require("../admin/login.js").main(result, request).then(function()
  45. {
  46. resolve();
  47. }).catch(function(err)
  48. {
  49. console.log(err);
  50. })
  51. }
  52. });
  53. }
  54. };