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.

54 lines
1.6 KiB

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