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

Feature/curljs #92

Merged
merged 43 commits into from
Oct 30, 2013
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
737d79f
simplify sqwidget layout to be more suitable for module
purge Oct 2, 2013
4b0504a
prepackage to compile
purge Oct 2, 2013
84a03da
works via npm install
purge Oct 2, 2013
b45f984
produce optimized rjs blob
purge Oct 2, 2013
c135d52
prepublish dist
purge Oct 3, 2013
6ad530f
test helper
purge Oct 3, 2013
4780dd7
add to DOM
purge Oct 3, 2013
c645990
read optimized package instead
purge Oct 10, 2013
d851058
import correct index
purge Oct 11, 2013
abfe7ad
don't use subdirectory for prepublish
purge Oct 14, 2013
ea23890
temporarily add built file
purge Oct 14, 2013
a4268d9
remove big deps
purge Oct 16, 2013
ece554c
domready
purge Oct 16, 2013
b532ffa
domready
purge Oct 16, 2013
dfb9032
sigh.
purge Oct 16, 2013
a461611
start of scaffold
purge Oct 17, 2013
3df627b
use grunt task for rendering rjs
purge Oct 18, 2013
2fb7e83
scaffold
purge Oct 21, 2013
ddcc507
install grunt scaffold globally
purge Oct 22, 2013
194152f
force overwrite
purge Oct 22, 2013
0d1d2fe
use symlink instead
purge Oct 22, 2013
fc843f9
i18n generator
purge Oct 23, 2013
1ffb841
demo of i18n support
purge Oct 23, 2013
e3b3c1e
clean up
purge Oct 25, 2013
ab61760
convert to curljs
purge Oct 25, 2013
5b187eb
build example for test
purge Oct 25, 2013
69b06b6
use patched grunt init. fix postinstall
purge Oct 25, 2013
2ffc011
auto build from template, use curljs, i18n port
purge Oct 25, 2013
2e6650c
working ractive plugin
purge Oct 25, 2013
4da1321
compile less
purge Oct 25, 2013
666eb96
cross domain test
purge Oct 25, 2013
822aa03
i18n rewrite (untested)
purge Oct 26, 2013
9d06740
ignore if not available
purge Oct 26, 2013
7120997
scaffold doesn't have any explicit names now and is entirely rjs comp…
purge Oct 27, 2013
4185522
clean up
purge Oct 27, 2013
5282116
move i18n to sqwidget plugin
purge Oct 28, 2013
e424660
put back locale
purge Oct 28, 2013
da26630
move around
purge Oct 28, 2013
a0c121b
more optional deps
purge Oct 28, 2013
3658f0e
coffee -> js
purge Oct 28, 2013
d93ef8b
add moment as a optioanl dep
purge Oct 28, 2013
53dd0d2
correct path
purge Oct 28, 2013
87933ef
fixed a bug whereby bower creates the eventEmitter directory whilst m…
csolar Oct 29, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bowerrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"directory": "sqwidget/lib"
"directory": "src/lib"
}
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
.DS_Store
node_modules/
config.js

# temporary!
compiled/**/*.*
src/lib/
dist/
compiled/
sqwidget.js
example-widget/
5 changes: 5 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
npm-debug.log
node_modules
src
test
compiled
86 changes: 19 additions & 67 deletions Gruntfile.coffee
Original file line number Diff line number Diff line change
@@ -1,94 +1,46 @@
module.exports = (grunt) ->

grunt.loadNpmTasks 'grunt-contrib-coffee'
grunt.loadNpmTasks 'grunt-contrib-clean'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😦

grunt.loadNpmTasks 'grunt-contrib-watch'
grunt.loadNpmTasks 'grunt-contrib-connect'
grunt.loadNpmTasks 'grunt-karma'
grunt.loadNpmTasks 'grunt-shell'

grunt.initConfig

clean:
all:
src: [ "compiled" ]
src: [ "compiled", "dist" ]

connect:
publisher:
options:
port: 8000
base: 'publisher'
base: '.'

sqwidget:
options:
port: 8001
base: 'sqwidget'

widgets:
options:
middleware: (connect, options) -> [
(req, res, next) ->
res.setHeader('Access-Control-Allow-Origin', '*')
next()
connect.static(options.base)
]
port: 8002
base: 'widgets'

coffee:
tests:
expand: true
cwd: 'sqwidget/tests',
src: '**/*.coffee'
dest: 'compiled/tests/js'
ext: '.js'
options:
sourceRoot: '../../../app'
bare: true
sourceMap: false

sqwidget:
expand: true
cwd: 'sqwidget/app',
src: '**/*.coffee'
dest: 'compiled/sqwidget/js'
ext: '.js'
options:
sourceRoot: '../../../app'
bare: true
sourceMap: true

widgets:
expand: true
cwd: 'widgets/',
src: '**/*.coffee'
dest: 'compiled/widgets/js'
ext: '.js'
options:
bare: true
sourceMap: true
base: 'example-widget'

karma:
integration:
configFile: 'config/karma.conf.js',
configFile: 'karma.conf.js',

watch:
sqwidget:
files: ["sqwidget/app/**/*.coffee"]
tasks: ["build"]
shell:
build_example:
command: "./build_example.sh"

widgets:
files: ["widgets/**/*.coffee"]
watch:
scaffold:
files: [
"grunt-scaffold/root/main.js"
"grunt-scaffold/root/app/**/*.js"
"grunt-scaffold/**/*.tmpl"
]
tasks: ["build"]

karma:
files: ["sqwidget/**/*.coffee", "sqwidget/tests/**/*.coffee"]
tasks: ["build", "karma"]

