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.

52 lines
1.5 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. return new Promise(function(resolve, reject)
  17. {
  18. if(request.session && request.session.user)
  19. {
  20. utils.getPostData(request).then(function (postData)
  21. {
  22. return require("../admin/newPost.js").main(result, postData);
  23. }).then(function(postData)
  24. {
  25. return require("../admin/addCategory.js").main(result, postData);
  26. }).then(function(postData)
  27. {
  28. result.write("</div>"); //ends main row
  29. return require("../admin/editPost.js").main(result, postData);
  30. }).then(function()
  31. {
  32. resolve();
  33. }).catch(function(error)
  34. {
  35. throw error;
  36. });
  37. }
  38. else
  39. {
  40. //login page
  41. require("../admin/login.js").main(result, request).then(function()
  42. {
  43. resolve();
  44. }).catch(function(err)
  45. {
  46. console.log(err);
  47. })
  48. }
  49. });
  50. }
  51. };