gina 0.1.1-alpha.14 → 0.1.1-alpha.142
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/AUTHORS +2 -1
- package/README.md +157 -19
- package/bin/cli +125 -54
- package/bin/cli-debug +4 -4
- package/bin/cmd +40 -18
- package/bin/gina +39 -33
- package/{framework/v0.1.1-alpha.14/core/template/command/gina.bat.tpl → bin/gina.bat} +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/AUTHORS +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/LICENSE +0 -0
- package/framework/v0.1.1-alpha.142/VERSION +1 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/asset/html/nolayout.html +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/asset/html/static.html +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/asset/img/android-chrome-192x192.png +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/asset/img/android-chrome-512x512.png +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/asset/img/apple-touch-icon.png +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/asset/img/favicon-16x16.png +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/asset/img/favicon-32x32.png +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/asset/img/favicon.ico +0 -0
- package/framework/{v0.1.1-alpha.14/core/asset/js → v0.1.1-alpha.142/core/asset}/plugin/dist/gina.js +0 -0
- package/framework/{v0.1.1-alpha.14/core/asset/js → v0.1.1-alpha.142/core/asset}/plugin/dist/gina.js.map +0 -0
- package/framework/{v0.1.1-alpha.14/core/asset/js → v0.1.1-alpha.142/core/asset}/plugin/dist/gina.min.css +0 -0
- package/framework/{v0.1.1-alpha.14/core/asset/js → v0.1.1-alpha.142/core/asset}/plugin/dist/gina.min.css.map +0 -0
- package/framework/{v0.1.1-alpha.14/core/asset/js → v0.1.1-alpha.142/core/asset}/plugin/dist/gina.min.js +0 -0
- package/framework/{v0.1.1-alpha.14/core/asset/js → v0.1.1-alpha.142/core/asset}/plugin/dist/gina.min.js.map +0 -0
- package/framework/{v0.1.1-alpha.14/core/asset/js → v0.1.1-alpha.142/core/asset}/plugin/dist/gina.onload.min.js +0 -0
- package/framework/{v0.1.1-alpha.14/core/asset/js → v0.1.1-alpha.142/core/asset}/plugin/dist/gina.onload.min.js.map +0 -0
- package/framework/v0.1.1-alpha.142/core/asset/plugin/dist/toolbar/css/toolbar-min.css +1 -0
- package/framework/v0.1.1-alpha.142/core/asset/plugin/dist/toolbar/css/toolbar.css +3 -0
- package/framework/v0.1.1-alpha.142/core/asset/plugin/dist/toolbar/css/toolbar.css.map +1 -0
- package/framework/v0.1.1-alpha.142/core/asset/plugin/dist/toolbar/js/jquery-3.1.0.min.js +4 -0
- package/framework/v0.1.1-alpha.142/core/asset/plugin/dist/toolbar/main.js +1542 -0
- package/framework/v0.1.1-alpha.142/core/asset/plugin/dist/toolbar/toolbar.html +251 -0
- package/framework/{v0.1.1-alpha.14/core/asset/js → v0.1.1-alpha.142/core/asset}/plugin/readme.md +5 -5
- package/framework/{v0.1.1-alpha.14/core/asset/js → v0.1.1-alpha.142/core/asset}/plugin/uuid.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/config.js +28 -13
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/connectors/couchbase/index.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/connectors/couchbase/lib/connector.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/connectors/couchbase/lib/connector.v2.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/connectors/couchbase/lib/connector.v3.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/connectors/couchbase/lib/n1ql.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/connectors/couchbase/lib/session-store.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/connectors/couchbase/lib/session-store.v2.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/connectors/couchbase/lib/session-store.v3.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/controller/controller.framework.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/controller/controller.js +664 -664
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/controller/index.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/deps/busboy/.travis.yml +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/deps/busboy/LICENSE +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/deps/busboy/README.md +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/deps/busboy/deps/encoding/encoding-indexes.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/deps/busboy/deps/encoding/encoding.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/deps/busboy/lib/main.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/deps/busboy/lib/types/multipart.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/deps/busboy/lib/types/urlencoded.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/deps/busboy/lib/utils.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/deps/busboy/package.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/deps/swig-client/swig-2.0.0.min.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/dev/index.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/dev/lib/class.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/dev/lib/factory.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/dev/lib/tools.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/gna.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/locales/README.md +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/locales/currency.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/locales/dist/language/en.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/locales/dist/language/fr.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/locales/dist/region/en.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/locales/dist/region/fr.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/locales/index.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/locales/src/make.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/locales/src/resources/currency.csv +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/locales/src/resources/region.csv +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/locales/src/resources/region.mapping.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/mime.types +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/model/entity.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/model/index.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/model/template/entityFactory.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/model/template/index.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/plugins/README.md +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/plugins/index.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/plugins/lib/file/README.md +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/plugins/lib/file/build.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/plugins/lib/file/package.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/plugins/lib/intl/README.md +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/plugins/lib/intl/build.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/plugins/lib/intl/package.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/plugins/lib/intl/src/main.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/plugins/lib/storage/README.md +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/plugins/lib/storage/build.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/plugins/lib/storage/package.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/plugins/lib/storage/src/main.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/plugins/lib/validator/README.md +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/plugins/lib/validator/build.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/plugins/lib/validator/package.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/plugins/lib/validator/src/form-validator.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/plugins/lib/validator/src/main.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/router.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/server.express.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/server.isaac.js +117 -108
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/server.js +1 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/status.codes +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/boilerplate/bundle/config/app.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/boilerplate/bundle/config/routing.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/boilerplate/bundle/config/settings.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/boilerplate/bundle/config/settings.server.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/boilerplate/bundle/config/templates.json +4 -4
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/boilerplate/bundle/controllers/controller.content.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/boilerplate/bundle/controllers/controller.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/boilerplate/bundle/controllers/setup.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/boilerplate/bundle/index.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/boilerplate/bundle_namespace/controllers/controller.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/boilerplate/bundle_public/css/default.css +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/boilerplate/bundle_public/css/vendor/readme.md +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/boilerplate/bundle_public/favicon.ico +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/boilerplate/bundle_public/js/vendor/readme.md +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/boilerplate/bundle_public/readme.md +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/boilerplate/bundle_templates/handlers/main.js +0 -0
- package/framework/v0.1.1-alpha.142/core/template/boilerplate/bundle_templates/html/content/homepage.html +8 -0
- package/framework/v0.1.1-alpha.142/core/template/boilerplate/bundle_templates/html/includes/error-msg-noscript.html +11 -0
- package/framework/v0.1.1-alpha.142/core/template/boilerplate/bundle_templates/html/includes/error-msg-outdated-browser.html +8 -0
- package/framework/{v0.1.1-alpha.14/core/template/boilerplate/bundle_templates/html/layout → v0.1.1-alpha.142/core/template/boilerplate/bundle_templates/html/layouts}/main.html +10 -3
- package/framework/v0.1.1-alpha.142/core/template/command/gina.bat.tpl +8 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/command/gina.tpl +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/conf/env.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/conf/manifest.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/conf/package.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/conf/settings.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/conf/statics.json +3 -3
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/conf/templates.json +2 -2
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/error/client/json/401.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/error/client/json/403.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/error/client/json/404.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/error/server/html/50x.html +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/error/server/json/500.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/error/server/json/503.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/core/template/extensions/logger/config.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/helpers/console.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/helpers/context.js +144 -4
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/helpers/dateFormat.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/helpers/index.js +9 -4
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/helpers/json/README.md +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/helpers/json/package.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/helpers/json/src/main.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/helpers/path.js +142 -88
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/helpers/plugins/README.md +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/helpers/plugins/package.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/helpers/plugins/src/api-error.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/helpers/plugins/src/main.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/helpers/prototypes.js +35 -36
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/helpers/task.js +21 -14
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/helpers/text.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/archiver/README.md +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/archiver/build.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/archiver/package.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/archiver/src/dep/jszip.min.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/archiver/src/main.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/aliases.json +4 -1
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/bundle/add.js +43 -17
- package/framework/v0.1.1-alpha.142/lib/cmd/bundle/arguments.json +6 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/bundle/copy.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/bundle/cp.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/bundle/help.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/bundle/help.txt +0 -0
- package/framework/v0.1.1-alpha.142/lib/cmd/bundle/list.js +176 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/bundle/remove.js +22 -22
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/bundle/rename.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/bundle/restart.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/bundle/rm.js +0 -0
- package/framework/v0.1.1-alpha.142/lib/cmd/bundle/start.js +416 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/bundle/status.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/bundle/stop.js +93 -74
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/env/add.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/env/get.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/env/help.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/env/help.txt +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/env/link-dev.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/env/list.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/env/remove.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/env/rm.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/env/set.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/env/unset.js +0 -0
- package/framework/{v0.1.1-alpha.14/lib/cmd/scope → v0.1.1-alpha.142/lib/cmd/env}/use.js +21 -1
- package/framework/v0.1.1-alpha.142/lib/cmd/framework/build.js +85 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/framework/dot.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/framework/get.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/framework/help.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/framework/help.txt +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/framework/init.js +64 -16
- package/framework/v0.1.1-alpha.142/lib/cmd/framework/link-node-modules.js +86 -0
- package/framework/v0.1.1-alpha.142/lib/cmd/framework/link.js +89 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/framework/msg.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/framework/open.js +15 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/framework/restart.js +53 -25
- package/framework/v0.1.1-alpha.142/lib/cmd/framework/set.js +264 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/framework/start.js +35 -12
- package/framework/v0.1.1-alpha.142/lib/cmd/framework/status.js +123 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/framework/stop.js +44 -28
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/framework/tail.js +106 -61
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/framework/update.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/framework/version.js +12 -3
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/gina-dev.1.md +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/gina-framework.1.md +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/gina.1.md +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/helper.js +73 -4
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/index.js +21 -21
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/msg.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/port/help.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/port/help.txt +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/port/inc/scan.js +32 -17
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/port/list.js +0 -0
- package/framework/v0.1.1-alpha.142/lib/cmd/port/reset.js +422 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/port/set.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/project/add.js +144 -120
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/project/arguments.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/project/build.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/project/help.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/project/help.txt +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/project/import.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/project/list.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/project/move.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/project/remove.js +17 -17
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/project/rename.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/project/restart.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/project/rm.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/project/start.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/project/status.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/project/stop.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/protocol/help.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/protocol/help.txt +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/protocol/list.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/protocol/set.js +239 -201
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/scope/help.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/scope/help.txt +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/scope/link-local.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/scope/list.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/scope/remove.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/scope/rm.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/scope/set.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/scope/unset.js +0 -0
- package/framework/{v0.1.1-alpha.14/lib/cmd/env → v0.1.1-alpha.142/lib/cmd/scope}/use.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cmd/view/add.js +34 -9
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/collection/README.md +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/collection/build.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/collection/package.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/collection/src/main.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/config.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cron/README.md +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cron/package.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/cron/src/main.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/generator/index.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/index.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/inherits/LICENSE +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/inherits/README.md +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/inherits/example/inheriting_eventemitter.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/inherits/example/protected_inheritance.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/inherits/example/simple_inheritance.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/inherits/example/super_attribute_overridden_by_child_on_init.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/inherits/package.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/inherits/src/main.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/logger/README.md +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/logger/package.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/logger/src/containers/default/index.js +13 -2
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/logger/src/containers/file/index.js +105 -14
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/logger/src/containers/file/lib/logrotator/README.md +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/logger/src/containers/file/lib/logrotator/index.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/logger/src/containers/mq/index.js +2 -1
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/logger/src/containers/mq/listener.js +16 -14
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/logger/src/containers/mq/speaker.js +32 -3
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/logger/src/helper.js +19 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/logger/src/main.js +4 -1
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/math/index.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/merge/README.md +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/merge/example/merge.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/merge/example/merge_2_literal objects.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/merge/example/merge_and_preserve_first.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/merge/package.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/merge/src/main.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/model.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/proc.js +69 -45
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/routing/README.md +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/routing/build.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/routing/package.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/routing/src/main.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/session-store.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/shell.js +3 -3
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/swig-filters/README.md +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/swig-filters/package.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/swig-filters/src/main.js +54 -51
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/url/README.md +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/url/index.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/url/mocks.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/url/routing.json +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/url/test.js +0 -0
- package/framework/{v0.1.1-alpha.14 → v0.1.1-alpha.142}/lib/validator.js +0 -0
- package/framework/v0.1.1-alpha.142/package.json +14 -0
- package/package.json +30 -21
- package/resources/home/main.json +19 -1
- package/resources/home/settings.json +5 -0
- package/resources/home/user/extensions/logger/default/config.json +1 -1
- package/resources/package.json.template +28 -17
- package/script/post_install.js +394 -120
- package/script/post_publish.js +185 -0
- package/script/pre_install.js +424 -76
- package/script/prepare_version.js +151 -21
- package/utils/helper.js +230 -44
- package/utils/prototypes.js +9 -9
- package/utils/prototypes.json_clone.js +31 -31
- package/doc/framework/cli/doc.json +0 -9
- package/doc/framework/index.md +0 -60
- package/framework/v0.1.1-alpha.14/VERSION +0 -1
- package/framework/v0.1.1-alpha.14/core/template/boilerplate/bundle_templates/html/homepage.html +0 -4
- package/framework/v0.1.1-alpha.14/lib/cmd/bundle/arguments.json +0 -4
- package/framework/v0.1.1-alpha.14/lib/cmd/bundle/list.js +0 -129
- package/framework/v0.1.1-alpha.14/lib/cmd/bundle/start.js +0 -394
- package/framework/v0.1.1-alpha.14/lib/cmd/framework/set.js +0 -161
- package/framework/v0.1.1-alpha.14/lib/cmd/framework/status.js +0 -72
- package/framework/v0.1.1-alpha.14/package.json +0 -14
|
@@ -44,9 +44,9 @@ function SuperController(options) {
|
|
|
44
44
|
|
|
45
45
|
//public
|
|
46
46
|
this.name = 'SuperController';
|
|
47
|
-
this.engine = {};
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
this.engine = {};
|
|
48
|
+
|
|
49
|
+
|
|
50
50
|
var self = this;
|
|
51
51
|
//private
|
|
52
52
|
var local = {
|
|
@@ -68,16 +68,16 @@ function SuperController(options) {
|
|
|
68
68
|
if ( typeof(SuperController.initialized) != 'undefined' ) {
|
|
69
69
|
return getInstance()
|
|
70
70
|
} else {
|
|
71
|
-
|
|
71
|
+
|
|
72
72
|
SuperController.instance = self;
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
|
|
74
|
+
|
|
75
75
|
if (local.options) {
|
|
76
76
|
SuperController.instance._options = local.options;
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
|
|
79
79
|
SuperController.initialized = true;
|
|
80
|
-
|
|
80
|
+
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -85,46 +85,46 @@ function SuperController(options) {
|
|
|
85
85
|
local.options = SuperController.instance._options = options;
|
|
86
86
|
// 2022-03-07 Fix for none-developpement environnements (without cache)
|
|
87
87
|
self._options = local.options;
|
|
88
|
-
|
|
88
|
+
|
|
89
89
|
return SuperController.instance;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
var hasViews = function() {
|
|
93
93
|
return ( typeof(local.options.template) != 'undefined' ) ? true : false;
|
|
94
94
|
}
|
|
95
|
-
|
|
95
|
+
|
|
96
96
|
/**
|
|
97
97
|
* isHttp2
|
|
98
98
|
* Returns `true` if server configured for HTTP/2
|
|
99
|
-
*
|
|
99
|
+
*
|
|
100
100
|
* @returns {boolean} isHttp2
|
|
101
101
|
*/
|
|
102
102
|
var isHttp2 = function() {
|
|
103
|
-
var options = local.options;
|
|
103
|
+
var options = local.options;
|
|
104
104
|
var protocolVersion = ~~options.conf.server.protocol.match(/\/(.*)$/)[1].replace(/\.\d+/, '');
|
|
105
105
|
var httpLib = options.conf.server.protocol.match(/^(.*)\//)[1] + ( (protocolVersion >= 2) ? protocolVersion : '' );
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
|
|
107
|
+
|
|
108
108
|
return /http2/.test(httpLib)
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
111
|
* isSecured
|
|
112
112
|
* Returns `true` if server configured to handle a HTTPS exchanges
|
|
113
|
-
*
|
|
113
|
+
*
|
|
114
114
|
* @returns {boolean} isSecured
|
|
115
115
|
*/
|
|
116
116
|
var isSecured = function() {
|
|
117
117
|
return /https/.test(local.options.conf.server.scheme)
|
|
118
118
|
}
|
|
119
|
-
|
|
119
|
+
|
|
120
120
|
this.getRequestObject = function() {
|
|
121
121
|
return local.req;
|
|
122
122
|
}
|
|
123
|
-
|
|
123
|
+
|
|
124
124
|
this.getResponseObject = function() {
|
|
125
125
|
return local.res;
|
|
126
126
|
}
|
|
127
|
-
|
|
127
|
+
|
|
128
128
|
this.getNextCallback = function() {
|
|
129
129
|
return local.next;
|
|
130
130
|
}
|
|
@@ -146,7 +146,7 @@ function SuperController(options) {
|
|
|
146
146
|
local.options = SuperController.instance._options = options;
|
|
147
147
|
local.options.renderingStack = (local.options.renderingStack) ? local.options.renderingStack : [];
|
|
148
148
|
local.options.isRenderingCustomError = (local.options.isRenderingCustomError) ? local.options.isRenderingCustomError : false;
|
|
149
|
-
|
|
149
|
+
|
|
150
150
|
|
|
151
151
|
// N.B.: Avoid setting `page` properties as much as possible from the routing.json
|
|
152
152
|
// It will be easier for the framework if set from the controller.
|
|
@@ -169,12 +169,12 @@ function SuperController(options) {
|
|
|
169
169
|
// var data = { page: { view: { title: "My Title"}}};
|
|
170
170
|
// self.render(data)
|
|
171
171
|
// }
|
|
172
|
-
|
|
172
|
+
|
|
173
173
|
if ( typeof(options.conf.content.routing[options.rule].param) != 'undefined' ) {
|
|
174
174
|
var str = 'page.'
|
|
175
175
|
, p = options.conf.content.routing[options.rule].param
|
|
176
176
|
;
|
|
177
|
-
|
|
177
|
+
|
|
178
178
|
for (var key in p) {
|
|
179
179
|
if ( p.hasOwnProperty(key) && !/^(control)$/.test(key) ) {
|
|
180
180
|
str += key + '.';
|
|
@@ -217,19 +217,19 @@ function SuperController(options) {
|
|
|
217
217
|
|
|
218
218
|
|
|
219
219
|
if ( typeof(local.options.template) != 'undefined' && local.options.template ) {
|
|
220
|
-
if (
|
|
221
|
-
typeof(local.options.template.ext) != 'undefined'
|
|
222
|
-
&& local.options.template.ext
|
|
220
|
+
if (
|
|
221
|
+
typeof(local.options.template.ext) != 'undefined'
|
|
222
|
+
&& local.options.template.ext
|
|
223
223
|
&& local.options.template.ext != ''
|
|
224
224
|
) {
|
|
225
225
|
ext = local.options.template.ext
|
|
226
226
|
}
|
|
227
|
-
|
|
227
|
+
|
|
228
228
|
if ( !/\./.test(ext) ) {
|
|
229
229
|
ext = '.' + ext;
|
|
230
230
|
local.options.template.ext = ext
|
|
231
231
|
}
|
|
232
|
-
|
|
232
|
+
|
|
233
233
|
if (
|
|
234
234
|
typeof(local.options.template.layout) == 'undefined'
|
|
235
235
|
|| /^false$/.test(local.options.template.layout)
|
|
@@ -238,27 +238,27 @@ function SuperController(options) {
|
|
|
238
238
|
isWithoutLayout = true;
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
|
-
|
|
242
|
-
|
|
241
|
+
|
|
242
|
+
|
|
243
243
|
if ( hasViews() ) {
|
|
244
244
|
|
|
245
245
|
if ( typeof(local.options.file) == 'undefined') {
|
|
246
246
|
local.options.file = 'index'
|
|
247
247
|
}
|
|
248
|
-
|
|
248
|
+
|
|
249
249
|
if ( typeof(local.options.isWithoutLayout) == 'undefined' || !isWithoutLayout ) {
|
|
250
250
|
local.options.isWithoutLayout = false;
|
|
251
251
|
}
|
|
252
|
-
|
|
252
|
+
|
|
253
253
|
rule = local.options.rule;
|
|
254
254
|
namespace = local.options.namespace || 'default';
|
|
255
|
-
|
|
256
|
-
|
|
255
|
+
|
|
256
|
+
|
|
257
257
|
set('page.view.file', local.options.file);
|
|
258
258
|
set('page.view.title', rule.replace(new RegExp('@' + options.conf.bundle), ''));
|
|
259
259
|
set('page.view.namespace', namespace);
|
|
260
|
-
}
|
|
261
|
-
|
|
260
|
+
}
|
|
261
|
+
|
|
262
262
|
|
|
263
263
|
var ctx = getContext('gina');
|
|
264
264
|
// new declaration && overrides
|
|
@@ -277,18 +277,18 @@ function SuperController(options) {
|
|
|
277
277
|
set('page.environment.env', process.env.NODE_ENV);
|
|
278
278
|
set('page.environment.envIsDev', self.isCacheless());
|
|
279
279
|
set('page.environment.date.now', new Date().format("isoDateTime"));
|
|
280
|
-
|
|
281
|
-
|
|
280
|
+
|
|
281
|
+
|
|
282
282
|
var routing = local.options.conf.routing = ctx.config.envConf.routing; // all routes
|
|
283
283
|
set('page.environment.routing', escape(JSON.stringify(routing))); // export for GFF
|
|
284
284
|
//reverseRouting
|
|
285
285
|
var reverseRouting = local.options.conf.reverseRouting = ctx.config.envConf.reverseRouting; // all routes
|
|
286
286
|
set('page.environment.reverseRouting', escape(JSON.stringify(reverseRouting))); // export for GFF
|
|
287
|
-
|
|
287
|
+
|
|
288
288
|
var forms = local.options.conf.forms = options.conf.content.forms // all forms
|
|
289
289
|
set('page.environment.forms', escape(JSON.stringify(forms))); // export for GFF
|
|
290
290
|
set('page.forms', options.conf.content.forms);
|
|
291
|
-
|
|
291
|
+
|
|
292
292
|
set('page.environment.hostname', ctx.config.envConf[options.conf.bundle][process.env.NODE_ENV].hostname);
|
|
293
293
|
set('page.environment.webroot', options.conf.server.webroot);
|
|
294
294
|
set('page.environment.bundle', options.conf.bundle);
|
|
@@ -298,14 +298,14 @@ function SuperController(options) {
|
|
|
298
298
|
set('page.environment.port', options.conf.server.port);
|
|
299
299
|
set('page.environment.debugPort', options.conf.server.debugPort);
|
|
300
300
|
set('page.environment.pid', process.pid);
|
|
301
|
-
|
|
302
|
-
|
|
301
|
+
|
|
302
|
+
|
|
303
303
|
set('page.view.ext', ext);
|
|
304
304
|
set('page.view.control', action);
|
|
305
305
|
set('page.view.controller', local.options.controller.replace(options.conf.bundlesPath, ''), true);
|
|
306
306
|
if (typeof (local.options.controlRequired) != 'undefined' ) {
|
|
307
307
|
set('page.view.controlRequired', local.options.controlRequired);
|
|
308
|
-
}
|
|
308
|
+
}
|
|
309
309
|
set('page.view.method', local.options.method);
|
|
310
310
|
set('page.view.namespace', namespace); // by default
|
|
311
311
|
set('page.view.url', req.url);
|
|
@@ -314,12 +314,12 @@ function SuperController(options) {
|
|
|
314
314
|
set('page.view.html.properties.mode.javascriptsDeferEnabled', local.options.template.javascriptsDeferEnabled);
|
|
315
315
|
set('page.view.html.properties.mode.routeNameAsFilenameEnabled', local.options.template.routeNameAsFilenameEnabled);
|
|
316
316
|
}
|
|
317
|
-
|
|
318
|
-
|
|
317
|
+
|
|
318
|
+
|
|
319
319
|
var parameters = JSON.clone(req.getParams());
|
|
320
320
|
parameters = merge(parameters, options.conf.content.routing[rule].param);
|
|
321
321
|
// excluding default page properties
|
|
322
|
-
delete parameters[0];
|
|
322
|
+
delete parameters[0];
|
|
323
323
|
delete parameters.file;
|
|
324
324
|
delete parameters.control;
|
|
325
325
|
delete parameters.title;
|
|
@@ -329,7 +329,7 @@ function SuperController(options) {
|
|
|
329
329
|
|
|
330
330
|
set('page.view.route', rule);
|
|
331
331
|
|
|
332
|
-
|
|
332
|
+
|
|
333
333
|
var acceptLanguage = GINA_CULTURE; // by default : language-COUNTRY
|
|
334
334
|
if ( typeof(req.headers['accept-language']) != 'undefined' ) {
|
|
335
335
|
acceptLanguage = req.headers['accept-language']
|
|
@@ -348,8 +348,8 @@ function SuperController(options) {
|
|
|
348
348
|
|
|
349
349
|
try {
|
|
350
350
|
userLocales = locales.findOne({ lang: userLangCode }).content;
|
|
351
|
-
} catch (err) {
|
|
352
|
-
//var defaultRegion = (local.options.conf.content.settings.region) ? local.options.conf.content.settings.region.shortCode
|
|
351
|
+
} catch (err) {
|
|
352
|
+
//var defaultRegion = (local.options.conf.content.settings.region) ? local.options.conf.content.settings.region.shortCode
|
|
353
353
|
console.warn('language code `'+ userLangCode +'` not handled by current locales setup: replacing by default: `'+ local.options.conf.content.settings.region.shortCode +'`');
|
|
354
354
|
userLocales = locales.findOne({ lang: local.options.conf.content.settings.region.shortCode }).content // by default
|
|
355
355
|
}
|
|
@@ -359,7 +359,7 @@ function SuperController(options) {
|
|
|
359
359
|
|
|
360
360
|
// user locale
|
|
361
361
|
options.conf.locale = new Collection(userLocales).findOne({ short: userCountryCode }) || {};
|
|
362
|
-
|
|
362
|
+
|
|
363
363
|
//set('page.date.now', new Date().format("isoDateTime"));
|
|
364
364
|
if ( typeof(options.conf.locale) == 'undefined' || !options.conf.locale ) {
|
|
365
365
|
options.conf.locale = {}
|
|
@@ -370,17 +370,17 @@ function SuperController(options) {
|
|
|
370
370
|
set('page.view.locale', options.conf.locale);
|
|
371
371
|
set('page.view.lang', userCulture);
|
|
372
372
|
}
|
|
373
|
-
|
|
373
|
+
|
|
374
374
|
if ( !getContext('isProxyHost') ) {
|
|
375
375
|
var isProxyHost = ( typeof(req.headers.host) != 'undefined' && local.options.conf.server.scheme +'://'+ req.headers.host != local.options.conf.hostname || typeof(req.headers[':authority']) != 'undefined' && local.options.conf.server.scheme +'://'+ req.headers[':authority'] != local.options.conf.hostname ) ? true : false;
|
|
376
376
|
setContext('isProxyHost', isProxyHost);
|
|
377
377
|
}
|
|
378
|
-
|
|
378
|
+
|
|
379
379
|
//TODO - detect when to use swig
|
|
380
380
|
var dir = null;
|
|
381
381
|
if (local.options.template || self.templates) {
|
|
382
382
|
dir = local.options.template.templates || self.templates;
|
|
383
|
-
|
|
383
|
+
|
|
384
384
|
var swigOptions = {
|
|
385
385
|
autoescape : ( typeof(local.options.autoescape) != 'undefined') ? local.options.autoescape : false,
|
|
386
386
|
// `memory` is no working yet ... advanced rendering setup required
|
|
@@ -401,11 +401,11 @@ function SuperController(options) {
|
|
|
401
401
|
// preserve the same timezone as the system
|
|
402
402
|
var defaultTZOffset = new Date().getTimezoneOffset();
|
|
403
403
|
swig.setDefaultTZOffset(defaultTZOffset);
|
|
404
|
-
|
|
404
|
+
|
|
405
405
|
self.engine = swig;
|
|
406
406
|
}
|
|
407
407
|
}
|
|
408
|
-
|
|
408
|
+
|
|
409
409
|
this.renderWithoutLayout = function (data, displayToolbar) {
|
|
410
410
|
|
|
411
411
|
// preventing multiple call of self.renderWithoutLayout() when controller is rendering from another required controller
|
|
@@ -414,7 +414,7 @@ function SuperController(options) {
|
|
|
414
414
|
}
|
|
415
415
|
|
|
416
416
|
local.options.isWithoutLayout = true;
|
|
417
|
-
|
|
417
|
+
|
|
418
418
|
self.render(data, displayToolbar);
|
|
419
419
|
}
|
|
420
420
|
|
|
@@ -444,47 +444,47 @@ function SuperController(options) {
|
|
|
444
444
|
) ? true : false;
|
|
445
445
|
if (isRenderingCustomError)
|
|
446
446
|
delete userData.isRenderingCustomError;
|
|
447
|
-
|
|
447
|
+
|
|
448
448
|
var localOptions = (errOptions) ? errOptions : local.options;
|
|
449
449
|
localOptions.renderingStack.push( self.name );
|
|
450
450
|
// preventing multiple call of self.render() when controller is rendering from another required controller
|
|
451
451
|
if ( localOptions.renderingStack.length > 1 && !isRenderingCustomError ) {
|
|
452
452
|
return false
|
|
453
453
|
}
|
|
454
|
-
|
|
455
|
-
|
|
454
|
+
|
|
455
|
+
|
|
456
456
|
var data = null
|
|
457
457
|
, layout = null
|
|
458
458
|
, template = null
|
|
459
459
|
, file = null
|
|
460
460
|
, path = null
|
|
461
461
|
, plugin = null
|
|
462
|
-
, isWithoutLayout = (localOptions.isWithoutLayout) ? true : false
|
|
462
|
+
, isWithoutLayout = (localOptions.isWithoutLayout) ? true : false
|
|
463
463
|
;
|
|
464
|
-
|
|
464
|
+
|
|
465
465
|
localOptions.debugMode = ( typeof(displayToolbar) == 'undefined' ) ? undefined : ( (/true/i.test(displayToolbar)) ? true : false ); // only active for dev env
|
|
466
|
-
|
|
466
|
+
|
|
467
467
|
// specific override
|
|
468
468
|
if (
|
|
469
469
|
self.isCacheless()
|
|
470
|
-
&& typeof(local.req[ local.req.method.toLowerCase() ]) != 'undefined'
|
|
471
|
-
&& typeof(local.req[ local.req.method.toLowerCase() ].debug) != 'undefined'
|
|
470
|
+
&& typeof(local.req[ local.req.method.toLowerCase() ]) != 'undefined'
|
|
471
|
+
&& typeof(local.req[ local.req.method.toLowerCase() ].debug) != 'undefined'
|
|
472
472
|
) {
|
|
473
473
|
localOptions.debugMode = ( /true/i.test(local.req[ local.req.method.toLowerCase() ].debug) ) ? true : false;
|
|
474
|
-
} else if (
|
|
475
|
-
self.isCacheless()
|
|
474
|
+
} else if (
|
|
475
|
+
self.isCacheless()
|
|
476
476
|
&& hasViews()
|
|
477
|
-
&& !isWithoutLayout
|
|
478
|
-
&& localOptions.debugMode == undefined
|
|
477
|
+
&& !isWithoutLayout
|
|
478
|
+
&& localOptions.debugMode == undefined
|
|
479
479
|
) {
|
|
480
480
|
localOptions.debugMode = true;
|
|
481
481
|
} else if ( localOptions.debugMode == undefined ) {
|
|
482
482
|
localOptions.debugMode = self.isCacheless()
|
|
483
483
|
}
|
|
484
|
-
|
|
484
|
+
|
|
485
485
|
try {
|
|
486
486
|
data = getData();
|
|
487
|
-
|
|
487
|
+
|
|
488
488
|
if (!userData) {
|
|
489
489
|
userData = { page: { view: {}}}
|
|
490
490
|
} else if ( userData && !userData['page']) {
|
|
@@ -502,7 +502,7 @@ function SuperController(options) {
|
|
|
502
502
|
if ( isWithoutLayout ) {
|
|
503
503
|
localTemplateConf = JSON.clone(localOptions.template);
|
|
504
504
|
localTemplateConf.javascripts = new Collection(localTemplateConf.javascripts).find({ isCommon: false}, { isCommon: true, name: 'gina' });
|
|
505
|
-
localTemplateConf.stylesheets = new Collection(localTemplateConf.stylesheets).find({ isCommon: false}, { isCommon: true, name: 'gina' });
|
|
505
|
+
localTemplateConf.stylesheets = new Collection(localTemplateConf.stylesheets).find({ isCommon: false}, { isCommon: true, name: 'gina' });
|
|
506
506
|
}
|
|
507
507
|
setResources(localTemplateConf);
|
|
508
508
|
// Allowing file & ext override
|
|
@@ -512,13 +512,13 @@ function SuperController(options) {
|
|
|
512
512
|
) {
|
|
513
513
|
data.page.view.file = localOptions.file = local.req.routing.param.file
|
|
514
514
|
}
|
|
515
|
-
if (
|
|
516
|
-
typeof(local.req.routing.param.ext) != 'undefined'
|
|
515
|
+
if (
|
|
516
|
+
typeof(local.req.routing.param.ext) != 'undefined'
|
|
517
517
|
&& data.page.view.ext !== local.req.routing.param.ext
|
|
518
518
|
) {
|
|
519
519
|
data.page.view.ext = localOptions.template.ext = local.req.routing.param.ext
|
|
520
520
|
}
|
|
521
|
-
|
|
521
|
+
|
|
522
522
|
file = (isRenderingCustomError) ? localOptions.file : data.page.view.file;
|
|
523
523
|
|
|
524
524
|
// pre-compiling variables
|
|
@@ -527,13 +527,13 @@ function SuperController(options) {
|
|
|
527
527
|
if (typeof(data.page.data) == 'undefined' ) {
|
|
528
528
|
data.page.data = {}
|
|
529
529
|
}
|
|
530
|
-
|
|
531
530
|
|
|
532
|
-
|
|
531
|
+
|
|
532
|
+
if (
|
|
533
533
|
!local.options.isRenderingCustomError
|
|
534
|
-
&& typeof(data.page.data.status) != 'undefined'
|
|
535
|
-
&& !/^2/.test(data.page.data.status)
|
|
536
|
-
&& typeof(data.page.data.error) != 'undefined'
|
|
534
|
+
&& typeof(data.page.data.status) != 'undefined'
|
|
535
|
+
&& !/^2/.test(data.page.data.status)
|
|
536
|
+
&& typeof(data.page.data.error) != 'undefined'
|
|
537
537
|
) {
|
|
538
538
|
var statusCode = localOptions.conf.server.coreConfiguration.statusCodes;
|
|
539
539
|
var errorObject = {
|
|
@@ -555,7 +555,7 @@ function SuperController(options) {
|
|
|
555
555
|
// excepted for custom paths
|
|
556
556
|
if ( !/^(\.|\/|\\)/.test(file) )
|
|
557
557
|
file = ''+ file.replace(localOptions.namespace+'-', '');
|
|
558
|
-
|
|
558
|
+
|
|
559
559
|
// means that rule name === namespace -> pointing to root namespace dir
|
|
560
560
|
if (!file || file === localOptions.namespace) {
|
|
561
561
|
file = 'index'
|
|
@@ -593,14 +593,14 @@ function SuperController(options) {
|
|
|
593
593
|
dic['page.'+d] = data.page[d]
|
|
594
594
|
}
|
|
595
595
|
|
|
596
|
-
|
|
596
|
+
|
|
597
597
|
|
|
598
598
|
// please, do not start with a slashe when including...
|
|
599
599
|
// ex.:
|
|
600
600
|
// /html/inc/_partial.html (BAD)
|
|
601
601
|
// html/inc/_partial.html (GOOD)
|
|
602
602
|
// ./html/namespace/page.html (GOOD)
|
|
603
|
-
|
|
603
|
+
|
|
604
604
|
if ( !fs.existsSync(path) ) {
|
|
605
605
|
msg = 'could not open "'+ path +'"' +
|
|
606
606
|
'\n1) The requested file does not exists in your templates/html (check your template directory). Can you find: '+path +
|
|
@@ -614,32 +614,32 @@ function SuperController(options) {
|
|
|
614
614
|
self.throwError(err);
|
|
615
615
|
return;
|
|
616
616
|
}
|
|
617
|
-
|
|
618
|
-
var isProxyHost = (
|
|
619
|
-
typeof(local.req.headers.host) != 'undefined'
|
|
620
|
-
&& localOptions.conf.server.scheme +'://'+ local.req.headers.host != localOptions.conf.hostname
|
|
621
|
-
|| typeof(local.req.headers[':authority']) != 'undefined'
|
|
622
|
-
&& localOptions.conf.server.scheme +'://'+ local.req.headers[':authority'] != localOptions.conf.hostname
|
|
617
|
+
|
|
618
|
+
var isProxyHost = (
|
|
619
|
+
typeof(local.req.headers.host) != 'undefined'
|
|
620
|
+
&& localOptions.conf.server.scheme +'://'+ local.req.headers.host != localOptions.conf.hostname
|
|
621
|
+
|| typeof(local.req.headers[':authority']) != 'undefined'
|
|
622
|
+
&& localOptions.conf.server.scheme +'://'+ local.req.headers[':authority'] != localOptions.conf.hostname
|
|
623
623
|
) ? true : false;
|
|
624
|
-
// setup swig default filters
|
|
624
|
+
// setup swig default filters
|
|
625
625
|
var filters = SwigFilters({
|
|
626
626
|
options : JSON.clone(localOptions),
|
|
627
627
|
isProxyHost : isProxyHost,
|
|
628
628
|
throwError : self.throwError,
|
|
629
629
|
req : local.req,
|
|
630
|
-
res : local.res
|
|
630
|
+
res : local.res
|
|
631
631
|
});
|
|
632
632
|
|
|
633
633
|
try {
|
|
634
|
-
|
|
634
|
+
|
|
635
635
|
// Extends default `length` filter
|
|
636
636
|
swig.setFilter('length', filters.length);
|
|
637
637
|
|
|
638
|
-
|
|
638
|
+
|
|
639
639
|
|
|
640
640
|
// Allows you to get a bundle web root
|
|
641
641
|
swig.setFilter('getWebroot', filters.getWebroot);
|
|
642
|
-
|
|
642
|
+
|
|
643
643
|
swig.setFilter('getUrl', filters.getUrl);
|
|
644
644
|
|
|
645
645
|
} catch (err) {
|
|
@@ -651,10 +651,10 @@ function SuperController(options) {
|
|
|
651
651
|
self.throwError(local.res, 500, new Error('template compilation exception encoutered: [ '+path+' ]\n'+(err.stack||err.message)));
|
|
652
652
|
return;
|
|
653
653
|
}
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
var layoutPath = null
|
|
654
|
+
|
|
655
|
+
|
|
656
|
+
|
|
657
|
+
var layoutPath = null
|
|
658
658
|
, assets = null
|
|
659
659
|
, mapping = null
|
|
660
660
|
, XHRData = null
|
|
@@ -665,26 +665,26 @@ function SuperController(options) {
|
|
|
665
665
|
, isWithSwigLayout = null
|
|
666
666
|
, isUsingGinaLayout = (!isWithoutLayout && typeof(localOptions.template.layout) != 'undefined' && fs.existsSync(local.options.template.layout)) ? true : false
|
|
667
667
|
;
|
|
668
|
-
|
|
668
|
+
|
|
669
669
|
if ( isWithoutLayout || isUsingGinaLayout ) {
|
|
670
670
|
layoutPath = (isWithoutLayout) ? localOptions.template.noLayout : localOptions.template.layout;
|
|
671
671
|
// user layout override
|
|
672
672
|
if ( isUsingGinaLayout && !isWithoutLayout ) {
|
|
673
673
|
layoutPath = localOptions.template.layout;
|
|
674
|
-
}
|
|
674
|
+
}
|
|
675
675
|
if (isWithoutLayout) {
|
|
676
676
|
data.page.view.layout = layoutPath;
|
|
677
|
-
}
|
|
677
|
+
}
|
|
678
678
|
} else { // without layout case
|
|
679
|
-
|
|
679
|
+
|
|
680
680
|
// by default
|
|
681
681
|
layoutPath = localOptions.template.layout;
|
|
682
682
|
if ( !/^\//.test(layoutPath)) {
|
|
683
683
|
layoutPath = localOptions.template.templates +'/'+ layoutPath;
|
|
684
684
|
}
|
|
685
685
|
// default layout
|
|
686
|
-
if (
|
|
687
|
-
!isWithoutLayout && !fs.existsSync(layoutPath) && layoutPath == localOptions.template.templates +'/index.html'
|
|
686
|
+
if (
|
|
687
|
+
!isWithoutLayout && !fs.existsSync(layoutPath) && layoutPath == localOptions.template.templates +'/index.html'
|
|
688
688
|
) {
|
|
689
689
|
console.warn('Layout '+ local.options.template.layout +' not found, replacing with `nolayout`: '+ localOptions.template.noLayout);
|
|
690
690
|
layoutPath = localOptions.template.noLayout
|
|
@@ -703,26 +703,26 @@ function SuperController(options) {
|
|
|
703
703
|
self.throwError(err);
|
|
704
704
|
return;
|
|
705
705
|
}
|
|
706
|
-
|
|
706
|
+
|
|
707
707
|
}
|
|
708
|
-
|
|
709
|
-
|
|
708
|
+
|
|
709
|
+
|
|
710
710
|
var isLoadingPartial = false;
|
|
711
|
-
try {
|
|
711
|
+
try {
|
|
712
712
|
assets = {assets:"${assets}"};
|
|
713
|
-
|
|
713
|
+
|
|
714
714
|
/**
|
|
715
715
|
* retrieve template & layout
|
|
716
|
-
* */
|
|
717
|
-
var tpl = null;
|
|
716
|
+
* */
|
|
717
|
+
var tpl = null;
|
|
718
718
|
// tpl = fs.readFileSync(path).toString();
|
|
719
|
-
// layout = fs.readFileSync(layoutPath).toString();
|
|
720
|
-
|
|
719
|
+
// layout = fs.readFileSync(layoutPath).toString();
|
|
720
|
+
|
|
721
721
|
await Promise.all([
|
|
722
722
|
readFile(layoutPath),
|
|
723
723
|
readFile(path)
|
|
724
724
|
])
|
|
725
|
-
.then(([_layout, _tpl]) => {
|
|
725
|
+
.then(([_layout, _tpl]) => {
|
|
726
726
|
layout = _layout.toString();
|
|
727
727
|
tpl = _tpl.toString();
|
|
728
728
|
})
|
|
@@ -730,30 +730,30 @@ function SuperController(options) {
|
|
|
730
730
|
console.error(error.message);
|
|
731
731
|
return;
|
|
732
732
|
});
|
|
733
|
-
|
|
734
|
-
|
|
733
|
+
|
|
734
|
+
|
|
735
735
|
// mappin conf
|
|
736
736
|
mapping = { filename: path };
|
|
737
737
|
if (isRenderingCustomError) {
|
|
738
738
|
// TODO - Test if there is a block call `gina-error` in the layout & replace block name from tpl
|
|
739
|
-
|
|
739
|
+
|
|
740
740
|
if ( !/\{\%(\s+extends|extends)/.test(tpl) ) {
|
|
741
741
|
tpl = "\n{% extends '"+ layoutPath +"' %}\n" + tpl;
|
|
742
742
|
}
|
|
743
743
|
if (!/\{\% block content/.test(tpl)) {
|
|
744
744
|
// TODO - test if lyout has <body>
|
|
745
745
|
tpl = '{% block content %}<p>If you view this message you didn’t define a content block in your template.</p>{% endblock %}' + tpl;
|
|
746
|
-
}
|
|
747
|
-
|
|
746
|
+
}
|
|
747
|
+
|
|
748
748
|
tpl = tpl.replace(/\{\{ page\.content \}\}/g, '');
|
|
749
749
|
}
|
|
750
|
-
|
|
750
|
+
|
|
751
751
|
if ( isWithoutLayout || isWithSwigLayout) {
|
|
752
|
-
layout = tpl;
|
|
752
|
+
layout = tpl;
|
|
753
753
|
} else if (isUsingGinaLayout) {
|
|
754
754
|
mapping = { filename: path };
|
|
755
755
|
if ( /(\{\{|\{\{\s+)page\.content/.test(layout) ) {
|
|
756
|
-
|
|
756
|
+
|
|
757
757
|
if ( /\{\%(\s+extends|extends)/.test(tpl) ) {
|
|
758
758
|
err = new Error('You cannot use at the same time `page.content` in your layout `'+ layoutPath +'` while calling `extends` from your page or content `'+ path +'`. You have to choose one or the other');
|
|
759
759
|
self.throwError(local.res, 500, err);
|
|
@@ -761,9 +761,9 @@ function SuperController(options) {
|
|
|
761
761
|
}
|
|
762
762
|
layout = layout.replace('{{ page.content }}', tpl);
|
|
763
763
|
} else {
|
|
764
|
-
layout = layout.replace(/\<\/body\>/i, '\t'+tpl+'\n</body>');
|
|
764
|
+
layout = layout.replace(/\<\/body\>/i, '\t'+tpl+'\n</body>');
|
|
765
765
|
}
|
|
766
|
-
|
|
766
|
+
|
|
767
767
|
} else {
|
|
768
768
|
tpl = tpl.replace('{{ page.view.layout }}', data.page.view.layout);
|
|
769
769
|
if (/\<\/body\>/i.test(layout)) {
|
|
@@ -771,78 +771,78 @@ function SuperController(options) {
|
|
|
771
771
|
}
|
|
772
772
|
else {
|
|
773
773
|
layout += tpl;
|
|
774
|
-
}
|
|
774
|
+
}
|
|
775
775
|
}
|
|
776
|
-
|
|
776
|
+
|
|
777
777
|
// precompilation needed in case of `extends` or in order to display the toolbar
|
|
778
|
-
if ( hasViews() && self.isCacheless() || /\{\%(\s+extends|extends)/.test(layout) ) {
|
|
778
|
+
if ( hasViews() && self.isCacheless() || /\{\%(\s+extends|extends)/.test(layout) ) {
|
|
779
779
|
layout = swig.compile(layout, mapping)(data);
|
|
780
780
|
}
|
|
781
|
-
//dic['page.content'] = layout;
|
|
782
|
-
|
|
781
|
+
//dic['page.content'] = layout;
|
|
782
|
+
|
|
783
783
|
} catch(err) {
|
|
784
784
|
err.stack = 'Exception, bad syntax or undefined data found: start investigating in '+ mapping.filename +'\n' + err.stack;
|
|
785
785
|
self.throwError(local.res, 500, err);
|
|
786
786
|
return
|
|
787
787
|
}
|
|
788
|
-
|
|
789
|
-
isLoadingPartial = (
|
|
790
|
-
!/\<html/i.test(layout)
|
|
791
|
-
|| !/\<head/i.test(layout)
|
|
792
|
-
|| !/\<body/i.test(layout)
|
|
788
|
+
|
|
789
|
+
isLoadingPartial = (
|
|
790
|
+
!/\<html/i.test(layout)
|
|
791
|
+
|| !/\<head/i.test(layout)
|
|
792
|
+
|| !/\<body/i.test(layout)
|
|
793
793
|
) ? true : false;
|
|
794
|
-
|
|
794
|
+
|
|
795
795
|
// if (isLoadingPartial) {
|
|
796
796
|
// console.warn('----------------> loading partial `'+ path);
|
|
797
797
|
// }
|
|
798
|
-
|
|
799
|
-
isDeferModeEnabled = localOptions.template.javascriptsDeferEnabled || localOptions.conf.content.templates._common.javascriptsDeferEnabled || false;
|
|
800
|
-
|
|
798
|
+
|
|
799
|
+
isDeferModeEnabled = localOptions.template.javascriptsDeferEnabled || localOptions.conf.content.templates._common.javascriptsDeferEnabled || false;
|
|
800
|
+
|
|
801
801
|
// iframe case - without HTML TAG
|
|
802
802
|
if (!self.isXMLRequest() && !/\<html/.test(layout) ) {
|
|
803
803
|
layout = '<html>\n\t<head></head>\n\t<body class="gina-iframe-body">\n\t\t'+ layout +'\n\t</body>\n</html>';
|
|
804
|
-
}
|
|
805
|
-
|
|
804
|
+
}
|
|
805
|
+
|
|
806
806
|
// adding stylesheets
|
|
807
807
|
if (!isWithoutLayout && data.page.view.stylesheets && !/\{\{\s+(page\.view\.stylesheets)\s+\}\}/.test(layout) ) {
|
|
808
808
|
layout = layout.replace(/\<\/head\>/i, '\n\t{{ page.view.stylesheets }}\n</head>')
|
|
809
809
|
}
|
|
810
|
-
|
|
810
|
+
|
|
811
811
|
if (hasViews() && isWithoutLayout) {
|
|
812
812
|
// $.getScript(...)
|
|
813
813
|
//var isProxyHost = ( typeof(local.req.headers.host) != 'undefined' && localOptions.conf.server.scheme +'://'+ local.req.headers.host != localOptions.conf.hostname || typeof(local.req.headers[':authority']) != 'undefined' && localOptions.conf.server.scheme +'://'+ local.req.headers[':authority'] != localOptions.conf.hostname ) ? true : false;
|
|
814
814
|
//var hostname = (isProxyHost) ? localOptions.conf.hostname.replace(/\:\d+$/, '') : localOptions.conf.hostname;
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
|
|
818
818
|
var scripts = data.page.view.scripts;
|
|
819
819
|
scripts = scripts.replace(/\s+\<script/g, '\n<script');
|
|
820
|
-
|
|
820
|
+
|
|
821
821
|
if (!isProxyHost) {
|
|
822
822
|
var webroot = data.page.environment.webroot;
|
|
823
823
|
scripts = scripts.replace(/src\=\"\/(.*)\"/g, 'src="'+ webroot +'$1"');
|
|
824
824
|
//stylesheets = stylesheets.replace(/href\=\"\/(.*)\"/g, 'href="'+ webroot +'$1"')
|
|
825
825
|
}
|
|
826
|
-
|
|
826
|
+
|
|
827
827
|
// iframe case - without HTML TAG
|
|
828
|
-
if (self.isXMLRequest() || !/\<html/.test(layout) ) {
|
|
829
|
-
layout += scripts;
|
|
830
|
-
//layout += stylesheets;
|
|
831
|
-
}
|
|
832
|
-
|
|
828
|
+
if (self.isXMLRequest() || !/\<html/.test(layout) ) {
|
|
829
|
+
layout += scripts;
|
|
830
|
+
//layout += stylesheets;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
833
|
}
|
|
834
834
|
|
|
835
835
|
// adding plugins
|
|
836
|
-
|
|
837
|
-
|
|
836
|
+
|
|
837
|
+
|
|
838
838
|
if (
|
|
839
|
-
hasViews() && self.isCacheless() && !isWithoutLayout
|
|
840
|
-
&& localOptions.debugMode
|
|
841
|
-
||
|
|
842
|
-
hasViews() && self.isCacheless() && !isWithoutLayout
|
|
843
|
-
&& typeof(localOptions.debugMode) == 'undefined'
|
|
844
|
-
||
|
|
845
|
-
hasViews() && localOptions.debugMode
|
|
839
|
+
hasViews() && self.isCacheless() && !isWithoutLayout
|
|
840
|
+
&& localOptions.debugMode
|
|
841
|
+
||
|
|
842
|
+
hasViews() && self.isCacheless() && !isWithoutLayout
|
|
843
|
+
&& typeof(localOptions.debugMode) == 'undefined'
|
|
844
|
+
||
|
|
845
|
+
hasViews() && localOptions.debugMode
|
|
846
846
|
) {
|
|
847
847
|
|
|
848
848
|
layout = ''
|
|
@@ -852,52 +852,52 @@ function SuperController(options) {
|
|
|
852
852
|
+ '{%- set ginaDataInspector.view.stylesheets = "ignored-by-toolbar" -%}'
|
|
853
853
|
+ layout
|
|
854
854
|
;
|
|
855
|
-
|
|
855
|
+
|
|
856
856
|
plugin = '\t'
|
|
857
857
|
+ '{# Gina Toolbar #}'
|
|
858
858
|
+ '{%- set userDataInspector = JSON.clone(page) -%}'
|
|
859
859
|
+ '{%- set userDataInspector.view.scripts = "ignored-by-toolbar" -%}'
|
|
860
860
|
+ '{%- set userDataInspector.view.stylesheets = "ignored-by-toolbar" -%}'
|
|
861
861
|
+ '{%- set userDataInspector.view.assets = '+ JSON.stringify(assets) +' -%}'
|
|
862
|
-
+ '{%- include "'+ getPath('gina').core +'/asset/
|
|
863
|
-
+ '{# END Gina Toolbar #}'
|
|
862
|
+
+ '{%- include "'+ getPath('gina').core +'/asset/plugin/dist/toolbar/toolbar.html" with { gina: ginaDataInspector, user: userDataInspector } -%}'// jshint ignore:line
|
|
863
|
+
+ '{# END Gina Toolbar #}'
|
|
864
864
|
;
|
|
865
|
-
|
|
865
|
+
|
|
866
866
|
|
|
867
867
|
if (isWithoutLayout && localOptions.debugMode || localOptions.debugMode ) {
|
|
868
868
|
|
|
869
869
|
XHRData = '\t<input type="hidden" id="gina-without-layout-xhr-data" value="'+ encodeURIComponent(JSON.stringify(data.page.data)) +'">\n\r';
|
|
870
|
-
|
|
870
|
+
|
|
871
871
|
layout = layout.replace(/<\/body>/i, XHRData + '\n\t</body>');
|
|
872
872
|
}
|
|
873
|
-
|
|
873
|
+
|
|
874
874
|
if (self.isCacheless() || localOptions.debugMode ) {
|
|
875
875
|
layout = layout.replace(/<\/body>/i, plugin + '\n\t</body>');
|
|
876
876
|
}
|
|
877
|
-
|
|
877
|
+
|
|
878
878
|
// adding javascripts
|
|
879
|
-
layout.replace('{{ page.view.scripts }}', '');
|
|
879
|
+
layout.replace('{{ page.view.scripts }}', '');
|
|
880
880
|
// placed in the HEAD excepted when rendering a partial or when `isDeferModeEnabled` == true
|
|
881
881
|
if (isLoadingPartial) {
|
|
882
882
|
layout += '\t{{ page.view.scripts }}';
|
|
883
883
|
} else {
|
|
884
884
|
if ( isDeferModeEnabled ) {
|
|
885
885
|
layout = layout.replace(/\<\/head\>/i, '\t{{ page.view.scripts }}\n\t</head>');
|
|
886
|
-
} else { // placed in the BODY
|
|
886
|
+
} else { // placed in the BODY
|
|
887
887
|
layout = layout.replace(/\<\/body\>/i, '\t{{ page.view.scripts }}\n</body>');
|
|
888
888
|
}
|
|
889
889
|
}
|
|
890
|
-
|
|
890
|
+
|
|
891
891
|
// ginaLoader cannot be deferred
|
|
892
892
|
if ( !localOptions.template.javascriptsExcluded || localOptions.template.javascriptsExcluded != '**' ) {
|
|
893
|
-
layout = layout.replace(/\<\/head\>/i, '\t'+ localOptions.template.ginaLoader +'\n</head>');
|
|
893
|
+
layout = layout.replace(/\<\/head\>/i, '\t'+ localOptions.template.ginaLoader +'\n</head>');
|
|
894
894
|
}
|
|
895
895
|
|
|
896
896
|
} else if ( hasViews() && self.isCacheless() && self.isXMLRequest() ) {
|
|
897
|
-
|
|
898
|
-
if (isWithoutLayout) {
|
|
897
|
+
|
|
898
|
+
if (isWithoutLayout) {
|
|
899
899
|
delete data.page.view.scripts;
|
|
900
|
-
delete data.page.view.stylesheets;
|
|
900
|
+
delete data.page.view.stylesheets;
|
|
901
901
|
}
|
|
902
902
|
// means that we don't want GFF context or we already have it loaded
|
|
903
903
|
viewInfos = JSON.clone(data.page.view);
|
|
@@ -911,38 +911,38 @@ function SuperController(options) {
|
|
|
911
911
|
layout += XHRData + XHRView;
|
|
912
912
|
|
|
913
913
|
} else { // other envs like prod ...
|
|
914
|
-
|
|
914
|
+
|
|
915
915
|
// adding javascripts
|
|
916
916
|
// cleanup first
|
|
917
|
-
layout.replace('{{ page.view.scripts }}', '');
|
|
917
|
+
layout.replace('{{ page.view.scripts }}', '');
|
|
918
918
|
// placed in the HEAD excepted when rendering a partial or when `isDeferModeEnabled` == true
|
|
919
919
|
// if (isLoadingPartial) {
|
|
920
920
|
// layout += '\t{{ page.view.scripts }}';
|
|
921
921
|
// } else {
|
|
922
922
|
// if ( isDeferModeEnabled ) {
|
|
923
923
|
// layout = layout.replace(/\<\/head\>/i, '\t{{ page.view.scripts }}\n\t</head>');
|
|
924
|
-
// } else { // placed in the BODY
|
|
924
|
+
// } else { // placed in the BODY
|
|
925
925
|
// layout = layout.replace(/\<\/body\>/i, '\t{{ page.view.scripts }}\n</body>');
|
|
926
926
|
// }
|
|
927
927
|
// }
|
|
928
|
-
|
|
928
|
+
|
|
929
929
|
// // ginaLoader cannot be deferred
|
|
930
930
|
// if ( !localOptions.template.javascriptsExcluded || localOptions.template.javascriptsExcluded != '**' ) {
|
|
931
|
-
// layout = layout.replace(/\<\/head\>/i, '\t'+ localOptions.template.ginaLoader +'\n</head>');
|
|
931
|
+
// layout = layout.replace(/\<\/head\>/i, '\t'+ localOptions.template.ginaLoader +'\n</head>');
|
|
932
932
|
// }
|
|
933
|
-
|
|
933
|
+
|
|
934
934
|
// adding javascripts
|
|
935
935
|
layout.replace('{{ page.view.scripts }}', '');
|
|
936
|
-
if (isLoadingPartial) {
|
|
936
|
+
if (isLoadingPartial) {
|
|
937
937
|
layout += '\t{{ page.view.scripts }}\n';
|
|
938
938
|
if ( !localOptions.template.javascriptsExcluded || localOptions.template.javascriptsExcluded != '**' ) {
|
|
939
939
|
layout += '\t'+ localOptions.template.ginaLoader +'\n';
|
|
940
940
|
}
|
|
941
941
|
} else {
|
|
942
|
-
if ( isDeferModeEnabled && /\<\/head\>/i.test(layout) ) { // placed in the HEAD
|
|
942
|
+
if ( isDeferModeEnabled && /\<\/head\>/i.test(layout) ) { // placed in the HEAD
|
|
943
943
|
layout = layout.replace(/\<\/head\>/i, '\t{{ page.view.scripts }}\n\t</head>');
|
|
944
|
-
|
|
945
|
-
} else { // placed in the BODY
|
|
944
|
+
|
|
945
|
+
} else { // placed in the BODY
|
|
946
946
|
layout = layout.replace(/\<\/body\>/i, '\t{{ page.view.scripts }}\n</body>');
|
|
947
947
|
}
|
|
948
948
|
// ginaLoader cannot be deferred
|
|
@@ -951,20 +951,20 @@ function SuperController(options) {
|
|
|
951
951
|
}
|
|
952
952
|
}
|
|
953
953
|
}
|
|
954
|
-
|
|
955
|
-
|
|
954
|
+
|
|
955
|
+
|
|
956
956
|
layout = whisper(dic, layout, /\{{ ([a-zA-Z.]+) \}}/g );
|
|
957
957
|
dic['page.content'] = layout;
|
|
958
958
|
/**
|
|
959
959
|
// special case for template without layout in debug mode - dev only
|
|
960
960
|
if ( hasViews() && localOptions.debugMode && self.isCacheless() && !/\{\# Gina Toolbar \#\}/.test(layout) ) {
|
|
961
|
-
try {
|
|
962
|
-
|
|
963
|
-
layout = layout.replace(/<\/body>/i, plugin + '\n\t</body>');
|
|
961
|
+
try {
|
|
962
|
+
|
|
963
|
+
layout = layout.replace(/<\/body>/i, plugin + '\n\t</body>');
|
|
964
964
|
layout = whisper(dic, layout, /\{{ ([a-zA-Z.]+) \}}/g );
|
|
965
965
|
//swig.invalidateCache();
|
|
966
966
|
layout = swig.compile(layout, mapping)(data);
|
|
967
|
-
|
|
967
|
+
|
|
968
968
|
|
|
969
969
|
} catch (err) {
|
|
970
970
|
filename = localOptions.template.html;
|
|
@@ -972,7 +972,7 @@ function SuperController(options) {
|
|
|
972
972
|
self.throwError(local.res, 500, new Error('Compilation error encountered while trying to process template `'+ filename + '`\n'+(err.stack||err.message)));
|
|
973
973
|
return;
|
|
974
974
|
}
|
|
975
|
-
}
|
|
975
|
+
}
|
|
976
976
|
else if (hasViews() && localOptions.debugMode && self.isCacheless()) {
|
|
977
977
|
try {
|
|
978
978
|
//layout = whisper(dic, layout, /\{{ ([a-zA-Z.]+) \}}/g );
|
|
@@ -983,9 +983,9 @@ function SuperController(options) {
|
|
|
983
983
|
self.throwError(local.res, 500, new Error('Compilation error encountered while trying to process template `'+ filename + '`\n'+(err.stack||err.message)));
|
|
984
984
|
return;
|
|
985
985
|
}
|
|
986
|
-
}
|
|
987
|
-
*/
|
|
988
|
-
|
|
986
|
+
}
|
|
987
|
+
*/
|
|
988
|
+
|
|
989
989
|
|
|
990
990
|
if ( !local.res.headersSent ) {
|
|
991
991
|
local.res.statusCode = ( typeof(localOptions.conf.server.coreConfiguration.statusCodes[data.page.data.status]) != 'undefined' ) ? data.page.data.status : 200; // by default
|
|
@@ -1004,62 +1004,62 @@ function SuperController(options) {
|
|
|
1004
1004
|
}
|
|
1005
1005
|
|
|
1006
1006
|
local.res.setHeader('content-type', localOptions.conf.server.coreConfiguration.mime['html'] + '; charset='+ localOptions.conf.encoding );
|
|
1007
|
-
|
|
1007
|
+
|
|
1008
1008
|
try {
|
|
1009
|
-
|
|
1009
|
+
|
|
1010
1010
|
// escape special chars
|
|
1011
1011
|
var blacklistRe = new RegExp('[\<\>]', 'g');
|
|
1012
1012
|
// DO NOT REPLACE IT BY JSON.clone() !!!!
|
|
1013
|
-
|
|
1013
|
+
|
|
1014
1014
|
data.page.data = JSON.parse(JSON.stringify(data.page.data).replace(blacklistRe, '\$&'));
|
|
1015
|
-
|
|
1015
|
+
|
|
1016
1016
|
} catch (err) {
|
|
1017
1017
|
filename = localOptions.template.html;
|
|
1018
1018
|
filename += ( typeof(data.page.view.namespace) != 'undefined' && data.page.view.namespace != '' && new RegExp('^' + data.page.view.namespace +'-').test(data.page.view.file) ) ? '/' + data.page.view.namespace + data.page.view.file.split(data.page.view.namespace +'-').join('/') + ( (data.page.view.ext != '') ? data.page.view.ext: '' ) : '/' + data.page.view.file+ ( (data.page.view.ext != '') ? data.page.view.ext: '' );
|
|
1019
1019
|
self.throwError(local.res, 500, new Error('Controller::render(...) compilation error encountered while trying to process template `'+ filename + '`\n' + (err.stack||err.message||err) ));
|
|
1020
1020
|
return;
|
|
1021
1021
|
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1022
|
+
|
|
1023
|
+
|
|
1024
1024
|
// Only available for http/2.0 for now
|
|
1025
1025
|
if ( !self.isXMLRequest() && /http\/2/.test(localOptions.conf.server.protocol) ) {
|
|
1026
1026
|
try {
|
|
1027
|
-
// TODO - button in toolbar to empty url assets cache
|
|
1027
|
+
// TODO - button in toolbar to empty url assets cache
|
|
1028
1028
|
if ( /** self.isCacheless() ||*/ typeof(localOptions.template.assets) == 'undefined' || typeof(localOptions.template.assets[local.req.url]) == 'undefined' ) {
|
|
1029
1029
|
// assets string -> object
|
|
1030
1030
|
//assets = self.serverInstance.getAssets(localOptions.conf, layout.toString(), swig, data);
|
|
1031
1031
|
assets = self.serverInstance.getAssets(localOptions.conf, layout, swig, data);
|
|
1032
1032
|
localOptions.template.assets = JSON.parse(assets);
|
|
1033
1033
|
}
|
|
1034
|
-
|
|
1034
|
+
|
|
1035
1035
|
// only for toolbar - TODO hasToolbar()
|
|
1036
1036
|
if (
|
|
1037
1037
|
self.isCacheless() && hasViews() && !isWithoutLayout
|
|
1038
1038
|
|| hasViews() && localOptions.debugMode
|
|
1039
|
-
|| self.isCacheless() && hasViews() && self.isXMLRequest()
|
|
1040
|
-
) {
|
|
1041
|
-
layout = layout.replace('{"assets":"${assets}"}', assets );
|
|
1039
|
+
|| self.isCacheless() && hasViews() && self.isXMLRequest()
|
|
1040
|
+
) {
|
|
1041
|
+
layout = layout.replace('{"assets":"${assets}"}', assets );
|
|
1042
1042
|
}
|
|
1043
|
-
|
|
1043
|
+
|
|
1044
1044
|
} catch (err) {
|
|
1045
1045
|
self.throwError(local.res, 500, new Error('Controller::render(...) calling getAssets(...) \n' + (err.stack||err.message||err) ));
|
|
1046
1046
|
return;
|
|
1047
1047
|
}
|
|
1048
1048
|
}
|
|
1049
|
-
|
|
1050
|
-
// Last compilation before rendering
|
|
1051
|
-
layout = swig.compile(layout, mapping)(data);
|
|
1052
|
-
|
|
1049
|
+
|
|
1050
|
+
// Last compilation before rendering
|
|
1051
|
+
layout = swig.compile(layout, mapping)(data);
|
|
1052
|
+
|
|
1053
1053
|
if ( !local.res.headersSent ) {
|
|
1054
1054
|
if ( local.options.isRenderingCustomError ) {
|
|
1055
1055
|
local.options.isRenderingCustomError = false;
|
|
1056
1056
|
}
|
|
1057
1057
|
local.res.end(layout);
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
1060
|
console.info(local.req.method +' ['+local.res.statusCode +'] '+ local.req.url);
|
|
1061
|
-
|
|
1062
|
-
} else if (typeof(local.next) != 'undefined') {
|
|
1061
|
+
|
|
1062
|
+
} else if (typeof(local.next) != 'undefined') {
|
|
1063
1063
|
// local.next();
|
|
1064
1064
|
return local.next();
|
|
1065
1065
|
} else {
|
|
@@ -1075,7 +1075,7 @@ function SuperController(options) {
|
|
|
1075
1075
|
return;
|
|
1076
1076
|
}
|
|
1077
1077
|
}
|
|
1078
|
-
|
|
1078
|
+
|
|
1079
1079
|
|
|
1080
1080
|
this.isXMLRequest = function() {
|
|
1081
1081
|
return local.options.isXMLRequest;
|
|
@@ -1102,21 +1102,21 @@ function SuperController(options) {
|
|
|
1102
1102
|
return false
|
|
1103
1103
|
}
|
|
1104
1104
|
if ( self.isProcessingError ) {
|
|
1105
|
-
return;
|
|
1105
|
+
return;
|
|
1106
1106
|
}
|
|
1107
1107
|
|
|
1108
1108
|
var request = local.req;
|
|
1109
1109
|
var response = local.res;
|
|
1110
1110
|
var next = local.next || null;
|
|
1111
1111
|
// var stream = null;
|
|
1112
|
-
// if ( /http\/2/.test(local.options.conf.server.protocol) ) {
|
|
1113
|
-
// stream = response.stream;
|
|
1112
|
+
// if ( /http\/2/.test(local.options.conf.server.protocol) ) {
|
|
1113
|
+
// stream = response.stream;
|
|
1114
1114
|
// }
|
|
1115
1115
|
|
|
1116
1116
|
if (!jsonObj) {
|
|
1117
1117
|
jsonObj = {}
|
|
1118
1118
|
}
|
|
1119
|
-
|
|
1119
|
+
|
|
1120
1120
|
try {
|
|
1121
1121
|
// just in case
|
|
1122
1122
|
if ( typeof(jsonObj) == 'string') {
|
|
@@ -1126,7 +1126,7 @@ function SuperController(options) {
|
|
|
1126
1126
|
// if( typeof(local.options) != "undefined" && typeof(local.options.charset) != "undefined" ){
|
|
1127
1127
|
// response.setHeader("charset", local.options.charset);
|
|
1128
1128
|
// }
|
|
1129
|
-
|
|
1129
|
+
|
|
1130
1130
|
|
|
1131
1131
|
//catching errors
|
|
1132
1132
|
if (
|
|
@@ -1164,17 +1164,17 @@ function SuperController(options) {
|
|
|
1164
1164
|
} else {
|
|
1165
1165
|
len = data.length
|
|
1166
1166
|
}
|
|
1167
|
-
|
|
1167
|
+
|
|
1168
1168
|
if (!response.headersSent)
|
|
1169
1169
|
response.setHeader("content-length", len);
|
|
1170
|
-
|
|
1171
|
-
|
|
1170
|
+
|
|
1171
|
+
|
|
1172
1172
|
// if (stream && !stream.destroyed) {
|
|
1173
1173
|
// //stream.respond(header);
|
|
1174
1174
|
// stream.end(data);
|
|
1175
1175
|
// } else {
|
|
1176
1176
|
response.write(data);
|
|
1177
|
-
|
|
1177
|
+
|
|
1178
1178
|
// required to close connection
|
|
1179
1179
|
setTimeout(function () {
|
|
1180
1180
|
response.end();
|
|
@@ -1184,17 +1184,17 @@ function SuperController(options) {
|
|
|
1184
1184
|
// Ignoring warning
|
|
1185
1185
|
//console.warn(err);
|
|
1186
1186
|
}
|
|
1187
|
-
|
|
1187
|
+
|
|
1188
1188
|
if ( next ) {
|
|
1189
1189
|
next()
|
|
1190
1190
|
}
|
|
1191
1191
|
}, 200);
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1192
|
+
|
|
1193
|
+
|
|
1194
|
+
|
|
1195
1195
|
return // force completion
|
|
1196
1196
|
// }
|
|
1197
|
-
|
|
1197
|
+
|
|
1198
1198
|
|
|
1199
1199
|
} else { // normal case
|
|
1200
1200
|
response.end(JSON.stringify(jsonObj));
|
|
@@ -1209,7 +1209,7 @@ function SuperController(options) {
|
|
|
1209
1209
|
if ( next ) {
|
|
1210
1210
|
next()
|
|
1211
1211
|
}
|
|
1212
|
-
|
|
1212
|
+
|
|
1213
1213
|
return;
|
|
1214
1214
|
}
|
|
1215
1215
|
}
|
|
@@ -1324,24 +1324,24 @@ function SuperController(options) {
|
|
|
1324
1324
|
self.throwError(500, new Error('No views configuration found. Did you try to add views before using Controller::render(...) ? Try to run: gina view:add '+ options.conf.bundle +' @'+ options.conf.projectName));
|
|
1325
1325
|
return;
|
|
1326
1326
|
}
|
|
1327
|
-
|
|
1327
|
+
|
|
1328
1328
|
var authority = ( typeof(local.req.headers['x-forwarded-proto']) != 'undefined' ) ? local.req.headers['x-forwarded-proto'] : local.options.conf.server.scheme;
|
|
1329
1329
|
authority += '://'+ local.req.headers.host;
|
|
1330
1330
|
var useWebroot = false;
|
|
1331
1331
|
if ( !/^\/$/.test(local.options.conf.server.webroot) && local.options.conf.server.webroot.length > 0 && local.options.conf.hostname.replace(/\:\d+$/, '') == authority ) {
|
|
1332
1332
|
useWebroot = true
|
|
1333
1333
|
}
|
|
1334
|
-
|
|
1334
|
+
|
|
1335
1335
|
var reURL = new RegExp('^'+ local.options.conf.server.webroot);
|
|
1336
1336
|
|
|
1337
1337
|
var cssStr = '', jsStr = '';
|
|
1338
|
-
|
|
1338
|
+
|
|
1339
1339
|
//Get css
|
|
1340
1340
|
if( viewConf.stylesheets ) {
|
|
1341
1341
|
cssStr = getNodeRes('css', viewConf.stylesheets, useWebroot, reURL)
|
|
1342
1342
|
}
|
|
1343
1343
|
//Get js
|
|
1344
|
-
if( viewConf.javascripts ) {
|
|
1344
|
+
if( viewConf.javascripts ) {
|
|
1345
1345
|
jsStr = getNodeRes('js', viewConf.javascripts, useWebroot, reURL)
|
|
1346
1346
|
}
|
|
1347
1347
|
|
|
@@ -1362,7 +1362,7 @@ function SuperController(options) {
|
|
|
1362
1362
|
* @private
|
|
1363
1363
|
* */
|
|
1364
1364
|
var getNodeRes = function(type, resArr, useWebroot, reURL) {
|
|
1365
|
-
|
|
1365
|
+
|
|
1366
1366
|
var r = 0
|
|
1367
1367
|
, rLen = resArr.length
|
|
1368
1368
|
, obj = null
|
|
@@ -1370,7 +1370,7 @@ function SuperController(options) {
|
|
|
1370
1370
|
;
|
|
1371
1371
|
switch(type){
|
|
1372
1372
|
case 'css':
|
|
1373
|
-
for (; r < rLen; ++r) {
|
|
1373
|
+
for (; r < rLen; ++r) {
|
|
1374
1374
|
obj = resArr[r];
|
|
1375
1375
|
if (useWebroot && !reURL.test(obj.url) ) {
|
|
1376
1376
|
obj.url = local.options.conf.server.webroot + obj.url.substr(1);
|
|
@@ -1378,32 +1378,32 @@ function SuperController(options) {
|
|
|
1378
1378
|
// TODO - add support for cdn
|
|
1379
1379
|
if (!/\:\/\//.test(obj.url) ) {
|
|
1380
1380
|
obj.url = local.options.conf.hostname + obj.url;
|
|
1381
|
-
}
|
|
1382
|
-
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
1383
|
if (obj.media)
|
|
1384
|
-
str += '\n\t\t<link href="'+ obj.url +'" media="'+ obj.media +'" rel="'+ obj.rel +'" type="'+ obj.type +'">';
|
|
1384
|
+
str += '\n\t\t<link href="'+ obj.url +'" media="'+ obj.media +'" rel="'+ obj.rel +'" type="'+ obj.type +'">';
|
|
1385
1385
|
else
|
|
1386
|
-
str += '\n\t\t<link href="'+ obj.url +'" rel="'+ obj.rel +'" type="'+ obj.type +'">';
|
|
1386
|
+
str += '\n\t\t<link href="'+ obj.url +'" rel="'+ obj.rel +'" type="'+ obj.type +'">';
|
|
1387
1387
|
}
|
|
1388
|
-
|
|
1388
|
+
|
|
1389
1389
|
return str;
|
|
1390
1390
|
break;
|
|
1391
1391
|
|
|
1392
1392
|
case 'js':
|
|
1393
1393
|
var deferMode = (local.options.template.javascriptsDeferEnabled) ? ' defer' : '';
|
|
1394
|
-
|
|
1394
|
+
|
|
1395
1395
|
for (; r < rLen; ++r) {
|
|
1396
1396
|
obj = resArr[r];
|
|
1397
1397
|
if (useWebroot && !reURL.test(obj.url) ) {
|
|
1398
1398
|
obj.url = local.options.conf.server.webroot + obj.url.substr(1);
|
|
1399
1399
|
}
|
|
1400
|
-
// TODO - add support for cdn
|
|
1400
|
+
// TODO - add support for cdn
|
|
1401
1401
|
if (!/\:\/\//.test(obj.url) ) {
|
|
1402
1402
|
obj.url = local.options.conf.hostname + obj.url;
|
|
1403
1403
|
}
|
|
1404
|
-
str += '\n\t\t<script'+ deferMode +' type="'+ obj.type +'" src="'+ obj.url +'"></script>'
|
|
1404
|
+
str += '\n\t\t<script'+ deferMode +' type="'+ obj.type +'" src="'+ obj.url +'"></script>'
|
|
1405
1405
|
}
|
|
1406
|
-
|
|
1406
|
+
|
|
1407
1407
|
return str;
|
|
1408
1408
|
break;
|
|
1409
1409
|
}
|
|
@@ -1419,17 +1419,17 @@ function SuperController(options) {
|
|
|
1419
1419
|
var getData = function() {
|
|
1420
1420
|
return refToObj( local.userData )
|
|
1421
1421
|
}
|
|
1422
|
-
|
|
1422
|
+
|
|
1423
1423
|
|
|
1424
1424
|
var isValidURL = function(url){
|
|
1425
1425
|
var re = /(http|ftp|https|sftp):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/;
|
|
1426
1426
|
return (re.test(url)) ? true : false
|
|
1427
1427
|
}
|
|
1428
|
-
|
|
1428
|
+
|
|
1429
1429
|
/**
|
|
1430
|
-
* Set method - Override current method
|
|
1430
|
+
* Set method - Override current method
|
|
1431
1431
|
* E.g.: in case of redirect, to force PUT to GET
|
|
1432
|
-
*
|
|
1432
|
+
*
|
|
1433
1433
|
* @param {string} requestMethod - GET, POST, PUT, DELETE
|
|
1434
1434
|
*/
|
|
1435
1435
|
var localRequestMethod = null, localRequestMethodParams = null;
|
|
@@ -1438,66 +1438,66 @@ function SuperController(options) {
|
|
|
1438
1438
|
if ( /http\/2/i.test(conf.server.protocolShort) ) {
|
|
1439
1439
|
local.req.headers[':method'] = local.req.method.toUpperCase()
|
|
1440
1440
|
}
|
|
1441
|
-
|
|
1441
|
+
|
|
1442
1442
|
localRequestMethod = local.req.method = local.req.routing.method = requestMethod.toUpperCase();
|
|
1443
|
-
|
|
1443
|
+
|
|
1444
1444
|
local.res.setHeader('access-control-allow-methods', localRequestMethod);
|
|
1445
|
-
|
|
1446
|
-
return localRequestMethod;
|
|
1445
|
+
|
|
1446
|
+
return localRequestMethod;
|
|
1447
1447
|
}
|
|
1448
|
-
|
|
1448
|
+
|
|
1449
1449
|
this.getRequestMethod = function() {
|
|
1450
1450
|
return localRequestMethod;
|
|
1451
1451
|
}
|
|
1452
|
-
|
|
1452
|
+
|
|
1453
1453
|
this.setRequestMethodParams = function(params) {
|
|
1454
1454
|
localRequestMethodParams = local.req[local.req.method.toLowerCase()] = localRequestMethodParams = params
|
|
1455
1455
|
}
|
|
1456
|
-
|
|
1456
|
+
|
|
1457
1457
|
this.getRequestMethodParams = function() {
|
|
1458
1458
|
return (localRequestMethodParams) ? localRequestMethodParams : local.req[local.req.method.toLowerCase()]
|
|
1459
1459
|
}
|
|
1460
|
-
|
|
1460
|
+
|
|
1461
1461
|
/**
|
|
1462
1462
|
* isStaticRoute
|
|
1463
1463
|
* Trying to determine if url is a `statics` ressource
|
|
1464
|
-
*
|
|
1464
|
+
*
|
|
1465
1465
|
* @param {string} url
|
|
1466
1466
|
* @param {string} method
|
|
1467
|
-
*
|
|
1467
|
+
*
|
|
1468
1468
|
* @returns {boolean} isStaticRoute
|
|
1469
1469
|
*/
|
|
1470
1470
|
var isStaticRoute = function(url, method, bundle, env, conf) {
|
|
1471
|
-
|
|
1471
|
+
|
|
1472
1472
|
if ( !/get/i.test(method) ) {
|
|
1473
1473
|
return false
|
|
1474
1474
|
}
|
|
1475
|
-
|
|
1475
|
+
|
|
1476
1476
|
// priority to statics - this portion of code has been duplicated to Server.js
|
|
1477
|
-
|
|
1477
|
+
|
|
1478
1478
|
var staticsArr = conf[bundle][env].publicResources;
|
|
1479
1479
|
var staticProps = {
|
|
1480
1480
|
firstLevel : '/' + url.split(/\//g)[1] + '/',
|
|
1481
1481
|
// to be considered as a stativ content, url must content at least 2 caracters after last `.`: .js, .html are ok
|
|
1482
1482
|
isStaticFilename : /(\.([A-Za-z0-9]+){2}|\/)$/.test(url)
|
|
1483
|
-
};
|
|
1484
|
-
|
|
1483
|
+
};
|
|
1484
|
+
|
|
1485
1485
|
// handle resources from public with webroot in url
|
|
1486
1486
|
if ( staticProps.isStaticFilename && conf[bundle][env].server.webroot != '/' && staticProps.firstLevel == conf[bundle][env].server.webroot ) {
|
|
1487
1487
|
var matchedFirstInUrl = url.replace(conf[bundle][env].server.webroot, '').match(/[A-Za-z0-9_-]+\/?/);
|
|
1488
1488
|
if ( matchedFirstInUrl && matchedFirstInUrl.length > 0 ) {
|
|
1489
1489
|
staticProps.firstLevel = conf[bundle][env].server.webroot + matchedFirstInUrl[0]
|
|
1490
|
-
}
|
|
1490
|
+
}
|
|
1491
1491
|
}
|
|
1492
|
-
|
|
1493
|
-
if (
|
|
1494
|
-
staticProps.isStaticFilename && staticsArr.indexOf(url) > -1
|
|
1495
|
-
|| staticProps.isStaticFilename && staticsArr.indexOf( url.replace(url.substr(url.lastIndexOf('/')+1), '') ) > -1
|
|
1492
|
+
|
|
1493
|
+
if (
|
|
1494
|
+
staticProps.isStaticFilename && staticsArr.indexOf(url) > -1
|
|
1495
|
+
|| staticProps.isStaticFilename && staticsArr.indexOf( url.replace(url.substr(url.lastIndexOf('/')+1), '') ) > -1
|
|
1496
1496
|
|| staticProps.isStaticFilename && staticsArr.indexOf(staticProps.firstLevel) > -1
|
|
1497
1497
|
) {
|
|
1498
1498
|
return true
|
|
1499
1499
|
}
|
|
1500
|
-
|
|
1500
|
+
|
|
1501
1501
|
return false;
|
|
1502
1502
|
}
|
|
1503
1503
|
|
|
@@ -1506,7 +1506,7 @@ function SuperController(options) {
|
|
|
1506
1506
|
*
|
|
1507
1507
|
* TODO - improve redirect based on `utils.routing`
|
|
1508
1508
|
* e.g.: self.redirect('project-get', { companyId: companyId, clientId: clientId, id: projectId }, true)
|
|
1509
|
-
*
|
|
1509
|
+
*
|
|
1510
1510
|
* How to avoid redirect inside popin context
|
|
1511
1511
|
* N.B.: When you are in a popin context, add an `id` to your template tag so it can be ignored by the default PopinHandler
|
|
1512
1512
|
* E.g.: id="delete-link" -> <a href="#" id="delete-link">delete</a>
|
|
@@ -1553,10 +1553,10 @@ function SuperController(options) {
|
|
|
1553
1553
|
* `ignoreWebRoot` behaves the like set to `false` by default
|
|
1554
1554
|
*
|
|
1555
1555
|
* N.B.: Gina will tell browsers not to cache redirections if you are using `dev` environement
|
|
1556
|
-
*
|
|
1556
|
+
*
|
|
1557
1557
|
* Trobleshouting:
|
|
1558
1558
|
* ---------------
|
|
1559
|
-
*
|
|
1559
|
+
*
|
|
1560
1560
|
* Redirecting to a popin from the controller while posting from a form
|
|
1561
1561
|
* If this does not work, like doing a real redirect, this
|
|
1562
1562
|
* only means that the ID you are using for the form might be
|
|
@@ -1567,7 +1567,7 @@ function SuperController(options) {
|
|
|
1567
1567
|
* @param {object} [params] TODO
|
|
1568
1568
|
*
|
|
1569
1569
|
* @callback [ next ]
|
|
1570
|
-
* */
|
|
1570
|
+
* */
|
|
1571
1571
|
this.redirect = function(req, res, next) {
|
|
1572
1572
|
var conf = self.getConfig();
|
|
1573
1573
|
var bundle = conf.bundle;
|
|
@@ -1579,14 +1579,14 @@ function SuperController(options) {
|
|
|
1579
1579
|
var ignoreWebRoot = null, isRelative = false;
|
|
1580
1580
|
var originalUrl = null;
|
|
1581
1581
|
var method = null;
|
|
1582
|
-
var originalMethod = null;
|
|
1582
|
+
var originalMethod = null;
|
|
1583
1583
|
|
|
1584
1584
|
if ( typeof(req) === 'string' ) {
|
|
1585
1585
|
|
|
1586
1586
|
// if ( typeof(res) == 'undefined') {
|
|
1587
1587
|
// // nothing to do
|
|
1588
1588
|
// ignoreWebRoot = false
|
|
1589
|
-
// } else
|
|
1589
|
+
// } else
|
|
1590
1590
|
if (typeof(res) === 'string' || typeof(res) === 'number' || typeof(res) === 'boolean') {
|
|
1591
1591
|
if ( /true|1/.test(res) ) {
|
|
1592
1592
|
ignoreWebRoot = true
|
|
@@ -1608,26 +1608,26 @@ function SuperController(options) {
|
|
|
1608
1608
|
ignoreWebRoot = false;
|
|
1609
1609
|
}
|
|
1610
1610
|
}
|
|
1611
|
-
|
|
1611
|
+
|
|
1612
1612
|
}
|
|
1613
1613
|
|
|
1614
1614
|
if ( req.substr(0,1) === '/') { // is relative (not checking if the URI is defined in the routing.json)
|
|
1615
1615
|
// if (wroot.substr(wroot.length-1,1) == '/') {
|
|
1616
1616
|
// wroot = wroot.substr(wroot.length-1,1).replace('/', '')
|
|
1617
1617
|
// }
|
|
1618
|
-
|
|
1618
|
+
|
|
1619
1619
|
if ( /^\//.test(req) && !ignoreWebRoot )
|
|
1620
1620
|
req = req.substr(1);
|
|
1621
|
-
|
|
1621
|
+
|
|
1622
1622
|
rte = ( ignoreWebRoot != null && ignoreWebRoot ) ? req : wroot + req;
|
|
1623
1623
|
// cleaning url in case of ?param=value
|
|
1624
|
-
originalUrl = rte;
|
|
1624
|
+
originalUrl = rte;
|
|
1625
1625
|
rte = rte.replace(/\?(.*)/, '');
|
|
1626
|
-
|
|
1626
|
+
|
|
1627
1627
|
req = local.req;
|
|
1628
|
-
originalMethod = ( typeof(req.originalMethod) != 'undefined') ? req.originalMethod : req.method;
|
|
1629
|
-
console.debug('[ BUNDLE ][ '+ local.options.conf.bundle +' ][ Controller ] trying to get route: ', rte, bundle, req.method);
|
|
1630
|
-
if ( !ignoreWebRoot || !isStaticRoute(rte, req.method, bundle, env, ctx.config.envConf) && !ignoreWebRoot ) {
|
|
1628
|
+
originalMethod = ( typeof(req.originalMethod) != 'undefined') ? req.originalMethod : req.method;
|
|
1629
|
+
console.debug('[ BUNDLE ][ '+ local.options.conf.bundle +' ][ Controller ] trying to get route: ', rte, bundle, req.method);
|
|
1630
|
+
if ( !ignoreWebRoot || !isStaticRoute(rte, req.method, bundle, env, ctx.config.envConf) && !ignoreWebRoot ) {
|
|
1631
1631
|
req.routing = lib.routing.getRouteByUrl(rte, bundle, req.method, req);
|
|
1632
1632
|
// try alternative method
|
|
1633
1633
|
if (!req.routing) {
|
|
@@ -1637,7 +1637,7 @@ function SuperController(options) {
|
|
|
1637
1637
|
method = req.method = 'GET'
|
|
1638
1638
|
}
|
|
1639
1639
|
}
|
|
1640
|
-
|
|
1640
|
+
|
|
1641
1641
|
//route = route = req.routing.name;
|
|
1642
1642
|
} else {
|
|
1643
1643
|
req.routing = {
|
|
@@ -1646,54 +1646,54 @@ function SuperController(options) {
|
|
|
1646
1646
|
}
|
|
1647
1647
|
}
|
|
1648
1648
|
}
|
|
1649
|
-
|
|
1649
|
+
|
|
1650
1650
|
res = local.res;
|
|
1651
1651
|
next = local.next;
|
|
1652
1652
|
isRelative = true;
|
|
1653
|
-
|
|
1653
|
+
|
|
1654
1654
|
req.routing.param.path = rte
|
|
1655
1655
|
} else if ( isValidURL(req) ) { // might be an URL
|
|
1656
1656
|
rte = req;
|
|
1657
|
-
originalUrl = rte;
|
|
1657
|
+
originalUrl = rte;
|
|
1658
1658
|
rte = rte.replace(/\?(.*)/, '');
|
|
1659
|
-
|
|
1659
|
+
|
|
1660
1660
|
req = local.req;
|
|
1661
1661
|
res = local.res;
|
|
1662
1662
|
next = local.next;
|
|
1663
|
-
|
|
1663
|
+
|
|
1664
1664
|
req.routing.param.url = rte
|
|
1665
1665
|
} else { // is by default a route name
|
|
1666
|
-
|
|
1666
|
+
|
|
1667
1667
|
if ( /\@/.test(req) ) {
|
|
1668
1668
|
var rteArr = req.split(/\//);
|
|
1669
1669
|
if ( typeof(rteArr[1]) != 'undefined' )
|
|
1670
1670
|
env = rteArr[1];
|
|
1671
|
-
|
|
1671
|
+
|
|
1672
1672
|
rte = route = rteArr[0];
|
|
1673
1673
|
rteArr = rteArr[0].split(/\@/);
|
|
1674
|
-
|
|
1674
|
+
|
|
1675
1675
|
bundle = rteArr[1];
|
|
1676
|
-
|
|
1676
|
+
|
|
1677
1677
|
} else {
|
|
1678
1678
|
rte = route = ( new RegExp('^/'+conf.bundle+'-$').test(req) ) ? req : wroot.match(/[^/]/g).join('') +'-'+ req;
|
|
1679
1679
|
}
|
|
1680
|
-
|
|
1681
|
-
|
|
1680
|
+
|
|
1681
|
+
|
|
1682
1682
|
req = local.req;
|
|
1683
1683
|
res = local.res;
|
|
1684
1684
|
next = local.next;
|
|
1685
|
-
|
|
1685
|
+
|
|
1686
1686
|
req.routing.param.route = routing[rte]
|
|
1687
|
-
}
|
|
1688
|
-
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
1689
|
} else {
|
|
1690
|
-
route = req.routing.param.route;
|
|
1690
|
+
route = req.routing.param.route;
|
|
1691
1691
|
}
|
|
1692
|
-
|
|
1692
|
+
|
|
1693
1693
|
if ( !originalMethod ) {
|
|
1694
1694
|
originalMethod = ( typeof(req.originalMethod) != 'undefined') ? req.originalMethod : req.method;
|
|
1695
1695
|
}
|
|
1696
|
-
|
|
1696
|
+
|
|
1697
1697
|
var path = originalUrl || req.routing.param.path || '';
|
|
1698
1698
|
var url = req.routing.param.url;
|
|
1699
1699
|
var code = req.routing.param.code || 301;
|
|
@@ -1710,20 +1710,20 @@ function SuperController(options) {
|
|
|
1710
1710
|
|
|
1711
1711
|
var isProxyHost = ( typeof(local.req.headers.host) != 'undefined' && local.options.conf.server.scheme +'://'+ local.req.headers.host != local.options.conf.hostname || typeof(local.req.headers[':authority']) != 'undefined' && local.options.conf.server.scheme +'://'+ local.req.headers[':authority'] != local.options.conf.hostname ) ? true : false;
|
|
1712
1712
|
var hostname = (isProxyHost) ? ctx.config.envConf[bundle][env].hostname.replace(/\:\d+$/, '') : ctx.config.envConf[bundle][env].hostname;
|
|
1713
|
-
|
|
1713
|
+
|
|
1714
1714
|
// if ( !/\:\d+$/.test(req.headers.host) )
|
|
1715
1715
|
// hostname = hostname.replace(/\:\d+$/, '');
|
|
1716
1716
|
|
|
1717
1717
|
if (route) { // will go with route first
|
|
1718
|
-
|
|
1718
|
+
|
|
1719
1719
|
if ( /\,/.test(routing[route].url) ) {
|
|
1720
1720
|
var paths = routing[route].url.split(/\,/g);
|
|
1721
1721
|
path = (ignoreWebRoot) ? paths[0].replace(wroot, '') : paths[0];
|
|
1722
1722
|
} else {
|
|
1723
1723
|
path = (ignoreWebRoot) ? routing[route].url.replace(wroot, '') : routing[route].url;
|
|
1724
1724
|
}
|
|
1725
|
-
|
|
1726
|
-
if (bundle != conf.bundle) {
|
|
1725
|
+
|
|
1726
|
+
if (bundle != conf.bundle) {
|
|
1727
1727
|
path = hostname + path;
|
|
1728
1728
|
}
|
|
1729
1729
|
} else if (url && !path) {
|
|
@@ -1737,15 +1737,15 @@ function SuperController(options) {
|
|
|
1737
1737
|
// nothing to do, just ignoring
|
|
1738
1738
|
//} else {
|
|
1739
1739
|
} else if ( !path && typeof(isRelative) == 'undefined' ) {
|
|
1740
|
-
|
|
1740
|
+
|
|
1741
1741
|
path = hostname + path
|
|
1742
1742
|
//path = local.req.headers.host + path
|
|
1743
1743
|
}
|
|
1744
|
-
|
|
1745
|
-
|
|
1744
|
+
|
|
1745
|
+
|
|
1746
1746
|
|
|
1747
1747
|
if (!local.res.headersSent) {
|
|
1748
|
-
|
|
1748
|
+
|
|
1749
1749
|
// backing up oldParams
|
|
1750
1750
|
var oldParams = local.req[originalMethod.toLowerCase()];
|
|
1751
1751
|
var requestParams = req[req.method.toLowerCase()] || {};
|
|
@@ -1754,42 +1754,42 @@ function SuperController(options) {
|
|
|
1754
1754
|
self.throwError(requestParams.error);
|
|
1755
1755
|
return;
|
|
1756
1756
|
}
|
|
1757
|
-
|
|
1758
|
-
if (
|
|
1759
|
-
!/GET/i.test(req.method)
|
|
1760
|
-
||
|
|
1761
|
-
originalMethod && !/GET/i.test(originalMethod)
|
|
1762
|
-
) { // trying to redirect using the wrong method ?
|
|
1763
|
-
|
|
1757
|
+
|
|
1758
|
+
if (
|
|
1759
|
+
!/GET/i.test(req.method)
|
|
1760
|
+
||
|
|
1761
|
+
originalMethod && !/GET/i.test(originalMethod)
|
|
1762
|
+
) { // trying to redirect using the wrong method ?
|
|
1763
|
+
|
|
1764
1764
|
console.warn(new Error('Your are trying to redirect using the wrong method: `'+ req.method+'`.\nThis can often occur while redirecting from a controller to another controller or from a bundle to another.\nA redirection is not permitted in this scenario.\nD\'ont panic :)\nSwitching request method to `GET` method instead.\n').message);
|
|
1765
1765
|
method = local.req.method = self.setRequestMethod('GET', conf);
|
|
1766
|
-
code = 303;
|
|
1766
|
+
code = 303;
|
|
1767
1767
|
}
|
|
1768
|
-
|
|
1769
|
-
|
|
1768
|
+
|
|
1769
|
+
|
|
1770
1770
|
// merging new & olds params
|
|
1771
1771
|
requestParams = merge(requestParams, oldParams);
|
|
1772
1772
|
// remove session to prevent reaching the 2000 chars limit
|
|
1773
1773
|
// if you need the session, you need to find another way to retrieve while in the next route
|
|
1774
|
-
if ( typeof(requestParams.session) != 'undefined' ) {
|
|
1774
|
+
if ( typeof(requestParams.session) != 'undefined' ) {
|
|
1775
1775
|
delete requestParams.session;
|
|
1776
1776
|
}
|
|
1777
|
-
if ( typeof(requestParams) != 'undefined' && requestParams.count() > 0 ) {
|
|
1777
|
+
if ( typeof(requestParams) != 'undefined' && requestParams.count() > 0 ) {
|
|
1778
1778
|
//if ( typeof(requestParams.error) != 'undefined' )
|
|
1779
|
-
|
|
1779
|
+
|
|
1780
1780
|
var inheritedData = null;
|
|
1781
1781
|
if ( /\?/.test(path) ) {
|
|
1782
|
-
inheritedData = '&inheritedData='+ encodeURIComponent(JSON.stringify(requestParams));
|
|
1782
|
+
inheritedData = '&inheritedData='+ encodeURIComponent(JSON.stringify(requestParams));
|
|
1783
1783
|
} else {
|
|
1784
|
-
inheritedData = '?inheritedData='+ encodeURIComponent(JSON.stringify(requestParams));
|
|
1785
|
-
}
|
|
1786
|
-
|
|
1784
|
+
inheritedData = '?inheritedData='+ encodeURIComponent(JSON.stringify(requestParams));
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1787
1787
|
if ( inheritedData.length > 2000 ) {
|
|
1788
1788
|
var error = new ApiError('Controller::redirect(...) exceptions: `inheritedData` reached 2000 chars limit', 424);
|
|
1789
1789
|
self.throwError(error);
|
|
1790
1790
|
return;
|
|
1791
1791
|
}
|
|
1792
|
-
|
|
1792
|
+
|
|
1793
1793
|
// if redirecting from a xhrRequest
|
|
1794
1794
|
if ( self.isXMLRequest() ) {
|
|
1795
1795
|
// `requestParams` should be stored in the session to avoid passing datas in clear
|
|
@@ -1803,21 +1803,21 @@ function SuperController(options) {
|
|
|
1803
1803
|
redirectObj.location += inheritedData;
|
|
1804
1804
|
}
|
|
1805
1805
|
}
|
|
1806
|
-
|
|
1806
|
+
|
|
1807
1807
|
self.renderJSON(redirectObj);
|
|
1808
1808
|
return;
|
|
1809
1809
|
}
|
|
1810
|
-
|
|
1810
|
+
|
|
1811
1811
|
path += inheritedData;
|
|
1812
|
-
}
|
|
1813
|
-
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
1814
|
var ext = 'html';
|
|
1815
1815
|
res.setHeader('content-type', local.options.conf.server.coreConfiguration.mime[ext]);
|
|
1816
|
-
|
|
1817
|
-
if (
|
|
1816
|
+
|
|
1817
|
+
if (
|
|
1818
1818
|
typeof(local.res._headers) != 'undefined'
|
|
1819
|
-
&& typeof(local.res._headers['access-control-allow-methods']) != 'undefined'
|
|
1820
|
-
&& local.res._headers['access-control-allow-methods'] != req.method
|
|
1819
|
+
&& typeof(local.res._headers['access-control-allow-methods']) != 'undefined'
|
|
1820
|
+
&& local.res._headers['access-control-allow-methods'] != req.method
|
|
1821
1821
|
||
|
|
1822
1822
|
!new RegExp(req.method, 'i').test( res.getHeader('access-control-allow-methods') )
|
|
1823
1823
|
) {
|
|
@@ -1825,11 +1825,11 @@ function SuperController(options) {
|
|
|
1825
1825
|
}
|
|
1826
1826
|
//path += '?query='+ JSON.stringify(self.getRequestMethodParams());
|
|
1827
1827
|
local.req[req.method.toLowerCase()] = self.getRequestMethodParams() || {};
|
|
1828
|
-
|
|
1828
|
+
|
|
1829
1829
|
var headInfos = {
|
|
1830
|
-
'location': path
|
|
1831
|
-
};
|
|
1832
|
-
|
|
1830
|
+
'location': path
|
|
1831
|
+
};
|
|
1832
|
+
|
|
1833
1833
|
if (self.isCacheless()) {
|
|
1834
1834
|
res.writeHead(code, merge(headInfos, {
|
|
1835
1835
|
'cache-control': 'no-cache, no-store, must-revalidate', // preventing browsers from using cache
|
|
@@ -1838,24 +1838,24 @@ function SuperController(options) {
|
|
|
1838
1838
|
}))
|
|
1839
1839
|
} else {
|
|
1840
1840
|
res.writeHead(code, headInfos)
|
|
1841
|
-
}
|
|
1842
|
-
// in case of query from another bundle waiting for a response
|
|
1843
|
-
var redirectObject = JSON.stringify({ status: code, headers: headInfos });
|
|
1841
|
+
}
|
|
1842
|
+
// in case of query from another bundle waiting for a response
|
|
1843
|
+
var redirectObject = JSON.stringify({ status: code, headers: headInfos });
|
|
1844
1844
|
res.end(redirectObject);
|
|
1845
1845
|
try {
|
|
1846
1846
|
local.res.headersSent = true;// done for the render() method
|
|
1847
1847
|
} catch(err){
|
|
1848
1848
|
// ignoring the warning
|
|
1849
1849
|
}
|
|
1850
|
-
|
|
1850
|
+
|
|
1851
1851
|
console.info(local.req.method.toUpperCase() +' ['+code+'] '+ path);
|
|
1852
|
-
|
|
1852
|
+
|
|
1853
1853
|
if ( typeof(next) != 'undefined' )
|
|
1854
1854
|
next();
|
|
1855
1855
|
else
|
|
1856
1856
|
return;
|
|
1857
1857
|
}
|
|
1858
|
-
|
|
1858
|
+
|
|
1859
1859
|
}
|
|
1860
1860
|
}
|
|
1861
1861
|
|
|
@@ -1896,7 +1896,7 @@ function SuperController(options) {
|
|
|
1896
1896
|
})
|
|
1897
1897
|
}
|
|
1898
1898
|
}
|
|
1899
|
-
|
|
1899
|
+
|
|
1900
1900
|
this.getBundleStatus = function(req, res, next) {
|
|
1901
1901
|
self.renderJSON({
|
|
1902
1902
|
status: 200,
|
|
@@ -1904,8 +1904,8 @@ function SuperController(options) {
|
|
|
1904
1904
|
message: 'I am alive !'
|
|
1905
1905
|
});
|
|
1906
1906
|
}
|
|
1907
|
-
|
|
1908
|
-
this.checkBundleStatus = async function(bundle, cb) {
|
|
1907
|
+
|
|
1908
|
+
this.checkBundleStatus = async function(bundle, cb) {
|
|
1909
1909
|
var opt = self.getConfig('app').proxy[bundle];
|
|
1910
1910
|
var route = lib.routing.getRoute('bundle-status@'+bundle);
|
|
1911
1911
|
opt.method = 'GET';
|
|
@@ -1915,29 +1915,29 @@ function SuperController(options) {
|
|
|
1915
1915
|
.then( function onQueryResponse(_status) {
|
|
1916
1916
|
response = _status
|
|
1917
1917
|
});
|
|
1918
|
-
|
|
1918
|
+
|
|
1919
1919
|
if (cb) {
|
|
1920
1920
|
cb(error, response);
|
|
1921
1921
|
} else {
|
|
1922
1922
|
return response;
|
|
1923
1923
|
}
|
|
1924
1924
|
}
|
|
1925
|
-
|
|
1925
|
+
|
|
1926
1926
|
/**
|
|
1927
1927
|
* downloadFromURL
|
|
1928
1928
|
* Download from an URL
|
|
1929
1929
|
* - attachment/inline
|
|
1930
1930
|
* OR
|
|
1931
|
-
* - locally: `Controller.store(target, cb)` must be called to store on `onComplete` event
|
|
1932
|
-
*
|
|
1931
|
+
* - locally: `Controller.store(target, cb)` must be called to store on `onComplete` event
|
|
1932
|
+
*
|
|
1933
1933
|
* @param {string} url - eg.: https://upload.wikimedia.org/wikipedia/fr/2/2f/Firefox_Old_Logo.png
|
|
1934
1934
|
* @param {object} [options]
|
|
1935
|
-
*
|
|
1936
|
-
*
|
|
1935
|
+
*
|
|
1936
|
+
*
|
|
1937
1937
|
* */
|
|
1938
1938
|
this.downloadFromURL = function(url, options) {
|
|
1939
|
-
|
|
1940
|
-
var defaultOptions = {
|
|
1939
|
+
|
|
1940
|
+
var defaultOptions = {
|
|
1941
1941
|
// file name i you want to rename the file
|
|
1942
1942
|
file: null,
|
|
1943
1943
|
fileSize: null,
|
|
@@ -1947,7 +1947,7 @@ function SuperController(options) {
|
|
|
1947
1947
|
contentDisposition: 'attachment',
|
|
1948
1948
|
// content-type (https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Configuring_server_MIME_types)
|
|
1949
1949
|
contentType: 'application/octet-stream',
|
|
1950
|
-
|
|
1950
|
+
|
|
1951
1951
|
agent: false,
|
|
1952
1952
|
// set to false to ignore certificate verification
|
|
1953
1953
|
rejectUnauthorized: true,
|
|
@@ -1957,9 +1957,9 @@ function SuperController(options) {
|
|
|
1957
1957
|
keepAlive: true,
|
|
1958
1958
|
headers: {}
|
|
1959
1959
|
};
|
|
1960
|
-
|
|
1960
|
+
|
|
1961
1961
|
var opt = ( typeof(options) != 'undefined' ) ? merge(options, defaultOptions) : defaultOptions;
|
|
1962
|
-
|
|
1962
|
+
|
|
1963
1963
|
var requestOptions = {};
|
|
1964
1964
|
for (var o in opt) {
|
|
1965
1965
|
if ( !/(toLocalDir|contentDisposition|contentType|file)/.test(o) )
|
|
@@ -1968,81 +1968,81 @@ function SuperController(options) {
|
|
|
1968
1968
|
|
|
1969
1969
|
// defining protocol & scheme
|
|
1970
1970
|
var protocol = null;
|
|
1971
|
-
var scheme = null;
|
|
1972
|
-
|
|
1971
|
+
var scheme = null;
|
|
1972
|
+
|
|
1973
1973
|
if ( /\:\/\//.test(url) ) {
|
|
1974
1974
|
scheme = url.match(/^\w+\:/)[0];
|
|
1975
1975
|
scheme = scheme.substr(0, scheme.length-1);
|
|
1976
|
-
|
|
1976
|
+
|
|
1977
1977
|
if ( !/^http/.test(scheme) ) {
|
|
1978
1978
|
self.throwError(local.res, 500, new Error('[ '+ scheme +' ] Scheme not supported. Ref.: `http` or `https` only'));
|
|
1979
1979
|
return;
|
|
1980
1980
|
}
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1981
|
+
|
|
1982
|
+
|
|
1983
|
+
|
|
1984
1984
|
} else { // by default
|
|
1985
1985
|
scheme = 'http';
|
|
1986
1986
|
}
|
|
1987
|
-
|
|
1987
|
+
|
|
1988
1988
|
requestOptions.scheme = scheme +':';
|
|
1989
|
-
|
|
1989
|
+
|
|
1990
1990
|
//defining port
|
|
1991
1991
|
var port = url.match(/\:\d+\//) || null;
|
|
1992
1992
|
if ( port != null ) {
|
|
1993
1993
|
port = port[0].substr(1, port[0].length-2);
|
|
1994
|
-
requestOptions.port = ~~port;
|
|
1994
|
+
requestOptions.port = ~~port;
|
|
1995
1995
|
}
|
|
1996
|
-
|
|
1996
|
+
|
|
1997
1997
|
// defining hostname & path
|
|
1998
1998
|
var parts = url.replace(new RegExp( scheme + '\:\/\/'), '').split(/\//g);
|
|
1999
1999
|
requestOptions.host = parts[0].replace(/\:\d+/, '');
|
|
2000
2000
|
requestOptions.path = '/' + parts.splice(1).join('/');
|
|
2001
|
-
|
|
2002
|
-
|
|
2001
|
+
|
|
2002
|
+
|
|
2003
2003
|
// extension and mime
|
|
2004
|
-
var filename = url.split(/\//g).pop();
|
|
2004
|
+
var filename = url.split(/\//g).pop();
|
|
2005
2005
|
if (!filename) {
|
|
2006
2006
|
self.throwError(local.res, 500, new Error('Filename not found in url: `'+ url +'`'));
|
|
2007
2007
|
return;
|
|
2008
2008
|
}
|
|
2009
|
-
|
|
2010
|
-
|
|
2009
|
+
|
|
2010
|
+
|
|
2011
2011
|
if ( !/\.\w+$/.test(filename) ) {
|
|
2012
2012
|
self.throwError(local.res, 500, new Error('[ '+ filename +' ] extension not found.'));
|
|
2013
2013
|
return;
|
|
2014
2014
|
}
|
|
2015
|
-
|
|
2016
|
-
|
|
2015
|
+
|
|
2016
|
+
|
|
2017
2017
|
// filename renaming
|
|
2018
2018
|
if (opt.file)
|
|
2019
2019
|
filename = opt.file;
|
|
2020
|
-
|
|
2020
|
+
|
|
2021
2021
|
if ( opt.contentDisposition == 'attachment') {
|
|
2022
2022
|
opt.contentDisposition += '; filename=' + filename;
|
|
2023
2023
|
}
|
|
2024
|
-
|
|
2024
|
+
|
|
2025
2025
|
var ext = filename.match(/\.\w+$/)[0].substr(1)
|
|
2026
2026
|
, contentType = null
|
|
2027
2027
|
, tmp = _(GINA_TMPDIR +'/'+ filename, true)
|
|
2028
2028
|
;
|
|
2029
|
-
|
|
2029
|
+
|
|
2030
2030
|
if ( typeof(local.options.conf.server.coreConfiguration.mime[ext]) != 'undefined' ) {
|
|
2031
2031
|
|
|
2032
2032
|
contentType = (opt.contentType != defaultOptions.contentType) ? opt.contentType : local.options.conf.server.coreConfiguration.mime[ext];
|
|
2033
|
-
|
|
2033
|
+
|
|
2034
2034
|
} else { // extension not supported
|
|
2035
2035
|
self.throwError(local.res, 500, new Error('[ '+ ext +' ] Extension not supported. Ref.: gina/core mime.types'));
|
|
2036
2036
|
return;
|
|
2037
2037
|
}
|
|
2038
|
-
|
|
2038
|
+
|
|
2039
2039
|
// defining responseType
|
|
2040
2040
|
requestOptions.headers['content-type'] = contentType;
|
|
2041
2041
|
requestOptions.headers['content-disposition'] = opt.contentDisposition;
|
|
2042
|
-
|
|
2042
|
+
|
|
2043
2043
|
var browser = require(''+ scheme);
|
|
2044
2044
|
//console.debug('requestOptions: \n', JSON.stringify(requestOptions, null, 4));
|
|
2045
|
-
|
|
2045
|
+
|
|
2046
2046
|
browser.get(requestOptions, function(response) {
|
|
2047
2047
|
|
|
2048
2048
|
local.res.setHeader('content-type', contentType + '; charset='+ local.options.conf.encoding);
|
|
@@ -2051,28 +2051,28 @@ function SuperController(options) {
|
|
|
2051
2051
|
local.res.setHeader('content-length', opt.fileSize);
|
|
2052
2052
|
}
|
|
2053
2053
|
//local.res.setHeader('content-length', opt.fileSize);
|
|
2054
|
-
// local.res.setHeader('cache-control', 'must-revalidate');
|
|
2055
|
-
// local.res.setHeader('pragma', 'must-revalidate');
|
|
2056
|
-
|
|
2054
|
+
// local.res.setHeader('cache-control', 'must-revalidate');
|
|
2055
|
+
// local.res.setHeader('pragma', 'must-revalidate');
|
|
2056
|
+
|
|
2057
2057
|
// response.on('end', function onResponsePipeEnd(){
|
|
2058
2058
|
// self.renderJSON({ url: url});
|
|
2059
2059
|
// //local.res.end( Buffer.from(data) );
|
|
2060
|
-
// //local.res.headersSent = true;
|
|
2061
|
-
|
|
2060
|
+
// //local.res.headersSent = true;
|
|
2061
|
+
|
|
2062
2062
|
// // if ( typeof(local.next) != 'undefined')
|
|
2063
2063
|
// // local.next();
|
|
2064
2064
|
// // else
|
|
2065
2065
|
// // return;
|
|
2066
2066
|
// });
|
|
2067
|
-
|
|
2067
|
+
|
|
2068
2068
|
response.pipe(local.res);
|
|
2069
2069
|
});
|
|
2070
|
-
|
|
2070
|
+
|
|
2071
2071
|
return;
|
|
2072
2072
|
|
|
2073
2073
|
}
|
|
2074
2074
|
|
|
2075
|
-
|
|
2075
|
+
|
|
2076
2076
|
/**
|
|
2077
2077
|
* Download to targeted filename.ext - Will create target if new
|
|
2078
2078
|
* Use `cb` callback or `onComplete` event
|
|
@@ -2081,17 +2081,17 @@ function SuperController(options) {
|
|
|
2081
2081
|
* @param {object} options
|
|
2082
2082
|
**/
|
|
2083
2083
|
this.downloadFromLocal = function(filename) {
|
|
2084
|
-
|
|
2085
|
-
var file = filename.split(/\//g).pop();
|
|
2084
|
+
|
|
2085
|
+
var file = filename.split(/\//g).pop();
|
|
2086
2086
|
var ext = file.split(/\./g).pop()
|
|
2087
2087
|
, contentType = null
|
|
2088
2088
|
;
|
|
2089
|
-
|
|
2089
|
+
|
|
2090
2090
|
if ( typeof(local.options.conf.server.coreConfiguration.mime[ext]) != 'undefined' ) {
|
|
2091
2091
|
|
|
2092
2092
|
contentType = local.options.conf.server.coreConfiguration.mime[ext];
|
|
2093
2093
|
local.res.setHeader('content-type', contentType);
|
|
2094
|
-
local.res.setHeader('content-disposition', 'attachment; filename=' + file);
|
|
2094
|
+
local.res.setHeader('content-disposition', 'attachment; filename=' + file);
|
|
2095
2095
|
|
|
2096
2096
|
var filestream = fs.createReadStream(filename);
|
|
2097
2097
|
filestream.pipe(local.res);
|
|
@@ -2099,7 +2099,7 @@ function SuperController(options) {
|
|
|
2099
2099
|
} else { // extension not supported
|
|
2100
2100
|
self.throwError(local.res, 500, new Error('[ '+ ext +' ] Extension not supported. Ref.: gina/core mime.types'));
|
|
2101
2101
|
return;
|
|
2102
|
-
}
|
|
2102
|
+
}
|
|
2103
2103
|
}
|
|
2104
2104
|
|
|
2105
2105
|
|
|
@@ -2122,17 +2122,17 @@ function SuperController(options) {
|
|
|
2122
2122
|
* */
|
|
2123
2123
|
this.store = async function(target, files, cb) {
|
|
2124
2124
|
|
|
2125
|
-
|
|
2125
|
+
|
|
2126
2126
|
var start = function(target, files, cb) {
|
|
2127
|
-
|
|
2127
|
+
|
|
2128
2128
|
if (arguments.length == 2 && typeof(arguments[1]) == 'function' ) {
|
|
2129
2129
|
var cb = arguments[1];
|
|
2130
2130
|
}
|
|
2131
|
-
|
|
2131
|
+
|
|
2132
2132
|
if ( typeof(files) == 'undefined' || typeof(files) == 'function' ) {
|
|
2133
2133
|
files = local.req.files
|
|
2134
2134
|
}
|
|
2135
|
-
|
|
2135
|
+
|
|
2136
2136
|
var uploadedFiles = [];
|
|
2137
2137
|
|
|
2138
2138
|
if ( typeof(files) == 'undefined' || files.count() == 0 ) {
|
|
@@ -2155,25 +2155,25 @@ function SuperController(options) {
|
|
|
2155
2155
|
self.emit('uploaded', folder)
|
|
2156
2156
|
}
|
|
2157
2157
|
} else {
|
|
2158
|
-
// files list
|
|
2159
|
-
var fileName = null;
|
|
2158
|
+
// files list
|
|
2159
|
+
var fileName = null;
|
|
2160
2160
|
for (var len = files.length; i < len; ++i ){
|
|
2161
|
-
|
|
2161
|
+
|
|
2162
2162
|
fileName = files[i].filename || files[i].originalFilename
|
|
2163
|
-
|
|
2163
|
+
|
|
2164
2164
|
list[i] = {
|
|
2165
2165
|
source: files[i].path,
|
|
2166
2166
|
target: _(uploadDir.toString() + '/' + fileName)
|
|
2167
2167
|
};
|
|
2168
|
-
|
|
2169
|
-
uploadedFiles[i] = {
|
|
2168
|
+
|
|
2169
|
+
uploadedFiles[i] = {
|
|
2170
2170
|
file : fileName,
|
|
2171
|
-
filename : list[i].target,
|
|
2171
|
+
filename : list[i].target,
|
|
2172
2172
|
size : files[i].size,
|
|
2173
2173
|
type : files[i].type,
|
|
2174
2174
|
encoding : files[i].encoding
|
|
2175
2175
|
};
|
|
2176
|
-
|
|
2176
|
+
|
|
2177
2177
|
}
|
|
2178
2178
|
|
|
2179
2179
|
movefiles(0, local.res, list, function (err) {
|
|
@@ -2279,7 +2279,7 @@ function SuperController(options) {
|
|
|
2279
2279
|
} while (cert.fingerprint256 !== lastprint256);
|
|
2280
2280
|
|
|
2281
2281
|
}*/
|
|
2282
|
-
|
|
2282
|
+
|
|
2283
2283
|
};
|
|
2284
2284
|
|
|
2285
2285
|
this.query = function() { // options, data, callback
|
|
@@ -2293,7 +2293,7 @@ function SuperController(options) {
|
|
|
2293
2293
|
data = arguments[arguments.length-1]
|
|
2294
2294
|
}
|
|
2295
2295
|
// preventing multiple call of self.query() when controller is rendering from another required controller
|
|
2296
|
-
if (
|
|
2296
|
+
if (
|
|
2297
2297
|
typeof(local.options) != 'undefined'
|
|
2298
2298
|
&& typeof(local.options.renderingStack) != 'undefined'
|
|
2299
2299
|
&& local.options.renderingStack.length > 1
|
|
@@ -2301,22 +2301,22 @@ function SuperController(options) {
|
|
|
2301
2301
|
return false
|
|
2302
2302
|
}
|
|
2303
2303
|
self.isProcessingError = false; // by default
|
|
2304
|
-
|
|
2304
|
+
|
|
2305
2305
|
var queryData = {}
|
|
2306
2306
|
, defaultOptions = local.query.options
|
|
2307
2307
|
, path = options.path
|
|
2308
|
-
, browser = null
|
|
2308
|
+
, browser = null
|
|
2309
2309
|
;
|
|
2310
2310
|
|
|
2311
2311
|
// options must be used as a copy in case of multiple calls of self.query(options, ...)
|
|
2312
2312
|
options = merge(JSON.clone(options), defaultOptions);
|
|
2313
|
-
|
|
2313
|
+
|
|
2314
2314
|
for (var o in options) {//cleaning
|
|
2315
2315
|
if ( typeof(options[o]) == 'undefined' || options[o] == undefined) {
|
|
2316
2316
|
delete options[o]
|
|
2317
2317
|
}
|
|
2318
2318
|
}
|
|
2319
|
-
|
|
2319
|
+
|
|
2320
2320
|
if (self.isCacheless() || self.isLocalScope() ) {
|
|
2321
2321
|
options.rejectUnauthorized = false;
|
|
2322
2322
|
}
|
|
@@ -2329,7 +2329,7 @@ function SuperController(options) {
|
|
|
2329
2329
|
self.emit('query#complete', err)
|
|
2330
2330
|
}
|
|
2331
2331
|
|
|
2332
|
-
|
|
2332
|
+
|
|
2333
2333
|
|
|
2334
2334
|
// if (arguments.length <3) {
|
|
2335
2335
|
// if ( typeof(data) == 'function') {
|
|
@@ -2362,7 +2362,7 @@ function SuperController(options) {
|
|
|
2362
2362
|
|
|
2363
2363
|
queryData = queryData.substring(0, queryData.length-1);
|
|
2364
2364
|
queryData = queryData.replace(/\s/g, '%20');
|
|
2365
|
-
|
|
2365
|
+
|
|
2366
2366
|
options.path += queryData;
|
|
2367
2367
|
}
|
|
2368
2368
|
|
|
@@ -2370,7 +2370,7 @@ function SuperController(options) {
|
|
|
2370
2370
|
queryData = ''
|
|
2371
2371
|
}
|
|
2372
2372
|
|
|
2373
|
-
|
|
2373
|
+
|
|
2374
2374
|
// Internet Explorer override
|
|
2375
2375
|
if ( local.req != null && /msie/i.test(local.req.headers['user-agent']) ) {
|
|
2376
2376
|
options.headers['content-type'] = 'text/plain';
|
|
@@ -2389,7 +2389,7 @@ function SuperController(options) {
|
|
|
2389
2389
|
|
|
2390
2390
|
//you need this, even when empty.
|
|
2391
2391
|
options.headers['content-length'] = queryData.length;
|
|
2392
|
-
|
|
2392
|
+
|
|
2393
2393
|
// adding gina headers
|
|
2394
2394
|
if ( local.req != null && typeof(local.req.ginaHeaders) != 'undefined' ) {
|
|
2395
2395
|
// gina form headers
|
|
@@ -2405,7 +2405,7 @@ function SuperController(options) {
|
|
|
2405
2405
|
;
|
|
2406
2406
|
// cleanup options.path
|
|
2407
2407
|
if (/\:\/\//.test(options.path)) {
|
|
2408
|
-
|
|
2408
|
+
|
|
2409
2409
|
var hArr = options.path.split(/^(https|http)\:\/\//);
|
|
2410
2410
|
var domain = hArr[1] +'://';
|
|
2411
2411
|
var host = hArr[2].split(/\//)[0];
|
|
@@ -2417,72 +2417,72 @@ function SuperController(options) {
|
|
|
2417
2417
|
.replace(options.host, '')
|
|
2418
2418
|
.replace(':'+port, '');
|
|
2419
2419
|
}
|
|
2420
|
-
|
|
2420
|
+
|
|
2421
2421
|
// retrieve protocol & scheme: if empty, take the bundles protocol
|
|
2422
2422
|
protocol = options.protocol || ctx.gina.config.envConf[ctx.bundle][ctx.env].server.protocol;// bundle servers's protocol by default
|
|
2423
2423
|
protocol = protocol.match(/[.a-z 0-9]+/ig)[0];
|
|
2424
2424
|
scheme = options.scheme || ctx.gina.config.envConf[ctx.bundle][ctx.env].server.scheme;// bundle servers's scheme by default
|
|
2425
2425
|
scheme = scheme.match(/[a-z 0-9]+/ig)[0];
|
|
2426
|
-
|
|
2426
|
+
|
|
2427
2427
|
//retrieving dynamic host, hostname & port
|
|
2428
2428
|
if ( /\@/.test(options.hostname) ) {
|
|
2429
|
-
|
|
2429
|
+
|
|
2430
2430
|
var bundle = ( options.hostname.replace(/(.*)\:\/\//, '') ).split(/\@/)[0];
|
|
2431
|
-
|
|
2431
|
+
|
|
2432
2432
|
// No shorcut possible because conf.hostname might differ from user inputs
|
|
2433
2433
|
options.host = ctx.gina.config.envConf[bundle][ctx.env].host.replace(/(.*)\:\/\//, '').replace(/\:\d+/, '');
|
|
2434
2434
|
options.hostname = ctx.gina.config.envConf[bundle][ctx.env].hostname;
|
|
2435
2435
|
options.port = ctx.gina.config.envConf[bundle][ctx.env].server.port;
|
|
2436
|
-
|
|
2436
|
+
|
|
2437
2437
|
options.protocol = ctx.gina.config.envConf[bundle][ctx.env].server.protocol;
|
|
2438
2438
|
options.scheme = ctx.gina.config.envConf[bundle][ctx.env].server.scheme;
|
|
2439
2439
|
// might be != from the bundle requesting
|
|
2440
2440
|
//options.protocol = ctx.gina.config.envConf[bundle][ctx.env].content.settings.server.protocol || ctx.gina.config.envConf[bundle][ctx.env].server.protocol;
|
|
2441
2441
|
//options.scheme = ctx.gina.config.envConf[bundle][ctx.env].content.settings.server.scheme || ctx.gina.config.envConf[bundle][ctx.env].server.scheme;
|
|
2442
2442
|
}
|
|
2443
|
-
|
|
2443
|
+
|
|
2444
2444
|
if ( typeof(options.protocol) == 'undefined' ) {
|
|
2445
2445
|
options.protocol = protocol
|
|
2446
2446
|
}
|
|
2447
2447
|
if ( typeof(options.scheme) == 'undefined' ) {
|
|
2448
2448
|
options.scheme = scheme
|
|
2449
2449
|
}
|
|
2450
|
-
|
|
2451
|
-
|
|
2450
|
+
|
|
2451
|
+
|
|
2452
2452
|
// reformating scheme
|
|
2453
2453
|
if( !/\:$/.test(options.scheme) )
|
|
2454
2454
|
options.scheme += ':';
|
|
2455
|
-
|
|
2456
|
-
try {
|
|
2457
|
-
options.queryData = queryData;
|
|
2455
|
+
|
|
2456
|
+
try {
|
|
2457
|
+
options.queryData = queryData;
|
|
2458
2458
|
var protocolVersion = ~~options.protocol.match(/\/(.*)$/)[1].replace(/\.\d+/, '');
|
|
2459
2459
|
var httpLib = options.protocol.match(/^(.*)\//)[1] + ( (protocolVersion >= 2) ? protocolVersion : '' );
|
|
2460
2460
|
if ( !/http2/.test(httpLib) && /https/.test(options.scheme) ) {
|
|
2461
2461
|
httpLib += 's';
|
|
2462
2462
|
}
|
|
2463
|
-
|
|
2464
|
-
browser = require(''+ httpLib);
|
|
2465
|
-
|
|
2463
|
+
|
|
2464
|
+
browser = require(''+ httpLib);
|
|
2465
|
+
|
|
2466
2466
|
if ( /http2/.test(httpLib) ) {
|
|
2467
2467
|
return handleHTTP2ClientRequest(browser, options, callback);
|
|
2468
2468
|
} else {
|
|
2469
|
-
return handleHTTP1ClientRequest(browser, options, callback);
|
|
2470
|
-
}
|
|
2471
|
-
|
|
2472
|
-
|
|
2469
|
+
return handleHTTP1ClientRequest(browser, options, callback);
|
|
2470
|
+
}
|
|
2471
|
+
|
|
2472
|
+
|
|
2473
2473
|
} catch(err) {
|
|
2474
2474
|
if (callback) {
|
|
2475
2475
|
return callback(err)
|
|
2476
2476
|
}
|
|
2477
2477
|
self.emit('query#complete', err)
|
|
2478
2478
|
}
|
|
2479
|
-
|
|
2479
|
+
|
|
2480
2480
|
}
|
|
2481
|
-
|
|
2481
|
+
|
|
2482
2482
|
var handleHTTP1ClientRequest = function(browser, options, callback) {
|
|
2483
|
-
|
|
2483
|
+
|
|
2484
2484
|
var altOpt = JSON.clone(options);
|
|
2485
|
-
|
|
2485
|
+
|
|
2486
2486
|
altOpt.protocol = options.scheme;
|
|
2487
2487
|
altOpt.hostname = options.host;
|
|
2488
2488
|
altOpt.port = options.port;
|
|
@@ -2492,24 +2492,24 @@ function SuperController(options) {
|
|
|
2492
2492
|
} catch(err) {
|
|
2493
2493
|
self.emit('query#complete', err);
|
|
2494
2494
|
}
|
|
2495
|
-
|
|
2495
|
+
|
|
2496
2496
|
} else {
|
|
2497
2497
|
console.warn('[ CONTROLLER ][ HTTP/1.0#query ] options.encKey not found !');
|
|
2498
2498
|
}
|
|
2499
|
-
|
|
2499
|
+
|
|
2500
2500
|
if ( typeof(altOpt.encCert) != 'undefined' ) {
|
|
2501
2501
|
try {
|
|
2502
2502
|
altOpt.encCert = fs.readFileSync(options.encCert);
|
|
2503
2503
|
} catch(err) {
|
|
2504
2504
|
self.emit('query#complete', err);
|
|
2505
2505
|
}
|
|
2506
|
-
|
|
2506
|
+
|
|
2507
2507
|
} else {
|
|
2508
2508
|
console.warn('[ CONTROLLER ][ HTTP/1.0#query ] options.encCert not found !');
|
|
2509
2509
|
}
|
|
2510
|
-
|
|
2510
|
+
|
|
2511
2511
|
altOpt.agent = new browser.Agent(altOpt);
|
|
2512
|
-
|
|
2512
|
+
|
|
2513
2513
|
var req = browser.request(altOpt, function(res) {
|
|
2514
2514
|
|
|
2515
2515
|
res.setEncoding('utf8');
|
|
@@ -2526,24 +2526,24 @@ function SuperController(options) {
|
|
|
2526
2526
|
});
|
|
2527
2527
|
|
|
2528
2528
|
res.on('end', function onEnd(err) {
|
|
2529
|
-
|
|
2530
|
-
|
|
2529
|
+
|
|
2530
|
+
|
|
2531
2531
|
// exceptions filter
|
|
2532
2532
|
if ( typeof(data) == 'string' && /^Unknown ALPN Protocol/.test(data) ) {
|
|
2533
2533
|
err = {
|
|
2534
2534
|
status: 500,
|
|
2535
2535
|
error: new Error(data)
|
|
2536
2536
|
};
|
|
2537
|
-
|
|
2537
|
+
|
|
2538
2538
|
if ( typeof(callback) != 'undefined' ) {
|
|
2539
2539
|
callback(err)
|
|
2540
2540
|
} else {
|
|
2541
2541
|
self.emit('query#complete', err)
|
|
2542
2542
|
}
|
|
2543
|
-
|
|
2543
|
+
|
|
2544
2544
|
return
|
|
2545
2545
|
}
|
|
2546
|
-
|
|
2546
|
+
|
|
2547
2547
|
//Only when needed.
|
|
2548
2548
|
if ( typeof(callback) != 'undefined' ) {
|
|
2549
2549
|
if ( typeof(data) == 'string' && /^(\{|%7B|\[{)|\[\]/.test(data) ) {
|
|
@@ -2573,7 +2573,7 @@ function SuperController(options) {
|
|
|
2573
2573
|
exception.status = 500;
|
|
2574
2574
|
self.throwError(exception);
|
|
2575
2575
|
return;
|
|
2576
|
-
}
|
|
2576
|
+
}
|
|
2577
2577
|
|
|
2578
2578
|
} else {
|
|
2579
2579
|
if ( typeof(data) == 'string' && /^(\{|%7B|\[{)|\[\]/.test(data) ) {
|
|
@@ -2600,14 +2600,14 @@ function SuperController(options) {
|
|
|
2600
2600
|
|
|
2601
2601
|
//starting from from >0.10.15
|
|
2602
2602
|
req.on('error', function onError(err) {
|
|
2603
|
-
|
|
2604
|
-
|
|
2603
|
+
|
|
2604
|
+
|
|
2605
2605
|
if (
|
|
2606
|
-
typeof(err.code) != 'undefined' && /ECONNREFUSED|ECONNRESET/.test(err.code)
|
|
2607
|
-
|| typeof(err.cause) != 'undefined' && typeof(err.cause.code) != 'undefined' && /ECONNREFUSED|ECONNRESET/.test(err.cause.code)
|
|
2606
|
+
typeof(err.code) != 'undefined' && /ECONNREFUSED|ECONNRESET/.test(err.code)
|
|
2607
|
+
|| typeof(err.cause) != 'undefined' && typeof(err.cause.code) != 'undefined' && /ECONNREFUSED|ECONNRESET/.test(err.cause.code)
|
|
2608
2608
|
) {
|
|
2609
2609
|
|
|
2610
|
-
var port = getContext('gina').ports[options.protocol][options.scheme.replace(/\:/, '')][ options.port ];//err.port || err.cause.port
|
|
2610
|
+
var port = getContext('gina').ports[options.protocol][options.scheme.replace(/\:/, '')][ options.port ];//err.port || err.cause.port
|
|
2611
2611
|
if ( typeof(port) != 'undefined' ) {
|
|
2612
2612
|
err.accessPoint = port;
|
|
2613
2613
|
err.message = '`Controller::query()` could not connect to [ ' + err.accessPoint + ' ] using port '+options.port+'.\n';
|
|
@@ -2667,30 +2667,30 @@ function SuperController(options) {
|
|
|
2667
2667
|
exception.status = 500;
|
|
2668
2668
|
self.throwError(exception);
|
|
2669
2669
|
return;
|
|
2670
|
-
}
|
|
2670
|
+
}
|
|
2671
2671
|
})
|
|
2672
2672
|
}
|
|
2673
|
-
|
|
2673
|
+
|
|
2674
2674
|
}
|
|
2675
2675
|
}
|
|
2676
|
-
|
|
2676
|
+
|
|
2677
2677
|
var handleHTTP2ClientRequest = function(browser, options, callback) {
|
|
2678
|
-
|
|
2679
|
-
//cleanup
|
|
2678
|
+
|
|
2679
|
+
//cleanup
|
|
2680
2680
|
options[':authority'] = options.hostname;
|
|
2681
|
-
|
|
2681
|
+
|
|
2682
2682
|
delete options.host;
|
|
2683
|
-
|
|
2683
|
+
|
|
2684
2684
|
if ( typeof(options[':path']) == 'undefined' ) {
|
|
2685
2685
|
options[':path'] = options.path;
|
|
2686
2686
|
delete options.path;
|
|
2687
|
-
}
|
|
2687
|
+
}
|
|
2688
2688
|
if ( typeof(options[':method']) == 'undefined' ) {
|
|
2689
2689
|
options[':method'] = options.method.toUpperCase();
|
|
2690
2690
|
delete options.method;
|
|
2691
2691
|
}
|
|
2692
|
-
|
|
2693
|
-
// only if binary !!
|
|
2692
|
+
|
|
2693
|
+
// only if binary !!
|
|
2694
2694
|
// if ( typeof(options['content-length']) == 'undefined' ) {
|
|
2695
2695
|
// options['content-length'] = options.headers['content-length'] ;
|
|
2696
2696
|
// delete options.headers['content-length'];
|
|
@@ -2699,11 +2699,11 @@ function SuperController(options) {
|
|
|
2699
2699
|
// options['content-type'] = options.headers['content-type'] ;
|
|
2700
2700
|
// delete options.headers['content-type'];
|
|
2701
2701
|
// }
|
|
2702
|
-
|
|
2702
|
+
|
|
2703
2703
|
if ( typeof(options[':scheme']) == 'undefined' ) {
|
|
2704
2704
|
options[':scheme'] = options.scheme ;
|
|
2705
2705
|
}
|
|
2706
|
-
|
|
2706
|
+
|
|
2707
2707
|
if ( typeof(options.ca) != 'undefined' ) {
|
|
2708
2708
|
try {
|
|
2709
2709
|
options.ca = fs.readFileSync(options.ca);
|
|
@@ -2713,58 +2713,58 @@ function SuperController(options) {
|
|
|
2713
2713
|
} else {
|
|
2714
2714
|
self.emit('query#complete', err);
|
|
2715
2715
|
}
|
|
2716
|
-
|
|
2716
|
+
|
|
2717
2717
|
return;
|
|
2718
2718
|
}
|
|
2719
|
-
|
|
2719
|
+
|
|
2720
2720
|
} else {
|
|
2721
2721
|
console.warn('[ CONTROLLER ][ HTTP/2.0#query ] options.ca not found !');
|
|
2722
2722
|
}
|
|
2723
|
-
|
|
2724
|
-
|
|
2723
|
+
|
|
2724
|
+
|
|
2725
2725
|
var body = Buffer.from(options.queryData);
|
|
2726
|
-
options.headers['content-length'] = body.length;
|
|
2726
|
+
options.headers['content-length'] = body.length;
|
|
2727
2727
|
delete options.queryData;
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
const client = browser.connect(options.hostname, options);
|
|
2732
|
-
|
|
2733
|
-
|
|
2728
|
+
|
|
2729
|
+
|
|
2730
|
+
|
|
2731
|
+
const client = browser.connect(options.hostname, options);
|
|
2732
|
+
|
|
2733
|
+
|
|
2734
2734
|
const {
|
|
2735
2735
|
HTTP2_HEADER_PROTOCOL,
|
|
2736
|
-
HTTP2_HEADER_SCHEME,
|
|
2736
|
+
HTTP2_HEADER_SCHEME,
|
|
2737
2737
|
HTTP2_HEADER_AUTHORITY,
|
|
2738
2738
|
HTTP2_HEADER_PATH,
|
|
2739
2739
|
HTTP2_HEADER_METHOD,
|
|
2740
2740
|
HTTP2_HEADER_STATUS
|
|
2741
2741
|
} = browser.constants;
|
|
2742
|
-
|
|
2743
|
-
|
|
2742
|
+
|
|
2743
|
+
|
|
2744
2744
|
if ( typeof(local.req.headers['x-requested-with']) != 'undefined' ) {
|
|
2745
2745
|
options.headers['x-requested-with'] = local.req.headers['x-requested-with']
|
|
2746
2746
|
}
|
|
2747
|
-
|
|
2747
|
+
|
|
2748
2748
|
if ( typeof(local.req.headers['access-control-allow-credentials']) != 'undefined' ) {
|
|
2749
2749
|
options.headers['access-control-allow-credentials'] = local.req.headers['access-control-allow-credentials']
|
|
2750
2750
|
}
|
|
2751
|
-
|
|
2751
|
+
|
|
2752
2752
|
if ( typeof(local.req.headers['content-type']) != 'undefined' && local.req.headers['content-type'] != options.headers['content-type'] ) {
|
|
2753
2753
|
options.headers['content-type'] = local.req.headers['content-type']
|
|
2754
2754
|
}
|
|
2755
|
-
|
|
2756
|
-
var headers = merge({
|
|
2755
|
+
|
|
2756
|
+
var headers = merge({
|
|
2757
2757
|
[HTTP2_HEADER_METHOD]: options[':method'],
|
|
2758
|
-
[HTTP2_HEADER_PATH]: options[':path']
|
|
2758
|
+
[HTTP2_HEADER_PATH]: options[':path']
|
|
2759
2759
|
}, options.headers);
|
|
2760
|
-
|
|
2760
|
+
|
|
2761
2761
|
// merging with user options
|
|
2762
2762
|
for (var o in options) {
|
|
2763
2763
|
if (!/^\:/.test(o) && !/headers/.test(o) && typeof(headers[o]) == 'undefined' ) {
|
|
2764
2764
|
headers[o] = options[o]
|
|
2765
2765
|
}
|
|
2766
2766
|
}
|
|
2767
|
-
|
|
2767
|
+
|
|
2768
2768
|
/**
|
|
2769
2769
|
* sessionOptions
|
|
2770
2770
|
* endStream <boolean> true if the Http2Stream writable side should be closed initially, such as when sending a GET request that should not expect a payload body.
|
|
@@ -2778,55 +2778,55 @@ function SuperController(options) {
|
|
|
2778
2778
|
endStream = false;
|
|
2779
2779
|
sessionOptions.endStream = endStream;
|
|
2780
2780
|
}
|
|
2781
|
-
|
|
2782
|
-
|
|
2781
|
+
|
|
2782
|
+
|
|
2783
2783
|
client.on('error', (error) => {
|
|
2784
|
-
|
|
2784
|
+
|
|
2785
2785
|
console.error( '`'+ options[':path']+ '` : '+ error.stack||error.message);
|
|
2786
|
-
if (
|
|
2787
|
-
typeof(error.cause) != 'undefined' && typeof(error.cause.code) != 'undefined' && /ECONNREFUSED|ECONNRESET/.test(error.cause.code)
|
|
2788
|
-
|| /ECONNREFUSED|ECONNRESET/.test(error.code)
|
|
2786
|
+
if (
|
|
2787
|
+
typeof(error.cause) != 'undefined' && typeof(error.cause.code) != 'undefined' && /ECONNREFUSED|ECONNRESET/.test(error.cause.code)
|
|
2788
|
+
|| /ECONNREFUSED|ECONNRESET/.test(error.code)
|
|
2789
2789
|
) {
|
|
2790
|
-
|
|
2790
|
+
|
|
2791
2791
|
var port = getContext('gina').ports[options.protocol][options.scheme.replace(/\:/, '')][ options.port ];
|
|
2792
2792
|
if ( typeof(port) != 'undefined' ) {
|
|
2793
2793
|
error.accessPoint = port;
|
|
2794
2794
|
error.message = 'Could not connect to [ ' + error.accessPoint + ' ].\nThe `'+port.split(/\@/)[0]+'` bundle is offline or unreachable.\n';
|
|
2795
|
-
}
|
|
2795
|
+
}
|
|
2796
2796
|
}
|
|
2797
2797
|
self.throwError(error);
|
|
2798
2798
|
return;
|
|
2799
2799
|
});
|
|
2800
|
-
|
|
2800
|
+
|
|
2801
2801
|
client.on('connect', () => {
|
|
2802
|
-
|
|
2802
|
+
|
|
2803
2803
|
var req = client.request( headers, sessionOptions );
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
// req.on('response', function onQueryResponse(headers, flags) {
|
|
2804
|
+
|
|
2805
|
+
|
|
2806
|
+
// req.on('response', function onQueryResponse(headers, flags) {
|
|
2807
2807
|
// for (const name in headers) {
|
|
2808
2808
|
// console.debug(`${name}: ${headers[name]}`);
|
|
2809
2809
|
// }
|
|
2810
2810
|
// });
|
|
2811
|
-
|
|
2811
|
+
|
|
2812
2812
|
req.setEncoding('utf8');
|
|
2813
2813
|
var data = '';
|
|
2814
|
-
req.on('data', function onQueryDataChunk(chunk) {
|
|
2815
|
-
data += chunk;
|
|
2814
|
+
req.on('data', function onQueryDataChunk(chunk) {
|
|
2815
|
+
data += chunk;
|
|
2816
2816
|
});
|
|
2817
|
-
|
|
2817
|
+
|
|
2818
2818
|
req.on('error', function onQueryError(error) {
|
|
2819
2819
|
|
|
2820
|
-
if (
|
|
2821
|
-
typeof(error.cause) != 'undefined' && typeof(error.cause.code) != 'undefined' && /ECONNREFUSED|ECONNRESET/.test(error.cause.code)
|
|
2822
|
-
|| /ECONNREFUSED|ECONNRESET/.test(error.code)
|
|
2820
|
+
if (
|
|
2821
|
+
typeof(error.cause) != 'undefined' && typeof(error.cause.code) != 'undefined' && /ECONNREFUSED|ECONNRESET/.test(error.cause.code)
|
|
2822
|
+
|| /ECONNREFUSED|ECONNRESET/.test(error.code)
|
|
2823
2823
|
) {
|
|
2824
|
-
|
|
2824
|
+
|
|
2825
2825
|
var port = getContext('gina').ports[options.protocol][options.scheme.replace(/\:/, '')][ options.port ];
|
|
2826
2826
|
if ( typeof(port) != 'undefined' ) {
|
|
2827
2827
|
error.accessPoint = port;
|
|
2828
2828
|
error.message = 'Could not connect to [ ' + error.accessPoint + ' ].\n' + error.message;
|
|
2829
|
-
}
|
|
2829
|
+
}
|
|
2830
2830
|
}
|
|
2831
2831
|
|
|
2832
2832
|
|
|
@@ -2834,7 +2834,7 @@ function SuperController(options) {
|
|
|
2834
2834
|
// you can get here if :
|
|
2835
2835
|
// - you are trying to query using: `enctype="multipart/form-data"`
|
|
2836
2836
|
// - server responded with an error
|
|
2837
|
-
if ( typeof(callback) != 'undefined' ) {
|
|
2837
|
+
if ( typeof(callback) != 'undefined' ) {
|
|
2838
2838
|
callback(error);
|
|
2839
2839
|
} else {
|
|
2840
2840
|
error = {
|
|
@@ -2844,28 +2844,28 @@ function SuperController(options) {
|
|
|
2844
2844
|
|
|
2845
2845
|
self.emit('query#complete', error)
|
|
2846
2846
|
}
|
|
2847
|
-
|
|
2847
|
+
|
|
2848
2848
|
return;
|
|
2849
2849
|
});
|
|
2850
|
-
|
|
2851
|
-
req.on('end', function onEnd() {
|
|
2852
|
-
|
|
2850
|
+
|
|
2851
|
+
req.on('end', function onEnd() {
|
|
2852
|
+
|
|
2853
2853
|
// exceptions filter
|
|
2854
2854
|
if ( typeof(data) == 'string' && /^Unknown ALPN Protocol/.test(data) ) {
|
|
2855
2855
|
var err = {
|
|
2856
2856
|
status: 500,
|
|
2857
2857
|
error: new Error(data)
|
|
2858
2858
|
};
|
|
2859
|
-
|
|
2859
|
+
|
|
2860
2860
|
if ( typeof(callback) != 'undefined' ) {
|
|
2861
2861
|
callback(err)
|
|
2862
2862
|
} else {
|
|
2863
2863
|
self.emit('query#complete', err)
|
|
2864
2864
|
}
|
|
2865
|
-
|
|
2865
|
+
|
|
2866
2866
|
return
|
|
2867
2867
|
}
|
|
2868
|
-
|
|
2868
|
+
|
|
2869
2869
|
//Only when needed.
|
|
2870
2870
|
if ( typeof(callback) != 'undefined' ) {
|
|
2871
2871
|
if ( typeof(data) == 'string' && /^(\{|%7B|\[{)|\[\]/.test(data) ) {
|
|
@@ -2896,24 +2896,24 @@ function SuperController(options) {
|
|
|
2896
2896
|
if ( data.status && /^3/.test(data.status) && typeof(data.headers) != 'undefined' ) {
|
|
2897
2897
|
local.res.writeHead(data.status, data.headers);
|
|
2898
2898
|
return local.res.end();
|
|
2899
|
-
}
|
|
2900
|
-
|
|
2899
|
+
}
|
|
2900
|
+
|
|
2901
2901
|
if ( data.status && !/^2/.test(data.status) && typeof(local.options.conf.server.coreConfiguration.statusCodes[data.status]) != 'undefined' ) {
|
|
2902
2902
|
if ( /^5/.test(data.status) ) {
|
|
2903
|
-
return callback(data)
|
|
2903
|
+
return callback(data)
|
|
2904
2904
|
} else {
|
|
2905
2905
|
self.throwError(data);
|
|
2906
2906
|
return;
|
|
2907
|
-
}
|
|
2907
|
+
}
|
|
2908
2908
|
} else {
|
|
2909
2909
|
// required when control is used in an halted state
|
|
2910
2910
|
// Ref.: resumeRequest()
|
|
2911
2911
|
if ( self && self.isHaltedRequest() && typeof(local.onHaltedRequestResumed) != 'undefined' ) {
|
|
2912
2912
|
local.onHaltedRequestResumed(false);
|
|
2913
2913
|
}
|
|
2914
|
-
return callback( false, data )
|
|
2914
|
+
return callback( false, data )
|
|
2915
2915
|
}
|
|
2916
|
-
|
|
2916
|
+
|
|
2917
2917
|
} catch (e) {
|
|
2918
2918
|
var infos = local.options, controllerName = infos.controller.substr(infos.controller.lastIndexOf('/'));
|
|
2919
2919
|
var msg = 'Controller Query Exception while catching back.\nBundle: '+ infos.bundle +'\nController File: /controllers'+ controllerName +'\nControl: this.'+ infos.control +'(...)\n\r' + e.stack;
|
|
@@ -2921,8 +2921,8 @@ function SuperController(options) {
|
|
|
2921
2921
|
exception.status = 500;
|
|
2922
2922
|
self.throwError(exception);
|
|
2923
2923
|
return;
|
|
2924
|
-
}
|
|
2925
|
-
|
|
2924
|
+
}
|
|
2925
|
+
|
|
2926
2926
|
} else {
|
|
2927
2927
|
if ( typeof(data) == 'string' && /^(\{|%7B|\[{)|\[\]/.test(data) ) {
|
|
2928
2928
|
try {
|
|
@@ -2935,13 +2935,13 @@ function SuperController(options) {
|
|
|
2935
2935
|
self.emit('query#complete', data)
|
|
2936
2936
|
}
|
|
2937
2937
|
}
|
|
2938
|
-
|
|
2938
|
+
|
|
2939
2939
|
// intercepting fallback redirect
|
|
2940
2940
|
if ( data.status && /^3/.test(data.status) && typeof(data.headers) != 'undefined' ) {
|
|
2941
2941
|
self.removeAllListeners(['query#complete']);
|
|
2942
2942
|
local.res.writeHead(data.status, data.headers);
|
|
2943
2943
|
return local.res.end();
|
|
2944
|
-
}
|
|
2944
|
+
}
|
|
2945
2945
|
|
|
2946
2946
|
if ( data.status && !/^2/.test(data.status) && typeof(local.options.conf.server.coreConfiguration.statusCodes[data.status]) != 'undefined' ) {
|
|
2947
2947
|
self.emit('query#complete', data)
|
|
@@ -2953,22 +2953,22 @@ function SuperController(options) {
|
|
|
2953
2953
|
}
|
|
2954
2954
|
self.emit('query#complete', false, data)
|
|
2955
2955
|
}
|
|
2956
|
-
}
|
|
2957
|
-
|
|
2956
|
+
}
|
|
2957
|
+
|
|
2958
2958
|
client.close();
|
|
2959
2959
|
});
|
|
2960
|
-
|
|
2960
|
+
|
|
2961
2961
|
if (!endStream) {
|
|
2962
2962
|
req.end(body);
|
|
2963
2963
|
}
|
|
2964
2964
|
});
|
|
2965
|
-
|
|
2966
|
-
|
|
2965
|
+
|
|
2966
|
+
|
|
2967
2967
|
return {
|
|
2968
2968
|
onComplete : function(cb) {
|
|
2969
|
-
|
|
2969
|
+
|
|
2970
2970
|
self.once('query#complete', function(err, data){
|
|
2971
|
-
|
|
2971
|
+
|
|
2972
2972
|
if ( typeof(data) == 'string' && /^(\{|%7B|\[{)|\[\]/.test(data) ) {
|
|
2973
2973
|
try {
|
|
2974
2974
|
data = JSON.parse(data)
|
|
@@ -2979,7 +2979,7 @@ function SuperController(options) {
|
|
|
2979
2979
|
}
|
|
2980
2980
|
}
|
|
2981
2981
|
}
|
|
2982
|
-
|
|
2982
|
+
|
|
2983
2983
|
try {
|
|
2984
2984
|
if ( data.status && !/^2/.test(data.status) && typeof(local.options.conf.server.coreConfiguration.statusCodes[data.status]) != 'undefined') {
|
|
2985
2985
|
cb(data)
|
|
@@ -2989,7 +2989,7 @@ function SuperController(options) {
|
|
|
2989
2989
|
if ( self.isHaltedRequest() && typeof(local.onHaltedRequestResumed) != 'undefined' ) {
|
|
2990
2990
|
local.onHaltedRequestResumed(err);
|
|
2991
2991
|
}
|
|
2992
|
-
|
|
2992
|
+
|
|
2993
2993
|
cb(err, data)
|
|
2994
2994
|
}
|
|
2995
2995
|
} catch (e) {
|
|
@@ -2999,7 +2999,7 @@ function SuperController(options) {
|
|
|
2999
2999
|
exception.status = 500;
|
|
3000
3000
|
self.throwError(exception);
|
|
3001
3001
|
return;
|
|
3002
|
-
}
|
|
3002
|
+
}
|
|
3003
3003
|
})
|
|
3004
3004
|
}
|
|
3005
3005
|
}
|
|
@@ -3066,8 +3066,8 @@ function SuperController(options) {
|
|
|
3066
3066
|
}
|
|
3067
3067
|
|
|
3068
3068
|
req.getParam = function(name) {
|
|
3069
|
-
|
|
3070
|
-
var param = null;
|
|
3069
|
+
|
|
3070
|
+
var param = null;
|
|
3071
3071
|
switch( req.method.toLowerCase() ) {
|
|
3072
3072
|
case 'get':
|
|
3073
3073
|
param = req.get[name];
|
|
@@ -3089,24 +3089,24 @@ function SuperController(options) {
|
|
|
3089
3089
|
return param
|
|
3090
3090
|
}
|
|
3091
3091
|
}
|
|
3092
|
-
|
|
3092
|
+
|
|
3093
3093
|
/**
|
|
3094
|
-
* Forward request
|
|
3094
|
+
* Forward request
|
|
3095
3095
|
* Allowing x-bundle forward
|
|
3096
3096
|
* Attention: this is a work in progres, do not use it yet
|
|
3097
|
-
*
|
|
3098
|
-
* @param {object} req
|
|
3099
|
-
* @param {object} res
|
|
3100
|
-
* @param {callback} next
|
|
3101
|
-
* @returns
|
|
3097
|
+
*
|
|
3098
|
+
* @param {object} req
|
|
3099
|
+
* @param {object} res
|
|
3100
|
+
* @param {callback} next
|
|
3101
|
+
* @returns
|
|
3102
3102
|
*/
|
|
3103
3103
|
this.forward = function(req, res, next) {
|
|
3104
3104
|
var route = req.routing;
|
|
3105
3105
|
if ( typeof(route.param.url) == 'undefined' || /^(null|\s*)$/.test(route.param.url) ) {
|
|
3106
3106
|
self.throwError( new Error('`route.param.url` must be defiend in your route: `'+ route.rule +'`') );
|
|
3107
3107
|
return;
|
|
3108
|
-
}
|
|
3109
|
-
|
|
3108
|
+
}
|
|
3109
|
+
|
|
3110
3110
|
var param = {};
|
|
3111
3111
|
for (let p in route.param) {
|
|
3112
3112
|
if ( /^(url|urlIndex|control|file|title|bundle|project|hostname|port|path|method)$/.test(p) ) {
|
|
@@ -3138,14 +3138,14 @@ function SuperController(options) {
|
|
|
3138
3138
|
port = route.param.port;
|
|
3139
3139
|
path = route.param.port;
|
|
3140
3140
|
}
|
|
3141
|
-
|
|
3141
|
+
|
|
3142
3142
|
var method = null;
|
|
3143
3143
|
if ( typeof(route.param.method) != 'undefined' ) {
|
|
3144
3144
|
method = route.param.method.toLowerCase();
|
|
3145
3145
|
} else {
|
|
3146
3146
|
method = req.method.toLowerCase();
|
|
3147
3147
|
}
|
|
3148
|
-
|
|
3148
|
+
|
|
3149
3149
|
var opt = {
|
|
3150
3150
|
ca: ca,
|
|
3151
3151
|
hostname: hostname,
|
|
@@ -3156,7 +3156,7 @@ function SuperController(options) {
|
|
|
3156
3156
|
if (self.isCacheless() || self.isLocalScope() ) {
|
|
3157
3157
|
opt.rejectUnauthorized = false;
|
|
3158
3158
|
}
|
|
3159
|
-
|
|
3159
|
+
|
|
3160
3160
|
var obj = req[ req.method.toLowerCase() ];
|
|
3161
3161
|
// if ( req.files != 'undefined' ) {
|
|
3162
3162
|
// obj.files = req.files;
|
|
@@ -3166,17 +3166,17 @@ function SuperController(options) {
|
|
|
3166
3166
|
self.throwError(err);
|
|
3167
3167
|
return;
|
|
3168
3168
|
}
|
|
3169
|
-
|
|
3169
|
+
|
|
3170
3170
|
// TODO - filter : redirect & location
|
|
3171
|
-
|
|
3171
|
+
|
|
3172
3172
|
// if ( self.isXMLRequest() || !hasViews() || !local.options.isUsingTemplate && !hasViews() || hasViews() && !local.options.isUsingTemplate ) {
|
|
3173
3173
|
self.renderJSON(result)
|
|
3174
3174
|
// } else {
|
|
3175
3175
|
// self.render(result)
|
|
3176
|
-
// }
|
|
3176
|
+
// }
|
|
3177
3177
|
});
|
|
3178
3178
|
}
|
|
3179
|
-
|
|
3179
|
+
|
|
3180
3180
|
|
|
3181
3181
|
/**
|
|
3182
3182
|
* Get config
|
|
@@ -3243,8 +3243,8 @@ function SuperController(options) {
|
|
|
3243
3243
|
} else if ( typeof(code) != 'undefined' ) (
|
|
3244
3244
|
console.warn('`'+ code +'` not supported : sticking with `short` code')
|
|
3245
3245
|
)
|
|
3246
|
-
|
|
3247
|
-
|
|
3246
|
+
|
|
3247
|
+
|
|
3248
3248
|
for ( var i = 0, len = userLocales.length; i< len; ++i ) {
|
|
3249
3249
|
|
|
3250
3250
|
if (userLocales[i][cde]) {
|
|
@@ -3297,8 +3297,8 @@ function SuperController(options) {
|
|
|
3297
3297
|
} else {
|
|
3298
3298
|
rules = JSON.clone(local.options.conf.content.forms).rules[form.id] || null;
|
|
3299
3299
|
}
|
|
3300
|
-
|
|
3301
|
-
if (!rules) {
|
|
3300
|
+
|
|
3301
|
+
if (!rules) {
|
|
3302
3302
|
rules = {};
|
|
3303
3303
|
console.warn('[CONTROLLER]['+ local.options.conf.bundle +'][Backend validation] did not find matching rules for form.id `'+ form.id +'` for `'+ bundle+' bundle`. Do not Panic if you did not defined any.')
|
|
3304
3304
|
}
|
|
@@ -3307,40 +3307,40 @@ function SuperController(options) {
|
|
|
3307
3307
|
return;
|
|
3308
3308
|
}
|
|
3309
3309
|
}
|
|
3310
|
-
|
|
3310
|
+
|
|
3311
3311
|
return rules;
|
|
3312
3312
|
}
|
|
3313
|
-
|
|
3313
|
+
|
|
3314
3314
|
this.push = function(payload) {
|
|
3315
|
-
|
|
3315
|
+
|
|
3316
3316
|
var req = local.req, res = local.res;
|
|
3317
3317
|
var method = req.method.toLowerCase();
|
|
3318
3318
|
// if no session defined, will push to all active clients
|
|
3319
3319
|
var sessionId = ( typeof(req[method].sessionID) != 'undefined' ) ? req[method].sessionID : null;
|
|
3320
|
-
|
|
3320
|
+
|
|
3321
3321
|
// resume current session
|
|
3322
|
-
|
|
3323
|
-
if (!payload) {
|
|
3324
|
-
payload = null;
|
|
3322
|
+
|
|
3323
|
+
if (!payload) {
|
|
3324
|
+
payload = null;
|
|
3325
3325
|
if ( typeof(req[method]) != 'undefined' && typeof(req[method].payload) != 'undefined' ) {
|
|
3326
3326
|
if ( typeof(payload) == 'string' ) {
|
|
3327
3327
|
payload = decodeURIComponent(req[method].payload)
|
|
3328
3328
|
} else {
|
|
3329
3329
|
payload = JSON.stringify(req[method].payload)
|
|
3330
|
-
}
|
|
3330
|
+
}
|
|
3331
3331
|
}
|
|
3332
3332
|
} else if ( typeof(payload) == 'object' ) {
|
|
3333
3333
|
payload = JSON.stringify(payload)
|
|
3334
|
-
}
|
|
3335
|
-
|
|
3334
|
+
}
|
|
3335
|
+
|
|
3336
3336
|
try {
|
|
3337
3337
|
var clients = null;
|
|
3338
3338
|
if (sessionId) {
|
|
3339
3339
|
clients = self.serverInstance.eio.getClientsBySessionId(sessionId);
|
|
3340
3340
|
if (clients)
|
|
3341
3341
|
clients.send(payload);
|
|
3342
|
-
}
|
|
3343
|
-
|
|
3342
|
+
}
|
|
3343
|
+
|
|
3344
3344
|
// send to all clients if no specific sessionId defined
|
|
3345
3345
|
if (!sessionId) {
|
|
3346
3346
|
clients = self.serverInstance.eio.clients;
|
|
@@ -3348,14 +3348,14 @@ function SuperController(options) {
|
|
|
3348
3348
|
clients[id].send(payload)
|
|
3349
3349
|
}
|
|
3350
3350
|
}
|
|
3351
|
-
|
|
3351
|
+
|
|
3352
3352
|
res.end();
|
|
3353
3353
|
} catch(err) {
|
|
3354
3354
|
self.throwError(err);
|
|
3355
3355
|
return;
|
|
3356
|
-
}
|
|
3356
|
+
}
|
|
3357
3357
|
}
|
|
3358
|
-
|
|
3358
|
+
|
|
3359
3359
|
var getSession = function() {
|
|
3360
3360
|
var session = null;
|
|
3361
3361
|
if ( typeof(local.req.session) != 'undefined') {
|
|
@@ -3365,10 +3365,10 @@ function SuperController(options) {
|
|
|
3365
3365
|
if (!session && typeof(local.req.session) != 'undefined' && typeof(local.req.session.user) != 'undefined') {
|
|
3366
3366
|
session = local.req.session.user;
|
|
3367
3367
|
}
|
|
3368
|
-
|
|
3368
|
+
|
|
3369
3369
|
return session;
|
|
3370
3370
|
}
|
|
3371
|
-
|
|
3371
|
+
|
|
3372
3372
|
this.isHaltedRequest = function(session) {
|
|
3373
3373
|
// trying to retrieve session since it is optional
|
|
3374
3374
|
if ( typeof(session) == 'undefined' ) {
|
|
@@ -3381,24 +3381,24 @@ function SuperController(options) {
|
|
|
3381
3381
|
// session = local.req.session.user;
|
|
3382
3382
|
// }
|
|
3383
3383
|
if (
|
|
3384
|
-
!session
|
|
3385
|
-
||
|
|
3384
|
+
!session
|
|
3385
|
+
||
|
|
3386
3386
|
typeof(session) != 'undefined'
|
|
3387
3387
|
&& typeof(session.haltedRequest) == 'undefined'
|
|
3388
3388
|
) {
|
|
3389
3389
|
return false;
|
|
3390
3390
|
}
|
|
3391
3391
|
}
|
|
3392
|
-
|
|
3392
|
+
|
|
3393
3393
|
return (typeof(session.haltedRequest) != 'undefined' ) ? true : false;
|
|
3394
3394
|
}
|
|
3395
|
-
|
|
3396
|
-
|
|
3395
|
+
|
|
3396
|
+
|
|
3397
3397
|
local.haltedRequestUrlResumed = false;
|
|
3398
|
-
|
|
3398
|
+
|
|
3399
3399
|
this.pauseRequest = function(data, requestStorage) {
|
|
3400
|
-
|
|
3401
|
-
|
|
3400
|
+
|
|
3401
|
+
|
|
3402
3402
|
// saving halted request
|
|
3403
3403
|
var req = local.req
|
|
3404
3404
|
, res = local.res
|
|
@@ -3410,22 +3410,22 @@ function SuperController(options) {
|
|
|
3410
3410
|
data : JSON.clone(data)
|
|
3411
3411
|
}
|
|
3412
3412
|
;
|
|
3413
|
-
|
|
3413
|
+
|
|
3414
3414
|
if (
|
|
3415
3415
|
typeof(requestStorage) == 'undefined'
|
|
3416
3416
|
&& typeof(req.session) != 'undefined'
|
|
3417
3417
|
) {
|
|
3418
3418
|
requestStorage = req.session;
|
|
3419
3419
|
}
|
|
3420
|
-
|
|
3420
|
+
|
|
3421
3421
|
if (
|
|
3422
|
-
typeof(requestStorage) == 'undefined'
|
|
3422
|
+
typeof(requestStorage) == 'undefined'
|
|
3423
3423
|
) {
|
|
3424
3424
|
var error = new ApiError('`requestStorage` is required', 424);
|
|
3425
3425
|
self.throwError(error);
|
|
3426
3426
|
return;
|
|
3427
3427
|
}
|
|
3428
|
-
|
|
3428
|
+
|
|
3429
3429
|
var requestParams = {}, i = 0;
|
|
3430
3430
|
for (var p in req.params) {
|
|
3431
3431
|
if (i > 0) {
|
|
@@ -3436,13 +3436,13 @@ function SuperController(options) {
|
|
|
3436
3436
|
if (requestParams.count() > 0) {
|
|
3437
3437
|
haltedRequest.params = requestParams;
|
|
3438
3438
|
}
|
|
3439
|
-
|
|
3439
|
+
|
|
3440
3440
|
requestStorage.haltedRequest = haltedRequest;
|
|
3441
|
-
|
|
3441
|
+
|
|
3442
3442
|
return requestStorage;
|
|
3443
3443
|
}
|
|
3444
|
-
|
|
3445
|
-
|
|
3444
|
+
|
|
3445
|
+
|
|
3446
3446
|
/**
|
|
3447
3447
|
* resumeRequest
|
|
3448
3448
|
* Used to resume an halted request
|
|
@@ -3450,35 +3450,35 @@ function SuperController(options) {
|
|
|
3450
3450
|
* - a middleware attached `haltedRequest` to userSession
|
|
3451
3451
|
* OR
|
|
3452
3452
|
* - a persistant object where `haltedRequest` is attached
|
|
3453
|
-
*
|
|
3454
|
-
* @param {object} req
|
|
3455
|
-
* @param {object} res
|
|
3453
|
+
*
|
|
3454
|
+
* @param {object} req
|
|
3455
|
+
* @param {object} res
|
|
3456
3456
|
* @param {callback|null} next
|
|
3457
3457
|
* @param {object} [requestStorage] - Will try to use sessionStorage if not passed
|
|
3458
3458
|
*/
|
|
3459
3459
|
this.resumeRequest = function(requestStorage) {
|
|
3460
|
-
|
|
3460
|
+
|
|
3461
3461
|
if (local.haltedRequestUrlResumed)
|
|
3462
3462
|
return;
|
|
3463
|
-
|
|
3463
|
+
|
|
3464
3464
|
var haltedRequest = null
|
|
3465
3465
|
, req = local.req
|
|
3466
3466
|
, res = local.res
|
|
3467
3467
|
, next = local.next
|
|
3468
3468
|
;
|
|
3469
|
-
|
|
3469
|
+
|
|
3470
3470
|
if (
|
|
3471
3471
|
typeof(requestStorage) == 'undefined'
|
|
3472
3472
|
&& typeof(req.session) != 'undefined'
|
|
3473
3473
|
) {
|
|
3474
3474
|
requestStorage = req.session;
|
|
3475
3475
|
}
|
|
3476
|
-
|
|
3476
|
+
|
|
3477
3477
|
if (
|
|
3478
|
-
typeof(requestStorage) == 'undefined'
|
|
3478
|
+
typeof(requestStorage) == 'undefined'
|
|
3479
3479
|
||
|
|
3480
|
-
typeof(requestStorage) != 'undefined'
|
|
3481
|
-
&& typeof(requestStorage.haltedRequest) == 'undefined'
|
|
3480
|
+
typeof(requestStorage) != 'undefined'
|
|
3481
|
+
&& typeof(requestStorage.haltedRequest) == 'undefined'
|
|
3482
3482
|
) {
|
|
3483
3483
|
var error = new ApiError('`requestStorage.haltedRequest` is required', 424);
|
|
3484
3484
|
self.throwError(error);
|
|
@@ -3493,11 +3493,11 @@ function SuperController(options) {
|
|
|
3493
3493
|
if (req.method.toLowerCase() == method) {
|
|
3494
3494
|
data = merge(data, req[method])
|
|
3495
3495
|
}
|
|
3496
|
-
|
|
3497
|
-
delete req[method];
|
|
3496
|
+
|
|
3497
|
+
delete req[method];
|
|
3498
3498
|
}
|
|
3499
|
-
|
|
3500
|
-
|
|
3499
|
+
|
|
3500
|
+
|
|
3501
3501
|
var dataAsParams = {};
|
|
3502
3502
|
if (data.count() > 0) {
|
|
3503
3503
|
dataAsParams = JSON.clone(haltedRequest.data);
|
|
@@ -3509,25 +3509,25 @@ function SuperController(options) {
|
|
|
3509
3509
|
requiredController = self.requireController(haltedRequest.routing.namespace, self._options );
|
|
3510
3510
|
} catch (err) {
|
|
3511
3511
|
self.throwError(err);
|
|
3512
|
-
}
|
|
3512
|
+
}
|
|
3513
3513
|
}
|
|
3514
3514
|
req.routing = haltedRequest.routing;
|
|
3515
3515
|
req.method = haltedRequest.method;
|
|
3516
3516
|
req[haltedRequest.method] = data;
|
|
3517
|
-
|
|
3517
|
+
|
|
3518
3518
|
local.haltedRequestUrlResumed = true;
|
|
3519
|
-
if ( /GET/i.test(req.method) ) {
|
|
3519
|
+
if ( /GET/i.test(req.method) ) {
|
|
3520
3520
|
if ( typeof(requestStorage.haltedRequest) != 'undefined' ) {
|
|
3521
3521
|
delete requestStorage.haltedRequest;
|
|
3522
3522
|
}
|
|
3523
3523
|
delete requestStorage.haltedRequest;
|
|
3524
3524
|
delete requestStorage.inheritedData;
|
|
3525
3525
|
requestStorage.haltedRequestUrlResumed = url;
|
|
3526
|
-
|
|
3526
|
+
|
|
3527
3527
|
requiredController.redirect(url, true);
|
|
3528
3528
|
} else {
|
|
3529
3529
|
local.onHaltedRequestResumed = function(err) {
|
|
3530
|
-
if (!err) {
|
|
3530
|
+
if (!err) {
|
|
3531
3531
|
delete requestStorage.haltedRequest;
|
|
3532
3532
|
delete requestStorage.inheritedData;
|
|
3533
3533
|
}
|
|
@@ -3535,7 +3535,7 @@ function SuperController(options) {
|
|
|
3535
3535
|
if ( typeof(next) == 'function' ) {
|
|
3536
3536
|
console.warn('About to override `next` param');
|
|
3537
3537
|
}
|
|
3538
|
-
|
|
3538
|
+
|
|
3539
3539
|
try {
|
|
3540
3540
|
requiredController[req.routing.param.control](req, res, next);
|
|
3541
3541
|
// consuming it
|
|
@@ -3544,12 +3544,12 @@ function SuperController(options) {
|
|
|
3544
3544
|
console.error('[ BUNDLE ][ '+ local.options.conf.bundle +' ][ Controller ] Could not resume haltedRequest\n' + err.stack );
|
|
3545
3545
|
self.throwError(err);
|
|
3546
3546
|
}
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
}
|
|
3547
|
+
|
|
3548
|
+
|
|
3549
|
+
}
|
|
3550
3550
|
}
|
|
3551
|
-
|
|
3552
|
-
|
|
3551
|
+
|
|
3552
|
+
|
|
3553
3553
|
this.renderCustomError = function (req, res, next) {
|
|
3554
3554
|
|
|
3555
3555
|
// preventing multiple call of self.renderWithoutLayout() when controller is rendering from another required controller
|
|
@@ -3559,13 +3559,13 @@ function SuperController(options) {
|
|
|
3559
3559
|
local.options.isRenderingCustomError = true;
|
|
3560
3560
|
|
|
3561
3561
|
//local.options.isWithoutLayout = true;
|
|
3562
|
-
|
|
3562
|
+
|
|
3563
3563
|
var data = null;
|
|
3564
3564
|
if ( typeof(req.routing.param.error) != 'undefined' ) {
|
|
3565
3565
|
data = JSON.clone(req.routing.param.error) || {};
|
|
3566
3566
|
delete req.routing.param.error
|
|
3567
3567
|
}
|
|
3568
|
-
|
|
3568
|
+
|
|
3569
3569
|
var session = getSession();
|
|
3570
3570
|
if (session) {
|
|
3571
3571
|
data.session = JSON.clone(session)
|
|
@@ -3603,13 +3603,13 @@ function SuperController(options) {
|
|
|
3603
3603
|
//assets: {}
|
|
3604
3604
|
};
|
|
3605
3605
|
errOptions = merge(localOptions, local.options);
|
|
3606
|
-
|
|
3607
|
-
|
|
3606
|
+
|
|
3607
|
+
|
|
3608
3608
|
}
|
|
3609
3609
|
delete local.options.namespace;
|
|
3610
3610
|
self.render(data, displayToolbar, errOptions);
|
|
3611
3611
|
}
|
|
3612
|
-
|
|
3612
|
+
|
|
3613
3613
|
|
|
3614
3614
|
/**
|
|
3615
3615
|
* Throw error
|
|
@@ -3623,7 +3623,7 @@ function SuperController(options) {
|
|
|
3623
3623
|
this.throwError = function(res, code, msg) {
|
|
3624
3624
|
self.isProcessingError = true;
|
|
3625
3625
|
var errorObject = null; // to be returned
|
|
3626
|
-
|
|
3626
|
+
|
|
3627
3627
|
// preventing multiple call of self.throwError() when controller is rendering from another required controller
|
|
3628
3628
|
if (local.options.renderingStack.length > 1) {
|
|
3629
3629
|
return false
|
|
@@ -3634,21 +3634,21 @@ function SuperController(options) {
|
|
|
3634
3634
|
// err.fallback must be a valide route object or a url string
|
|
3635
3635
|
var fallback = null;
|
|
3636
3636
|
var standardErrorMessage = null;
|
|
3637
|
-
if (
|
|
3638
|
-
arguments[0] instanceof Error
|
|
3637
|
+
if (
|
|
3638
|
+
arguments[0] instanceof Error
|
|
3639
3639
|
|| arguments.length == 1 && typeof(res) == 'object'
|
|
3640
3640
|
|| arguments[arguments.length-1] instanceof Error
|
|
3641
|
-
|| typeof(arguments[arguments.length-1]) == 'string' && !(arguments[0] instanceof Error)
|
|
3641
|
+
|| typeof(arguments[arguments.length-1]) == 'string' && !(arguments[0] instanceof Error)
|
|
3642
3642
|
) {
|
|
3643
|
-
|
|
3643
|
+
|
|
3644
3644
|
code = ( res && typeof(res.status) != 'undefined' ) ? res.status : 500;
|
|
3645
|
-
|
|
3645
|
+
|
|
3646
3646
|
if ( typeof(statusCodes[code]) != 'undefined' ) {
|
|
3647
3647
|
standardErrorMessage = statusCodes[code];
|
|
3648
3648
|
} else {
|
|
3649
3649
|
console.warn('[ ApiValidator ] statusCode `'+ code +'` not matching any definition in `'+_( getPath('gina').core + '/status.codes')+'`\nPlease contact the Gina dev team to add one if required');
|
|
3650
3650
|
}
|
|
3651
|
-
|
|
3651
|
+
|
|
3652
3652
|
errorObject = {
|
|
3653
3653
|
status : code,
|
|
3654
3654
|
error : res.error || res.message || standardErrorMessage
|
|
@@ -3663,17 +3663,17 @@ function SuperController(options) {
|
|
|
3663
3663
|
} else if (res.message) {
|
|
3664
3664
|
console.warn('[ Controller ] Ignoring message because of the format.\n'+res.message)
|
|
3665
3665
|
}
|
|
3666
|
-
|
|
3666
|
+
|
|
3667
3667
|
} else if ( typeof(arguments[arguments.length-1]) == 'string' ) {
|
|
3668
3668
|
// formated error
|
|
3669
3669
|
errorObject.message = arguments[arguments.length-1]
|
|
3670
3670
|
} else if (
|
|
3671
|
-
arguments[arguments.length-1] instanceof Error
|
|
3672
|
-
|| typeof(res) == 'object' && typeof(res.stack) != 'undefined'
|
|
3671
|
+
arguments[arguments.length-1] instanceof Error
|
|
3672
|
+
|| typeof(res) == 'object' && typeof(res.stack) != 'undefined'
|
|
3673
3673
|
) {
|
|
3674
3674
|
errorObject = merge(arguments[arguments.length-1], errorObject)
|
|
3675
3675
|
}
|
|
3676
|
-
|
|
3676
|
+
|
|
3677
3677
|
if ( typeof(res.fallback) != 'undefined' ) {
|
|
3678
3678
|
fallback = res.fallback
|
|
3679
3679
|
}
|
|
@@ -3685,7 +3685,7 @@ function SuperController(options) {
|
|
|
3685
3685
|
code = res || 500;
|
|
3686
3686
|
res = local.res;
|
|
3687
3687
|
}
|
|
3688
|
-
|
|
3688
|
+
|
|
3689
3689
|
var responseHeaders = res.getHeaders() || local.res.getHeaders();
|
|
3690
3690
|
var req = local.req;
|
|
3691
3691
|
var next = local.next;
|
|
@@ -3694,18 +3694,18 @@ function SuperController(options) {
|
|
|
3694
3694
|
// but if we are calling it from a view, we should render the error back to the view
|
|
3695
3695
|
if ( self.isXMLRequest() || !hasViews() && !/delete/i.test(req.method) || !local.options.isUsingTemplate && !hasViews() || hasViews() && !local.options.isUsingTemplate ) {
|
|
3696
3696
|
// fallback interception
|
|
3697
|
-
if ( fallback ) {
|
|
3697
|
+
if ( fallback ) {
|
|
3698
3698
|
if ( typeof(fallback) == 'string' ){ // string url: user provided
|
|
3699
3699
|
return self.redirect( fallback, true )
|
|
3700
3700
|
} else {
|
|
3701
3701
|
// else, using url from route object
|
|
3702
3702
|
// Reminder
|
|
3703
3703
|
// Here, we use route.toUrl() intead of
|
|
3704
|
-
// route.url to support x-bundle com
|
|
3704
|
+
// route.url to support x-bundle com
|
|
3705
3705
|
return self.redirect( fallback.toUrl() );
|
|
3706
3706
|
}
|
|
3707
3707
|
}
|
|
3708
|
-
|
|
3708
|
+
|
|
3709
3709
|
// allowing this.throwError(err)
|
|
3710
3710
|
if ( typeof(code) == 'object' && !msg && typeof(code.status) != 'undefined' && typeof(code.error) != 'undefined' ) {
|
|
3711
3711
|
msg = code.error || code.message;
|
|
@@ -3725,7 +3725,7 @@ function SuperController(options) {
|
|
|
3725
3725
|
// res.writeHead(code, { 'content-type': bundleConf.server.coreConfiguration.mime['json']} );
|
|
3726
3726
|
// }
|
|
3727
3727
|
// }
|
|
3728
|
-
|
|
3728
|
+
|
|
3729
3729
|
// TODO - test with internet explorer then remove this if working
|
|
3730
3730
|
if ( typeof(req.headers['user-agent']) != 'undefined' ) {
|
|
3731
3731
|
if ( /msie/i.test(req.headers['user-agent']) ) {
|
|
@@ -3743,8 +3743,8 @@ function SuperController(options) {
|
|
|
3743
3743
|
res.writeHead(code, "content-type", bundleConf.server.coreConfiguration.mime['json']+ '; charset='+ bundleConf.encoding);
|
|
3744
3744
|
}
|
|
3745
3745
|
|
|
3746
|
-
|
|
3747
|
-
|
|
3746
|
+
|
|
3747
|
+
|
|
3748
3748
|
if (!errorObject) {
|
|
3749
3749
|
errorObject = {
|
|
3750
3750
|
status: code,
|
|
@@ -3754,7 +3754,7 @@ function SuperController(options) {
|
|
|
3754
3754
|
stack: msg.stack
|
|
3755
3755
|
}
|
|
3756
3756
|
}
|
|
3757
|
-
|
|
3757
|
+
|
|
3758
3758
|
var errOutput = null, output = errorObject.toString();
|
|
3759
3759
|
if ( output == '[object Object]' ) {
|
|
3760
3760
|
errOutput = JSON.stringify(errorObject);
|
|
@@ -3766,15 +3766,15 @@ function SuperController(options) {
|
|
|
3766
3766
|
}
|
|
3767
3767
|
);
|
|
3768
3768
|
}
|
|
3769
|
-
|
|
3770
|
-
console.error('[ BUNDLE ][ '+ bundleConf.bundle +' ][ Controller ] '+ req.method +' ['+res.statusCode +'] '+ req.url +'\n'+ errOutput);
|
|
3769
|
+
|
|
3770
|
+
console.error('[ BUNDLE ][ '+ bundleConf.bundle +' ][ Controller ] '+ req.method +' ['+res.statusCode +'] '+ req.url +'\n'+ errOutput);
|
|
3771
3771
|
return res.end(errOutput);
|
|
3772
3772
|
} else {
|
|
3773
|
-
|
|
3774
|
-
|
|
3773
|
+
|
|
3774
|
+
|
|
3775
3775
|
console.error(req.method +' ['+ errorObject.status +'] '+ req.url);
|
|
3776
|
-
|
|
3777
|
-
|
|
3776
|
+
|
|
3777
|
+
|
|
3778
3778
|
// intercept none HTML mime types
|
|
3779
3779
|
var url = unescape(local.req.url) /// avoid %20
|
|
3780
3780
|
, ext = null
|
|
@@ -3789,8 +3789,8 @@ function SuperController(options) {
|
|
|
3789
3789
|
if ( !ext || /^(html|htm)$/i.test(ext) ) {
|
|
3790
3790
|
isHtmlContent = true;
|
|
3791
3791
|
}
|
|
3792
|
-
|
|
3793
|
-
if (
|
|
3792
|
+
|
|
3793
|
+
if (
|
|
3794
3794
|
isHtmlContent
|
|
3795
3795
|
&& typeof(bundleConf.content.templates._common.errorFiles) != 'undefined'
|
|
3796
3796
|
&& typeof(bundleConf.content.templates._common.errorFiles[code]) != 'undefined'
|
|
@@ -3810,11 +3810,11 @@ function SuperController(options) {
|
|
|
3810
3810
|
//message : errorObject.message || msg || null,
|
|
3811
3811
|
pathname : url
|
|
3812
3812
|
};
|
|
3813
|
-
|
|
3813
|
+
|
|
3814
3814
|
if ( errorObject ) {
|
|
3815
3815
|
eData = merge(errorObject, eData);
|
|
3816
3816
|
}
|
|
3817
|
-
|
|
3817
|
+
|
|
3818
3818
|
if ( typeof(msg) == 'object' ) {
|
|
3819
3819
|
if ( typeof(msg.stack) != 'undefined' ) {
|
|
3820
3820
|
eData.stack = msg.stack
|
|
@@ -3823,8 +3823,8 @@ function SuperController(options) {
|
|
|
3823
3823
|
eData.message = msg.message
|
|
3824
3824
|
}
|
|
3825
3825
|
}
|
|
3826
|
-
if (
|
|
3827
|
-
code
|
|
3826
|
+
if (
|
|
3827
|
+
code
|
|
3828
3828
|
// See: framework/${version}/core/status.code
|
|
3829
3829
|
&& typeof(bundleConf.server.coreConfiguration.statusCodes[code]) != 'undefined'
|
|
3830
3830
|
) {
|
|
@@ -3834,13 +3834,13 @@ function SuperController(options) {
|
|
|
3834
3834
|
// if ( typeof(local.req.routing) != 'undefined' ) {
|
|
3835
3835
|
// eData.routing = local.req.routing;
|
|
3836
3836
|
// }
|
|
3837
|
-
|
|
3837
|
+
|
|
3838
3838
|
if (typeof(bundleConf.content.templates._common.errorFiles[code]) != 'undefined') {
|
|
3839
3839
|
eFilename = bundleConf.content.templates._common.errorFiles[code];
|
|
3840
3840
|
} else {
|
|
3841
3841
|
eFilename = bundleConf.content.templates._common.errorFiles[eCode];
|
|
3842
3842
|
}
|
|
3843
|
-
|
|
3843
|
+
|
|
3844
3844
|
if (!local.options.isRenderingCustomError) {
|
|
3845
3845
|
var eRule = 'custom-error-page@'+ bundle;
|
|
3846
3846
|
var routeObj = bundleConf.content.routing[eRule];
|
|
@@ -3851,16 +3851,16 @@ function SuperController(options) {
|
|
|
3851
3851
|
routeObj.param.error = eData;
|
|
3852
3852
|
routeObj.param.displayToolbar = self.isCacheless();
|
|
3853
3853
|
routeObj.param.isLocalOptionResetNeeded = true;
|
|
3854
|
-
|
|
3855
|
-
|
|
3854
|
+
|
|
3855
|
+
|
|
3856
3856
|
local.req.routing = routeObj;
|
|
3857
3857
|
local.req.params.errorObject = errorObject;
|
|
3858
3858
|
self.renderCustomError(local.req, res, local.next);
|
|
3859
3859
|
return;
|
|
3860
3860
|
}
|
|
3861
|
-
|
|
3861
|
+
|
|
3862
3862
|
}
|
|
3863
|
-
|
|
3863
|
+
|
|
3864
3864
|
// if (!errorObject) {
|
|
3865
3865
|
// errorObject = {
|
|
3866
3866
|
// status: code,
|
|
@@ -3871,7 +3871,7 @@ function SuperController(options) {
|
|
|
3871
3871
|
// }
|
|
3872
3872
|
// }
|
|
3873
3873
|
var msgString = '<h1 class="status">Error '+ code +'.</h1>';
|
|
3874
|
-
|
|
3874
|
+
|
|
3875
3875
|
console.error('[ BUNDLE ][ '+ local.options.conf.bundle +' ][ Controller ] `this.'+ req.routing.param.control +'(...)` ['+res.statusCode +'] '+ req.url);
|
|
3876
3876
|
if ( typeof(msg) == 'object' ) {
|
|
3877
3877
|
|
|
@@ -3913,7 +3913,7 @@ function SuperController(options) {
|
|
|
3913
3913
|
if (typeof(errorObject) != 'undefined' && errorObject && typeof(errorObject.stack) != 'undefined' ) {
|
|
3914
3914
|
stack = errorObject.stack
|
|
3915
3915
|
}
|
|
3916
|
-
|
|
3916
|
+
|
|
3917
3917
|
if (title) {
|
|
3918
3918
|
msgString += '<pre class="'+ eCode +' title">'+ title +'</pre>';
|
|
3919
3919
|
}
|
|
@@ -3922,7 +3922,7 @@ function SuperController(options) {
|
|
|
3922
3922
|
}
|
|
3923
3923
|
if (stack) {
|
|
3924
3924
|
msgString += '<pre class="'+ eCode +' stack">'+ stack +'</pre>';
|
|
3925
|
-
}
|
|
3925
|
+
}
|
|
3926
3926
|
}
|
|
3927
3927
|
res.writeHead(code, { 'content-type': bundleConf.server.coreConfiguration.mime[ext]+'; charset='+ bundleConf.encoding } );
|
|
3928
3928
|
// if ( isHtmlContent && hasCustomErrorFile ) {
|
|
@@ -3931,7 +3931,7 @@ function SuperController(options) {
|
|
|
3931
3931
|
//if ( isHtmlContent && !hasCustomErrorFile ) {
|
|
3932
3932
|
res.end(msgString);
|
|
3933
3933
|
//}
|
|
3934
|
-
|
|
3934
|
+
|
|
3935
3935
|
return;
|
|
3936
3936
|
}
|
|
3937
3937
|
} else {
|