Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some Javascript frameworks #569

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions js-frameworks/knockout/.npmignore
@@ -0,0 +1,4 @@
# Only package the build output for npm. Developers who want sources/tests can get them from the KO repo.
*
!build/output/knockout-latest.js
!build/output/knockout-latest.debug.js
1 change: 1 addition & 0 deletions js-frameworks/knockout/.travis.yml
@@ -0,0 +1 @@
language: node_js
179 changes: 179 additions & 0 deletions js-frameworks/knockout/Gruntfile.js
@@ -0,0 +1,179 @@
/*global module:false*/
module.exports = function(grunt) {
var _ = grunt.util._;

// Project configuration
grunt.initConfig({
// Metadata
pkg: grunt.file.readJSON('package.json'),
fragments: './build/fragments/',
banner: '/*!\n' +
' * Knockout JavaScript library v<%= pkg.version %>\n' +
' * (c) Steven Sanderson - <%= pkg.homepage %>\n' +
' * License: <%= pkg.licenses[0].type %> (<%= pkg.licenses[0].url %>)\n' +
' */\n\n',

checktrailingspaces: {
main: {
src: [
"**/*.{js,html,css,bat,ps1,sh}",
"!build/output/**",
"!node_modules/**"
],
filter: 'isFile'
}
},
build: {
debug: './build/output/knockout-latest.debug.js',
min: './build/output/knockout-latest.js'
},
dist: {
debug: './dist/knockout.debug.js',
min: './dist/knockout.js'
},
test: {
phantomjs: 'spec/runner.phantom.js',
node: 'spec/runner.node.js'
}
});

grunt.registerTask('clean', 'Clean up output files.', function (target) {
var output = grunt.config('build');
var files = [ output.debug, output.min ];
var options = { force: (target == 'force') };
_.forEach(files, function (file) {
if (grunt.file.exists(file))
grunt.file.delete(file, options);
});
return !this.errorCount;
});

var trailingSpaceRegex = /[ ]$/;
grunt.registerMultiTask('checktrailingspaces', 'checktrailingspaces', function() {
var matches = [];
this.files[0].src.forEach(function(filepath) {
var content = grunt.file.read(filepath),
lines = content.split(/\r*\n/);
lines.forEach(function(line, index) {
if (trailingSpaceRegex.test(line)) {
matches.push([filepath, (index+1), line].join(':'));
}
});
});
if (matches.length) {
grunt.log.error("The following files have trailing spaces that need to be cleaned up:");
grunt.log.writeln(matches.join('\n'));
return false;
}
});

function getReferencedSources(sourceReferencesFilename) {
// Returns the array of filenames referenced by a file like source-references.js
var result;
global.knockoutDebugCallback = function(sources) { result = sources; };
eval(grunt.file.read(sourceReferencesFilename));
return result;
}

function getCombinedSources() {
var fragments = grunt.config('fragments'),
sourceFilenames = [
fragments + 'extern-pre.js',
fragments + 'amd-pre.js',
getReferencedSources(fragments + 'source-references.js'),
fragments + 'amd-post.js',
fragments + 'extern-post.js'
],
flattenedSourceFilenames = Array.prototype.concat.apply([], sourceFilenames),
combinedSources = flattenedSourceFilenames.map(function(filename) {
return grunt.file.read('./' + filename);
}).join('');

return combinedSources.replace('##VERSION##', grunt.config('pkg.version'));
}

function buildDebug(output) {
var source = [];
source.push(grunt.config('banner'));
source.push('(function(){\n');
source.push('var DEBUG=true;\n');
source.push(getCombinedSources());
source.push('})();\n');
grunt.file.write(output, source.join('').replace(/\r\n/g, '\n'));
}

function buildMin(output, done) {
var cc = require('closure-compiler');
var options = {
compilation_level: 'ADVANCED_OPTIMIZATIONS',
output_wrapper: '(function() {%output%})();'
};
grunt.log.write('Compiling...');
cc.compile('/**@const*/var DEBUG=false;' + getCombinedSources(), options, function (err, stdout, stderr) {
if (err) {
grunt.log.error(err);
done(false);
} else {
grunt.log.ok();
grunt.file.write(output, (grunt.config('banner') + stdout).replace(/\r\n/g, '\n'));
done(true);
}
});
}

grunt.registerMultiTask('build', 'Build', function() {
if (!this.errorCount) {
var output = this.data;
if (this.target === 'debug') {
buildDebug(output);
} else if (this.target === 'min') {
buildMin(output, this.async());
}
}
return !this.errorCount;
});

grunt.registerMultiTask('test', 'Run tests', function () {
var done = this.async();
grunt.util.spawn({ cmd: this.target, args: [this.data] },
function (error, result, code) {
if (code === 127 /*not found*/) {
grunt.verbose.error(result.stderr);
// ignore this error
done(true);
} else {
grunt.log.writeln(result.stdout);
if (error)
grunt.log.error(result.stderr);
done(!error);
}
}
);
});

grunt.registerTask('dist', function() {
// Update the version in bower.json
var bowerConfig = grunt.file.readJSON('bower.json'),
version = grunt.config('pkg.version');
bowerConfig.version = version;
grunt.file.write('bower.json', JSON.stringify(bowerConfig, true, 2));

var buildConfig = grunt.config('build'),
distConfig = grunt.config('dist');
grunt.file.copy(buildConfig.debug, distConfig.debug);
grunt.file.copy(buildConfig.min, distConfig.min);

console.log('To publish, run:');
console.log(' git add bower.json');
console.log(' git add -f ' + distConfig.debug);
console.log(' git add -f ' + distConfig.min);
console.log(' git checkout head');
console.log(' git commit -m \'Version ' + version + ' for distribution\'');
console.log(' git tag -a v' + version + ' -m \'Add tag v' + version + '\'');
console.log(' git checkout master');
console.log(' git push origin --tags');
});

// Default task.
grunt.registerTask('default', ['clean', 'checktrailingspaces', 'build', 'test']);
};
22 changes: 22 additions & 0 deletions js-frameworks/knockout/LICENSE
@@ -0,0 +1,22 @@
The MIT License (MIT) - http://www.opensource.org/licenses/mit-license.php

Copyright (c) Steven Sanderson, the Knockout.js team, and other contributors
http://knockoutjs.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.
50 changes: 50 additions & 0 deletions js-frameworks/knockout/README.md
@@ -0,0 +1,50 @@
**Knockout** is a JavaScript [MVVM](http://en.wikipedia.org/wiki/Model_View_ViewModel) (a modern variant of MVC) library that makes it easier to create rich, desktop-like user interfaces with JavaScript and HTML. It uses *observers* to make your UI automatically stay in sync with an underlying data model, along with a powerful and extensible set of *declarative bindings* to enable productive development.

##Getting started

[![Join the chat at https://gitter.im/knockout/knockout](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/knockout/knockout?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

**Totally new to Knockout?** The most fun place to start is the [online interactive tutorials](http://learn.knockoutjs.com/).

For more details, see

* Documentation on [the project's website](http://knockoutjs.com/documentation/introduction.html)
* Online examples at [http://knockoutjs.com/examples/](http://knockoutjs.com/examples/)

##Downloading Knockout

You can [download released versions of Knockout](http://knockoutjs.com/downloads/) from the project's website.

For Node.js developers, Knockout is also available from [npm](https://npmjs.org/) - just run `npm install knockout`.

##Building Knockout from sources

If you prefer to build the library yourself:

1. **Clone the repo from GitHub**

git clone https://github.com/knockout/knockout.git
cd knockout

2. **Acquire build dependencies.** Make sure you have [Node.js](http://nodejs.org/) installed on your workstation. This is only needed to _build_ Knockout from sources. Knockout itself has no dependency on Node.js once it is built (it works with any server technology or none). Now run:

npm install -g grunt-cli
npm install

The first `npm` command sets up the popular [Grunt](http://gruntjs.com/) build tool. You might need to run this command with `sudo` if you're on Linux or Mac OS X, or in an Administrator command prompt on Windows. The second `npm` command fetches the remaining build dependencies.

3. **Run the build tool**

grunt

Now you'll find the built files in `build/output/`.

## Running the tests

If you have [phantomjs](http://phantomjs.org/download.html) installed, then the `grunt` script will automatically run the specification suite and report its results.

Or, if you want to run the specs in a browser (e.g., for debugging), simply open `spec/runner.html` in your browser.

##License

MIT license - [http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php)
26 changes: 26 additions & 0 deletions js-frameworks/knockout/bower.json
@@ -0,0 +1,26 @@
{
"name": "knockout",
"version": "3.3.0",
"homepage": "http://knockoutjs.com/",
"description": "Knockout makes it easier to create rich, responsive UIs with JavaScript",
"main": "dist/knockout.js",
"moduleType": [
"amd",
"globals",
"node"
],
"keywords": [
"knockout",
"mvvm",
"mvc",
"spa"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"spec",
"build/output"
]
}
1 change: 1 addition & 0 deletions js-frameworks/knockout/build/fragments/amd-post.js
@@ -0,0 +1 @@
}));
13 changes: 13 additions & 0 deletions js-frameworks/knockout/build/fragments/amd-pre.js
@@ -0,0 +1,13 @@
(function(factory) {
// Support three module loading scenarios
if (typeof define === 'function' && define['amd']) {
// [1] AMD anonymous module
define(['exports', 'require'], factory);
} else if (typeof require === 'function' && typeof exports === 'object' && typeof module === 'object') {
// [2] CommonJS/Node.js
factory(module['exports'] || exports); // module.exports is for Node.js
} else {
// [3] No module loader (plain <script> tag) - put directly in global namespace
factory(window['ko'] = {});
}
}(function(koExports, amdRequire){
1 change: 1 addition & 0 deletions js-frameworks/knockout/build/fragments/extern-post.js
@@ -0,0 +1 @@
}());
8 changes: 8 additions & 0 deletions js-frameworks/knockout/build/fragments/extern-pre.js
@@ -0,0 +1,8 @@
(function(undefined){
// (0, eval)('this') is a robust way of getting a reference to the global object
// For details, see http://stackoverflow.com/questions/14119988/return-this-0-evalthis/14120023#14120023
var window = this || (0, eval)('this'),
document = window['document'],
navigator = window['navigator'],
jQueryInstance = window["jQuery"],
JSON = window["JSON"];
56 changes: 56 additions & 0 deletions js-frameworks/knockout/build/fragments/source-references.js
@@ -0,0 +1,56 @@
knockoutDebugCallback([
'src/namespace.js',
'src/google-closure-compiler-utils.js',
'src/version.js',
'src/utils.js',
'src/utils.domData.js',
'src/utils.domNodeDisposal.js',
'src/utils.domManipulation.js',
'src/memoization.js',
'src/tasks.js',
'src/subscribables/extenders.js',
'src/subscribables/subscribable.js',
'src/subscribables/dependencyDetection.js',
'src/subscribables/observable.js',
'src/subscribables/observableArray.js',
'src/subscribables/observableArray.changeTracking.js',
'src/subscribables/dependentObservable.js',
'src/subscribables/mappingHelpers.js',
'src/binding/selectExtensions.js',
'src/binding/expressionRewriting.js',
'src/virtualElements.js',
'src/binding/bindingProvider.js',
'src/binding/bindingAttributeSyntax.js',
'src/components/loaderRegistry.js',
'src/components/defaultLoader.js',
'src/components/customElements.js',
'src/components/componentBinding.js',
'src/binding/defaultBindings/attr.js',
'src/binding/defaultBindings/checked.js',
'src/binding/defaultBindings/css.js',
'src/binding/defaultBindings/enableDisable.js',
'src/binding/defaultBindings/event.js',
'src/binding/defaultBindings/foreach.js',
'src/binding/defaultBindings/hasfocus.js',
'src/binding/defaultBindings/html.js',
'src/binding/defaultBindings/ifIfnotWith.js',
'src/binding/defaultBindings/options.js',
'src/binding/defaultBindings/selectedOptions.js',
'src/binding/defaultBindings/style.js',
'src/binding/defaultBindings/submit.js',
'src/binding/defaultBindings/text.js',
'src/binding/defaultBindings/textInput.js',
'src/binding/defaultBindings/uniqueName.js',
'src/binding/defaultBindings/value.js',
'src/binding/defaultBindings/visible.js',
// click depends on event - The order matters for specs, which includes each file individually
'src/binding/defaultBindings/click.js',
'src/templating/templateEngine.js',
'src/templating/templateRewriting.js',
'src/templating/templateSources.js',
'src/templating/templating.js',
'src/binding/editDetection/compareArrays.js',
'src/binding/editDetection/arrayToDomNodeChildren.js',
'src/templating/native/nativeTemplateEngine.js',
'src/templating/jquery.tmpl/jqueryTmplTemplateEngine.js'
]);