-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1,032 changed files
with
32,088 additions
and
5,607 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Running Narrative in local Docker | ||
|
||
It is useful to run the Narrative within a local docker container. E.g. this makes it easy to work on Narrative ui locally integrated with a local instance of kbase-ui. | ||
|
||
|
||
|
||
## Narrative | ||
|
||
The following changes are required: | ||
|
||
- omit the line `RUN grunt minify` from /Dockerfile | ||
|
||
- build the image manually. | ||
|
||
The makefile has a tag of 1.0.3, we don't need that, so just use a more convenient "dev" tag for local usage. | ||
|
||
```bash | ||
docker build -t kbase/narrative:dev . | ||
``` | ||
|
||
- start the container using the `scripts/local-dev-run.sh` script. | ||
|
||
This script starts the narrative image using features to integrate it with local kbase-ui. | ||
|
||
```bash | ||
env=ci bash scripts/local-dev-run.sh | ||
``` | ||
|
||
where env sets the ENVIRON environment variable for the Docker container; ci is the environment in which you are working (needs to be same as the ui is running on.) | ||
|
||
- uses the config set $env; makes it easy to test different environments alongside ui | ||
- uses kbase-dev network; allows interoperation with the kbase-ui proxier | ||
- uses name "narrative"; same | ||
- mounts kbase static directory inside container; allows editing files on host and having changes reflected with a Narrative reload | ||
- removes container when done; easy cleanup | ||
- uses "dev" tagged container; matches the docker build task above | ||
|
||
## Notes | ||
|
||
The container can't be killed with Ctrl-C; you'll need to stop it using Docker or another tool like Kitematic. | ||
|
||
If you need to update or change dependencies (bower.json), you'll need to rebuild the image. | ||
|
||
### config.json changes | ||
|
||
The Dockerfile runs 'src/scripts/kb-update-config' to generate '/kb/deployment/ui-common/narrative_version'. This script has the unfortunate side effect of overwriting the config file source in /src/config.json. | ||
This is a little frustrating because it means that a committer has to be very careful to omit this file when building the image for development or testing. | ||
|
||
|
||
## kbase-ui | ||
|
||
The kbase-ui proxier needs to route narrative requests. In order to enable this, the proxier's nginx config needs to be modified: | ||
|
||
- in your kbase-ui repo | ||
|
||
- edit tools/proxier/docker/src/conf/nginx.conf.tmpl | ||
|
||
- comment out the line `proxy_pass https://{{ .Env.deploy_ui_hostname }}/narrative;` and uncomment the line below it | ||
|
||
- comment out the line `proxy_pass https://{{ .Env.deploy_hostname }}/narrative;` and uncomment the line below it. | ||
|
||
- rebuild the proxier image: make proxier-image | ||
|
||
- launch the proxier image: make run-proxier-image env=ci | ||
|
||
## Done? | ||
|
||
You should now be able to navigate to https://ci.kbase.us, log in, and pull a Narrative from the Dashboard. | ||
|
||
## Full Recipe | ||
|
||
TODO: all steps to from zero to hero. | ||
|
||
TODO: copy version of this doc into kbase-ui docs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@root | ||
|
||
module | ||
|
||
tabs | ||
indent 2 | ||
maxlen 100 | ||
|
||
ass | ||
nomen | ||
plusplus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.DS_Store | ||
/node_modules | ||
/npm-debug.log | ||
/.lintcache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
sudo: false # http://docs.travis-ci.com/user/workers/container-based-infrastructure/ | ||
language: node_js | ||
node_js: | ||
- 0.12 | ||
- 4 | ||
- 5 | ||
|
||
before_install: | ||
- mkdir node_modules; ln -s ../ node_modules/d | ||
|
||
notifications: | ||
email: | ||
- medikoo+d@medikoo.com | ||
|
||
script: "npm test && npm run lint" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
v1.0.0 -- 2015.12.04 | ||
- autoBind changes: | ||
- replace `bindTo` argument with options and `resolveContext` option | ||
- Add support `overwriteDefinition` | ||
- Introduce IE11 bug workaround in `lazy` handler | ||
|
||
v0.1.1 -- 2014.04.24 | ||
- Add `autoBind` and `lazy` utilities | ||
- Allow to pass other options to be merged onto created descriptor. | ||
Useful when used with other custom utilties | ||
|
||
v0.1.0 -- 2013.06.20 | ||
Initial (derived from es5-ext project) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (C) 2013 Mariusz Nowak (www.medikoo.com) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# D | ||
## Property descriptor factory | ||
|
||
_Originally derived from [es5-ext](https://github.com/medikoo/es5-ext) package._ | ||
|
||
Defining properties with descriptors is very verbose: | ||
|
||
```javascript | ||
var Account = function () {}; | ||
Object.defineProperties(Account.prototype, { | ||
deposit: { value: function () { | ||
/* ... */ | ||
}, configurable: true, enumerable: false, writable: true }, | ||
withdraw: { value: function () { | ||
/* ... */ | ||
}, configurable: true, enumerable: false, writable: true }, | ||
balance: { get: function () { | ||
/* ... */ | ||
}, configurable: true, enumerable: false } | ||
}); | ||
``` | ||
|
||
D cuts that to: | ||
|
||
```javascript | ||
var d = require('d'); | ||
|
||
var Account = function () {}; | ||
Object.defineProperties(Account.prototype, { | ||
deposit: d(function () { | ||
/* ... */ | ||
}), | ||
withdraw: d(function () { | ||
/* ... */ | ||
}), | ||
balance: d.gs(function () { | ||
/* ... */ | ||
}) | ||
}); | ||
``` | ||
|
||
By default, created descriptor follow characteristics of native ES5 properties, and defines values as: | ||
|
||
```javascript | ||
{ configurable: true, enumerable: false, writable: true } | ||
``` | ||
|
||
You can overwrite it by preceding _value_ argument with instruction: | ||
```javascript | ||
d('c', value); // { configurable: true, enumerable: false, writable: false } | ||
d('ce', value); // { configurable: true, enumerable: true, writable: false } | ||
d('e', value); // { configurable: false, enumerable: true, writable: false } | ||
|
||
// Same way for get/set: | ||
d.gs('e', value); // { configurable: false, enumerable: true } | ||
``` | ||
|
||
### Installation | ||
|
||
$ npm install d | ||
|
||
To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: [Browserify](http://browserify.org/), [Webmake](https://github.com/medikoo/modules-webmake) or [Webpack](http://webpack.github.io/) | ||
|
||
### Other utilities | ||
|
||
#### autoBind(obj, props) _(d/auto-bind)_ | ||
|
||
Define methods which will be automatically bound to its instances | ||
|
||
```javascript | ||
var d = require('d'); | ||
var autoBind = require('d/auto-bind'); | ||
|
||
var Foo = function () { this._count = 0; }; | ||
Object.defineProperties(Foo.prototype, autoBind({ | ||
increment: d(function () { ++this._count; }); | ||
})); | ||
|
||
var foo = new Foo(); | ||
|
||
// Increment foo counter on each domEl click | ||
domEl.addEventListener('click', foo.increment, false); | ||
``` | ||
|
||
#### lazy(obj, props) _(d/lazy)_ | ||
|
||
Define lazy properties, which will be resolved on first access | ||
|
||
```javascript | ||
var d = require('d'); | ||
var lazy = require('d/lazy'); | ||
|
||
var Foo = function () {}; | ||
Object.defineProperties(Foo.prototype, lazy({ | ||
items: d(function () { return []; }) | ||
})); | ||
|
||
var foo = new Foo(); | ||
foo.items.push(1, 2); // foo.items array created and defined directly on foo | ||
``` | ||
|
||
## Tests [![Build Status](https://travis-ci.org/medikoo/d.png)](https://travis-ci.org/medikoo/d) | ||
|
||
$ npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use strict'; | ||
|
||
var copy = require('es5-ext/object/copy') | ||
, normalizeOptions = require('es5-ext/object/normalize-options') | ||
, ensureCallable = require('es5-ext/object/valid-callable') | ||
, map = require('es5-ext/object/map') | ||
, callable = require('es5-ext/object/valid-callable') | ||
, validValue = require('es5-ext/object/valid-value') | ||
|
||
, bind = Function.prototype.bind, defineProperty = Object.defineProperty | ||
, hasOwnProperty = Object.prototype.hasOwnProperty | ||
, define; | ||
|
||
define = function (name, desc, options) { | ||
var value = validValue(desc) && callable(desc.value), dgs; | ||
dgs = copy(desc); | ||
delete dgs.writable; | ||
delete dgs.value; | ||
dgs.get = function () { | ||
if (!options.overwriteDefinition && hasOwnProperty.call(this, name)) return value; | ||
desc.value = bind.call(value, options.resolveContext ? options.resolveContext(this) : this); | ||
defineProperty(this, name, desc); | ||
return this[name]; | ||
}; | ||
return dgs; | ||
}; | ||
|
||
module.exports = function (props/*, options*/) { | ||
var options = normalizeOptions(arguments[1]); | ||
if (options.resolveContext != null) ensureCallable(options.resolveContext); | ||
return map(props, function (desc, name) { return define(name, desc, options); }); | ||
}; |
Oops, something went wrong.