Skip to content

Commit

Permalink
Structure: Yeoman jquery generator
Browse files Browse the repository at this point in the history
  • Loading branch information
tabalinas committed Apr 2, 2015
1 parent e91fb16 commit b639173
Show file tree
Hide file tree
Showing 14 changed files with 349 additions and 8 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
@@ -0,0 +1,16 @@
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[package.json]
indent_style = space
indent_size = 4

[*.md]
trim_trailing_whitespace = false
9 changes: 3 additions & 6 deletions .gitignore
@@ -1,6 +1,3 @@
node_modules/
bower_components/
*.log

build/
dist/
/node_modules/
/bower_components/
dist
18 changes: 18 additions & 0 deletions .jshintrc
@@ -0,0 +1,18 @@
{
"node": true,
"browser": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 4,
"latedef": true,
"newcap": true,
"noarg": true,
"quotmark": "double",
"undef": true,
"unused": true,
"strict": true
}
6 changes: 6 additions & 0 deletions .travis.yml
@@ -0,0 +1,6 @@
sudo: false
language: node_js
node_js:
- 'iojs'
- '0.12'
- '0.10'
102 changes: 102 additions & 0 deletions Gruntfile.js
@@ -0,0 +1,102 @@
"use strict";
module.exports = function(grunt) {
// Load all grunt tasks
require("load-grunt-tasks")(grunt);
// Show elapsed time at the end
require("time-grunt")(grunt);

// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON("package.json"),
banner: "/*! <%= pkg.name %> - v<%= pkg.version %> - " +
"<%= grunt.template.today('yyyy-mm-dd') %>\n" +
"<%= pkg.homepage ? '* ' + pkg.homepage + '\\n' : '' %>" +
"* Copyright (c) <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>;" +
" Licensed MIT */\n",
// Task configuration.
clean: {
files: ["dist"]
},
concat: {
options: {
banner: "<%= banner %>",
stripBanners: true
},
dist: {
src: ["src/<%= pkg.name %>.js"],
dest: "dist/<%= pkg.name %>.js"
}
},
uglify: {
options: {
banner: "<%= banner %>"
},
dist: {
src: "<%= concat.dist.dest %>",
dest: "dist/<%= pkg.name %>.min.js"
}
},
qunit: {
all: {
options: {
urls: ["http://localhost:9000/test/<%= pkg.name %>.html"]
}
}
},
jshint: {
options: {
reporter: require("jshint-stylish")
},
gruntfile: {
options: {
jshintrc: ".jshintrc"
},
src: "Gruntfile.js"
},
src: {
options: {
jshintrc: "src/.jshintrc"
},
src: ["src/**/*.js"]
},
test: {
options: {
jshintrc: "test/.jshintrc"
},
src: ["test/**/*.js"]
}
},
watch: {
gruntfile: {
files: "<%= jshint.gruntfile.src %>",
tasks: ["jshint:gruntfile"]
},
src: {
files: "<%= jshint.src.src %>",
tasks: ["jshint:src", "qunit"]
},
test: {
files: "<%= jshint.test.src %>",
tasks: ["jshint:test", "qunit"]
}
},
connect: {
server: {
options: {
hostname: "*",
port: 9000
}
}
}
});

// Default task.
grunt.registerTask("default", ["jshint", "connect", "qunit", "clean", "concat", "uglify"]);
grunt.registerTask("server", function() {
grunt.log.warn("The `server` task has been deprecated. Use `grunt serve` to start a server.");
grunt.task.run(["serve"]);
});
grunt.registerTask("serve", ["connect", "watch"]);
grunt.registerTask("test", ["jshint", "connect", "qunit"]);
};
30 changes: 28 additions & 2 deletions README.md
@@ -1,2 +1,28 @@
# js-socials
jQuery Social Network Sharing Plugin
# jsSocials

> Simple social networks sharing jQuery plugin

## Getting Started

Download the [production version][min] or the [development version][max].

[min]: https://raw.githubusercontent.com/tabalinas/jquery-js-socials/master/dist/jquery.js-socials.min.js
[max]: https://raw.githubusercontent.com/tabalinas/jquery-js-socials/master/dist/jquery.js-socials.js

In your web page:

```html
<script src="jquery.js"></script>
<script src="dist/js-socials.min.js"></script>
<script>
jQuery(function ($) {
$.awesome(); // "awesome"
});
</script>
```


## License

MIT © Artem Tabalin
9 changes: 9 additions & 0 deletions bower.json
@@ -0,0 +1,9 @@
{
"name": "js-socials",
"version": "0.0.1",
"dependencies": {},
"devDependencies": {
"qunit": "~1.12.0",
"jquery": "~1.11.2"
}
}
32 changes: 32 additions & 0 deletions contributing.md
@@ -0,0 +1,32 @@
# Contributing

## Important notes
Please don't edit files in the `dist` subdirectory as they are generated via Grunt. You'll find source code in the `src` subdirectory!

