Skip to content

Commit 71d5615

Browse files
committed
Converting build to use grunt
1 parent c0781b4 commit 71d5615

35 files changed

+12476
-1717
lines changed

.gitignore

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
test/localize_test.js
2-
test/qunit_setup.js
3-
1+
/node_modules/

.jshintrc

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"curly": true,
3+
"eqeqeq": true,
4+
"immed": true,
5+
"latedef": true,
6+
"newcap": true,
7+
"noarg": true,
8+
"sub": true,
9+
"undef": true,
10+
"unused": true,
11+
"boss": true,
12+
"eqnull": true,
13+
"node": true
14+
}

.travis.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
language: node_js
2+
node_js:
3+
- "0.11"
4+
before_script:
5+
- npm install -g grunt-cli

CONTRIBUTING.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Contributing
2+
3+
## Important notes
4+
Please don't edit files in the `dist` subdirectory as they are generated via Grunt. You'll find source code in the `src` subdirectory!
5+
6+
### Code style
7+
Regarding code style like indentation and whitespace, **follow the conventions you see used in the source already.**
8+
9+
### PhantomJS
10+
While Grunt can run the included unit tests via [PhantomJS](http://phantomjs.org/), this shouldn't be considered a substitute for the real thing. Please be sure to test the `test/*.html` unit test file(s) in _actual_ browsers.
11+
12+
## Modifying the code
13+
First, ensure that you have the latest [Node.js](http://nodejs.org/) and [npm](http://npmjs.org/) installed.
14+
15+
Test that Grunt's CLI is installed by running `grunt --version`. If the command isn't found, run `npm install -g grunt-cli`. For more information about installing Grunt, see the [getting started guide](http://gruntjs.com/getting-started).
16+
17+
1. Fork and clone the repo.
18+
1. Run `npm install` to install all dependencies (including Grunt).
19+
1. Run `grunt` to grunt this project.
20+
21+
Assuming that you don't see any red, you're ready to go. Just be sure to run `grunt` after making any changes, to ensure that nothing is broken.
22+
23+
## Submitting pull requests
24+
25+
1. Create a new branch, please don't work in your `master` branch directly.
26+
1. Add failing tests for the change you want to make. Run `grunt` to see the tests fail.
27+
1. Fix stuff.
28+
1. Run `grunt` to see if the tests pass. Repeat steps 2-4 until done.
29+
1. Open `test/*.html` unit test file(s) in actual browser to ensure tests pass everywhere.
30+
1. Update the documentation to reflect any changes.
31+
1. Push to your fork and submit a pull request.

Gruntfile.js

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
'use strict';
2+
3+
module.exports = function(grunt) {
4+
5+
// Project configuration.
6+
grunt.initConfig({
7+
// Metadata.
8+
pkg: grunt.file.readJSON('localize.jquery.json'),
9+
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
10+
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
11+
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
12+
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
13+
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
14+
// Task configuration.
15+
clean: {
16+
files: ['dist']
17+
},
18+
coffee: {
19+
compile: {
20+
files: {
21+
'dist/<%= pkg.name %>.js' : 'src/*.coffee',
22+
'test/localize_test.js' : 'test/localize_test.coffee',
23+
'test/qunit_setup.js' : 'test/qunit_setup.coffee'
24+
}
25+
}
26+
},
27+
uglify: {
28+
options: {
29+
banner: '<%= banner %>'
30+
},
31+
dist: {
32+
src: 'dist/<%= pkg.name %>.js',
33+
dest: 'dist/<%= pkg.name %>.min.js'
34+
},
35+
},
36+
qunit: {
37+
all: {
38+
options: {
39+
urls: ['1.7.2', '1.8.3', '1.9.1', '1.10.2', '1.11.0', '2.0.3', '2.1.0'].map(function(version) {
40+
return 'http://localhost:<%= connect.server.options.port %>/test/localize.html?jquery=' + version;
41+
})
42+
}
43+
}
44+
},
45+
connect: {
46+
server: {
47+
options: {
48+
port: 8085 // This is a random port, feel free to change it.
49+
}
50+
}
51+
},
52+
});
53+
54+
// These plugins provide necessary tasks.
55+
grunt.loadNpmTasks('grunt-contrib-clean');
56+
grunt.loadNpmTasks('grunt-contrib-uglify');
57+
grunt.loadNpmTasks('grunt-contrib-qunit');
58+
grunt.loadNpmTasks('grunt-contrib-coffee');
59+
grunt.loadNpmTasks('grunt-contrib-connect');
60+
61+
// Default task.
62+
grunt.registerTask('default', ['connect', 'clean', 'coffee', 'uglify', 'qunit']);
63+
grunt.registerTask('test', ['connect', 'qunit']);
64+
};

LICENSE-MIT

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Copyright (c) 2014 jgolla
2+
3+
Permission is hereby granted, free of charge, to any person
4+
obtaining a copy of this software and associated documentation
5+
files (the "Software"), to deal in the Software without
6+
restriction, including without limitation the rights to use,
7+
copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the
9+
Software is furnished to do so, subject to the following
10+
conditions:
11+
12+
The above copyright notice and this permission notice shall be
13+
included in all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.

README.markdown

-165
This file was deleted.

README.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Localize
2+
3+
A jQuery plugin that makes it easy to i18n your static web site.
4+
5+
## Getting Started
6+
Download the [production version][min] or the [development version][max].
7+
8+
[min]: https://raw.github.com/jgolla/jquery-localize/master/dist/localize.min.js
9+
[max]: https://raw.github.com/jgolla/jquery-localize/master/dist/localize.js
10+
11+
In your web page:
12+
13+
```html
14+
<script src="jquery.js"></script>
15+
<script src="dist/localize.min.js"></script>
16+
<script>
17+
jQuery(function($) {
18+
$.awesome(); // "awesome"
19+
});
20+
</script>
21+
```
22+
23+
## Documentation
24+
_(Coming soon)_
25+
26+
## Examples
27+
_(Coming soon)_
28+
29+
## Release History
30+
_(Nothing yet)_

build/README

-7
This file was deleted.

builder

-2
This file was deleted.

build/jquery.localize.js renamed to dist/jquery.localize.js

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
// Generated by CoffeeScript 1.3.3
1+
2+
/*
3+
Copyright (c) Jim Garvin (http://github.com/coderifous), 2008.
4+
Dual licensed under the GPL (http://dev.jquery.com/browser/trunk/jquery/GPL-LICENSE.txt) and MIT (http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt) licenses.
5+
Written by Jim Garvin (@coderifous) for use on LMGTFY.com.
6+
http://github.com/coderifous/jquery-localize
7+
Based off of Keith Wood's Localisation jQuery plugin.
8+
http://keith-wood.name/localisation.html
9+
*/
10+
211
(function() {
312
var $, normaliseLang;
413

@@ -51,7 +60,7 @@
5160
}
5261
};
5362
jsonCall = function(file, pkg, lang, level) {
54-
var ajaxOptions, successFunc;
63+
var ajaxOptions, errorFunc, successFunc;
5564
if (options.pathPrefix != null) {
5665
file = "" + options.pathPrefix + "/" + file;
5766
}
@@ -60,12 +69,18 @@
6069
notifyDelegateLanguageLoaded(intermediateLangData);
6170
return loadLanguage(pkg, lang, level + 1);
6271
};
72+
errorFunc = function() {
73+
if (options.fallback && options.fallback !== lang) {
74+
return loadLanguage(pkg, options.fallback);
75+
}
76+
};
6377
ajaxOptions = {
6478
url: file,
6579
dataType: "json",
6680
async: false,
6781
timeout: options.timeout != null ? options.timeout : 500,
68-
success: successFunc
82+
success: successFunc,
83+
error: errorFunc
6984
};
7085
if (window.location.protocol === "file:") {
7186
ajaxOptions.error = function(xhr) {

0 commit comments

Comments
 (0)