Commit 825a5b38 authored by Moises Sacal's avatar Moises Sacal
Browse files

initial commit

parents
# Editor configuration, see http://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false
\ No newline at end of file
# See http://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
/dist
/dist-server
/tmp
/out-tsc
# dependencies
node_modules
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings
# e2e
e2e/*.js
e2e/*.map
# System Files
.DS_Store
Thumbs.db
test/angular
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
## A Sails Hook Redbox Template
In this example template you will find the barebones requirements for a Hook
This Project is divided between folders
## api
Main API of your Hook can be stored in controllers and services
- controllers
- services
## config & form-config
This configurations are redbox-portal dependent. They will allow redbox to be available as a record
If you require to have a form in your portal
- `config/recordtype`
- `config/workflow`
- `form-config/template-1.0-draft`
## index
Main entry point for the hook
### initialize
Init code before it gets hooked.
### routes
Controller routes exposed to the sails front-end
```javascript
'get /your/route' : YourController.method
```
### configure
Add configuration and services to your sails app
```javascript
sails.services['YourService'] = function() { };
sails.config = _.merge(sails.config, {object});
```
## test
First run `npm install`
Test your sails hook with mocha by running `npm test` before adding the hook to your redbox-portal.
It may cause your application to not lift.
```sh
$ npm test
> @uts-ersearch/sails-hook-redbox-template@1.0.0 test /Users/moises/source/code.research/sails-hook-redbox-template
> NODE_ENV=test node_modules/.bin/mocha
Basic tests ::
✓ should have a service
✓ should have a form
✓ should have a route
✓ sails does not crash
4 passing (864ms)
```
For more information on testing your hook go to : https://sailsjs.com/documentation/concepts/testing
const TemplateService = require('../services/TemplateService');
module.exports = {
helloWorld: function (req, res, next) {
const hello = TemplateService.helloWorld();
return res.send(hello);
}
};
module.exports = {
helloWorld: function () {
return 'Hello World';
}
};
module.exports.recordtype = {
"template": {
"packageType": "workspace",
searchFilters: [
{
name: "text_title",
title: "search-refine-title",
type: "exact",
typeLabel: "search-refine-contains"
},
{
name: "text_description",
title: "search-refine-description",
type: "exact",
typeLabel: "search-refine-contains"
},
{
name: "grant_number_name",
title: "search-refine-grant_number_name",
type: "facet",
typeLabel: null,
alwaysActive: true
},
{
name: "finalKeywords",
title: "search-refine-keywords",
type: "facet",
typeLabel: null,
alwaysActive: true
},
{
name: "workflow_stageLabel",
title: "search-refine-workflow_stageLabel",
type: "facet",
typeLabel: null,
alwaysActive: true
}
]
}
};
module.exports.workflow = {
"template": {
"draft": {
config: {
workflow: {
stage: 'draft',
stageLabel: 'Draft',
},
authorization: {
viewRoles: ['Admin', 'Librarians'],
editRoles: ['Admin', 'Librarians']
},
form: 'example-1.0-draft'
},
starting: true
}
}
}
/**
* Template form
*/
module.exports = {
name: 'template-1.0-draft',
type: 'template',
skipValidationOnSave: true,
editCssClasses: 'row col-md-12',
viewCssClasses: 'row col-md-offset-1 col-md-10',
messages: {
'saving': ['@dmpt-form-saving'],
'validationFail': ['@dmpt-form-validation-fail-prefix', '@dmpt-form-validation-fail-suffix'],
'saveSuccess': ['@dmpt-form-save-success'],
'saveError': ['@dmpt-form-save-error']
},
fields: [
{
class: 'Container',
compClass: 'TextBlockComponent',
viewOnly: false,
definition: {
name: 'title',
value: 'Template',
type: 'h2'
}
}
]
};
const _ = require('lodash');
const TemplateController = require('./api/controllers/TemplateController');
const TemplateService = require('./api/services/TemplateService');
const recordTypeConfig = require('./config/recordtype.js');
const workflowConfig = require('./config/workflow.js');
const recordFormConfig = require('./form-config/template-1.0-draft.js');
module.exports = function (sails) {
return {
initialize: function (cb) {
// Do Some initialisation tasks
// This can be for example: copy files or images to the redbox-portal front end
return cb();
},
//If each route middleware do not exist sails.lift will fail during hook.load()
routes: {
before: {},
after: {
'get /:branding/:portal/ws/template/hello': TemplateController.helloWorld
}
},
configure: function () {
sails.services['TemplateService'] = TemplateService;
sails.config = _.merge(sails.config, recordTypeConfig);
sails.config = _.merge(sails.config, workflowConfig);
sails.config['form']['forms'] = _.merge(sails.config['form']['forms'], {'template-1.0-draft': recordFormConfig});
}
}
};
{
"name": "@uts-ersearch/sails-hook-redbox-template",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@sailshq/lodash": {
"version": "3.10.3",
"resolved": "https://registry.npmjs.org/@sailshq/lodash/-/lodash-3.10.3.tgz",
"integrity": "sha512-XTF5BtsTSiSpTnfqrCGS5Q8FvSHWCywA0oRxFAZo8E1a8k1MMFUvk3VlRk3q/SusEYwy7gvVdyt9vvNlTa2VuA==",
"dev": true
},
"accepts": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz",
"integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=",
"dev": true,
"requires": {
"mime-types": "2.1.18",
"negotiator": "0.6.1"
}
},
"anchor": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/anchor/-/anchor-1.3.0.tgz",
"integrity": "sha512-mA+EfMr/WVT69u1HisKqQED7+LmTxpb0Lm9Lo/qTT/uf7AOFA3qYYb/ZPiMi3aQqWn2ji4fC6UQuRIP0XBV9ZA==",
"dev": true,
"requires": {
"@sailshq/lodash": "3.10.3",
"validator": "5.7.0"
}
},
"ansi-regex": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
"dev": true
},
"ansi-styles": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz",
"integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=",
"dev": true
},
"array-flatten": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=",
"dev": true
},
"async": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/async/-/async-2.5.0.tgz",
"integrity": "sha512-e+lJAJeNWuPCNyxZKOBdaJGyLGHugXVQtrAwtuAe2vhxTYxFTKE73p8JuTmdH0qdQZtDvI4dhJwjZc5zsfIsYw==",
"dev": true,
"requires": {
"lodash": "4.17.10"
}
},
"asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=",
"dev": true
},
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
"dev": true
},
"bluebird": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.2.1.tgz",
"integrity": "sha1-POzzUEkEwwzj55wXCHfok6EZEP0=",
"dev": true
},
"body-parser": {
"version": "1.18.2",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.2.tgz",
"integrity": "sha1-h2eKGdhLR9hZuDGZvVm84iKxBFQ=",
"dev": true,
"requires": {
"bytes": "3.0.0",
"content-type": "1.0.4",
"debug": "2.6.9",
"depd": "1.1.2",
"http-errors": "1.6.3",
"iconv-lite": "0.4.19",
"on-finished": "2.3.0",
"qs": "6.5.1",
"raw-body": "2.3.2",
"type-is": "1.6.16"
},
"dependencies": {
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"dev": true,
"requires": {
"ms": "2.0.0"
}
},
"http-errors": {
"version": "1.6.3",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz",
"integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=",
"dev": true,
"requires": {
"depd": "1.1.2",
"inherits": "2.0.3",
"setprototypeof": "1.1.0",
"statuses": "1.5.0"
}
},
"setprototypeof": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz",
"integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==",
"dev": true
},
"statuses": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
"integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=",
"dev": true
}
}
},
"brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true,
"requires": {
"balanced-match": "1.0.0",
"concat-map": "0.0.1"
}
},
"browser-stdout": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz",
"integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==",
"dev": true
},
"bytes": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz",
"integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=",
"dev": true
},
"camelcase": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz",
"integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=",
"dev": true
},
"captains-log": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/captains-log/-/captains-log-2.0.0.tgz",
"integrity": "sha512-ICNwMIjnPvEm9tVoZ1mxFtuN3t9hCFjVOXj5AgeYBrnqErgx0zd4JqueEv6LgRQzSssYe4Tj//S3W86G68pbmg==",
"dev": true,
"requires": {
"@sailshq/lodash": "3.10.3",
"chalk": "1.1.3",
"rc": "1.0.1",
"semver": "5.4.1"
},
"dependencies": {
"chalk": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
"dev": true,
"requires": {
"ansi-styles": "2.2.1",
"escape-string-regexp": "1.0.5",
"has-ansi": "2.0.0",
"strip-ansi": "3.0.1",
"supports-color": "2.0.0"
}
},
"rc": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/rc/-/rc-1.0.1.tgz",
"integrity": "sha1-+RnCXoBMsKpg9v2S2Sn8hrRQE+g=",
"dev": true,
"requires": {
"deep-extend": "0.2.11",
"ini": "1.3.5",
"minimist": "0.0.8",
"strip-json-comments": "0.1.3"
}
},
"semver": {
"version": "5.4.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz",
"integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==",
"dev": true
},
"supports-color": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz",
"integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=",
"dev": true
}
}
},
"chalk": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz",
"integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==",
"dev": true,
"requires": {
"ansi-styles": "3.2.1",
"escape-string-regexp": "1.0.5",
"supports-color": "4.4.0"
},
"dependencies": {
"ansi-styles": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
"integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
"dev": true,
"requires": {
"color-convert": "1.9.1"
}
}
}
},
"color-convert": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz",
"integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==",
"dev": true,
"requires": {
"color-name": "1.1.3"
}
},
"color-name": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
"dev": true
},
"colors": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/colors/-/colors-0.6.2.tgz",
"integrity": "sha1-JCP+ZnisDF2uiFLl0OW+CMmXq8w=",
"dev": true
},
"combined-stream": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz",
"integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=",
"dev": true,
"requires": {
"delayed-stream": "1.0.0"
}
},
"commander": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz",
"integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==",
"dev": true
},
"common-js-file-extensions": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/common-js-file-extensions/-/common-js-file-extensions-1.0.2.tgz",
"integrity": "sha1-Hs8ThwARVtpoD1gUmovpvrgEvx4=",
"dev": true
},
"component-emitter": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz",
"integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=",
"dev": true
},
"compressible": {
"version": "2.0.13",
"resolved": "https://registry.npmjs.org/compressible/-/compressible-2.0.13.tgz",
"integrity": "sha1-DRAgq5JLL9tNYnmHXH1tq6a6p6k=",
"dev": true,
"requires": {
"mime-db": "1.33.0"
}
},
"compression": {
"version": "1.7.1",
"resolved": "https://registry.npmjs.org/compression/-/compression-1.7.1.tgz",
"integrity": "sha1-7/JgPvwuIs+G810uuTWJ+YdTc9s=",
"dev": true,
"requires": {
"accepts": "1.3.5",
"bytes": "3.0.0",
"compressible": "2.0.13",
"debug": "2.6.9",
"on-headers": "1.0.1",
"safe-buffer": "5.1.1",
"vary": "1.1.2"
},
"dependencies": {
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"dev": true,
"requires": {
"ms": "2.0.0"
}
}
}
},
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true
},
"connect": {
"version": "3.6.5",
"resolved": "https://registry.npmjs.org/connect/-/connect-3.6.5.tgz",
"integrity": "sha1-+43ee6B2OHfQ7J352sC0tA5yx9o=",
"dev": true,
"requires": {
"debug": "2.6.9",
"finalhandler": "1.0.6",
"parseurl": "1.3.2",
"utils-merge": "1.0.1"
},
"dependencies": {
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"dev": true,
"requires": {