grunt.loadNpmTasks('grunt-contrib-coffee')
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect')
grunt.loadNpmTasks('grunt-contrib-copy')
grunt.loadNpmTasks('grunt-karma')

grunt.registerTask "build", [ "coffee" ]
grunt.registerTask "test", [ "clean", "build", "karma", "watch:karma" ]
grunt.registerTask "build", [ "shell:build_example" ]
grunt.registerTask "test", [ "clean", "build", "karma" ]
grunt.registerTask "default", [ "clean", "build", "connect", "watch" ]

21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
PATH := ./node_modules/.bin:${PATH}

.PHONY : init bower build test dist publish

init: bower
npm install

build:
grunt build

test:
grunt test

bower:
bower install

dist:
grunt dist
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no task dist in Gruntfile.coffee


publish: dist
npm publish
14 changes: 4 additions & 10 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@
"name": "sqwidget",
"version": "0.0.1",
"dependencies": {
"underscore-amd" : "",
"backbone-amd" : "",
"requirejs": "",
"requirejs-i18n": "",
"jquery": "",
"require-css": "",
"requirejs-text": "",
"requirejs-ractive": "",
"ractive": "",
"normalize-css": ""
"curl": "~0.8.4",
"bonzo": "~1.3.6",
"qwery": "~3.4.1",
"eventEmitter": "[email protected]:Wolfy87/EventEmitter.git#master"
}
}
9 changes: 9 additions & 0 deletions build_example.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

rm -Rf example-widget
mkdir example-widget
cd example-widget
../node_modules/grunt-init/bin/grunt-init ../grunt-scaffold --yes
npm install
bower install
grunt build
2 changes: 2 additions & 0 deletions grunt-scaffold/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
root/bower.json
root/package.json
5 changes: 5 additions & 0 deletions grunt-scaffold/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

mkdir -p ~/.grunt-init
rm -f ~/.grunt-init/sqwidget
ln -fs . ~/.grunt-init/sqwidget
8 changes: 8 additions & 0 deletions grunt-scaffold/rename.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"app/lib/**/*": false,
"app/nls/**/*": false,
"dist/**/*": false,
"node_modules/**/*": false,
"bower.json.tmpl": "bower.json",
"package.json.tmpl": "package.json"
}
3 changes: 3 additions & 0 deletions grunt-scaffold/root/.bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory": "app/lib"
}
3 changes: 3 additions & 0 deletions grunt-scaffold/root/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
app/nls
app/lib
app/compiled
49 changes: 49 additions & 0 deletions grunt-scaffold/root/Gruntfile.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
module.exports = (grunt) ->

grunt.loadNpmTasks 'grunt-contrib-less'
grunt.loadTasks 'tasks'

grunt.initConfig

jshint:
options:
curly: true
eqeqeq: true
immed: true
latedef: true
newcap: true
noarg: true
sub: true
undef: true
unused: true
boss: true
eqnull: true
browser: true

clean:
all:
src: [ "compiled", "dist" ]

connect:
widget:
options:
port: 8080
base: '.'

watch:
widget:
files: ["app/src/**/*"]
tasks: ["build"]

'requirejs-i18n':
widget:
options:
src: 'app/i18n.yml'
dest: 'app/nls/'
less:
widget:
files:
"app/compiled/css/main.css": "app/less/main.less"

grunt.registerTask 'default', ['build', 'connect', 'watch']
grunt.registerTask 'build', ['less:widget', 'requirejs-i18n:widget']
1 change: 1 addition & 0 deletions grunt-scaffold/root/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

5 changes: 5 additions & 0 deletions grunt-scaffold/root/app/i18n.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
en-gb:
hello: "Hello"

fr-fr:
hello: "Bonjour"
21 changes: 21 additions & 0 deletions grunt-scaffold/root/app/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
define([
'Ractive',
'./plugin/i18n!./nls/strings',
'./plugin/rv!./templates/index.html',
'css!./compiled/css/main',
], function(Ractive, strings, template ) {

var module = { views: {} };

module.Controller = function (opts) {
this.view = new Ractive({
el: opts.el,
template: template,
data: {
message: strings.root.hello + " World"
}
});
};

return module;
});
1 change: 1 addition & 0 deletions grunt-scaffold/root/app/less/main.less
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
h1 { color: red; }
52 changes: 52 additions & 0 deletions grunt-scaffold/root/app/plugin/_fetchText.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
define(/*=='curl/plugin/_fetchText',==*/ [], function () {

var xhr, progIds;

progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];

xhr = function () {
if (typeof XMLHttpRequest !== "undefined") {
// rewrite the getXhr method to always return the native implementation
xhr = function () {
return new XMLHttpRequest();
};
}
else {
// keep trying progIds until we find the correct one, then rewrite the getXhr method
// to always return that one.
var noXhr = xhr = function () {
throw new Error("getXhr(): XMLHttpRequest not available");
};
while (progIds.length > 0 && xhr === noXhr) (function (id) {
try {
new ActiveXObject(id);
xhr = function () {
return new ActiveXObject(id);
};
}
catch (ex) {
}
}(progIds.shift()));
}
return xhr();
};

function fetchText (url, callback, errback) {
var x = xhr();
x.open('GET', url, true);
x.onreadystatechange = function (e) {
if (x.readyState === 4) {
if (x.status < 400) {
callback(x.responseText);
}
else {
errback(new Error('fetchText() failed. status: ' + x.statusText));
}
}
};
x.send(null);
}

return fetchText;

});
Loading