elderwand 0.1.74 → 0.1.77

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (445) hide show
  1. package/BaseController/BaseController.js +795 -788
  2. package/Environment/environment.js +2 -2
  3. package/NoDuplicate/README.md +94 -46
  4. package/NoDuplicate/no-duplicate.js +43 -25
  5. package/NoDuplicate/package-lock.json +1420 -0
  6. package/NoDuplicate/package.json +22 -24
  7. package/NoDuplicate/tests/characterization.test.js +359 -0
  8. package/SoftDelete/mongoose-soft-delete.js +60 -8
  9. package/SoftDelete/package-lock.json +1391 -0
  10. package/SoftDelete/package.json +20 -22
  11. package/SoftDelete/tests/characterization.test.js +375 -0
  12. package/ToolBox/RequestTrackTools.js +0 -14
  13. package/ToolBox/Routes.js +148 -54
  14. package/ToolBox/package-lock.json +2533 -0
  15. package/ToolBox/package.json +23 -7
  16. package/ToolBox/tests/event-log.test.js +365 -0
  17. package/ToolBox/tests/helpers.js +241 -0
  18. package/ToolBox/tests/request-track-tools.test.js +197 -0
  19. package/ToolBox/tests/routes.test.js +313 -0
  20. package/package.json +36 -29
  21. package/threads/Workers/ControllerWorker.js +38 -58
  22. package/threads/Workers/DBWorker.js +21 -17
  23. package/threads/Workers/MongoClientWorker.js +36 -24
  24. package/threads/package-lock.json +2082 -27
  25. package/threads/package.json +21 -10
  26. package/threads/tests/CrashWorker.js +17 -0
  27. package/threads/tests/DuplicatePartialWorker.js +32 -0
  28. package/threads/tests/EchoWorker.js +13 -0
  29. package/threads/tests/LargePayloadWorker.js +39 -0
  30. package/threads/tests/MalformedPartialWorker.js +27 -0
  31. package/threads/tests/SlowWorker.js +17 -0
  32. package/threads/tests/StreamingPartialWorker.js +47 -0
  33. package/threads/tests/bug-reproducers.js +309 -0
  34. package/threads/tests/locked-interface.js +250 -0
  35. package/threads/tests/tests.js +529 -46
  36. package/threads/threads.js +440 -363
  37. package/utils/package-lock.json +1343 -0
  38. package/utils/package.json +14 -5
  39. package/utils/tests/coordination.test.js +247 -0
  40. package/utils/tests/crypto.test.js +81 -0
  41. package/utils/tests/helpers.js +111 -0
  42. package/utils/tests/http.test.js +324 -0
  43. package/utils/tests/pure.test.js +284 -0
  44. package/utils/tests/strings.test.js +112 -0
  45. package/utils/utils.js +37 -17
  46. package/.idea/.name +0 -1
  47. package/.idea/encodings.xml +0 -6
  48. package/.idea/jsLibraryMappings.xml +0 -6
  49. package/.idea/kle-ElderWand.iml +0 -9
  50. package/.idea/libraries/kle_ElderWand_node_modules.xml +0 -14
  51. package/.idea/misc.xml +0 -13
  52. package/.idea/modules.xml +0 -8
  53. package/.idea/vcs.xml +0 -6
  54. package/.idea/workspace.xml +0 -793
  55. package/BoilerPlate/Documents/.editorconfig +0 -10
  56. package/BoilerPlate/Documents/.sailsrc +0 -5
  57. package/BoilerPlate/Documents/CONTRIBUTING.md +0 -1
  58. package/BoilerPlate/Documents/LICENSE.txt +0 -21
  59. package/BoilerPlate/Documents/Procfile +0 -1
  60. package/BoilerPlate/Documents/README.md +0 -63
  61. package/BoilerPlate/Documents/app/controllers/documents.js +0 -45
  62. package/BoilerPlate/Documents/app/controllers/sectionGrups.js +0 -22
  63. package/BoilerPlate/Documents/app/controllers/sectionTypes.js +0 -51
  64. package/BoilerPlate/Documents/app/controllers/sections.js +0 -139
  65. package/BoilerPlate/Documents/app/controllers/users.js +0 -74
  66. package/BoilerPlate/Documents/app/models/document.js +0 -105
  67. package/BoilerPlate/Documents/app/models/section.js +0 -156
  68. package/BoilerPlate/Documents/app/models/sectionGrup.js +0 -136
  69. package/BoilerPlate/Documents/app/models/sectionType.js +0 -135
  70. package/BoilerPlate/Documents/app/models/user.js +0 -202
  71. package/BoilerPlate/Documents/app/views/404.html +0 -5
  72. package/BoilerPlate/Documents/app/views/500.html +0 -13
  73. package/BoilerPlate/Documents/app/views/documentation.html +0 -37
  74. package/BoilerPlate/Documents/app/views/documents/document.html +0 -11
  75. package/BoilerPlate/Documents/app/views/documents/edit.html +0 -1
  76. package/BoilerPlate/Documents/app/views/documents/form.html +0 -43
  77. package/BoilerPlate/Documents/app/views/documents/index.html +0 -58
  78. package/BoilerPlate/Documents/app/views/documents/new.html +0 -1
  79. package/BoilerPlate/Documents/app/views/documents/show.html +0 -2
  80. package/BoilerPlate/Documents/app/views/includes/foot.html +0 -29
  81. package/BoilerPlate/Documents/app/views/includes/footer.html +0 -1
  82. package/BoilerPlate/Documents/app/views/includes/head.html +0 -31
  83. package/BoilerPlate/Documents/app/views/includes/header.html +0 -47
  84. package/BoilerPlate/Documents/app/views/includes/messages.html +0 -43
  85. package/BoilerPlate/Documents/app/views/layouts/default.html +0 -25
  86. package/BoilerPlate/Documents/app/views/sectionGrups/edit.html +0 -1
  87. package/BoilerPlate/Documents/app/views/sectionGrups/form.html +0 -47
  88. package/BoilerPlate/Documents/app/views/sectionGrups/index.html +0 -33
  89. package/BoilerPlate/Documents/app/views/sectionGrups/new.html +0 -1
  90. package/BoilerPlate/Documents/app/views/sectionGrups/sectionGrup.html +0 -11
  91. package/BoilerPlate/Documents/app/views/sectionGrups/show.html +0 -55
  92. package/BoilerPlate/Documents/app/views/sectionTypes/edit.html +0 -1
  93. package/BoilerPlate/Documents/app/views/sectionTypes/form.html +0 -42
  94. package/BoilerPlate/Documents/app/views/sectionTypes/index.html +0 -33
  95. package/BoilerPlate/Documents/app/views/sectionTypes/new.html +0 -1
  96. package/BoilerPlate/Documents/app/views/sectionTypes/sectionType.html +0 -17
  97. package/BoilerPlate/Documents/app/views/sectionTypes/show.html +0 -55
  98. package/BoilerPlate/Documents/app/views/sections/edit.html +0 -320
  99. package/BoilerPlate/Documents/app/views/sections/form.html +0 -277
  100. package/BoilerPlate/Documents/app/views/sections/index.html +0 -40
  101. package/BoilerPlate/Documents/app/views/sections/liste.html +0 -39
  102. package/BoilerPlate/Documents/app/views/sections/new.html +0 -1
  103. package/BoilerPlate/Documents/app/views/sections/section.html +0 -1
  104. package/BoilerPlate/Documents/app/views/sections/section_Like_blog.html +0 -32
  105. package/BoilerPlate/Documents/app/views/sections/section_Like_project.html +0 -35
  106. package/BoilerPlate/Documents/app/views/sections/section_about.html +0 -31
  107. package/BoilerPlate/Documents/app/views/sections/section_blog.html +0 -47
  108. package/BoilerPlate/Documents/app/views/sections/section_clients.html +0 -23
  109. package/BoilerPlate/Documents/app/views/sections/section_contact.html +0 -74
  110. package/BoilerPlate/Documents/app/views/sections/section_detay1Resimli.html +0 -23
  111. package/BoilerPlate/Documents/app/views/sections/section_detay1Resimsiz.html +0 -11
  112. package/BoilerPlate/Documents/app/views/sections/section_features.html +0 -23
  113. package/BoilerPlate/Documents/app/views/sections/section_funfact.html +0 -19
  114. package/BoilerPlate/Documents/app/views/sections/section_projects.html +0 -49
  115. package/BoilerPlate/Documents/app/views/sections/section_sadeceParagraf.html +0 -13
  116. package/BoilerPlate/Documents/app/views/sections/section_services.html +0 -34
  117. package/BoilerPlate/Documents/app/views/sections/section_slider.html +0 -195
  118. package/BoilerPlate/Documents/app/views/sections/section_team.html +0 -42
  119. package/BoilerPlate/Documents/app/views/sections/section_testimonialSSS.html +0 -51
  120. package/BoilerPlate/Documents/app/views/sections/section_video_about.html +0 -31
  121. package/BoilerPlate/Documents/app/views/sections/show.html +0 -55
  122. package/BoilerPlate/Documents/app/views/users/auth.html +0 -12
  123. package/BoilerPlate/Documents/app/views/users/index.html +0 -26
  124. package/BoilerPlate/Documents/app/views/users/login.html +0 -33
  125. package/BoilerPlate/Documents/app/views/users/show.html +0 -5
  126. package/BoilerPlate/Documents/app/views/users/signup.html +0 -43
  127. package/BoilerPlate/Documents/app/views/users/user.html +0 -28
  128. package/BoilerPlate/Documents/config/config.js +0 -35
  129. package/BoilerPlate/Documents/config/env/development.js +0 -53
  130. package/BoilerPlate/Documents/config/env/env.json +0 -12
  131. package/BoilerPlate/Documents/config/env/production.js +0 -33
  132. package/BoilerPlate/Documents/config/env/test.js +0 -33
  133. package/BoilerPlate/Documents/config/express.js +0 -124
  134. package/BoilerPlate/Documents/config/imager.js +0 -36
  135. package/BoilerPlate/Documents/config/middlewares/authorization.js +0 -55
  136. package/BoilerPlate/Documents/config/passport/facebook.js +0 -43
  137. package/BoilerPlate/Documents/config/passport/github.js +0 -43
  138. package/BoilerPlate/Documents/config/passport/google.js +0 -43
  139. package/BoilerPlate/Documents/config/passport/linkedin.js +0 -44
  140. package/BoilerPlate/Documents/config/passport/local.js +0 -37
  141. package/BoilerPlate/Documents/config/passport/twitter.js +0 -42
  142. package/BoilerPlate/Documents/config/passport.js +0 -40
  143. package/BoilerPlate/Documents/config/routes.js +0 -104
  144. package/BoilerPlate/Documents/lib/utils.js +0 -79
  145. package/BoilerPlate/Documents/nodemon.json +0 -5
  146. package/BoilerPlate/Documents/package-lock.json +0 -8993
  147. package/BoilerPlate/Documents/package.json +0 -49
  148. package/BoilerPlate/Documents/public/css/TheDocs.min.css +0 -1
  149. package/BoilerPlate/Documents/public/css/custom.css +0 -102
  150. package/BoilerPlate/Documents/public/css/skin/skin-blue.css +0 -71
  151. package/BoilerPlate/Documents/public/css/skin/skin-blue.css.map +0 -10
  152. package/BoilerPlate/Documents/public/css/skin/skin-blue.min.css +0 -1
  153. package/BoilerPlate/Documents/public/css/skin/skin-brown.css +0 -71
  154. package/BoilerPlate/Documents/public/css/skin/skin-brown.css.map +0 -10
  155. package/BoilerPlate/Documents/public/css/skin/skin-brown.min.css +0 -1
  156. package/BoilerPlate/Documents/public/css/skin/skin-cyan.css +0 -71
  157. package/BoilerPlate/Documents/public/css/skin/skin-cyan.css.map +0 -10
  158. package/BoilerPlate/Documents/public/css/skin/skin-cyan.min.css +0 -1
  159. package/BoilerPlate/Documents/public/css/skin/skin-dark.css +0 -71
  160. package/BoilerPlate/Documents/public/css/skin/skin-dark.css.map +0 -10
  161. package/BoilerPlate/Documents/public/css/skin/skin-dark.min.css +0 -1
  162. package/BoilerPlate/Documents/public/css/skin/skin-gray.css +0 -71
  163. package/BoilerPlate/Documents/public/css/skin/skin-gray.css.map +0 -10
  164. package/BoilerPlate/Documents/public/css/skin/skin-gray.min.css +0 -1
  165. package/BoilerPlate/Documents/public/css/skin/skin-green.css +0 -71
  166. package/BoilerPlate/Documents/public/css/skin/skin-green.css.map +0 -10
  167. package/BoilerPlate/Documents/public/css/skin/skin-green.min.css +0 -1
  168. package/BoilerPlate/Documents/public/css/skin/skin-orange.css +0 -71
  169. package/BoilerPlate/Documents/public/css/skin/skin-orange.css.map +0 -10
  170. package/BoilerPlate/Documents/public/css/skin/skin-orange.min.css +0 -1
  171. package/BoilerPlate/Documents/public/css/skin/skin-pink.css +0 -71
  172. package/BoilerPlate/Documents/public/css/skin/skin-pink.css.map +0 -10
  173. package/BoilerPlate/Documents/public/css/skin/skin-pink.min.css +0 -1
  174. package/BoilerPlate/Documents/public/css/skin/skin-purple.css +0 -71
  175. package/BoilerPlate/Documents/public/css/skin/skin-purple.css.map +0 -10
  176. package/BoilerPlate/Documents/public/css/skin/skin-purple.min.css +0 -1
  177. package/BoilerPlate/Documents/public/css/skin/skin-red.css +0 -71
  178. package/BoilerPlate/Documents/public/css/skin/skin-red.css.map +0 -10
  179. package/BoilerPlate/Documents/public/css/skin/skin-red.min.css +0 -1
  180. package/BoilerPlate/Documents/public/css/skin/skin-teal.css +0 -71
  181. package/BoilerPlate/Documents/public/css/skin/skin-teal.css.map +0 -10
  182. package/BoilerPlate/Documents/public/css/skin/skin-teal.min.css +0 -1
  183. package/BoilerPlate/Documents/public/css/skin/skin-yellow.css +0 -71
  184. package/BoilerPlate/Documents/public/css/skin/skin-yellow.css.map +0 -10
  185. package/BoilerPlate/Documents/public/css/skin/skin-yellow.min.css +0 -1
  186. package/BoilerPlate/Documents/public/css/theDocs/_alerts.scss +0 -49
  187. package/BoilerPlate/Documents/public/css/theDocs/_banner.scss +0 -225
  188. package/BoilerPlate/Documents/public/css/theDocs/_blog.scss +0 -240
  189. package/BoilerPlate/Documents/public/css/theDocs/_breadcrumb.scss +0 -10
  190. package/BoilerPlate/Documents/public/css/theDocs/_buttons.scss +0 -143
  191. package/BoilerPlate/Documents/public/css/theDocs/_carousel.scss +0 -92
  192. package/BoilerPlate/Documents/public/css/theDocs/_code.scss +0 -372
  193. package/BoilerPlate/Documents/public/css/theDocs/_color.scss +0 -38
  194. package/BoilerPlate/Documents/public/css/theDocs/_content.scss +0 -108
  195. package/BoilerPlate/Documents/public/css/theDocs/_faq.scss +0 -82
  196. package/BoilerPlate/Documents/public/css/theDocs/_files.scss +0 -137
  197. package/BoilerPlate/Documents/public/css/theDocs/_footer.scss +0 -82
  198. package/BoilerPlate/Documents/public/css/theDocs/_form.scss +0 -24
  199. package/BoilerPlate/Documents/public/css/theDocs/_header.scss +0 -374
  200. package/BoilerPlate/Documents/public/css/theDocs/_jumbotron.scss +0 -150
  201. package/BoilerPlate/Documents/public/css/theDocs/_labels.scss +0 -23
  202. package/BoilerPlate/Documents/public/css/theDocs/_media.scss +0 -24
  203. package/BoilerPlate/Documents/public/css/theDocs/_mixins.scss +0 -66
  204. package/BoilerPlate/Documents/public/css/theDocs/_pagination.scss +0 -75
  205. package/BoilerPlate/Documents/public/css/theDocs/_promo.scss +0 -112
  206. package/BoilerPlate/Documents/public/css/theDocs/_requirements.scss +0 -53
  207. package/BoilerPlate/Documents/public/css/theDocs/_sidebar.scss +0 -666
  208. package/BoilerPlate/Documents/public/css/theDocs/_step.scss +0 -161
  209. package/BoilerPlate/Documents/public/css/theDocs/_tab.scss +0 -105
  210. package/BoilerPlate/Documents/public/css/theDocs/_tables.scss +0 -106
  211. package/BoilerPlate/Documents/public/css/theDocs/_toc.scss +0 -78
  212. package/BoilerPlate/Documents/public/css/theDocs/_typography.scss +0 -282
  213. package/BoilerPlate/Documents/public/css/theDocs/_variables.scss +0 -98
  214. package/BoilerPlate/Documents/public/css/theDocs/_views.scss +0 -215
  215. package/BoilerPlate/Documents/public/css/theDocs/skins/_skin.scss +0 -76
  216. package/BoilerPlate/Documents/public/css/theDocs/skins/skin-blue.scss +0 -3
  217. package/BoilerPlate/Documents/public/css/theDocs/skins/skin-brown.scss +0 -3
  218. package/BoilerPlate/Documents/public/css/theDocs/skins/skin-cyan.scss +0 -3
  219. package/BoilerPlate/Documents/public/css/theDocs/skins/skin-dark.scss +0 -3
  220. package/BoilerPlate/Documents/public/css/theDocs/skins/skin-gray.scss +0 -3
  221. package/BoilerPlate/Documents/public/css/theDocs/skins/skin-green.scss +0 -3
  222. package/BoilerPlate/Documents/public/css/theDocs/skins/skin-orange.scss +0 -3
  223. package/BoilerPlate/Documents/public/css/theDocs/skins/skin-pink.scss +0 -3
  224. package/BoilerPlate/Documents/public/css/theDocs/skins/skin-purple.scss +0 -3
  225. package/BoilerPlate/Documents/public/css/theDocs/skins/skin-red.scss +0 -3
  226. package/BoilerPlate/Documents/public/css/theDocs/skins/skin-teal.scss +0 -3
  227. package/BoilerPlate/Documents/public/css/theDocs/skins/skin-yellow.scss +0 -3
  228. package/BoilerPlate/Documents/public/css/theDocs.all.min.css +0 -24
  229. package/BoilerPlate/Documents/public/css/theDocs.css +0 -3945
  230. package/BoilerPlate/Documents/public/css/theDocs.css.map +0 -38
  231. package/BoilerPlate/Documents/public/css/theDocs.scss +0 -70
  232. package/BoilerPlate/Documents/public/fonts/FontAwesome.otf +0 -0
  233. package/BoilerPlate/Documents/public/fonts/fontawesome-webfont.eot +0 -0
  234. package/BoilerPlate/Documents/public/fonts/fontawesome-webfont.svg +0 -2671
  235. package/BoilerPlate/Documents/public/fonts/fontawesome-webfont.ttf +0 -0
  236. package/BoilerPlate/Documents/public/fonts/fontawesome-webfont.woff +0 -0
  237. package/BoilerPlate/Documents/public/fonts/fontawesome-webfont.woff2 +0 -0
  238. package/BoilerPlate/Documents/public/fonts/glyphicons-halflings-regular.eot +0 -0
  239. package/BoilerPlate/Documents/public/fonts/glyphicons-halflings-regular.svg +0 -288
  240. package/BoilerPlate/Documents/public/fonts/glyphicons-halflings-regular.ttf +0 -0
  241. package/BoilerPlate/Documents/public/fonts/glyphicons-halflings-regular.woff +0 -0
  242. package/BoilerPlate/Documents/public/fonts/glyphicons-halflings-regular.woff2 +0 -0
  243. package/BoilerPlate/Documents/public/img/apple-touch-icon-114x114.png +0 -0
  244. package/BoilerPlate/Documents/public/img/apple-touch-icon-72x72.png +0 -0
  245. package/BoilerPlate/Documents/public/img/apple-touch-icon.png +0 -0
  246. package/BoilerPlate/Documents/public/img/arrow-circle-down.svg +0 -1
  247. package/BoilerPlate/Documents/public/img/arrow-circle-right.svg +0 -1
  248. package/BoilerPlate/Documents/public/img/atlassian.svg +0 -1
  249. package/BoilerPlate/Documents/public/img/avatar-1.jpg +0 -0
  250. package/BoilerPlate/Documents/public/img/banner-default.png +0 -0
  251. package/BoilerPlate/Documents/public/img/banner-full-height.png +0 -0
  252. package/BoilerPlate/Documents/public/img/banner-lg.png +0 -0
  253. package/BoilerPlate/Documents/public/img/banner-sample1.png +0 -0
  254. package/BoilerPlate/Documents/public/img/banner-sample2.png +0 -0
  255. package/BoilerPlate/Documents/public/img/banner-sample3.png +0 -0
  256. package/BoilerPlate/Documents/public/img/banner-sm.png +0 -0
  257. package/BoilerPlate/Documents/public/img/banner.jpg +0 -0
  258. package/BoilerPlate/Documents/public/img/banner1.jpg +0 -0
  259. package/BoilerPlate/Documents/public/img/banner2.jpg +0 -0
  260. package/BoilerPlate/Documents/public/img/banner3.jpg +0 -0
  261. package/BoilerPlate/Documents/public/img/banner4.png +0 -0
  262. package/BoilerPlate/Documents/public/img/banner5.png +0 -0
  263. package/BoilerPlate/Documents/public/img/check-circle.svg +0 -1
  264. package/BoilerPlate/Documents/public/img/chevron-circle-right.svg +0 -1
  265. package/BoilerPlate/Documents/public/img/circle-with-minus.svg +0 -1
  266. package/BoilerPlate/Documents/public/img/circle-with-plus.svg +0 -1
  267. package/BoilerPlate/Documents/public/img/cloud.svg +0 -1
  268. package/BoilerPlate/Documents/public/img/conference-image-1.jpg +0 -0
  269. package/BoilerPlate/Documents/public/img/conference-image-2.jpg +0 -0
  270. package/BoilerPlate/Documents/public/img/conference-image-3.jpg +0 -0
  271. package/BoilerPlate/Documents/public/img/edward.jpg +0 -0
  272. package/BoilerPlate/Documents/public/img/elderwand-logo.png +0 -0
  273. package/BoilerPlate/Documents/public/img/email.svg +0 -1
  274. package/BoilerPlate/Documents/public/img/envato.svg +0 -1
  275. package/BoilerPlate/Documents/public/img/facebook.svg +0 -1
  276. package/BoilerPlate/Documents/public/img/favicon.png +0 -0
  277. package/BoilerPlate/Documents/public/img/heart.svg +0 -1
  278. package/BoilerPlate/Documents/public/img/images.svg +0 -1
  279. package/BoilerPlate/Documents/public/img/index.png +0 -0
  280. package/BoilerPlate/Documents/public/img/jacob.jpg +0 -0
  281. package/BoilerPlate/Documents/public/img/jquery.svg +0 -1
  282. package/BoilerPlate/Documents/public/img/jumbotron-bg.png +0 -0
  283. package/BoilerPlate/Documents/public/img/layout-single1.png +0 -0
  284. package/BoilerPlate/Documents/public/img/layout-single2.png +0 -0
  285. package/BoilerPlate/Documents/public/img/layout-single3.png +0 -0
  286. package/BoilerPlate/Documents/public/img/location-pin.svg +0 -1
  287. package/BoilerPlate/Documents/public/img/lucy.jpg +0 -0
  288. package/BoilerPlate/Documents/public/img/mamtas-logo-simple.png +0 -0
  289. package/BoilerPlate/Documents/public/img/music.svg +0 -1
  290. package/BoilerPlate/Documents/public/img/nathan.jpg +0 -0
  291. package/BoilerPlate/Documents/public/img/navbar-dark.png +0 -0
  292. package/BoilerPlate/Documents/public/img/navbar-default.png +0 -0
  293. package/BoilerPlate/Documents/public/img/navbar-fullwidth.png +0 -0
  294. package/BoilerPlate/Documents/public/img/navbar-lg.png +0 -0
  295. package/BoilerPlate/Documents/public/img/navbar-light.png +0 -0
  296. package/BoilerPlate/Documents/public/img/navbar-sm.png +0 -0
  297. package/BoilerPlate/Documents/public/img/phone.svg +0 -1
  298. package/BoilerPlate/Documents/public/img/placeholder-1900.png +0 -0
  299. package/BoilerPlate/Documents/public/img/placeholder.png +0 -0
  300. package/BoilerPlate/Documents/public/img/sidebar-default.png +0 -0
  301. package/BoilerPlate/Documents/public/img/sidebar-icon.png +0 -0
  302. package/BoilerPlate/Documents/public/img/sidebar-line.png +0 -0
  303. package/BoilerPlate/Documents/public/img/skin-blue.png +0 -0
  304. package/BoilerPlate/Documents/public/img/skin-brown.png +0 -0
  305. package/BoilerPlate/Documents/public/img/skin-cyan.png +0 -0
  306. package/BoilerPlate/Documents/public/img/skin-dark.png +0 -0
  307. package/BoilerPlate/Documents/public/img/skin-default.png +0 -0
  308. package/BoilerPlate/Documents/public/img/skin-gray.png +0 -0
  309. package/BoilerPlate/Documents/public/img/skin-green.png +0 -0
  310. package/BoilerPlate/Documents/public/img/skin-orange.png +0 -0
  311. package/BoilerPlate/Documents/public/img/skin-pink.png +0 -0
  312. package/BoilerPlate/Documents/public/img/skin-purple.png +0 -0
  313. package/BoilerPlate/Documents/public/img/skin-red.png +0 -0
  314. package/BoilerPlate/Documents/public/img/skin-teal.png +0 -0
  315. package/BoilerPlate/Documents/public/img/skin-yellow.png +0 -0
  316. package/BoilerPlate/Documents/public/img/skype.svg +0 -1
  317. package/BoilerPlate/Documents/public/img/step1.png +0 -0
  318. package/BoilerPlate/Documents/public/img/step2.png +0 -0
  319. package/BoilerPlate/Documents/public/img/step3.png +0 -0
  320. package/BoilerPlate/Documents/public/img/step4.png +0 -0
  321. package/BoilerPlate/Documents/public/img/tumblr.svg +0 -1
  322. package/BoilerPlate/Documents/public/img/twitter.svg +0 -1
  323. package/BoilerPlate/Documents/public/img/video-dawn.mp4 +0 -0
  324. package/BoilerPlate/Documents/public/img/video.svg +0 -1
  325. package/BoilerPlate/Documents/public/js/custom.js +0 -26
  326. package/BoilerPlate/Documents/public/js/default.js +0 -1
  327. package/BoilerPlate/Documents/public/js/theDocs.all.min.js +0 -102
  328. package/BoilerPlate/Documents/public/js/theDocs.js +0 -482
  329. package/BoilerPlate/Documents/public/js/theDocs.min.js +0 -6
  330. package/BoilerPlate/Documents/public/js/vendor/bootstrap.carousel.js +0 -1
  331. package/BoilerPlate/Documents/public/js/vendor/bootstrap.collapse.js +0 -1
  332. package/BoilerPlate/Documents/public/js/vendor/bootstrap.dropdown.js +0 -1
  333. package/BoilerPlate/Documents/public/js/vendor/bootstrap.tab.js +0 -1
  334. package/BoilerPlate/Documents/public/js/vendor/bootstrap.transition.js +0 -1
  335. package/BoilerPlate/Documents/public/js/vendor/jquery-1.11.3.min.js +0 -4
  336. package/BoilerPlate/Documents/public/js/vendor/jquery.drawsvg.js +0 -1
  337. package/BoilerPlate/Documents/public/js/vendor/jquery.mobile.custom.min.js +0 -1
  338. package/BoilerPlate/Documents/public/js/vendor/webfontloader.js +0 -1
  339. package/BoilerPlate/Documents/public/sample.html +0 -530
  340. package/BoilerPlate/Documents/public/style.css +0 -10
  341. package/BoilerPlate/Documents/public/vendors/bootstrap/css/bootstrap-theme.css +0 -587
  342. package/BoilerPlate/Documents/public/vendors/bootstrap/css/bootstrap-theme.css.map +0 -1
  343. package/BoilerPlate/Documents/public/vendors/bootstrap/css/bootstrap-theme.min.css +0 -6
  344. package/BoilerPlate/Documents/public/vendors/bootstrap/css/bootstrap-theme.min.css.map +0 -1
  345. package/BoilerPlate/Documents/public/vendors/bootstrap/css/bootstrap.css +0 -6757
  346. package/BoilerPlate/Documents/public/vendors/bootstrap/css/bootstrap.css.map +0 -1
  347. package/BoilerPlate/Documents/public/vendors/bootstrap/css/bootstrap.min.css +0 -6
  348. package/BoilerPlate/Documents/public/vendors/bootstrap/css/bootstrap.min.css.map +0 -1
  349. package/BoilerPlate/Documents/public/vendors/bootstrap/fonts/glyphicons-halflings-regular.eot +0 -0
  350. package/BoilerPlate/Documents/public/vendors/bootstrap/fonts/glyphicons-halflings-regular.svg +0 -288
  351. package/BoilerPlate/Documents/public/vendors/bootstrap/fonts/glyphicons-halflings-regular.ttf +0 -0
  352. package/BoilerPlate/Documents/public/vendors/bootstrap/fonts/glyphicons-halflings-regular.woff +0 -0
  353. package/BoilerPlate/Documents/public/vendors/bootstrap/fonts/glyphicons-halflings-regular.woff2 +0 -0
  354. package/BoilerPlate/Documents/public/vendors/bootstrap/js/bootstrap.js +0 -2377
  355. package/BoilerPlate/Documents/public/vendors/bootstrap/js/bootstrap.min.js +0 -7
  356. package/BoilerPlate/Documents/public/vendors/bootstrap/js/npm.js +0 -13
  357. package/BoilerPlate/Documents/public/vendors/clipboard.js/clipboard.js +0 -778
  358. package/BoilerPlate/Documents/public/vendors/clipboard.js/clipboard.min.js +0 -7
  359. package/BoilerPlate/Documents/public/vendors/fitvids/jquery.fitvids.js +0 -11
  360. package/BoilerPlate/Documents/public/vendors/font-awesome/css/font-awesome.css +0 -2337
  361. package/BoilerPlate/Documents/public/vendors/font-awesome/css/font-awesome.min.css +0 -4
  362. package/BoilerPlate/Documents/public/vendors/font-awesome/fonts/FontAwesome.otf +0 -0
  363. package/BoilerPlate/Documents/public/vendors/font-awesome/fonts/fontawesome-webfont.eot +0 -0
  364. package/BoilerPlate/Documents/public/vendors/font-awesome/fonts/fontawesome-webfont.svg +0 -2671
  365. package/BoilerPlate/Documents/public/vendors/font-awesome/fonts/fontawesome-webfont.ttf +0 -0
  366. package/BoilerPlate/Documents/public/vendors/font-awesome/fonts/fontawesome-webfont.woff +0 -0
  367. package/BoilerPlate/Documents/public/vendors/font-awesome/fonts/fontawesome-webfont.woff2 +0 -0
  368. package/BoilerPlate/Documents/public/vendors/font-awesome/less/animated.less +0 -34
  369. package/BoilerPlate/Documents/public/vendors/font-awesome/less/bordered-pulled.less +0 -25
  370. package/BoilerPlate/Documents/public/vendors/font-awesome/less/core.less +0 -12
  371. package/BoilerPlate/Documents/public/vendors/font-awesome/less/fixed-width.less +0 -6
  372. package/BoilerPlate/Documents/public/vendors/font-awesome/less/font-awesome.less +0 -18
  373. package/BoilerPlate/Documents/public/vendors/font-awesome/less/icons.less +0 -789
  374. package/BoilerPlate/Documents/public/vendors/font-awesome/less/larger.less +0 -13
  375. package/BoilerPlate/Documents/public/vendors/font-awesome/less/list.less +0 -19
  376. package/BoilerPlate/Documents/public/vendors/font-awesome/less/mixins.less +0 -60
  377. package/BoilerPlate/Documents/public/vendors/font-awesome/less/path.less +0 -15
  378. package/BoilerPlate/Documents/public/vendors/font-awesome/less/rotated-flipped.less +0 -20
  379. package/BoilerPlate/Documents/public/vendors/font-awesome/less/screen-reader.less +0 -5
  380. package/BoilerPlate/Documents/public/vendors/font-awesome/less/stacked.less +0 -20
  381. package/BoilerPlate/Documents/public/vendors/font-awesome/less/variables.less +0 -800
  382. package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_animated.scss +0 -34
  383. package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_bordered-pulled.scss +0 -25
  384. package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_core.scss +0 -12
  385. package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_fixed-width.scss +0 -6
  386. package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_icons.scss +0 -789
  387. package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_larger.scss +0 -13
  388. package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_list.scss +0 -19
  389. package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_mixins.scss +0 -60
  390. package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_path.scss +0 -15
  391. package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_rotated-flipped.scss +0 -20
  392. package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_screen-reader.scss +0 -5
  393. package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_stacked.scss +0 -20
  394. package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_variables.scss +0 -800
  395. package/BoilerPlate/Documents/public/vendors/font-awesome/scss/font-awesome.scss +0 -18
  396. package/BoilerPlate/Documents/public/vendors/jquery/jquery.min.js +0 -4
  397. package/BoilerPlate/Documents/public/vendors/lity/lity.css +0 -200
  398. package/BoilerPlate/Documents/public/vendors/lity/lity.js +0 -637
  399. package/BoilerPlate/Documents/public/vendors/lity/lity.min.css +0 -3
  400. package/BoilerPlate/Documents/public/vendors/lity/lity.min.js +0 -4
  401. package/BoilerPlate/Documents/public/vendors/matchHeight.min.js +0 -11
  402. package/BoilerPlate/Documents/public/vendors/perfect-scrollbar/css/perfect-scrollbar.css +0 -113
  403. package/BoilerPlate/Documents/public/vendors/perfect-scrollbar/css/perfect-scrollbar.min.css +0 -2
  404. package/BoilerPlate/Documents/public/vendors/perfect-scrollbar/js/perfect-scrollbar.jquery.js +0 -1580
  405. package/BoilerPlate/Documents/public/vendors/perfect-scrollbar/js/perfect-scrollbar.jquery.min.js +0 -2
  406. package/BoilerPlate/Documents/public/vendors/perfect-scrollbar/js/perfect-scrollbar.js +0 -1553
  407. package/BoilerPlate/Documents/public/vendors/perfect-scrollbar/js/perfect-scrollbar.min.js +0 -2
  408. package/BoilerPlate/Documents/public/vendors/prism/prism.css +0 -7
  409. package/BoilerPlate/Documents/public/vendors/prism/prism.js +0 -54
  410. package/BoilerPlate/Documents/server.js +0 -63
  411. package/BoilerPlate/Documents/tempUploads/068f2b77c0e0723b97909b2ffa438fe6.pdf +0 -0
  412. package/BoilerPlate/Documents/tempUploads/6443f8fd5d507b5a5f76829962fc2dc0.docx +0 -0
  413. package/BoilerPlate/Documents/tempUploads/7e4560af2cd6cae130bdb79fecaa6437.pdf +0 -0
  414. package/BoilerPlate/Documents/tempUploads/84b6ad7e0deefc348cfd582c9715ec1d.pdf +0 -0
  415. package/BoilerPlate/Documents/tempUploads/a894549ed062ada5f48f364a236a7e76.png +0 -0
  416. package/BoilerPlate/Documents/tempUploads/c2727b94bc909b118b25ae35f0897713.png +0 -0
  417. package/BoilerPlate/Documents/tempUploads/c588a76c8b0c4b76df2e36bd602a8821.docx +0 -0
  418. package/BoilerPlate/Documents/tempUploads/d6476c43a03950899e6db91c95dbc8aa.docx +0 -0
  419. package/BoilerPlate/Documents/tempUploads/dc4ffdc0a703353e0280384afc6ad082.png +0 -0
  420. package/BoilerPlate/Documents/test/helper.js +0 -27
  421. package/BoilerPlate/Documents/test/test-articles.js +0 -176
  422. package/BoilerPlate/Documents/test/test-users.js +0 -106
  423. package/BoilerPlate/Documents/uploads/section/5ad9bb9853017c217c6673d5/0cb1f166cbb6b46ffc630cb1c86db0a1.png +0 -0
  424. package/BoilerPlate/Documents/uploads/section/5ad9bb9853017c217c6673d5/37fbc499e5eea091ab7215855bf7918b.png +0 -0
  425. package/BoilerPlate/Documents/uploads/section/5ad9bb9853017c217c6673d5/4b0d6e11c87b31cc6c32e18be5a49b6b.pdf +0 -0
  426. package/BoilerPlate/Documents/uploads/section/5ad9bb9853017c217c6673d5/d4248bccecc0f55dd2fe7cd388c4c1ce.docx +0 -0
  427. package/BoilerPlate/Documents/uploads/section/5ad9bbd853017c217c6673d8/7c7b0d7f03359c38e3411ec448bdc746.png +0 -0
  428. package/BoilerPlate/Documents/uploads/section/5ad9bbd853017c217c6673d8/8c7eeb092084ee8349f12ceb7e6dab2d.docx +0 -0
  429. package/BoilerPlate/Documents/uploads/section/5ad9bbd853017c217c6673d8/b512a8558523894f0d9292f39dcd9d82.pdf +0 -0
  430. package/BoilerPlate/Documents/uploads/section/5ad9bc111b67922eb0f547d5/06cdca751d7c5897179af1bb956e13d3.docx +0 -0
  431. package/BoilerPlate/Documents/uploads/section/5ad9bc111b67922eb0f547d5/4fe0695295a41c9e3e5af0d2fd52bbae.png +0 -0
  432. package/BoilerPlate/Documents/uploads/section/5ad9c7ce673a50173865614b/1c68ca7ae23099cd139801766ccec600.docx +0 -0
  433. package/BoilerPlate/Documents/uploads/section/5ad9c7ce673a50173865614b/7d7d49834eea7899d77a29dda1d25bf4.pdf +0 -0
  434. package/BoilerPlate/Documents/uploads/section/5ad9c826673a50173865614e/301398c02f647d1e1804d48233e9e7e0.pdf +0 -0
  435. package/BoilerPlate/Documents/uploads/section/5ad9c826673a50173865614e/c9ca2431eed90529a633f88c6781e686.docx +0 -0
  436. package/BoilerPlate/Documents/uploads/section/5ad9c85f673a501738656153/71b1d92caefe43821426d139e6c931d1.pdf +0 -0
  437. package/BoilerPlate/Documents/uploads/section/5ad9c85f673a501738656153/a0735aa1e0befd14449b26063c112d46.docx +0 -0
  438. package/BoilerPlate/Documents/uploads/section/5ad9ce22f534442218fb8016/31724098865f19fd968d6167736bd388.docx +0 -0
  439. package/BoilerPlate/Documents/uploads/section/5ad9d714f534442218fb801b/a71e1f795a7c2f260ccbd877e9e03b17.docx +0 -0
  440. package/BoilerPlate/Documents/uploads/section/5ad9d755f534442218fb801e/c23154466cfcbb8aa9101509cc990962.docx +0 -0
  441. package/BoilerPlate/Documents/uploads/section/5ad9d816f534442218fb8021/e90f3adde177c831dd96d8fcf2f6bf17.docx +0 -0
  442. package/BoilerPlate/Documents/uploads/section/5ad9d83bf534442218fb8024/11a310205cd7c1b3f0a53cd4a3e1cd91.png +0 -0
  443. package/BoilerPlate/Documents/uploads/section/5ad9d83bf534442218fb8024/4c45d0286d8b0ae23fe1ccfd2d0f6b52.pdf +0 -0
  444. package/BoilerPlate/Documents/uploads/section/5ad9d83bf534442218fb8024/6dd38b8628ef60ea09e982c375720d94.docx +0 -0
  445. package/dump.rdb +0 -0
@@ -1,820 +1,827 @@
1
1
  /**
2
2
  * Module dependencies.
3
3
  */
4
- 'use strict';
5
- var childControllers = [];
6
- var async = require('async');
7
- var mv = require('mv');
8
- var fs = require('fs');
9
- var path = require('path');
10
- const archiver = require('archiver');
4
+ 'use strict';
5
+ var childControllers = [];
6
+ var async = require('async');
7
+ var mv = require('mv');
8
+ var fs = require('fs');
9
+ var path = require('path');
10
+ const archiver = require('archiver');
11
11
  //var utils = rekuire('/lib/utils');
12
12
  var extend = require('util')._extend;
13
13
  var ObjectId = require('mongoose').Types.ObjectId
14
14
  var viewsDir = 'app/views/'
15
15
  module.exports.getChildControllers = function(){
16
- return childControllers;
16
+ return childControllers;
17
17
  };
18
18
  module.exports.inherit = function (child) {
19
- /**
20
- * Load
21
- */
22
- if(childControllers.indexInArray(child, function(item){return this.pluralName == item.pluralName}) == -1){
23
- childControllers.push(child);
24
- };
25
- child.super = {};
26
- child.elements = []
27
- child.coveredMethods = [];
28
- child.coveredMethods.push("load");
29
- child.load = function (req, res, next, id) {
30
- if(ObjectId.isValid(id)){
31
- child.model.load(id, function (err, model) {
32
- if (err){
33
- res.errors.push(err)
34
- res.statusData = "Error";
35
- return next(err);
36
- }
37
- if (!model){
38
- res.statusData = "Error"
39
- return next(new Error('not found'));
40
- }
41
- if (!model.canSeeByUser(req.user)) {
42
- //req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
43
- if(req.user){
44
- res.statusData = "Error"
45
- return res.redirect('/users/' + req.user.id);
46
- }else{
47
- res.statusData = "Error"
48
- return res.redirect('/login');
49
- }
50
- return;
51
- }
52
- req[child.singularName] = model;
53
- next();
54
- });
55
- }else{
56
- next()
57
- }
58
- };
59
-
60
-
61
- /**
62
- * List
63
- */
64
-
65
- child.coveredMethods.push("index");
66
- child.index = function (req, res) {
67
- //if (!utils.canAccessByUser(req.user, child.pluralName, child.group)) {
68
- // req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
69
- // res.redirect('/users/' + req.user.id);
70
- // return;
71
- //};
72
-
73
-
74
- var callback = function (err, models) {
75
- if (err) {
76
- res.statusData = "Error"
77
- return res.render('500', {});
78
- }
79
- child.model.count(options.criteria || {}).exec(function (err, count) {
80
- var pageCount = Math.ceil(count / perPage);
81
- var pages = [];
82
- var start = pageCount > 10 && page - 5 > 0 ? page - 5 : 0;
83
- var end = pageCount > 10 && page + 5 < pageCount ? page + 5 : pageCount;
84
- for(var i = start; i < end; i++){
85
- pages.push(i);
86
- }
87
- if(start > 0){
88
- pages.splice(0,0, "...");
89
- pages.splice(0,0,0);
90
- }
91
- if(end < pageCount){
92
- pages.push("...");
93
- pages.push(pageCount - 1);
94
- }
95
- var data = {
96
- user: req.user,
97
- title: child.title + ' Listesi',
98
- page: page + 1,
99
- pages: pages,
100
- perPage: perPage,
101
- pageCount: pageCount,
102
- isFiltered: Object.keys(req.anyKey).length > 0 ? true : false,
103
- //menu: utils.getUserMenu(req.user),
104
- };
105
- data[child.pluralName] = models;
106
- data["items"] = models;
107
- data["pluralName"] = child.pluralName
108
- data["singularName"] = child.singularName
109
- data["title"] = child.title
110
- res.errors.push(err)
111
- child.loadRelatedData(data, req, res, function (relatedData) {
112
- data.inject(relatedData);
113
- res.statusData = "Success"
114
-
115
- if(fs.existsSync(viewsDir + child.pluralName)){
116
- res.render(child.pluralName + '/index', data);
117
- }else{
118
- res.render("__basicItems" + '/index', data);
119
- }
120
- });
121
- });
122
- }
123
-
124
- var page = parseInt(req.anyKey.page > 0 ? req.anyKey.page : 1) - 1;
125
- var perPage = parseInt(req.anyKey.perPage > 0 ? req.anyKey.perPage : 10);
126
- var text = req.anyKey.q
127
- var options = {
128
- perPage: perPage,
129
- page: page,
130
- search: text,
131
- criteria:{}
132
- };
133
- options.inject(req.options)
134
-
135
- if(child.model.generateCriteria){
136
- options.criteria.inject(child.model.generateCriteria(req.anyKey))
137
- }
138
-
139
- if(child.model.listByUserOptions){
140
- options.criteria = child.model.listByUserOptions(options, req.user, callback)
141
- }else{
142
- options.criteria = child.model.list(options, callback);
143
- }
144
- };
145
-
146
- /**
147
- * New article
148
- */
149
-
150
- child.coveredMethods.push("new");
151
- child.new = function (req, res) {
152
- //if (!utils.canAccessByUser(req.user, child.pluralName, child.group)) {
153
- // req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
154
- // res.redirect('/users/' + req.user.id);
155
- // return;
156
- //};
157
-
158
- var data = {
159
- user: req.user,
160
- title: child.title,
161
- pluralName: child.pluralName,
162
- //menu: utils.getUserMenu(req.user),
163
- };
164
- var virtual = new child.model({});
165
- if (virtual){// && virtual.canEditByUser(req.user)) {
166
- child.loadRelatedData(data, req, res, function (relatedData) {
167
- data.inject(relatedData);
168
- res.statusData = "Success"
169
-
170
-
171
- if(fs.existsSync(viewsDir + child.pluralName)){
172
- res.render(child.pluralName + '/new', data);
173
- }else{
174
- res.render("__basicItems" + '/new', data);
175
- }
176
- });
177
- } else {
178
- req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
179
- if(req.user){
180
- res.statusData = "Error"
181
- return res.redirect('/users/' + req.user.id);
182
- }else{
183
- res.statusData = "Error"
184
- return res.redirect('/login');
185
- }
186
-
187
- }
188
- };
189
-
190
- /**
191
- * Create an article
192
- * Upload an image
193
- */
194
-
195
- child.coveredMethods.push("create");
196
- child.create = function (req, res) {
197
- //if (!utils.canAccessByUser(req.user, child.pluralName, child.group)) {
198
- // req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
199
- // res.redirect('/users/' + req.user.id);
200
- // return;
201
- //};
202
- var model = new child.model(req.body);
203
- model.user = req.user;
204
- if (model && model.canEditByUser(req.user)) {
205
- model.save(function (err) {
206
- req[child.singularName] = model
207
- child.handleFiles(req, res, function(error){
208
- if (!err && !error) {
209
- req.flash('success', child.title + ' Başarıyla Yaratıldı');
210
- res.model = model
211
- res.model[child.singularName] = model
212
- res.statusData = "Success"
213
- if(req.anyKey.__redirectUrl){
214
- return res.redirect(req.anyKey.__redirectUrl);
215
- }else{
216
- return res.redirect('/' + child.pluralName);
217
- }
218
- } else if (child.onError) {
219
- //console.log(err);
220
- res.statusData = "Error"
221
- child.onError(req, res, 'create', err ? err : error);
222
- } else if(req.user){
223
- //console.log(err);
224
- //console.log(err.stacktrace);
225
- req.flash('info', 'Bilinmeyen bir hata oluştu');
226
- if(err){
227
- res.errors.push(err)
228
- req.flash('error', err.message);
229
- }
230
- if(error){
231
- res.errors.push(error)
232
- req.flash('error', error.message);
233
- }
234
- res.statusData = "Error"
235
- res.redirect('/users/' + req.user.id);
236
- }else {
237
- req.flash('info', 'Bilinmeyen bir hata oluştu');
238
- if(err){
239
- res.errors.push(err)
240
- req.flash('error', err.message);
241
- }
242
- if(error){
243
- res.errors.push(error)
244
- req.flash('error', error.message);
245
- }
246
- res.statusData = "Error"
247
- res.redirect('/login/');
248
- }
249
- })
250
- });
251
- } else {
252
- //EWLog("yetki", child.singularName, req[child.singularName])
253
- req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
254
- if(req.user){
255
- res.statusData = "Error"
256
- return res.redirect('/users/' + req.user.id);
257
- }else{
258
- res.statusData = "Error"
259
- return res.redirect('/login');
260
- }
261
- }
19
+ /**
20
+ * Load
21
+ */
22
+ if(childControllers.indexInArray(child, function(item){return this.pluralName == item.pluralName}) == -1){
23
+ childControllers.push(child);
262
24
  };
263
-
264
- /**
265
- * Edit an article
266
- */
267
-
268
- child.coveredMethods.push("edit");
269
- child.edit = function (req, res) {
270
- //if (!utils.canAccessByUser(req.user, child.pluralName, child.group)) {
271
- // req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
272
- // res.redirect('/users/' + req.user.id);
273
- // return;
274
- //};
275
- var data = {
276
- user: req.user,
277
- title: child.title,
278
- pluralName: child.pluralName,
279
- //menu: utils.getUserMenu(req.user),
280
- };
281
-
282
- data[child.singularName] = req[child.singularName];
283
- if (data[child.singularName]){// && data[child.singularName].canEditByUser(req.user)) {
284
- child.loadRelatedData(data, req, res, function (relatedData) {
285
- data.inject(relatedData);
286
- res.statusData = "Success"
287
- data.item = data[child.singularName]
288
- if(fs.existsSync(viewsDir + child.pluralName)){
289
- res.render(child.pluralName + '/edit', data);
290
- }else{
291
- res.render("__basicItems" + '/edit', data);
25
+ child.super = {};
26
+ child.elements = []
27
+ child.coveredMethods = [];
28
+ child.coveredMethods.push("load");
29
+ child.load = function (req, res, next, id) {
30
+ if(ObjectId.isValid(id)){
31
+ child.model.load(id, function (err, model) {
32
+ if (err){
33
+ res.errors.push(err)
34
+ res.statusData = "Error";
35
+ return next(err);
292
36
  }
293
- });
294
- } else {
295
- req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
296
- if(req.user){
297
- res.statusData = "Error"
298
- return res.redirect('/users/' + req.user.id);
299
- }else{
300
- res.statusData = "Error"
301
- return res.redirect('/login');
302
- }
303
- }
304
-
305
- };
306
-
307
- /**
308
- * Update article
309
- */
310
-
311
- child.coveredMethods.push("update");
312
- child.update = function (req, res) {
313
- //if (!utils.canAccessByUser(req.user, child.pluralName, child.group)) {
314
- // req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
315
- // res.redirect('/users/' + req.user.id);
316
- // return;
317
- //};
318
- var model = req[child.singularName];
319
-
320
- // make sure no one changes the user
321
- delete req.body.user;
322
- if (model){// && model.canEditByUser(req.user)) {
323
- model = extend(model, req.body);
324
- if (model && model.canEditByUser(req.user)) {
325
- child.handleFiles(req, res, function(err){
326
- model.save(function (error, model) {
327
- //EWLog(error, err)
328
- if (!err && !error) {
329
- req.flash('success', child.title + ' Başarıyla Güncellendi');
330
- res.model = model
331
- res.statusData = "Success"
332
-
333
- if(req.anyKey.__redirectUrl){
334
- return res.redirect(req.anyKey.__redirectUrl);
335
- }else{
336
- return res.redirect('/' + child.pluralName);
337
- }
338
- } else if (child.onError) {
339
- // console.log(err);
340
- req.flash('info', 'Bilinmeyen bir hata oluştu');
341
- if(err){
342
- res.errors.push(err)
343
- req.flash('error', err.message);
344
- }
345
- if(error){
346
- res.errors.push(error)
347
- req.flash('error', error.message);
348
- }
349
- res.statusData = "Error"
350
- child.onError(req, res, 'update', err || error);
351
- } else {
352
- // console.log(err.stacktrace);
353
- req.flash('info', 'Bilinmeyen bir hata oluştu');
354
- if(err){
355
- res.errors.push(err)
356
- req.flash('error', err.message);
357
- }
358
- if(error){
359
- res.errors.push(error)
360
- req.flash('error', error.message);
361
- }
362
- res.statusData = "Error"
363
- res.redirect('/users/' + req.user.id);
364
- }
365
- });
366
- })
367
- } else {
368
- req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
369
- if(req.user){
370
- res.statusData = "Error"
371
- return res.redirect('/users/' + req.user.id);
372
- }else{
37
+ if (!model){
373
38
  res.statusData = "Error"
374
- return res.redirect('/login');
39
+ return next(new Error('not found'));
375
40
  }
376
- }
377
- } else {
378
- req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
379
- if(req.user){
380
- res.statusData = "Error"
381
- return res.redirect('/users/' + req.user.id);
382
- }else{
383
- res.statusData = "Error"
384
- return res.redirect('/login');
385
- }
386
- }
387
- };
388
-
389
- /**
390
- * Show
391
- */
392
- child.coveredMethods.push("show");
393
- child.show = function (req, res) {
394
- //if (!utils.canAccessByUser(req.user, child.pluralName, child.group)) {
395
- // req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
396
- // res.redirect('/users/' + req.user.id);
397
- // return;
398
- //};
399
- var data = {
400
- title: child.title,
401
- pluralName: child.pluralName,
402
- //menu: utils.getUserMenu(req.user),
403
- };
404
- data[child.singularName] = req[child.singularName];
405
- if (data[child.singularName] && data[child.singularName].canSeeByUser(req.user)) {
406
- child.loadRelatedData(data, req, res, function (relatedData) {
407
- data.inject(relatedData)
408
- res.statusData = "Success"
409
- data.item = data[child.singularName]
410
- if(fs.existsSync(viewsDir + child.pluralName)){
411
- res.render(child.pluralName + '/show', data);
412
- }else{
413
- res.render("__basicItems" + '/show', data);
414
- }
415
- })
416
- } else {
417
- req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
418
- if(req.user){
419
- res.statusData = "Error"
420
- return res.redirect('/users/' + req.user.id);
421
- }else{
422
- res.statusData = "Error"
423
- return res.redirect('/login');
424
- }
425
- }
426
- };
427
-
428
- /**
429
- * Delete an company
430
- */
431
-
432
- child.coveredMethods.push("destroy");
433
- child.destroy = function (req, res) {
434
- //if (!utils.canAccessByUser(req.user, child.pluralName, child.group)) {
435
- // req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
436
- // res.redirect('/users/' + req.user.id);
437
- // return;
438
- //};
439
- var model = req[child.singularName];
440
- if (model && model.canEditByUser(req.user)) {
441
- model.remove(function (err) {
442
- req.flash('info', 'Başarıyla Silindi');
443
- res.statusData = "Success"
444
-
445
- if(req.anyKey.__redirectUrl){
446
- return res.redirect(req.anyKey.__redirectUrl);
447
- }else{
448
- return res.redirect('/' + child.pluralName);
41
+ if (!model.canSeeByUser(req.user)) {
42
+ //req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
43
+ if(req.user){
44
+ res.statusData = "Error"
45
+ return res.redirect('/users/' + req.user.id);
46
+ }else{
47
+ res.statusData = "Error"
48
+ return res.redirect('/login');
49
+ }
50
+ return;
449
51
  }
52
+ req[child.singularName] = model;
53
+ next();
450
54
  });
451
55
  }else{
452
- req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
453
- if(req.user){
454
- res.statusData = "Error"
455
- return res.redirect('/users/' + req.user.id);
456
- }else{
457
- res.statusData = "Error"
458
- return res.redirect('/login');
459
- }
56
+ next()
460
57
  }
461
58
  };
462
59
 
463
60
 
464
- child.coveredMethods.push("destroyMultiple");
465
- child.destroyMultiple = function (req, res) {
466
-
467
- var callback = function(){
468
-
469
- }
470
- var page = parseInt(req.anyKey.page > 0 ? req.anyKey.page : 1) - 1;
471
- var perPage = parseInt(req.anyKey.perPage > 0 ? req.anyKey.perPage : 10);
472
- var text = req.anyKey.q
473
- var options = {
474
- perPage: perPage,
475
- page: page,
476
- search: text
477
-
478
- };
479
- options.inject(req.options)
480
-
481
- var ids = req.anyKey.ids
482
- if(ids.indexOf("all") == -1){
483
- options["criteria"] = {_id: {$in: ids}}
484
- }
485
- var criteria = {}
486
- if(child.model.listByUserOptions){
487
- criteria = child.model.listByUserOptions(options, req.user, callback)
61
+ /**
62
+ * List
63
+ */
64
+
65
+ child.coveredMethods.push("index");
66
+ child.index = function (req, res) {
67
+ //if (!utils.canAccessByUser(req.user, child.pluralName, child.group)) {
68
+ // req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
69
+ // res.redirect('/users/' + req.user.id);
70
+ // return;
71
+ //};
72
+
73
+
74
+ var callback = function (err, models) {
75
+ if (err) {
76
+ res.statusData = "Error"
77
+ return res.render('500', {});
78
+ }
79
+ child.model.count(options.criteria || {}).exec(function (err, count) {
80
+ var pageCount = Math.ceil(count / perPage);
81
+ var pages = [];
82
+ var start = pageCount > 10 && page - 5 > 0 ? page - 5 : 0;
83
+ var end = pageCount > 10 && page + 5 < pageCount ? page + 5 : pageCount;
84
+ for(var i = start; i < end; i++){
85
+ pages.push(i);
86
+ }
87
+ if(start > 0){
88
+ pages.splice(0,0, "...");
89
+ pages.splice(0,0,0);
90
+ }
91
+ if(end < pageCount){
92
+ pages.push("...");
93
+ pages.push(pageCount - 1);
94
+ }
95
+ var data = {
96
+ user: req.user,
97
+ title: child.title + ' Listesi',
98
+ page: page + 1,
99
+ pages: pages,
100
+ perPage: perPage,
101
+ pageCount: pageCount,
102
+ isFiltered: Object.keys(req.anyKey).length > 0 ? true : false,
103
+ //menu: utils.getUserMenu(req.user),
104
+ };
105
+ data[child.pluralName] = models;
106
+ data["items"] = models;
107
+ data["pluralName"] = child.pluralName
108
+ data["singularName"] = child.singularName
109
+ data["title"] = child.title
110
+ res.errors.push(err)
111
+ child.loadRelatedData(data, req, res, function (relatedData) {
112
+ data.inject(relatedData);
113
+ res.statusData = "Success"
114
+
115
+ if(fs.existsSync(viewsDir + child.pluralName)){
116
+ res.render(child.pluralName + '/index', data);
117
+ }else{
118
+ res.render("__basicItems" + '/index', data);
119
+ }
120
+ });
121
+ });
122
+ }
123
+
124
+ var page = parseInt(req.anyKey.page > 0 ? req.anyKey.page : 1) - 1;
125
+ var perPage = parseInt(req.anyKey.perPage > 0 ? req.anyKey.perPage : 10);
126
+ var text = req.anyKey.q
127
+ var options = {
128
+ perPage: perPage,
129
+ page: page,
130
+ search: text,
131
+ criteria:{}
132
+ };
133
+ options.inject(req.options)
134
+
135
+ if (req?.anyKey?.sort) {
136
+ var sortObj = {};
137
+ var sortDir = (req.anyKey?.dir || 'asc').toLowerCase();
138
+ sortObj[req.anyKey?.sort] = sortDir === 'desc' ? -1 : 1;
139
+ options.sort = sortObj;
140
+ }
141
+
142
+ if(child.model.generateCriteria){
143
+ options.criteria.inject(child.model.generateCriteria(req.anyKey))
144
+ }
145
+
146
+ if(child.model.listByUserOptions){
147
+ options.criteria = child.model.listByUserOptions(options, req.user, callback)
488
148
  }else{
489
- criteria = child.model.list(options, callback);
490
- }
491
- child.model.deleteMany(criteria, function(err){
492
- req.flash('info', 'Başarıyla Silindi');
493
- res.statusData = "Success"
494
-
495
- if(req.anyKey.__redirectUrl){
496
- return res.redirect(req.anyKey.__redirectUrl);
497
- }else{
498
- return res.redirect('/' + child.pluralName);
499
- }
500
- })
501
- }
502
-
503
-
504
- child.coveredMethods.push("loadRelatedData");
505
- child.loadRelatedData = function (data, req, res, callback) {
506
- data.extras = {
507
- pluralName : child.pluralName,
508
- singularName : child.singularName
509
- }
510
- data.elements = child.elements
511
- data.url = req.url,
512
- data.user = req.user
513
- if(req.csrfToken){
514
- data.csrf_token = req.csrfToken()
149
+ options.criteria = child.model.list(options, callback);
515
150
  }
516
- callback(data);
517
- };
518
- child.super.loadRelatedData = child.loadRelatedData
519
- child.coveredMethods.push("authFilter");
520
- child.authFilter = function (req, res, documents, callback) {
521
- callback(documents);
522
- }
523
- child.coveredMethods.push("search");
524
- child.search = function (req, res) {
525
- var text = req.body.text
526
- if (text) {
527
- child.model.find(
528
- {$text: {$search: text}},
529
- {score: {$meta: "textScore"}}
530
- )
531
- .sort({score: {$meta: "textScore"}})
532
- .limit(20)
533
- .exec(function (error, documents) {//this is standard array.filter method;
534
- documents = documents.filter(function (doc) {
535
- return doc.canSeeByUser(req.user)
536
- });
537
- if (documents) {
538
- res.json({query: text, results: documents});
539
- } else {
540
- res.json({});
541
- }
151
+ };
152
+
153
+ /**
154
+ * New article
155
+ */
156
+
157
+ child.coveredMethods.push("new");
158
+ child.new = function (req, res) {
159
+ //if (!utils.canAccessByUser(req.user, child.pluralName, child.group)) {
160
+ // req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
161
+ // res.redirect('/users/' + req.user.id);
162
+ // return;
163
+ //};
164
+
165
+ var data = {
166
+ user: req.user,
167
+ title: child.title,
168
+ pluralName: child.pluralName,
169
+ //menu: utils.getUserMenu(req.user),
170
+ };
171
+ var virtual = new child.model({});
172
+ if (virtual){// && virtual.canEditByUser(req.user)) {
173
+ child.loadRelatedData(data, req, res, function (relatedData) {
174
+ data.inject(relatedData);
175
+ res.statusData = "Success"
176
+
177
+
178
+ if(fs.existsSync(viewsDir + child.pluralName)){
179
+ res.render(child.pluralName + '/new', data);
180
+ }else{
181
+ res.render("__basicItems" + '/new', data);
182
+ }
183
+ });
184
+ } else {
185
+ req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
186
+ if(req.user){
187
+ res.statusData = "Error"
188
+ return res.redirect('/users/' + req.user.id);
189
+ }else{
190
+ res.statusData = "Error"
191
+ return res.redirect('/login');
192
+ }
193
+
194
+ }
195
+ };
196
+
197
+ /**
198
+ * Create an article
199
+ * Upload an image
200
+ */
201
+
202
+ child.coveredMethods.push("create");
203
+ child.create = function (req, res) {
204
+ //if (!utils.canAccessByUser(req.user, child.pluralName, child.group)) {
205
+ // req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
206
+ // res.redirect('/users/' + req.user.id);
207
+ // return;
208
+ //};
209
+ var model = new child.model(req.body);
210
+ model.user = req.user;
211
+ if (model && model.canEditByUser(req.user)) {
212
+ model.save(function (err) {
213
+ req[child.singularName] = model
214
+ child.handleFiles(req, res, function(error){
215
+ if (!err && !error) {
216
+ req.flash('success', child.title + ' Başarıyla Yaratıldı');
217
+ res.model = model
218
+ res.model[child.singularName] = model
219
+ res.statusData = "Success"
220
+ if(req.anyKey.__redirectUrl){
221
+ return res.redirect(req.anyKey.__redirectUrl);
222
+ }else{
223
+ return res.redirect('/' + child.pluralName);
224
+ }
225
+ } else if (child.onError) {
226
+ //console.log(err);
227
+ res.statusData = "Error"
228
+ child.onError(req, res, 'create', err ? err : error);
229
+ } else if(req.user){
230
+ //console.log(err);
231
+ //console.log(err.stacktrace);
232
+ req.flash('info', 'Bilinmeyen bir hata oluştu');
233
+ if(err){
234
+ res.errors.push(err)
235
+ req.flash('error', err.message);
236
+ }
237
+ if(error){
238
+ res.errors.push(error)
239
+ req.flash('error', error.message);
240
+ }
241
+ res.statusData = "Error"
242
+ res.redirect('/users/' + req.user.id);
243
+ }else {
244
+ req.flash('info', 'Bilinmeyen bir hata oluştu');
245
+ if(err){
246
+ res.errors.push(err)
247
+ req.flash('error', err.message);
248
+ }
249
+ if(error){
250
+ res.errors.push(error)
251
+ req.flash('error', error.message);
252
+ }
253
+ res.statusData = "Error"
254
+ res.redirect('/login/');
255
+ }
256
+ })
257
+ });
258
+ } else {
259
+ //EWLog("yetki", child.singularName, req[child.singularName])
260
+ req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
261
+ if(req.user){
262
+ res.statusData = "Error"
263
+ return res.redirect('/users/' + req.user.id);
264
+ }else{
265
+ res.statusData = "Error"
266
+ return res.redirect('/login');
267
+ }
268
+ }
269
+ };
270
+
271
+ /**
272
+ * Edit an article
273
+ */
274
+
275
+ child.coveredMethods.push("edit");
276
+ child.edit = function (req, res) {
277
+ //if (!utils.canAccessByUser(req.user, child.pluralName, child.group)) {
278
+ // req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
279
+ // res.redirect('/users/' + req.user.id);
280
+ // return;
281
+ //};
282
+ var data = {
283
+ user: req.user,
284
+ title: child.title,
285
+ pluralName: child.pluralName,
286
+ //menu: utils.getUserMenu(req.user),
287
+ };
288
+
289
+ data[child.singularName] = req[child.singularName];
290
+ if (data[child.singularName]){// && data[child.singularName].canEditByUser(req.user)) {
291
+ child.loadRelatedData(data, req, res, function (relatedData) {
292
+ data.inject(relatedData);
293
+ res.statusData = "Success"
294
+ data.item = data[child.singularName]
295
+ if(fs.existsSync(viewsDir + child.pluralName)){
296
+ res.render(child.pluralName + '/edit', data);
297
+ }else{
298
+ res.render("__basicItems" + '/edit', data);
299
+ }
300
+ });
301
+ } else {
302
+ req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
303
+ if(req.user){
304
+ res.statusData = "Error"
305
+ return res.redirect('/users/' + req.user.id);
306
+ }else{
307
+ res.statusData = "Error"
308
+ return res.redirect('/login');
309
+ }
310
+ }
311
+
312
+ };
313
+
314
+ /**
315
+ * Update article
316
+ */
317
+
318
+ child.coveredMethods.push("update");
319
+ child.update = function (req, res) {
320
+ //if (!utils.canAccessByUser(req.user, child.pluralName, child.group)) {
321
+ // req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
322
+ // res.redirect('/users/' + req.user.id);
323
+ // return;
324
+ //};
325
+ var model = req[child.singularName];
326
+
327
+ // make sure no one changes the user
328
+ delete req.body.user;
329
+ if (model){// && model.canEditByUser(req.user)) {
330
+ model = extend(model, req.body);
331
+ if (model && model.canEditByUser(req.user)) {
332
+ child.handleFiles(req, res, function(err){
333
+ model.save(function (error, model) {
334
+ //EWLog(error, err)
335
+ if (!err && !error) {
336
+ req.flash('success', child.title + ' Başarıyla Güncellendi');
337
+ res.model = model
338
+ res.statusData = "Success"
339
+
340
+ if(req.anyKey.__redirectUrl){
341
+ return res.redirect(req.anyKey.__redirectUrl);
342
+ }else{
343
+ return res.redirect('/' + child.pluralName);
344
+ }
345
+ } else if (child.onError) {
346
+ // console.log(err);
347
+ req.flash('info', 'Bilinmeyen bir hata oluştu');
348
+ if(err){
349
+ res.errors.push(err)
350
+ req.flash('error', err.message);
351
+ }
352
+ if(error){
353
+ res.errors.push(error)
354
+ req.flash('error', error.message);
355
+ }
356
+ res.statusData = "Error"
357
+ child.onError(req, res, 'update', err || error);
358
+ } else {
359
+ // console.log(err.stacktrace);
360
+ req.flash('info', 'Bilinmeyen bir hata oluştu');
361
+ if(err){
362
+ res.errors.push(err)
363
+ req.flash('error', err.message);
364
+ }
365
+ if(error){
366
+ res.errors.push(error)
367
+ req.flash('error', error.message);
368
+ }
369
+ res.statusData = "Error"
370
+ res.redirect('/users/' + req.user.id);
371
+ }
372
+ });
373
+ })
374
+ } else {
375
+ req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
376
+ if(req.user){
377
+ res.statusData = "Error"
378
+ return res.redirect('/users/' + req.user.id);
379
+ }else{
380
+ res.statusData = "Error"
381
+ return res.redirect('/login');
382
+ }
383
+ }
384
+ } else {
385
+ req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
386
+ if(req.user){
387
+ res.statusData = "Error"
388
+ return res.redirect('/users/' + req.user.id);
389
+ }else{
390
+ res.statusData = "Error"
391
+ return res.redirect('/login');
392
+ }
393
+ }
394
+ };
395
+
396
+ /**
397
+ * Show
398
+ */
399
+ child.coveredMethods.push("show");
400
+ child.show = function (req, res) {
401
+ //if (!utils.canAccessByUser(req.user, child.pluralName, child.group)) {
402
+ // req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
403
+ // res.redirect('/users/' + req.user.id);
404
+ // return;
405
+ //};
406
+ var data = {
407
+ title: child.title,
408
+ pluralName: child.pluralName,
409
+ //menu: utils.getUserMenu(req.user),
410
+ };
411
+ data[child.singularName] = req[child.singularName];
412
+ if (data[child.singularName] && data[child.singularName].canSeeByUser(req.user)) {
413
+ child.loadRelatedData(data, req, res, function (relatedData) {
414
+ data.inject(relatedData)
415
+ res.statusData = "Success"
416
+ data.item = data[child.singularName]
417
+ if(fs.existsSync(viewsDir + child.pluralName)){
418
+ res.render(child.pluralName + '/show', data);
419
+ }else{
420
+ res.render("__basicItems" + '/show', data);
421
+ }
422
+ })
423
+ } else {
424
+ req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
425
+ if(req.user){
426
+ res.statusData = "Error"
427
+ return res.redirect('/users/' + req.user.id);
428
+ }else{
429
+ res.statusData = "Error"
430
+ return res.redirect('/login');
431
+ }
432
+ }
433
+ };
434
+
435
+ /**
436
+ * Delete an company
437
+ */
438
+
439
+ child.coveredMethods.push("destroy");
440
+ child.destroy = function (req, res) {
441
+ //if (!utils.canAccessByUser(req.user, child.pluralName, child.group)) {
442
+ // req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
443
+ // res.redirect('/users/' + req.user.id);
444
+ // return;
445
+ //};
446
+ var model = req[child.singularName];
447
+ if (model && model.canEditByUser(req.user)) {
448
+ model.remove(function (err) {
449
+ req.flash('info', 'Başarıyla Silindi');
450
+ res.statusData = "Success"
451
+
452
+ if(req.anyKey.__redirectUrl){
453
+ return res.redirect(req.anyKey.__redirectUrl);
454
+ }else{
455
+ return res.redirect('/' + child.pluralName);
456
+ }
457
+ });
458
+ }else{
459
+ req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
460
+ if(req.user){
461
+ res.statusData = "Error"
462
+ return res.redirect('/users/' + req.user.id);
463
+ }else{
464
+ res.statusData = "Error"
465
+ return res.redirect('/login');
466
+ }
467
+ }
468
+ };
469
+
470
+
471
+ child.coveredMethods.push("destroyMultiple");
472
+ child.destroyMultiple = function (req, res) {
473
+
474
+ var callback = function(){
542
475
 
543
- });
544
476
  }
545
-
546
- };
547
- child.coveredMethods.push("lookFile");
548
- child.lookFile = function(req, res){
549
- if(req[child.singularName] && req[child.singularName].canSeeByUser(req.user)){
550
- res.sendFile(path.resolve('uploads/' + child.singularName + "/" + req[child.singularName]['id'] + '/' + req.params.fileName))
551
- }else{
552
- res.json({error: "You are not authorized"})
553
- }
554
- }
555
- child.coveredMethods.push("lookMultipleFiles");
556
- child.lookMultipleFiles = function(req, res) {
557
- if (req[child.singularName] && req[child.singularName].canSeeByUser(req.user)) {
558
- const zipNames = req.params.zipName.split('&').map(name => name.trim());
559
- const id = req[child.singularName]._id.toString();
560
- const uploadPath = path.resolve('uploads', child.singularName, id.toString());
561
- const zipFileName = `${id}.zip`;
562
- const zipFilePath = path.join(uploadPath, zipFileName);
563
- const output = fs.createWriteStream(zipFilePath);
564
- const archive = archiver('zip');
565
-
566
- output.on('close', function() {
567
- res.download(zipFilePath, function(err) {
568
- if (err) {
569
- console.error('İndirme işlemi başarısız:', err);
570
- }
571
- fs.unlink(zipFilePath, (err) => {
572
- if (err) console.error('Zip dosyası silinemedi:', err);
573
- });
574
- });
575
- });
576
-
577
- archive.on('error', function(err) {
578
- console.error('Arşivleme hatası:', err);
579
- return res.status(500).json({ error: 'Zipping failed' });
580
- });
581
-
582
- archive.pipe(output);
583
-
584
- zipNames.forEach(file => {
585
- const filePath = path.join(uploadPath, file);
586
- if (fs.existsSync(filePath)) {
587
- archive.file(filePath, { name: file });
588
- } else {
589
- console.warn(`Dosya mevcut değil: ${filePath}`);
590
- }
591
- });
592
-
593
- archive.finalize();
594
- } else {
595
- res.json({ error: "Yetkiniz yok" });
596
- }
597
- };
598
-
599
- child.coveredMethods.push("uploadFile");
600
- child.uploadFile = function(req, res){
601
- child.handleFiles(req,res, function(error){
602
- if((!err && !error) || (err != null && error != null)){
603
- res.json({success:"images has been uploaded"})
604
- }else{
605
- res.json({error:error, err:err})
606
- }
607
- })
608
- }
609
- child.coveredMethods.push("handleFiles");
610
- child.handleFiles = function(req, res, next){
611
- if(req[child.singularName] && req[child.singularName].canEditByUser(req.user)){
612
- if (!fs.existsSync(path.resolve('uploads/' + child.singularName))){
613
- fs.mkdirSync(path.resolve('uploads/' + child.singularName));
614
- }
615
- if (!fs.existsSync(path.resolve('uploads/' + child.singularName + "/" + req[child.singularName].id))){
616
- fs.mkdirSync(path.resolve('uploads/' + child.singularName + "/" + req[child.singularName].id));
617
- }
618
- var needToSave = false
619
-
620
- if(req.files == null){
621
- req.files = {}
622
- }
623
- async.each(Object.keys(req.files), function(key, next){
624
- if(req[child.singularName].walk(key) == undefined || req[child.singularName].walk(key) == null){
625
- req[child.singularName].walk(key, [])
626
- }
627
- needToSave = true
628
- if(req.files[key].isArray() ){
629
- if(req[child.singularName].walk(key) == undefined || req[child.singularName].walk(key) == null){
630
- req[child.singularName].walk(key, [])
631
- }
632
- async.each(req.files[key], function(file, tick){
633
- file["dataPath"] = path.resolve('uploads/' + child.singularName + "/" + req[child.singularName].id + '/' + file.name)
634
- var item = req[child.singularName].walk(key);
635
- item.push(file.name)
636
- mv(file.newPath, file.dataPath, tick)
637
- }, next)
638
- }else {
639
- if(req[child.singularName].walk(key) == undefined || req[child.singularName].walk(key) == null){
640
- req[child.singularName].walk(key, {})
641
- }
642
- req.files[key]["dataPath"] = path.resolve('uploads/' + child.singularName + "/" + req[child.singularName].id + '/' + req.files[key].name)
643
- req[child.singularName].walk(key, req.files[key].name);
644
- mv(req.files[key].newPath, req.files[key].dataPath, next)
645
- }
646
- }, function(err){
647
- //EWLog(needToSave)
648
- if(needToSave){
649
- req[child.singularName].save(next)
650
- }else{
651
- next()
652
- }
653
- })
654
- }else{
655
- req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
656
- if(req.user){
657
- res.statusData = "Error"
658
- return res.redirect('/users/' + req.user.id);
659
- }else{
660
- res.statusData = "Error"
661
- return res.redirect('/login');
662
- }
663
- }
664
- }
665
- child.apify = function(funcName){
666
- var method = function(req, res){
667
- var argsPre = arguments.toArrayEW();
668
- res._redirect = res.redirect
669
- res.redirect = function(name){
670
- var data = {
671
- status: res.statusData,
672
- type:"redirect",
673
- name:name,
674
- model:res.model,
675
- flash:res.flashData
676
- }
677
- data[child.singularName] = res.model
678
- res.json(data);
679
- }
680
- res._render = res.redirect
681
- res.render = function(name, model){
682
- var data = {
683
- status:res.statusData,
684
- type:"render",
685
- name:name,
686
- model:model,
687
- flash:res.flashData
688
- }
689
- data[child.singularName] = res.model
690
- res.json(data);
691
- }
692
- res._flash = res.flash
693
- res.flash = function(name, message){
694
- if(res.flashData == undefined || res.flashData == null){
695
- res.flashData = []
696
- }
697
- res.flashData.push({name:name, message:message});
698
- }
699
- req._flash = req.flash
700
- req.flash = function(name, message){
701
- if(res.flashData == undefined || res.flashData == null){
702
- res.flashData = []
703
- }
704
- res.flashData.push({name:name, message:message});
705
- }
706
- child[funcName].apply(this, argsPre);
707
- }
708
- child[funcName + "API"] = function(req, res){
709
- var argsInner = arguments.toArrayEW();
710
- if(req.params[child.singularName + 'Id']){
711
- child.load(req, res, function(){
712
- method.apply(this, argsInner)
713
- }, req.params[child.singularName + 'Id'])
714
- }else if(req.body[child.singularName + 'Id']){
715
- child.load(req, res, function(){
716
- method.apply(this, argsInner)
717
- }, req.body[child.singularName + 'Id'])
718
- }else if(req.query[child.singularName + 'Id']){
719
- child.load(req, res, function(){
720
- method.apply(this, argsInner)
721
- }, req.query[child.singularName + 'Id'])
722
- }else{
723
- method.apply(this, argsInner)
724
- }
725
- }
726
- }
727
- /*
728
- child.apifyAllRequests = function(s){ // need function that encapsulated to have first arg as req and second arg as res
729
- for(var key in this){
730
- var obj = this[key];
731
- if(key != 'loadRelatedData' && typeof obj == "function" && !key.includes("API")){
732
- var params = getParamNames(obj);
733
- if(params[0] == "req" && params[1] == "res" && params.length == 2){
734
- this.apify(key);
735
- }
736
- }
737
- }
738
- };
739
- child.apifyAllRequests();*/
740
-
741
-
742
- child.acceptCheck = function(funcName){
743
- child[funcName] = child[funcName].goAOP()
744
- child[funcName].preCall = function(req, res, n){
745
- if(!res.errors){
746
- res.errors = []
747
- }
748
- if(req.accepts('html')){
749
- }else if(req.accepts('json')){
750
- res._redirect = res.redirect
751
- res.redirect = function(name){
752
- var data = {
753
- status: res.statusData,
754
- type:"redirect",
755
- name:name,
756
- model:res.model,
757
- flash:res.flashData
758
- }
759
- data[child.singularName] = res.model
760
- res.json(data);
761
- }
762
- res._render = res.redirect
763
- res.render = function(name, model){
764
- var data = {
765
- status:res.statusData,
766
- type:"render",
767
- name:name,
768
- model:model,
769
- flash:res.flashData
770
- }
771
- data[child.singularName] = res.model
772
- res.json(data);
773
- }
774
- res._flash = res.flash
775
- res.flash = function(name, message){
776
- if(res.flashData == undefined || res.flashData == null){
777
- res.flashData = []
778
- }
779
- res.flashData.push({name:name, message:message});
780
- }
781
- req._flash = req.flash
782
- req.flash = function(name, message){
783
- if(res.flashData == undefined || res.flashData == null){
784
- res.flashData = []
785
- }
786
- res.flashData.push({name:name, message:message});
787
- }
788
- }
789
-
790
-
791
- var argsPre = arguments.toArrayEW();
792
- var next = argsPre[argsPre.length -1];
793
- next.apply(this,argsPre);
794
- }
795
- }
796
- child.acceptCheckAllRequests = function(s){ // need function that encapsulated to have first arg as req and second arg as res
797
- for(var key in this){
798
- var obj = this[key];
799
- if(key != 'loadRelatedData' && typeof obj == "function" && !key.includes("API")){
800
- var params = getParamNames(obj);
801
- if(params[0] == "req" && params[1] == "res" && params.length == 2){
802
- //EWLog(child.pluralName, key)
803
- this.apify(key);
804
- this.acceptCheck(key);
805
- }
477
+ var page = parseInt(req.anyKey.page > 0 ? req.anyKey.page : 1) - 1;
478
+ var perPage = parseInt(req.anyKey.perPage > 0 ? req.anyKey.perPage : 10);
479
+ var text = req.anyKey.q
480
+ var options = {
481
+ perPage: perPage,
482
+ page: page,
483
+ search: text
484
+
485
+ };
486
+ options.inject(req.options)
487
+
488
+ var ids = req.anyKey.ids
489
+ if(ids.indexOf("all") == -1){
490
+ options["criteria"] = {_id: {$in: ids}}
491
+ }
492
+ var criteria = {}
493
+ if(child.model.listByUserOptions){
494
+ criteria = child.model.listByUserOptions(options, req.user, callback)
495
+ }else{
496
+ criteria = child.model.list(options, callback);
497
+ }
498
+ child.model.deleteMany(criteria, function(err){
499
+ req.flash('info', 'Başarıyla Silindi');
500
+ res.statusData = "Success"
501
+
502
+ if(req.anyKey.__redirectUrl){
503
+ return res.redirect(req.anyKey.__redirectUrl);
504
+ }else{
505
+ return res.redirect('/' + child.pluralName);
506
+ }
507
+ })
508
+ }
509
+
510
+
511
+ child.coveredMethods.push("loadRelatedData");
512
+ child.loadRelatedData = function (data, req, res, callback) {
513
+ data.extras = {
514
+ pluralName : child.pluralName,
515
+ singularName : child.singularName
516
+ }
517
+ data.elements = child.elements
518
+ data.url = req.url,
519
+ data.user = req.user
520
+ if(req.csrfToken){
521
+ data.csrf_token = req.csrfToken()
522
+ }
523
+ callback(data);
524
+ };
525
+ child.super.loadRelatedData = child.loadRelatedData
526
+ child.coveredMethods.push("authFilter");
527
+ child.authFilter = function (req, res, documents, callback) {
528
+ callback(documents);
529
+ }
530
+ child.coveredMethods.push("search");
531
+ child.search = function (req, res) {
532
+ var text = req.body.text
533
+ if (text) {
534
+ child.model.find(
535
+ {$text: {$search: text}},
536
+ {score: {$meta: "textScore"}}
537
+ )
538
+ .sort({score: {$meta: "textScore"}})
539
+ .limit(20)
540
+ .exec(function (error, documents) {//this is standard array.filter method;
541
+ documents = documents.filter(function (doc) {
542
+ return doc.canSeeByUser(req.user)
543
+ });
544
+ if (documents) {
545
+ res.json({query: text, results: documents});
546
+ } else {
547
+ res.json({});
548
+ }
549
+
550
+ });
551
+ }
552
+
553
+ };
554
+ child.coveredMethods.push("lookFile");
555
+ child.lookFile = function(req, res){
556
+ if(req[child.singularName] && req[child.singularName].canSeeByUser(req.user)){
557
+ res.sendFile(path.resolve('uploads/' + child.singularName + "/" + req[child.singularName]['id'] + '/' + req.params.fileName))
558
+ }else{
559
+ res.json({error: "You are not authorized"})
560
+ }
561
+ }
562
+ child.coveredMethods.push("lookMultipleFiles");
563
+ child.lookMultipleFiles = function(req, res) {
564
+ if (req[child.singularName] && req[child.singularName].canSeeByUser(req.user)) {
565
+ const zipNames = req.params.zipName.split('&').map(name => name.trim());
566
+ const id = req[child.singularName]._id.toString();
567
+ const uploadPath = path.resolve('uploads', child.singularName, id.toString());
568
+ const zipFileName = `${id}.zip`;
569
+ const zipFilePath = path.join(uploadPath, zipFileName);
570
+ const output = fs.createWriteStream(zipFilePath);
571
+ const archive = archiver('zip');
572
+
573
+ output.on('close', function() {
574
+ res.download(zipFilePath, function(err) {
575
+ if (err) {
576
+ console.error('İndirme işlemi başarısız:', err);
577
+ }
578
+ fs.unlink(zipFilePath, (err) => {
579
+ if (err) console.error('Zip dosyası silinemedi:', err);
580
+ });
581
+ });
582
+ });
583
+
584
+ archive.on('error', function(err) {
585
+ console.error('Arşivleme hatası:', err);
586
+ return res.status(500).json({ error: 'Zipping failed' });
587
+ });
588
+
589
+ archive.pipe(output);
590
+
591
+ zipNames.forEach(file => {
592
+ const filePath = path.join(uploadPath, file);
593
+ if (fs.existsSync(filePath)) {
594
+ archive.file(filePath, { name: file });
595
+ } else {
596
+ console.warn(`Dosya mevcut değil: ${filePath}`);
597
+ }
598
+ });
599
+
600
+ archive.finalize();
601
+ } else {
602
+ res.json({ error: "Yetkiniz yok" });
603
+ }
604
+ };
605
+
606
+ child.coveredMethods.push("uploadFile");
607
+ child.uploadFile = function(req, res){
608
+ child.handleFiles(req,res, function(error){
609
+ if((!err && !error) || (err != null && error != null)){
610
+ res.json({success:"images has been uploaded"})
611
+ }else{
612
+ res.json({error:error, err:err})
613
+ }
614
+ })
615
+ }
616
+ child.coveredMethods.push("handleFiles");
617
+ child.handleFiles = function(req, res, next){
618
+ if(req[child.singularName] && req[child.singularName].canEditByUser(req.user)){
619
+ if (!fs.existsSync(path.resolve('uploads/' + child.singularName))){
620
+ fs.mkdirSync(path.resolve('uploads/' + child.singularName));
621
+ }
622
+ if (!fs.existsSync(path.resolve('uploads/' + child.singularName + "/" + req[child.singularName].id))){
623
+ fs.mkdirSync(path.resolve('uploads/' + child.singularName + "/" + req[child.singularName].id));
624
+ }
625
+ var needToSave = false
626
+
627
+ if(req.files == null){
628
+ req.files = {}
629
+ }
630
+ async.each(Object.keys(req.files), function(key, next){
631
+ if(req[child.singularName].walk(key) == undefined || req[child.singularName].walk(key) == null){
632
+ req[child.singularName].walk(key, [])
633
+ }
634
+ needToSave = true
635
+ if(req.files[key].isArray() ){
636
+ if(req[child.singularName].walk(key) == undefined || req[child.singularName].walk(key) == null){
637
+ req[child.singularName].walk(key, [])
638
+ }
639
+ async.each(req.files[key], function(file, tick){
640
+ file["dataPath"] = path.resolve('uploads/' + child.singularName + "/" + req[child.singularName].id + '/' + file.name)
641
+ var item = req[child.singularName].walk(key);
642
+ item.push(file.name)
643
+ mv(file.newPath, file.dataPath, tick)
644
+ }, next)
645
+ }else {
646
+ if(req[child.singularName].walk(key) == undefined || req[child.singularName].walk(key) == null){
647
+ req[child.singularName].walk(key, {})
648
+ }
649
+ req.files[key]["dataPath"] = path.resolve('uploads/' + child.singularName + "/" + req[child.singularName].id + '/' + req.files[key].name)
650
+ req[child.singularName].walk(key, req.files[key].name);
651
+ mv(req.files[key].newPath, req.files[key].dataPath, next)
652
+ }
653
+ }, function(err){
654
+ //EWLog(needToSave)
655
+ if(needToSave){
656
+ req[child.singularName].save(next)
657
+ }else{
658
+ next()
659
+ }
660
+ })
661
+ }else{
662
+ req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
663
+ if(req.user){
664
+ res.statusData = "Error"
665
+ return res.redirect('/users/' + req.user.id);
666
+ }else{
667
+ res.statusData = "Error"
668
+ return res.redirect('/login');
669
+ }
670
+ }
671
+ }
672
+ child.apify = function(funcName){
673
+ var method = function(req, res){
674
+ var argsPre = arguments.toArrayEW();
675
+ res._redirect = res.redirect
676
+ res.redirect = function(name){
677
+ var data = {
678
+ status: res.statusData,
679
+ type:"redirect",
680
+ name:name,
681
+ model:res.model,
682
+ flash:res.flashData
683
+ }
684
+ data[child.singularName] = res.model
685
+ res.json(data);
686
+ }
687
+ res._render = res.redirect
688
+ res.render = function(name, model){
689
+ var data = {
690
+ status:res.statusData,
691
+ type:"render",
692
+ name:name,
693
+ model:model,
694
+ flash:res.flashData
695
+ }
696
+ data[child.singularName] = res.model
697
+ res.json(data);
698
+ }
699
+ res._flash = res.flash
700
+ res.flash = function(name, message){
701
+ if(res.flashData == undefined || res.flashData == null){
702
+ res.flashData = []
703
+ }
704
+ res.flashData.push({name:name, message:message});
705
+ }
706
+ req._flash = req.flash
707
+ req.flash = function(name, message){
708
+ if(res.flashData == undefined || res.flashData == null){
709
+ res.flashData = []
710
+ }
711
+ res.flashData.push({name:name, message:message});
712
+ }
713
+ child[funcName].apply(this, argsPre);
714
+ }
715
+ child[funcName + "API"] = function(req, res){
716
+ var argsInner = arguments.toArrayEW();
717
+ if(req.params[child.singularName + 'Id']){
718
+ child.load(req, res, function(){
719
+ method.apply(this, argsInner)
720
+ }, req.params[child.singularName + 'Id'])
721
+ }else if(req.body[child.singularName + 'Id']){
722
+ child.load(req, res, function(){
723
+ method.apply(this, argsInner)
724
+ }, req.body[child.singularName + 'Id'])
725
+ }else if(req.query[child.singularName + 'Id']){
726
+ child.load(req, res, function(){
727
+ method.apply(this, argsInner)
728
+ }, req.query[child.singularName + 'Id'])
729
+ }else{
730
+ method.apply(this, argsInner)
731
+ }
732
+ }
733
+ }
734
+ /*
735
+ child.apifyAllRequests = function(s){ // need function that encapsulated to have first arg as req and second arg as res
736
+ for(var key in this){
737
+ var obj = this[key];
738
+ if(key != 'loadRelatedData' && typeof obj == "function" && !key.includes("API")){
739
+ var params = getParamNames(obj);
740
+ if(params[0] == "req" && params[1] == "res" && params.length == 2){
741
+ this.apify(key);
742
+ }
743
+ }
744
+ }
745
+ };
746
+ child.apifyAllRequests();*/
747
+
748
+
749
+ child.acceptCheck = function(funcName){
750
+ child[funcName] = child[funcName].goAOP()
751
+ child[funcName].preCall = function(req, res, n){
752
+ if(!res.errors){
753
+ res.errors = []
806
754
  }
807
- }
808
- };
809
- child.apifyAllRequests = child.apifyAllRequests
755
+ if(req.accepts('html')){
756
+ }else if(req.accepts('json')){
757
+ res._redirect = res.redirect
758
+ res.redirect = function(name){
759
+ var data = {
760
+ status: res.statusData,
761
+ type:"redirect",
762
+ name:name,
763
+ model:res.model,
764
+ flash:res.flashData
765
+ }
766
+ data[child.singularName] = res.model
767
+ res.json(data);
768
+ }
769
+ res._render = res.redirect
770
+ res.render = function(name, model){
771
+ var data = {
772
+ status:res.statusData,
773
+ type:"render",
774
+ name:name,
775
+ model:model,
776
+ flash:res.flashData
777
+ }
778
+ data[child.singularName] = res.model
779
+ res.json(data);
780
+ }
781
+ res._flash = res.flash
782
+ res.flash = function(name, message){
783
+ if(res.flashData == undefined || res.flashData == null){
784
+ res.flashData = []
785
+ }
786
+ res.flashData.push({name:name, message:message});
787
+ }
788
+ req._flash = req.flash
789
+ req.flash = function(name, message){
790
+ if(res.flashData == undefined || res.flashData == null){
791
+ res.flashData = []
792
+ }
793
+ res.flashData.push({name:name, message:message});
794
+ }
795
+ }
796
+
797
+
798
+ var argsPre = arguments.toArrayEW();
799
+ var next = argsPre[argsPre.length -1];
800
+ next.apply(this,argsPre);
801
+ }
802
+ }
803
+ child.acceptCheckAllRequests = function(s){ // need function that encapsulated to have first arg as req and second arg as res
804
+ for(var key in this){
805
+ var obj = this[key];
806
+ if(key != 'loadRelatedData' && typeof obj == "function" && !key.includes("API")){
807
+ var params = getParamNames(obj);
808
+ if(params[0] == "req" && params[1] == "res" && params.length == 2){
809
+ //EWLog(child.pluralName, key)
810
+ this.apify(key);
811
+ this.acceptCheck(key);
812
+ }
813
+ }
814
+ }
815
+ };
816
+ child.apifyAllRequests = child.apifyAllRequests
810
817
  };
811
818
  var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
812
819
  var ARGUMENT_NAMES = /([^\s,]+)/g;
813
820
 
814
821
  function getParamNames (func) {
815
- var fnStr = func.toString().replace(STRIP_COMMENTS, '');
816
- var result = fnStr.slice(fnStr.indexOf('(')+1, fnStr.indexOf(')')).match(ARGUMENT_NAMES);
817
- if(result === null)
818
- result = [];
819
- return result;
822
+ var fnStr = func.toString().replace(STRIP_COMMENTS, '');
823
+ var result = fnStr.slice(fnStr.indexOf('(')+1, fnStr.indexOf(')')).match(ARGUMENT_NAMES);
824
+ if(result === null)
825
+ result = [];
826
+ return result;
820
827
  }