### Code style
Regarding code style like indentation and whitespace, **follow the conventions you see used in the source already.**

### PhantomJS
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.

## Modifying the code
First, ensure that you have the latest [Node.js](http://nodejs.org/) and [npm](http://npmjs.org/) installed.

Test that Grunt's CLI and Bower are installed by running `grunt --version` and `bower --version`. If the commands aren't found, run `npm install -g grunt-cli bower`. For more information about installing the tools, see the [getting started with Grunt guide](http://gruntjs.com/getting-started) or [bower.io](http://bower.io/) respectively.

1. Fork and clone the repo.
1. Run `npm install` to install all build dependencies (including Grunt).
1. Run `bower install` to install the front-end dependencies.
1. Run `grunt` to grunt this project.

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.

## Submitting pull requests

1. Create a new branch, please don't work in your `master` branch directly.
1. Add failing tests for the change you want to make. Run `grunt` to see the tests fail.
1. Fix stuff.
1. Run `grunt` to see if the tests pass. Repeat steps 2-4 until done.
1. Open `test/*.html` unit test file(s) in actual browser to ensure tests pass everywhere.
1. Update the documentation to reflect any changes.
1. Push to your fork and submit a pull request.
34 changes: 34 additions & 0 deletions package.json
@@ -0,0 +1,34 @@
{
"name": "js-socials",
"version": "0.0.1",
"description": "jsSocials",
"keywords": [
"jquery-plugin",
"social-network",
"sharing",
"social-share"
],
"author": {
"name": "Artem Tabalin",
"email": "tabalinas@gmail.com",
"url": "https://github.com/tabalinas"
},
"repository": "tabalinas/js-socials",
"license": "MIT",
"scripts": {
"test": "grunt"
},
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-concat": "^0.5.0",
"grunt-contrib-connect": "^0.9.0",
"grunt-contrib-jshint": "^0.10.0",
"grunt-contrib-qunit": "^0.5.1",
"grunt-contrib-uglify": "^0.7.0",
"grunt-contrib-watch": "^0.6.1",
"jshint-stylish": "^1.0.0",
"load-grunt-tasks": "^2.0.0",
"time-grunt": "^1.0.0"
}
}
15 changes: 15 additions & 0 deletions src/.jshintrc
@@ -0,0 +1,15 @@
{
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"sub": true,
"undef": true,
"unused": true,
"boss": true,
"eqnull": true,
"browser": true,
"predef": ["jQuery"]
}
8 changes: 8 additions & 0 deletions src/js-socials.js
@@ -0,0 +1,8 @@
(function($) {
$.fn.jsSocials = function() {
return this.each(function(i) {
// Do something to each selected element.
$(this).html("jsSocials" + i);
});
};
}(jQuery));
33 changes: 33 additions & 0 deletions test/.jshintrc
@@ -0,0 +1,33 @@
{
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"sub": true,
"undef": true,
"unused": true,
"boss": true,
"eqnull": true,
"browser": true,
"node": true,
"predef": [
"jQuery",
"QUnit",
"module",
"test",
"asyncTest",
"expect",
"start",
"stop",
"ok",
"equal",
"notEqual",
"deepEqual",
"notDeepEqual",
"strictEqual",
"notStrictEqual",
"throws"
]
}
27 changes: 27 additions & 0 deletions test/js-socials.html
@@ -0,0 +1,27 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>jsSocials Test Suite</title>
<!-- Load local jQuery. -->
<script src="../bower_components/jquery/dist/jquery.js"></script>
<!-- Load local QUnit. -->
<link rel="stylesheet" href="../bower_components/qunit/qunit/qunit.css" media="screen">
<script src="../bower_components/qunit/qunit/qunit.js"></script>
<!-- Load local lib and tests. -->
<script src="../src/js-socials.js"></script>
<script src="js-socials_test.js"></script>
<!-- Removing access to jQuery and $. But it'll still be available as _$, if
you REALLY want to mess around with jQuery in the console. REMEMBER WE
ARE TESTING A PLUGIN HERE, THIS HELPS ENSURE BEST PRACTICES. REALLY. -->
<script>window._$ = jQuery.noConflict(true);</script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture">
<span>lame test markup</span>
<span>normal test markup</span>
<span>awesome test markup</span>
</div>
</body>
</html>
18 changes: 18 additions & 0 deletions test/js-socials_test.js
@@ -0,0 +1,18 @@
(function($) {
module("jQuery#jsSocials", {
setup: function() {
this.elems = $("#qunit-fixture").children();
}
});

test("is chainable", function() {
expect(1);
strictEqual(this.elems.jsSocials(), this.elems, "should be chainable");
});

test("is jsSocials", function() {
expect(1);
strictEqual(this.elems.jsSocials().text(), "jsSocials0jsSocials1jsSocials2", "should be jsSocials");
});

}(jQuery));

0 comments on commit b639173

Please sign in to comment.