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.

47 lines
1.4 KiB

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