Commit 01a76d3f authored by Moises Sacal's avatar Moises Sacal
Browse files

issue #2

parent cfa9f075
## A Sails Hook Redbox Template
## A Sails Hook Redbox LabArchives
In this example template you will find the barebones requirements for a Hook
This Project is divided between folders
......@@ -18,7 +17,7 @@ If you require to have a form in your portal
- `config/recordtype`
- `config/workflow`
- `form-config/template-1.0-draft`
- `form-config/labarchives-1.0-draft`
## index
......@@ -55,7 +54,7 @@ It may cause your application to not lift.
```sh
$ npm test
> @uts-eresearch/sails-hook-redbox-template@1.0.0 test /Users/moises/source/code.research/sails-hook-redbox-template
> @uts-eresearch/sails-hook-redbox-labarchives@1.0.0 test /Users/moises/source/code.research/sails-hook-redbox-labarchives
> NODE_ENV=test node_modules/.bin/mocha
......@@ -89,7 +88,7 @@ npm link into redbox-portal
```bash
cd /into/redbox-portal/
npm link sails-hook-redbox-gitlab
npm link sails-hook-redbox-labarchives
```
## Vagrant/Docker
......@@ -105,7 +104,7 @@ In the `docker-compose.yml` file in redbox-portal verify that the service has th
For Vagrant to place the code inside of the same machine/docker. You can share it via the VagrantFile using sync_folder
```yml
config.vm.synced_folder "/Users/moises/source/qcif/sails-hook-redbox-template", "/opt/hooks/sails-hook-redbox-template", id: "template"
config.vm.synced_folder "/Users/moises/source/qcif/sails-hook-redbox-labarchives", "/opt/hooks/sails-hook-redbox-labarchives", id: "labarchives"
```
Now inside the docker instance of redbox-portal link the hook and your redbox-portal
......@@ -117,7 +116,7 @@ docker exec -it redbox-portal_redboxportal_1 /bin/bash
run npm link in the hook folder
```bash
cd /opt/hooks/sails-hook-redbox-template
cd /opt/hooks/sails-hook-redbox-labarchives
npm link
```
......@@ -126,6 +125,6 @@ now link this alias in your redbox-portal
```bash
cd /opt/redbox-portal
npm link sails-hook-redbox-template
npm link sails-hook-redbox-labarchives
```
const TemplateService = require('../services/TemplateService');
const LabArchivesService = require('../services/LabArchivesService');
module.exports = {
helloWorld: function (req, res, next) {
const hello = TemplateService.helloWorld();
const hello = LabArchivesService.helloWorld();
return res.send(hello);
}
};
module.exports.recordtype = {
"template": {
"labarchives": {
"packageType": "workspace",
searchFilters: [
{
......
module.exports.workflow = {
"template": {
"labarchives": {
"draft": {
config: {
workflow: {
......@@ -10,7 +10,7 @@ module.exports.workflow = {
viewRoles: ['Admin', 'Librarians'],
editRoles: ['Admin', 'Librarians']
},
form: 'example-1.0-draft'
form: 'labarchives-1.0-draft'
},
starting: true
}
......
......@@ -2,8 +2,8 @@
* Template form
*/
module.exports = {
name: 'template-1.0-draft',
type: 'template',
name: 'labarchives-1.0-draft',
type: 'labarchives',
skipValidationOnSave: true,
editCssClasses: 'row col-md-12',
viewCssClasses: 'row col-md-offset-1 col-md-10',
......
const _ = require('lodash');
const TemplateController = require('./api/controllers/TemplateController');
const TemplateService = require('./api/services/TemplateService');
const LabArchivesController = require('./api/controllers/LabArchivesController');
const LabArchivesService = require('./api/services/LabArchivesService');
const recordTypeConfig = require('./config/recordtype.js');
const workflowConfig = require('./config/workflow.js');
const recordFormConfig = require('./form-config/template-1.0-draft.js');
......@@ -17,14 +17,14 @@ module.exports = function (sails) {
routes: {
before: {},
after: {
'get /:branding/:portal/ws/template/hello': TemplateController.helloWorld
'get /:branding/:portal/ws/labarchives/hello': LabArchivesController.helloWorld
}
},
configure: function () {
sails.services['TemplateService'] = TemplateService;
sails.services['LabArchivesService'] = LabArchivesService;
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});
sails.config['form']['forms'] = _.merge(sails.config['form']['forms'], {'labarchives-1.0-draft': recordFormConfig});
}
}
};
{
"name": "@uts-eresearch/sails-hook-redbox-template",
"name": "@uts-eresearch/sails-hook-redbox-labarchives",
"version": "1.0.0",
"description": "A Sails Hook Template",
"description": "A Sails Hook for LabArchives",
"main": "index.js",
"sails": {
"isHook": true,
"hookName": "template"
"hookName": "labarchives"
},
"scripts": {
"test": "NODE_ENV=test node_modules/.bin/mocha"
},
"repository": {
"type": "git",
"url": "git@code.research.uts.edu.au:eresearch/sails-hook-redbox-template.git"
"url": "git@code.research.uts.edu.au:eresearch/sails-hook-redbox-labarchives.git"
},
"keywords": [
"sails",
......
......@@ -2,7 +2,7 @@ const Sails = require('sails').Sails;
const assert = require('assert');
var supertest = require('supertest');
const TemplateService = require('../api/services/TemplateService');
const LabArchivesService = require('../api/services/LabArchivesService');
describe('Basic tests ::', function () {
......@@ -18,7 +18,7 @@ describe('Basic tests ::', function () {
Sails().lift({
hooks: {
// Load the hook
"sails-hook-redbox-template": require('../'),
"sails-hook-redbox-labarchives": require('../'),
// Skip grunt (unless your hook uses it)
"grunt": false
},
......@@ -32,19 +32,19 @@ describe('Basic tests ::', function () {
});
it('should have a service', function (done) {
assert.equal(sails.services['TemplateService'].helloWorld(), 'Hello World');
assert.equal(sails.services['LabArchivesService'].helloWorld(), 'Hello World');
done();
});
it('should have a form', function (done) {
const type = sails.config['form']['forms']['template-1.0-draft']['type'];
assert.equal(type, 'template');
const type = sails.config['form']['forms']['labarchives-1.0-draft']['type'];
assert.equal(type, 'labarchives');
done();
});
it('should have a route', function (done) {
supertest(sails.hooks.http.app)
.get('/:branding/:portal/ws/template/hello')
.get('/:branding/:portal/ws/labarchives/hello')
.expect(200)
.end(function (err, res) {
assert.equal(res.text, 'Hello World');
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment