Skip to content

Commit

Permalink
sets up greeneyes as a nodeJS applciation stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
herereadthis committed Jul 25, 2014
1 parent 63d3bd7 commit aa7cf5e
Show file tree
Hide file tree
Showing 11 changed files with 227 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory": "src/components/"
}
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: node_js
node_js:
- "0.11"
- "0.10"
before_script:
- npm install
- npm install -g grunt-cli
- npm install -g bower
- bower install
script:
- grunt test
54 changes: 54 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

// The "wrapper" function
module.exports = function(grunt) {
// Do grunt-related things in here
// Project configuration.
require('load-grunt-tasks')(grunt);
grunt.initConfig({
// imports the JSON metadata stored in package.json
pkg: grunt.file.readJSON('package.json'),
// compiles LESS file to minified CSS
paths: {
src: './src',
build: './build',
components: './src/components'
},
requirejs: {
build: {
options: {
baseUrl: "<%= paths.src %>/js/",
mainConfigFile: "<%= paths.src %>/js/main.js",
name: "main",
out: "<%= paths.build %>/js/main.js",
optimize: 'uglify2',
}
}
},
uglify: {
options: {
preserveComments: false
},
require: {
files: {
'<%= paths.build %>/js/require.js': ['<%= paths.components %>/**/require.js']
}
}
},
watch: {
// runs less task when any less files change
js: {
files: ['./src/js/*'],
tasks: ['requirejs']
}
}
});

grunt.registerTask('default', [
'requirejs',
'uglify',
'watch'
]);
grunt.registerTask('test', [
'watch'
]);
};
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2014 Jimmy Ha

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.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Greeneyes
========

[![Bower version](https://badge.fury.io/bo/greeneyes.svg)](http://badge.fury.io/bo/greeneyes)
[![Build Status](https://secure.travis-ci.org/herereadthis/greeneyes.svg?branch=master)](http://travis-ci.org/herereadthis/greeneyes)
[![devDependency Status](https://david-dm.org/herereadthis/greeneyes/dev-status.svg)](https://david-dm.org/herereadthis/greeneyes#info=devDependencies)

Greeneyes is an AMD Javascript library of utility modules made for RequireJS"

## Build

```
$ git clone https://github.com/herereadthis/greeneyes.git
$ cd greeneyes/
$ npm install
$ grunt
```


#### Recommended: Add Greeneyes as a Bower dependency

```
$ bower install --save greeneyes
```
30 changes: 30 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "greeneyes",
"version": "0.1.0",
"authors": [
{
"name": "Jimmy Ha",
"homepage": "http://herereadthis.com"
}
],
"description": "AMD Javascript library of utility modules made for RequireJS",
"homepage": "http://herereadthis.com/code/greeneyes",
"main": [
"src/js/analytics.less"
],
"license": "MIT",
"ignore": [
".bowerrc",
".gitignore",
".sass-cache",
".travis.yml",
"docs",
"Gruntfile.js",
"index.html",
"node_modules",
"src/components"
],
"dependencies": {
"requirejs": "~2.1.14"
}
}
5 changes: 5 additions & 0 deletions build/js/main.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build/js/require.js

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "greeneyes",
"version": "0.1.0",
"description": "AMD Javascript library of utility modules made for RequireJS",
"main": "index.html",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/herereadthis/greeneyes.git"
},
"keywords": [
"AMD",
"RequireJS",
"JavaScript"
],
"author": {
"name": "Jimmy Ha",
"email": "herereadthis@gmail.com",
"url": "http://herereadthis.com/"
},
"licenses": [
{
"type": "GPL",
"url": "https://github.com/herereadthis/greeneyes/blob/master/LICENSE"
}
],
"bugs": {
"url": "https://github.com/herereadthis/greeneyes/issues"
},
"homepage": "https://github.com/herereadthis/greeneyes",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-requirejs": "^0.4.4",
"grunt-contrib-uglify": "^0.5.0",
"grunt-contrib-watch": "^0.6.1",
"load-grunt-tasks": "^0.6.0"
}
}
25 changes: 25 additions & 0 deletions src/js/analytics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Google Analytics, defined as an AMD for RequireJS

(function() {
define(function(require) {
var $, exports;
$ = require("jquery");
exports = {
track: function(accountId) {
var ga, s, _gaq;
accountId = $("body").data("google-analytics") || accountId;
_gaq = window._gaq = _gaq || [];
ga = document.createElement("script");
s = document.getElementsByTagName('script')[0];
_gaq.push(['_setAccount', accountId]);
_gaq.push(['_trackPageview']);
console.log(_gaq);
ga.type = "text/javascript";
ga.async = true;
ga.src = ('https:' === document.location.protocol ? 'https://ssl' : 'http://www') + ".google-analytics.com/ga.js";
return s.parentNode.insertBefore(ga, s);
}
};
return exports;
});
}).call(this);
13 changes: 13 additions & 0 deletions src/js/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(function() {
requirejs.config({
paths: {
// google analytics
"Analytics": "analytics",
// jQuery
"jquery": '../components/jquery/dist/jquery.min',
}
});
require(['jquery', 'Analytics'], function($, Analytics) {
return Analytics.track();
});
}).call(this);

0 comments on commit aa7cf5e

Please sign in to comment.