Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
eResearch
sails-hook-redbox-labarchives
Commits
01a76d3f
Commit
01a76d3f
authored
Nov 23, 2018
by
Moises Sacal
Browse files
issue
#2
parent
cfa9f075
Changes
9
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
01a76d3f
## 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-
git
lab
npm
link
sails-hook-redbox-lab
archives
```
## 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
```
api/controllers/
Template
Controller.js
→
api/controllers/
LabArchives
Controller.js
View file @
01a76d3f
const
Template
Service
=
require
(
'
../services/
Template
Service
'
);
const
LabArchives
Service
=
require
(
'
../services/
LabArchives
Service
'
);
module
.
exports
=
{
helloWorld
:
function
(
req
,
res
,
next
)
{
const
hello
=
Template
Service
.
helloWorld
();
const
hello
=
LabArchives
Service
.
helloWorld
();
return
res
.
send
(
hello
);
}
};
api/services/
Template
Service.js
→
api/services/
LabArchives
Service.js
View file @
01a76d3f
File moved
config/recordtype.js
View file @
01a76d3f
module
.
exports
.
recordtype
=
{
"
template
"
:
{
"
labarchives
"
:
{
"
packageType
"
:
"
workspace
"
,
searchFilters
:
[
{
...
...
config/workflow.js
View file @
01a76d3f
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
}
...
...
form-config/template-1.0-draft.js
View file @
01a76d3f
...
...
@@ -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
'
,
...
...
index.js
View file @
01a76d3f
const
_
=
require
(
'
lodash
'
);
const
Template
Controller
=
require
(
'
./api/controllers/
Template
Controller
'
);
const
Template
Service
=
require
(
'
./api/services/
Template
Service
'
);
const
LabArchives
Controller
=
require
(
'
./api/controllers/
LabArchives
Controller
'
);
const
LabArchives
Service
=
require
(
'
./api/services/
LabArchives
Service
'
);
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
'
:
Template
Controller
.
helloWorld
'
get /:branding/:portal/ws/
labarchives/hello
'
:
LabArchives
Controller
.
helloWorld
}
},
configure
:
function
()
{
sails
.
services
[
'
Template
Service
'
]
=
Template
Service
;
sails
.
services
[
'
LabArchives
Service
'
]
=
LabArchives
Service
;
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
});
}
}
};
package.json
View file @
01a76d3f
{
"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"
,
...
...
test/dependencies.spec.js
View file @
01a76d3f
...
...
@@ -2,7 +2,7 @@ const Sails = require('sails').Sails;
const
assert
=
require
(
'
assert
'
);
var
supertest
=
require
(
'
supertest
'
);
const
Template
Service
=
require
(
'
../api/services/
Template
Service
'
);
const
LabArchives
Service
=
require
(
'
../api/services/
LabArchives
Service
'
);
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
[
'
Template
Service
'
].
helloWorld
(),
'
Hello World
'
);
assert
.
equal
(
sails
.
services
[
'
LabArchives
Service
'
].
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
'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment