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.
- package/BaseController/BaseController.js +795 -788
- package/Environment/environment.js +2 -2
- package/NoDuplicate/README.md +94 -46
- package/NoDuplicate/no-duplicate.js +43 -25
- package/NoDuplicate/package-lock.json +1420 -0
- package/NoDuplicate/package.json +22 -24
- package/NoDuplicate/tests/characterization.test.js +359 -0
- package/SoftDelete/mongoose-soft-delete.js +60 -8
- package/SoftDelete/package-lock.json +1391 -0
- package/SoftDelete/package.json +20 -22
- package/SoftDelete/tests/characterization.test.js +375 -0
- package/ToolBox/RequestTrackTools.js +0 -14
- package/ToolBox/Routes.js +148 -54
- package/ToolBox/package-lock.json +2533 -0
- package/ToolBox/package.json +23 -7
- package/ToolBox/tests/event-log.test.js +365 -0
- package/ToolBox/tests/helpers.js +241 -0
- package/ToolBox/tests/request-track-tools.test.js +197 -0
- package/ToolBox/tests/routes.test.js +313 -0
- package/package.json +36 -29
- package/threads/Workers/ControllerWorker.js +38 -58
- package/threads/Workers/DBWorker.js +21 -17
- package/threads/Workers/MongoClientWorker.js +36 -24
- package/threads/package-lock.json +2082 -27
- package/threads/package.json +21 -10
- package/threads/tests/CrashWorker.js +17 -0
- package/threads/tests/DuplicatePartialWorker.js +32 -0
- package/threads/tests/EchoWorker.js +13 -0
- package/threads/tests/LargePayloadWorker.js +39 -0
- package/threads/tests/MalformedPartialWorker.js +27 -0
- package/threads/tests/SlowWorker.js +17 -0
- package/threads/tests/StreamingPartialWorker.js +47 -0
- package/threads/tests/bug-reproducers.js +309 -0
- package/threads/tests/locked-interface.js +250 -0
- package/threads/tests/tests.js +529 -46
- package/threads/threads.js +440 -363
- package/utils/package-lock.json +1343 -0
- package/utils/package.json +14 -5
- package/utils/tests/coordination.test.js +247 -0
- package/utils/tests/crypto.test.js +81 -0
- package/utils/tests/helpers.js +111 -0
- package/utils/tests/http.test.js +324 -0
- package/utils/tests/pure.test.js +284 -0
- package/utils/tests/strings.test.js +112 -0
- package/utils/utils.js +37 -17
- package/.idea/.name +0 -1
- package/.idea/encodings.xml +0 -6
- package/.idea/jsLibraryMappings.xml +0 -6
- package/.idea/kle-ElderWand.iml +0 -9
- package/.idea/libraries/kle_ElderWand_node_modules.xml +0 -14
- package/.idea/misc.xml +0 -13
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/.idea/workspace.xml +0 -793
- package/BoilerPlate/Documents/.editorconfig +0 -10
- package/BoilerPlate/Documents/.sailsrc +0 -5
- package/BoilerPlate/Documents/CONTRIBUTING.md +0 -1
- package/BoilerPlate/Documents/LICENSE.txt +0 -21
- package/BoilerPlate/Documents/Procfile +0 -1
- package/BoilerPlate/Documents/README.md +0 -63
- package/BoilerPlate/Documents/app/controllers/documents.js +0 -45
- package/BoilerPlate/Documents/app/controllers/sectionGrups.js +0 -22
- package/BoilerPlate/Documents/app/controllers/sectionTypes.js +0 -51
- package/BoilerPlate/Documents/app/controllers/sections.js +0 -139
- package/BoilerPlate/Documents/app/controllers/users.js +0 -74
- package/BoilerPlate/Documents/app/models/document.js +0 -105
- package/BoilerPlate/Documents/app/models/section.js +0 -156
- package/BoilerPlate/Documents/app/models/sectionGrup.js +0 -136
- package/BoilerPlate/Documents/app/models/sectionType.js +0 -135
- package/BoilerPlate/Documents/app/models/user.js +0 -202
- package/BoilerPlate/Documents/app/views/404.html +0 -5
- package/BoilerPlate/Documents/app/views/500.html +0 -13
- package/BoilerPlate/Documents/app/views/documentation.html +0 -37
- package/BoilerPlate/Documents/app/views/documents/document.html +0 -11
- package/BoilerPlate/Documents/app/views/documents/edit.html +0 -1
- package/BoilerPlate/Documents/app/views/documents/form.html +0 -43
- package/BoilerPlate/Documents/app/views/documents/index.html +0 -58
- package/BoilerPlate/Documents/app/views/documents/new.html +0 -1
- package/BoilerPlate/Documents/app/views/documents/show.html +0 -2
- package/BoilerPlate/Documents/app/views/includes/foot.html +0 -29
- package/BoilerPlate/Documents/app/views/includes/footer.html +0 -1
- package/BoilerPlate/Documents/app/views/includes/head.html +0 -31
- package/BoilerPlate/Documents/app/views/includes/header.html +0 -47
- package/BoilerPlate/Documents/app/views/includes/messages.html +0 -43
- package/BoilerPlate/Documents/app/views/layouts/default.html +0 -25
- package/BoilerPlate/Documents/app/views/sectionGrups/edit.html +0 -1
- package/BoilerPlate/Documents/app/views/sectionGrups/form.html +0 -47
- package/BoilerPlate/Documents/app/views/sectionGrups/index.html +0 -33
- package/BoilerPlate/Documents/app/views/sectionGrups/new.html +0 -1
- package/BoilerPlate/Documents/app/views/sectionGrups/sectionGrup.html +0 -11
- package/BoilerPlate/Documents/app/views/sectionGrups/show.html +0 -55
- package/BoilerPlate/Documents/app/views/sectionTypes/edit.html +0 -1
- package/BoilerPlate/Documents/app/views/sectionTypes/form.html +0 -42
- package/BoilerPlate/Documents/app/views/sectionTypes/index.html +0 -33
- package/BoilerPlate/Documents/app/views/sectionTypes/new.html +0 -1
- package/BoilerPlate/Documents/app/views/sectionTypes/sectionType.html +0 -17
- package/BoilerPlate/Documents/app/views/sectionTypes/show.html +0 -55
- package/BoilerPlate/Documents/app/views/sections/edit.html +0 -320
- package/BoilerPlate/Documents/app/views/sections/form.html +0 -277
- package/BoilerPlate/Documents/app/views/sections/index.html +0 -40
- package/BoilerPlate/Documents/app/views/sections/liste.html +0 -39
- package/BoilerPlate/Documents/app/views/sections/new.html +0 -1
- package/BoilerPlate/Documents/app/views/sections/section.html +0 -1
- package/BoilerPlate/Documents/app/views/sections/section_Like_blog.html +0 -32
- package/BoilerPlate/Documents/app/views/sections/section_Like_project.html +0 -35
- package/BoilerPlate/Documents/app/views/sections/section_about.html +0 -31
- package/BoilerPlate/Documents/app/views/sections/section_blog.html +0 -47
- package/BoilerPlate/Documents/app/views/sections/section_clients.html +0 -23
- package/BoilerPlate/Documents/app/views/sections/section_contact.html +0 -74
- package/BoilerPlate/Documents/app/views/sections/section_detay1Resimli.html +0 -23
- package/BoilerPlate/Documents/app/views/sections/section_detay1Resimsiz.html +0 -11
- package/BoilerPlate/Documents/app/views/sections/section_features.html +0 -23
- package/BoilerPlate/Documents/app/views/sections/section_funfact.html +0 -19
- package/BoilerPlate/Documents/app/views/sections/section_projects.html +0 -49
- package/BoilerPlate/Documents/app/views/sections/section_sadeceParagraf.html +0 -13
- package/BoilerPlate/Documents/app/views/sections/section_services.html +0 -34
- package/BoilerPlate/Documents/app/views/sections/section_slider.html +0 -195
- package/BoilerPlate/Documents/app/views/sections/section_team.html +0 -42
- package/BoilerPlate/Documents/app/views/sections/section_testimonialSSS.html +0 -51
- package/BoilerPlate/Documents/app/views/sections/section_video_about.html +0 -31
- package/BoilerPlate/Documents/app/views/sections/show.html +0 -55
- package/BoilerPlate/Documents/app/views/users/auth.html +0 -12
- package/BoilerPlate/Documents/app/views/users/index.html +0 -26
- package/BoilerPlate/Documents/app/views/users/login.html +0 -33
- package/BoilerPlate/Documents/app/views/users/show.html +0 -5
- package/BoilerPlate/Documents/app/views/users/signup.html +0 -43
- package/BoilerPlate/Documents/app/views/users/user.html +0 -28
- package/BoilerPlate/Documents/config/config.js +0 -35
- package/BoilerPlate/Documents/config/env/development.js +0 -53
- package/BoilerPlate/Documents/config/env/env.json +0 -12
- package/BoilerPlate/Documents/config/env/production.js +0 -33
- package/BoilerPlate/Documents/config/env/test.js +0 -33
- package/BoilerPlate/Documents/config/express.js +0 -124
- package/BoilerPlate/Documents/config/imager.js +0 -36
- package/BoilerPlate/Documents/config/middlewares/authorization.js +0 -55
- package/BoilerPlate/Documents/config/passport/facebook.js +0 -43
- package/BoilerPlate/Documents/config/passport/github.js +0 -43
- package/BoilerPlate/Documents/config/passport/google.js +0 -43
- package/BoilerPlate/Documents/config/passport/linkedin.js +0 -44
- package/BoilerPlate/Documents/config/passport/local.js +0 -37
- package/BoilerPlate/Documents/config/passport/twitter.js +0 -42
- package/BoilerPlate/Documents/config/passport.js +0 -40
- package/BoilerPlate/Documents/config/routes.js +0 -104
- package/BoilerPlate/Documents/lib/utils.js +0 -79
- package/BoilerPlate/Documents/nodemon.json +0 -5
- package/BoilerPlate/Documents/package-lock.json +0 -8993
- package/BoilerPlate/Documents/package.json +0 -49
- package/BoilerPlate/Documents/public/css/TheDocs.min.css +0 -1
- package/BoilerPlate/Documents/public/css/custom.css +0 -102
- package/BoilerPlate/Documents/public/css/skin/skin-blue.css +0 -71
- package/BoilerPlate/Documents/public/css/skin/skin-blue.css.map +0 -10
- package/BoilerPlate/Documents/public/css/skin/skin-blue.min.css +0 -1
- package/BoilerPlate/Documents/public/css/skin/skin-brown.css +0 -71
- package/BoilerPlate/Documents/public/css/skin/skin-brown.css.map +0 -10
- package/BoilerPlate/Documents/public/css/skin/skin-brown.min.css +0 -1
- package/BoilerPlate/Documents/public/css/skin/skin-cyan.css +0 -71
- package/BoilerPlate/Documents/public/css/skin/skin-cyan.css.map +0 -10
- package/BoilerPlate/Documents/public/css/skin/skin-cyan.min.css +0 -1
- package/BoilerPlate/Documents/public/css/skin/skin-dark.css +0 -71
- package/BoilerPlate/Documents/public/css/skin/skin-dark.css.map +0 -10
- package/BoilerPlate/Documents/public/css/skin/skin-dark.min.css +0 -1
- package/BoilerPlate/Documents/public/css/skin/skin-gray.css +0 -71
- package/BoilerPlate/Documents/public/css/skin/skin-gray.css.map +0 -10
- package/BoilerPlate/Documents/public/css/skin/skin-gray.min.css +0 -1
- package/BoilerPlate/Documents/public/css/skin/skin-green.css +0 -71
- package/BoilerPlate/Documents/public/css/skin/skin-green.css.map +0 -10
- package/BoilerPlate/Documents/public/css/skin/skin-green.min.css +0 -1
- package/BoilerPlate/Documents/public/css/skin/skin-orange.css +0 -71
- package/BoilerPlate/Documents/public/css/skin/skin-orange.css.map +0 -10
- package/BoilerPlate/Documents/public/css/skin/skin-orange.min.css +0 -1
- package/BoilerPlate/Documents/public/css/skin/skin-pink.css +0 -71
- package/BoilerPlate/Documents/public/css/skin/skin-pink.css.map +0 -10
- package/BoilerPlate/Documents/public/css/skin/skin-pink.min.css +0 -1
- package/BoilerPlate/Documents/public/css/skin/skin-purple.css +0 -71
- package/BoilerPlate/Documents/public/css/skin/skin-purple.css.map +0 -10
- package/BoilerPlate/Documents/public/css/skin/skin-purple.min.css +0 -1
- package/BoilerPlate/Documents/public/css/skin/skin-red.css +0 -71
- package/BoilerPlate/Documents/public/css/skin/skin-red.css.map +0 -10
- package/BoilerPlate/Documents/public/css/skin/skin-red.min.css +0 -1
- package/BoilerPlate/Documents/public/css/skin/skin-teal.css +0 -71
- package/BoilerPlate/Documents/public/css/skin/skin-teal.css.map +0 -10
- package/BoilerPlate/Documents/public/css/skin/skin-teal.min.css +0 -1
- package/BoilerPlate/Documents/public/css/skin/skin-yellow.css +0 -71
- package/BoilerPlate/Documents/public/css/skin/skin-yellow.css.map +0 -10
- package/BoilerPlate/Documents/public/css/skin/skin-yellow.min.css +0 -1
- package/BoilerPlate/Documents/public/css/theDocs/_alerts.scss +0 -49
- package/BoilerPlate/Documents/public/css/theDocs/_banner.scss +0 -225
- package/BoilerPlate/Documents/public/css/theDocs/_blog.scss +0 -240
- package/BoilerPlate/Documents/public/css/theDocs/_breadcrumb.scss +0 -10
- package/BoilerPlate/Documents/public/css/theDocs/_buttons.scss +0 -143
- package/BoilerPlate/Documents/public/css/theDocs/_carousel.scss +0 -92
- package/BoilerPlate/Documents/public/css/theDocs/_code.scss +0 -372
- package/BoilerPlate/Documents/public/css/theDocs/_color.scss +0 -38
- package/BoilerPlate/Documents/public/css/theDocs/_content.scss +0 -108
- package/BoilerPlate/Documents/public/css/theDocs/_faq.scss +0 -82
- package/BoilerPlate/Documents/public/css/theDocs/_files.scss +0 -137
- package/BoilerPlate/Documents/public/css/theDocs/_footer.scss +0 -82
- package/BoilerPlate/Documents/public/css/theDocs/_form.scss +0 -24
- package/BoilerPlate/Documents/public/css/theDocs/_header.scss +0 -374
- package/BoilerPlate/Documents/public/css/theDocs/_jumbotron.scss +0 -150
- package/BoilerPlate/Documents/public/css/theDocs/_labels.scss +0 -23
- package/BoilerPlate/Documents/public/css/theDocs/_media.scss +0 -24
- package/BoilerPlate/Documents/public/css/theDocs/_mixins.scss +0 -66
- package/BoilerPlate/Documents/public/css/theDocs/_pagination.scss +0 -75
- package/BoilerPlate/Documents/public/css/theDocs/_promo.scss +0 -112
- package/BoilerPlate/Documents/public/css/theDocs/_requirements.scss +0 -53
- package/BoilerPlate/Documents/public/css/theDocs/_sidebar.scss +0 -666
- package/BoilerPlate/Documents/public/css/theDocs/_step.scss +0 -161
- package/BoilerPlate/Documents/public/css/theDocs/_tab.scss +0 -105
- package/BoilerPlate/Documents/public/css/theDocs/_tables.scss +0 -106
- package/BoilerPlate/Documents/public/css/theDocs/_toc.scss +0 -78
- package/BoilerPlate/Documents/public/css/theDocs/_typography.scss +0 -282
- package/BoilerPlate/Documents/public/css/theDocs/_variables.scss +0 -98
- package/BoilerPlate/Documents/public/css/theDocs/_views.scss +0 -215
- package/BoilerPlate/Documents/public/css/theDocs/skins/_skin.scss +0 -76
- package/BoilerPlate/Documents/public/css/theDocs/skins/skin-blue.scss +0 -3
- package/BoilerPlate/Documents/public/css/theDocs/skins/skin-brown.scss +0 -3
- package/BoilerPlate/Documents/public/css/theDocs/skins/skin-cyan.scss +0 -3
- package/BoilerPlate/Documents/public/css/theDocs/skins/skin-dark.scss +0 -3
- package/BoilerPlate/Documents/public/css/theDocs/skins/skin-gray.scss +0 -3
- package/BoilerPlate/Documents/public/css/theDocs/skins/skin-green.scss +0 -3
- package/BoilerPlate/Documents/public/css/theDocs/skins/skin-orange.scss +0 -3
- package/BoilerPlate/Documents/public/css/theDocs/skins/skin-pink.scss +0 -3
- package/BoilerPlate/Documents/public/css/theDocs/skins/skin-purple.scss +0 -3
- package/BoilerPlate/Documents/public/css/theDocs/skins/skin-red.scss +0 -3
- package/BoilerPlate/Documents/public/css/theDocs/skins/skin-teal.scss +0 -3
- package/BoilerPlate/Documents/public/css/theDocs/skins/skin-yellow.scss +0 -3
- package/BoilerPlate/Documents/public/css/theDocs.all.min.css +0 -24
- package/BoilerPlate/Documents/public/css/theDocs.css +0 -3945
- package/BoilerPlate/Documents/public/css/theDocs.css.map +0 -38
- package/BoilerPlate/Documents/public/css/theDocs.scss +0 -70
- package/BoilerPlate/Documents/public/fonts/FontAwesome.otf +0 -0
- package/BoilerPlate/Documents/public/fonts/fontawesome-webfont.eot +0 -0
- package/BoilerPlate/Documents/public/fonts/fontawesome-webfont.svg +0 -2671
- package/BoilerPlate/Documents/public/fonts/fontawesome-webfont.ttf +0 -0
- package/BoilerPlate/Documents/public/fonts/fontawesome-webfont.woff +0 -0
- package/BoilerPlate/Documents/public/fonts/fontawesome-webfont.woff2 +0 -0
- package/BoilerPlate/Documents/public/fonts/glyphicons-halflings-regular.eot +0 -0
- package/BoilerPlate/Documents/public/fonts/glyphicons-halflings-regular.svg +0 -288
- package/BoilerPlate/Documents/public/fonts/glyphicons-halflings-regular.ttf +0 -0
- package/BoilerPlate/Documents/public/fonts/glyphicons-halflings-regular.woff +0 -0
- package/BoilerPlate/Documents/public/fonts/glyphicons-halflings-regular.woff2 +0 -0
- package/BoilerPlate/Documents/public/img/apple-touch-icon-114x114.png +0 -0
- package/BoilerPlate/Documents/public/img/apple-touch-icon-72x72.png +0 -0
- package/BoilerPlate/Documents/public/img/apple-touch-icon.png +0 -0
- package/BoilerPlate/Documents/public/img/arrow-circle-down.svg +0 -1
- package/BoilerPlate/Documents/public/img/arrow-circle-right.svg +0 -1
- package/BoilerPlate/Documents/public/img/atlassian.svg +0 -1
- package/BoilerPlate/Documents/public/img/avatar-1.jpg +0 -0
- package/BoilerPlate/Documents/public/img/banner-default.png +0 -0
- package/BoilerPlate/Documents/public/img/banner-full-height.png +0 -0
- package/BoilerPlate/Documents/public/img/banner-lg.png +0 -0
- package/BoilerPlate/Documents/public/img/banner-sample1.png +0 -0
- package/BoilerPlate/Documents/public/img/banner-sample2.png +0 -0
- package/BoilerPlate/Documents/public/img/banner-sample3.png +0 -0
- package/BoilerPlate/Documents/public/img/banner-sm.png +0 -0
- package/BoilerPlate/Documents/public/img/banner.jpg +0 -0
- package/BoilerPlate/Documents/public/img/banner1.jpg +0 -0
- package/BoilerPlate/Documents/public/img/banner2.jpg +0 -0
- package/BoilerPlate/Documents/public/img/banner3.jpg +0 -0
- package/BoilerPlate/Documents/public/img/banner4.png +0 -0
- package/BoilerPlate/Documents/public/img/banner5.png +0 -0
- package/BoilerPlate/Documents/public/img/check-circle.svg +0 -1
- package/BoilerPlate/Documents/public/img/chevron-circle-right.svg +0 -1
- package/BoilerPlate/Documents/public/img/circle-with-minus.svg +0 -1
- package/BoilerPlate/Documents/public/img/circle-with-plus.svg +0 -1
- package/BoilerPlate/Documents/public/img/cloud.svg +0 -1
- package/BoilerPlate/Documents/public/img/conference-image-1.jpg +0 -0
- package/BoilerPlate/Documents/public/img/conference-image-2.jpg +0 -0
- package/BoilerPlate/Documents/public/img/conference-image-3.jpg +0 -0
- package/BoilerPlate/Documents/public/img/edward.jpg +0 -0
- package/BoilerPlate/Documents/public/img/elderwand-logo.png +0 -0
- package/BoilerPlate/Documents/public/img/email.svg +0 -1
- package/BoilerPlate/Documents/public/img/envato.svg +0 -1
- package/BoilerPlate/Documents/public/img/facebook.svg +0 -1
- package/BoilerPlate/Documents/public/img/favicon.png +0 -0
- package/BoilerPlate/Documents/public/img/heart.svg +0 -1
- package/BoilerPlate/Documents/public/img/images.svg +0 -1
- package/BoilerPlate/Documents/public/img/index.png +0 -0
- package/BoilerPlate/Documents/public/img/jacob.jpg +0 -0
- package/BoilerPlate/Documents/public/img/jquery.svg +0 -1
- package/BoilerPlate/Documents/public/img/jumbotron-bg.png +0 -0
- package/BoilerPlate/Documents/public/img/layout-single1.png +0 -0
- package/BoilerPlate/Documents/public/img/layout-single2.png +0 -0
- package/BoilerPlate/Documents/public/img/layout-single3.png +0 -0
- package/BoilerPlate/Documents/public/img/location-pin.svg +0 -1
- package/BoilerPlate/Documents/public/img/lucy.jpg +0 -0
- package/BoilerPlate/Documents/public/img/mamtas-logo-simple.png +0 -0
- package/BoilerPlate/Documents/public/img/music.svg +0 -1
- package/BoilerPlate/Documents/public/img/nathan.jpg +0 -0
- package/BoilerPlate/Documents/public/img/navbar-dark.png +0 -0
- package/BoilerPlate/Documents/public/img/navbar-default.png +0 -0
- package/BoilerPlate/Documents/public/img/navbar-fullwidth.png +0 -0
- package/BoilerPlate/Documents/public/img/navbar-lg.png +0 -0
- package/BoilerPlate/Documents/public/img/navbar-light.png +0 -0
- package/BoilerPlate/Documents/public/img/navbar-sm.png +0 -0
- package/BoilerPlate/Documents/public/img/phone.svg +0 -1
- package/BoilerPlate/Documents/public/img/placeholder-1900.png +0 -0
- package/BoilerPlate/Documents/public/img/placeholder.png +0 -0
- package/BoilerPlate/Documents/public/img/sidebar-default.png +0 -0
- package/BoilerPlate/Documents/public/img/sidebar-icon.png +0 -0
- package/BoilerPlate/Documents/public/img/sidebar-line.png +0 -0
- package/BoilerPlate/Documents/public/img/skin-blue.png +0 -0
- package/BoilerPlate/Documents/public/img/skin-brown.png +0 -0
- package/BoilerPlate/Documents/public/img/skin-cyan.png +0 -0
- package/BoilerPlate/Documents/public/img/skin-dark.png +0 -0
- package/BoilerPlate/Documents/public/img/skin-default.png +0 -0
- package/BoilerPlate/Documents/public/img/skin-gray.png +0 -0
- package/BoilerPlate/Documents/public/img/skin-green.png +0 -0
- package/BoilerPlate/Documents/public/img/skin-orange.png +0 -0
- package/BoilerPlate/Documents/public/img/skin-pink.png +0 -0
- package/BoilerPlate/Documents/public/img/skin-purple.png +0 -0
- package/BoilerPlate/Documents/public/img/skin-red.png +0 -0
- package/BoilerPlate/Documents/public/img/skin-teal.png +0 -0
- package/BoilerPlate/Documents/public/img/skin-yellow.png +0 -0
- package/BoilerPlate/Documents/public/img/skype.svg +0 -1
- package/BoilerPlate/Documents/public/img/step1.png +0 -0
- package/BoilerPlate/Documents/public/img/step2.png +0 -0
- package/BoilerPlate/Documents/public/img/step3.png +0 -0
- package/BoilerPlate/Documents/public/img/step4.png +0 -0
- package/BoilerPlate/Documents/public/img/tumblr.svg +0 -1
- package/BoilerPlate/Documents/public/img/twitter.svg +0 -1
- package/BoilerPlate/Documents/public/img/video-dawn.mp4 +0 -0
- package/BoilerPlate/Documents/public/img/video.svg +0 -1
- package/BoilerPlate/Documents/public/js/custom.js +0 -26
- package/BoilerPlate/Documents/public/js/default.js +0 -1
- package/BoilerPlate/Documents/public/js/theDocs.all.min.js +0 -102
- package/BoilerPlate/Documents/public/js/theDocs.js +0 -482
- package/BoilerPlate/Documents/public/js/theDocs.min.js +0 -6
- package/BoilerPlate/Documents/public/js/vendor/bootstrap.carousel.js +0 -1
- package/BoilerPlate/Documents/public/js/vendor/bootstrap.collapse.js +0 -1
- package/BoilerPlate/Documents/public/js/vendor/bootstrap.dropdown.js +0 -1
- package/BoilerPlate/Documents/public/js/vendor/bootstrap.tab.js +0 -1
- package/BoilerPlate/Documents/public/js/vendor/bootstrap.transition.js +0 -1
- package/BoilerPlate/Documents/public/js/vendor/jquery-1.11.3.min.js +0 -4
- package/BoilerPlate/Documents/public/js/vendor/jquery.drawsvg.js +0 -1
- package/BoilerPlate/Documents/public/js/vendor/jquery.mobile.custom.min.js +0 -1
- package/BoilerPlate/Documents/public/js/vendor/webfontloader.js +0 -1
- package/BoilerPlate/Documents/public/sample.html +0 -530
- package/BoilerPlate/Documents/public/style.css +0 -10
- package/BoilerPlate/Documents/public/vendors/bootstrap/css/bootstrap-theme.css +0 -587
- package/BoilerPlate/Documents/public/vendors/bootstrap/css/bootstrap-theme.css.map +0 -1
- package/BoilerPlate/Documents/public/vendors/bootstrap/css/bootstrap-theme.min.css +0 -6
- package/BoilerPlate/Documents/public/vendors/bootstrap/css/bootstrap-theme.min.css.map +0 -1
- package/BoilerPlate/Documents/public/vendors/bootstrap/css/bootstrap.css +0 -6757
- package/BoilerPlate/Documents/public/vendors/bootstrap/css/bootstrap.css.map +0 -1
- package/BoilerPlate/Documents/public/vendors/bootstrap/css/bootstrap.min.css +0 -6
- package/BoilerPlate/Documents/public/vendors/bootstrap/css/bootstrap.min.css.map +0 -1
- package/BoilerPlate/Documents/public/vendors/bootstrap/fonts/glyphicons-halflings-regular.eot +0 -0
- package/BoilerPlate/Documents/public/vendors/bootstrap/fonts/glyphicons-halflings-regular.svg +0 -288
- package/BoilerPlate/Documents/public/vendors/bootstrap/fonts/glyphicons-halflings-regular.ttf +0 -0
- package/BoilerPlate/Documents/public/vendors/bootstrap/fonts/glyphicons-halflings-regular.woff +0 -0
- package/BoilerPlate/Documents/public/vendors/bootstrap/fonts/glyphicons-halflings-regular.woff2 +0 -0
- package/BoilerPlate/Documents/public/vendors/bootstrap/js/bootstrap.js +0 -2377
- package/BoilerPlate/Documents/public/vendors/bootstrap/js/bootstrap.min.js +0 -7
- package/BoilerPlate/Documents/public/vendors/bootstrap/js/npm.js +0 -13
- package/BoilerPlate/Documents/public/vendors/clipboard.js/clipboard.js +0 -778
- package/BoilerPlate/Documents/public/vendors/clipboard.js/clipboard.min.js +0 -7
- package/BoilerPlate/Documents/public/vendors/fitvids/jquery.fitvids.js +0 -11
- package/BoilerPlate/Documents/public/vendors/font-awesome/css/font-awesome.css +0 -2337
- package/BoilerPlate/Documents/public/vendors/font-awesome/css/font-awesome.min.css +0 -4
- package/BoilerPlate/Documents/public/vendors/font-awesome/fonts/FontAwesome.otf +0 -0
- package/BoilerPlate/Documents/public/vendors/font-awesome/fonts/fontawesome-webfont.eot +0 -0
- package/BoilerPlate/Documents/public/vendors/font-awesome/fonts/fontawesome-webfont.svg +0 -2671
- package/BoilerPlate/Documents/public/vendors/font-awesome/fonts/fontawesome-webfont.ttf +0 -0
- package/BoilerPlate/Documents/public/vendors/font-awesome/fonts/fontawesome-webfont.woff +0 -0
- package/BoilerPlate/Documents/public/vendors/font-awesome/fonts/fontawesome-webfont.woff2 +0 -0
- package/BoilerPlate/Documents/public/vendors/font-awesome/less/animated.less +0 -34
- package/BoilerPlate/Documents/public/vendors/font-awesome/less/bordered-pulled.less +0 -25
- package/BoilerPlate/Documents/public/vendors/font-awesome/less/core.less +0 -12
- package/BoilerPlate/Documents/public/vendors/font-awesome/less/fixed-width.less +0 -6
- package/BoilerPlate/Documents/public/vendors/font-awesome/less/font-awesome.less +0 -18
- package/BoilerPlate/Documents/public/vendors/font-awesome/less/icons.less +0 -789
- package/BoilerPlate/Documents/public/vendors/font-awesome/less/larger.less +0 -13
- package/BoilerPlate/Documents/public/vendors/font-awesome/less/list.less +0 -19
- package/BoilerPlate/Documents/public/vendors/font-awesome/less/mixins.less +0 -60
- package/BoilerPlate/Documents/public/vendors/font-awesome/less/path.less +0 -15
- package/BoilerPlate/Documents/public/vendors/font-awesome/less/rotated-flipped.less +0 -20
- package/BoilerPlate/Documents/public/vendors/font-awesome/less/screen-reader.less +0 -5
- package/BoilerPlate/Documents/public/vendors/font-awesome/less/stacked.less +0 -20
- package/BoilerPlate/Documents/public/vendors/font-awesome/less/variables.less +0 -800
- package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_animated.scss +0 -34
- package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_bordered-pulled.scss +0 -25
- package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_core.scss +0 -12
- package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_fixed-width.scss +0 -6
- package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_icons.scss +0 -789
- package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_larger.scss +0 -13
- package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_list.scss +0 -19
- package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_mixins.scss +0 -60
- package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_path.scss +0 -15
- package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_rotated-flipped.scss +0 -20
- package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_screen-reader.scss +0 -5
- package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_stacked.scss +0 -20
- package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_variables.scss +0 -800
- package/BoilerPlate/Documents/public/vendors/font-awesome/scss/font-awesome.scss +0 -18
- package/BoilerPlate/Documents/public/vendors/jquery/jquery.min.js +0 -4
- package/BoilerPlate/Documents/public/vendors/lity/lity.css +0 -200
- package/BoilerPlate/Documents/public/vendors/lity/lity.js +0 -637
- package/BoilerPlate/Documents/public/vendors/lity/lity.min.css +0 -3
- package/BoilerPlate/Documents/public/vendors/lity/lity.min.js +0 -4
- package/BoilerPlate/Documents/public/vendors/matchHeight.min.js +0 -11
- package/BoilerPlate/Documents/public/vendors/perfect-scrollbar/css/perfect-scrollbar.css +0 -113
- package/BoilerPlate/Documents/public/vendors/perfect-scrollbar/css/perfect-scrollbar.min.css +0 -2
- package/BoilerPlate/Documents/public/vendors/perfect-scrollbar/js/perfect-scrollbar.jquery.js +0 -1580
- package/BoilerPlate/Documents/public/vendors/perfect-scrollbar/js/perfect-scrollbar.jquery.min.js +0 -2
- package/BoilerPlate/Documents/public/vendors/perfect-scrollbar/js/perfect-scrollbar.js +0 -1553
- package/BoilerPlate/Documents/public/vendors/perfect-scrollbar/js/perfect-scrollbar.min.js +0 -2
- package/BoilerPlate/Documents/public/vendors/prism/prism.css +0 -7
- package/BoilerPlate/Documents/public/vendors/prism/prism.js +0 -54
- package/BoilerPlate/Documents/server.js +0 -63
- package/BoilerPlate/Documents/tempUploads/068f2b77c0e0723b97909b2ffa438fe6.pdf +0 -0
- package/BoilerPlate/Documents/tempUploads/6443f8fd5d507b5a5f76829962fc2dc0.docx +0 -0
- package/BoilerPlate/Documents/tempUploads/7e4560af2cd6cae130bdb79fecaa6437.pdf +0 -0
- package/BoilerPlate/Documents/tempUploads/84b6ad7e0deefc348cfd582c9715ec1d.pdf +0 -0
- package/BoilerPlate/Documents/tempUploads/a894549ed062ada5f48f364a236a7e76.png +0 -0
- package/BoilerPlate/Documents/tempUploads/c2727b94bc909b118b25ae35f0897713.png +0 -0
- package/BoilerPlate/Documents/tempUploads/c588a76c8b0c4b76df2e36bd602a8821.docx +0 -0
- package/BoilerPlate/Documents/tempUploads/d6476c43a03950899e6db91c95dbc8aa.docx +0 -0
- package/BoilerPlate/Documents/tempUploads/dc4ffdc0a703353e0280384afc6ad082.png +0 -0
- package/BoilerPlate/Documents/test/helper.js +0 -27
- package/BoilerPlate/Documents/test/test-articles.js +0 -176
- package/BoilerPlate/Documents/test/test-users.js +0 -106
- package/BoilerPlate/Documents/uploads/section/5ad9bb9853017c217c6673d5/0cb1f166cbb6b46ffc630cb1c86db0a1.png +0 -0
- package/BoilerPlate/Documents/uploads/section/5ad9bb9853017c217c6673d5/37fbc499e5eea091ab7215855bf7918b.png +0 -0
- package/BoilerPlate/Documents/uploads/section/5ad9bb9853017c217c6673d5/4b0d6e11c87b31cc6c32e18be5a49b6b.pdf +0 -0
- package/BoilerPlate/Documents/uploads/section/5ad9bb9853017c217c6673d5/d4248bccecc0f55dd2fe7cd388c4c1ce.docx +0 -0
- package/BoilerPlate/Documents/uploads/section/5ad9bbd853017c217c6673d8/7c7b0d7f03359c38e3411ec448bdc746.png +0 -0
- package/BoilerPlate/Documents/uploads/section/5ad9bbd853017c217c6673d8/8c7eeb092084ee8349f12ceb7e6dab2d.docx +0 -0
- package/BoilerPlate/Documents/uploads/section/5ad9bbd853017c217c6673d8/b512a8558523894f0d9292f39dcd9d82.pdf +0 -0
- package/BoilerPlate/Documents/uploads/section/5ad9bc111b67922eb0f547d5/06cdca751d7c5897179af1bb956e13d3.docx +0 -0
- package/BoilerPlate/Documents/uploads/section/5ad9bc111b67922eb0f547d5/4fe0695295a41c9e3e5af0d2fd52bbae.png +0 -0
- package/BoilerPlate/Documents/uploads/section/5ad9c7ce673a50173865614b/1c68ca7ae23099cd139801766ccec600.docx +0 -0
- package/BoilerPlate/Documents/uploads/section/5ad9c7ce673a50173865614b/7d7d49834eea7899d77a29dda1d25bf4.pdf +0 -0
- package/BoilerPlate/Documents/uploads/section/5ad9c826673a50173865614e/301398c02f647d1e1804d48233e9e7e0.pdf +0 -0
- package/BoilerPlate/Documents/uploads/section/5ad9c826673a50173865614e/c9ca2431eed90529a633f88c6781e686.docx +0 -0
- package/BoilerPlate/Documents/uploads/section/5ad9c85f673a501738656153/71b1d92caefe43821426d139e6c931d1.pdf +0 -0
- package/BoilerPlate/Documents/uploads/section/5ad9c85f673a501738656153/a0735aa1e0befd14449b26063c112d46.docx +0 -0
- package/BoilerPlate/Documents/uploads/section/5ad9ce22f534442218fb8016/31724098865f19fd968d6167736bd388.docx +0 -0
- package/BoilerPlate/Documents/uploads/section/5ad9d714f534442218fb801b/a71e1f795a7c2f260ccbd877e9e03b17.docx +0 -0
- package/BoilerPlate/Documents/uploads/section/5ad9d755f534442218fb801e/c23154466cfcbb8aa9101509cc990962.docx +0 -0
- package/BoilerPlate/Documents/uploads/section/5ad9d816f534442218fb8021/e90f3adde177c831dd96d8fcf2f6bf17.docx +0 -0
- package/BoilerPlate/Documents/uploads/section/5ad9d83bf534442218fb8024/11a310205cd7c1b3f0a53cd4a3e1cd91.png +0 -0
- package/BoilerPlate/Documents/uploads/section/5ad9d83bf534442218fb8024/4c45d0286d8b0ae23fe1ccfd2d0f6b52.pdf +0 -0
- package/BoilerPlate/Documents/uploads/section/5ad9d83bf534442218fb8024/6dd38b8628ef60ea09e982c375720d94.docx +0 -0
- package/dump.rdb +0 -0
|
@@ -1,820 +1,827 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Module dependencies.
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
16
|
+
return childControllers;
|
|
17
17
|
};
|
|
18
18
|
module.exports.inherit = function (child) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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
|
|
39
|
+
return next(new Error('not found'));
|
|
375
40
|
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
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
|
-
|
|
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
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
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
|
-
|
|
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
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
child.
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
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
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
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
|
-
|
|
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
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
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
|
}
|