From dbb5a8e78d1f9b10fb11a806b6f0fdade2f48f05 Mon Sep 17 00:00:00 2001 From: Tim Branyen Date: Wed, 6 Aug 2014 17:11:29 -0400 Subject: [PATCH 1/5] Convert the Gruntfile to CoffeeScript --- Gruntfile.coffee | 22 +++++ Gruntfile.js | 226 ----------------------------------------------- 2 files changed, 22 insertions(+), 226 deletions(-) create mode 100644 Gruntfile.coffee delete mode 100644 Gruntfile.js diff --git a/Gruntfile.coffee b/Gruntfile.coffee new file mode 100644 index 0000000..846112d --- /dev/null +++ b/Gruntfile.coffee @@ -0,0 +1,22 @@ +module.exports = -> + + # Load task configurations. + @loadTasks "build/tasks" + + # Run JSHint and a quick test. + @registerTask "test", [ + "jshint" + "karma:run" + ] + + # When running the default Grunt command, just lint the code. + @registerTask "default", [ + "clean" + "jshint" + "karma:run" + "processhtml" + "copy" + "requirejs" + "styles" + "cssmin" + ] diff --git a/Gruntfile.js b/Gruntfile.js deleted file mode 100644 index 7e2353e..0000000 --- a/Gruntfile.js +++ /dev/null @@ -1,226 +0,0 @@ -module.exports = function(grunt) { - "use strict"; - - grunt.initConfig({ - // Wipe out previous builds and test reporting. - clean: ["dist/", "test/reports"], - - // Run your source code through JSHint's defaults. - jshint: ["app/**/*.js"], - - // This task uses James Burke's excellent r.js AMD builder to take all - // modules and concatenate them into a single file. - requirejs: { - release: { - options: { - mainConfigFile: "app/config.js", - generateSourceMaps: true, - include: ["main"], - insertRequire: ["main"], - out: "dist/source.min.js", - optimize: "uglify2", - - // Since we bootstrap with nested `require` calls this option allows - // R.js to find them. - findNestedDependencies: true, - - // Include a minimal AMD implementation shim. - name: "almond", - - // Setting the base url to the distribution directory allows the - // Uglify minification process to correctly map paths for Source - // Maps. - baseUrl: "dist/app", - - // Wrap everything in an IIFE. - wrap: true, - - // Do not preserve any license comments when working with source - // maps. These options are incompatible. - preserveLicenseComments: false - } - } - }, - - // This task simplifies working with CSS inside Backbone Boilerplate - // projects. Instead of manually specifying your stylesheets inside the - // HTML, you can use `@imports` and this task will concatenate only those - // paths. - styles: { - // Out the concatenated contents of the following styles into the below - // development file path. - "dist/styles.css": { - // Point this to where your `index.css` file is location. - src: "app/styles/index.css", - - // The relative path to use for the @imports. - paths: ["app/styles"], - - // Rewrite image paths during release to be relative to the `img` - // directory. - forceRelative: "/app/img/" - } - }, - - // Minfiy the distribution CSS. - cssmin: { - release: { - files: { - "dist/styles.min.css": ["dist/styles.css"] - } - } - }, - - server: { - options: { - host: "0.0.0.0", - port: 8000 - }, - - development: {}, - - release: { - options: { - prefix: "dist" - } - }, - - test: { - options: { - forever: false, - port: 8001 - } - } - }, - - processhtml: { - release: { - files: { - "dist/index.html": ["index.html"] - } - } - }, - - // Move vendor and app logic during a build. - copy: { - release: { - files: [ - { src: ["app/**"], dest: "dist/" }, - { src: "vendor/**", dest: "dist/" } - ] - } - }, - - compress: { - release: { - options: { - archive: "dist/source.min.js.gz" - }, - - files: ["dist/source.min.js"] - } - }, - - // Unit testing is provided by Karma. Change the two commented locations - // below to either: mocha, jasmine, or qunit. - karma: { - options: { - basePath: process.cwd(), - singleRun: true, - captureTimeout: 7000, - autoWatch: true, - - reporters: ["progress", "coverage"], - browsers: ["PhantomJS"], - - // Change this to the framework you want to use. - frameworks: ["mocha"], - - plugins: [ - "karma-jasmine", - "karma-mocha", - "karma-qunit", - "karma-phantomjs-launcher", - "karma-coverage" - ], - - preprocessors: { - "app/**/*.js": "coverage" - }, - - coverageReporter: { - type: "lcov", - dir: "test/coverage" - }, - - files: [ - // You can optionally remove this or swap out for a different expect. - "vendor/bower/chai/chai.js", - "vendor/bower/requirejs/require.js", - "test/runner.js", - - { pattern: "app/**/*.*", included: false }, - // Derives test framework from Karma configuration. - { - pattern: "test/<%= karma.options.frameworks[0] %>/**/*.spec.js", - included: false - }, - { pattern: "vendor/**/*.js", included: false } - ] - }, - - // This creates a server that will automatically run your tests when you - // save a file and display results in the terminal. - daemon: { - options: { - singleRun: false - } - }, - - // This is useful for running the tests just once. - run: { - options: { - singleRun: true - } - } - }, - - coveralls: { - options: { - coverage_dir: "test/coverage/PhantomJS 1.9.2 (Linux)/" - } - } - }); - - // Grunt contribution tasks. - grunt.loadNpmTasks("grunt-contrib-clean"); - grunt.loadNpmTasks("grunt-contrib-jshint"); - grunt.loadNpmTasks("grunt-contrib-cssmin"); - grunt.loadNpmTasks("grunt-contrib-copy"); - grunt.loadNpmTasks("grunt-contrib-compress"); - - // Third-party tasks. - grunt.loadNpmTasks("grunt-karma"); - grunt.loadNpmTasks("grunt-karma-coveralls"); - grunt.loadNpmTasks("grunt-processhtml"); - - // Grunt BBB tasks. - grunt.loadNpmTasks("grunt-bbb-server"); - grunt.loadNpmTasks("grunt-bbb-requirejs"); - grunt.loadNpmTasks("grunt-bbb-styles"); - - // Create an aliased test task. - grunt.registerTask("test", ["karma:run"]); - - // When running the default Grunt command, just lint the code. - grunt.registerTask("default", [ - "clean", - "jshint", - "processhtml", - "copy", - "requirejs", - "styles", - "cssmin", - //"compress", - ]); -}; From 43ca770e37bf3aeb8f11d649ffc1b4f430b737ae Mon Sep 17 00:00:00 2001 From: Tim Branyen Date: Wed, 6 Aug 2014 17:14:59 -0400 Subject: [PATCH 2/5] Updated Bower configuration Converted dependencies over to new Backbone Boilerplate defaults. Changed the default path to the more standard `bower_components`. --- .bowerrc | 2 +- .gitignore | 2 +- bower.json | 21 +++++++++------------ 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/.bowerrc b/.bowerrc index e751899..5e4a746 100644 --- a/.bowerrc +++ b/.bowerrc @@ -1,4 +1,4 @@ { - "directory": "vendor/bower" + "directory": "bower_components" } diff --git a/.gitignore b/.gitignore index ff807f3..3acbeb4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ /node_modules/ -/vendor/bower/ +/bower_components/ /dist/ /test/coverage/ diff --git a/bower.json b/bower.json index c1a94b0..fb0507f 100644 --- a/bower.json +++ b/bower.json @@ -1,17 +1,14 @@ { "name": "github-viewer", - "dependencies": { - "html5-boilerplate": "~4.3.0", - "almond": "~0.2.6", - "lodash": "~2.2.1", - "lodash-template-loader": "~0.1.3", - "backbone": "~1.1.0", - "jquery": "~2.0.3", - "requirejs": "~2.1.9", - "layoutmanager": "~0.9.4", - "mocha": "~1.14.0", - "chai": "~1.8.1", - "bootstrap": "~3.0.3" + "lodash": "~2.4.1", + "combyne-amd-loader": "~0.1.0", + "backbone": "~1.1.2", + "jquery": "~2.1.1", + "requirejs": "~2.1.14", + "layoutmanager": "~0.9.5", + "mocha": "~1.21.3", + "chai": "~1.9.1", + "pure": "~0.5.0" } } From 5413df3e49f3ec1c4f10fd44dba09993bccf2345 Mon Sep 17 00:00:00 2001 From: Tim Branyen Date: Wed, 6 Aug 2014 17:19:43 -0400 Subject: [PATCH 3/5] Updated the LICENSE date --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 80bc57c..8fe4c2f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2013 Tim Branyen +Copyright (c) 2014 Tim Branyen 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 From d00cbdfd31d90c925a87d360099c04be7d7c09b2 Mon Sep 17 00:00:00 2001 From: Tim Branyen Date: Wed, 6 Aug 2014 17:20:13 -0400 Subject: [PATCH 4/5] Removed useless Backbone Boilerplate example tests This also reconfigures the test runner to use Mocha by default. --- test/index.html | 26 +++++++ test/jasmine/specs/boilerplate/router.spec.js | 17 ---- test/jasmine/specs/example.spec.js | 77 ------------------- test/qunit/specs/boilerplate/router.js | 17 ---- test/qunit/specs/example.spec.js | 60 --------------- test/runner.js | 9 ++- 6 files changed, 34 insertions(+), 172 deletions(-) create mode 100644 test/index.html delete mode 100644 test/jasmine/specs/boilerplate/router.spec.js delete mode 100644 test/jasmine/specs/example.spec.js delete mode 100644 test/qunit/specs/boilerplate/router.js delete mode 100644 test/qunit/specs/example.spec.js diff --git a/test/index.html b/test/index.html new file mode 100644 index 0000000..cad53b6 --- /dev/null +++ b/test/index.html @@ -0,0 +1,26 @@ + + + + + + + + GitHub Viewer Test Suite + + + + + + + +
+ + + + + + + + + + diff --git a/test/jasmine/specs/boilerplate/router.spec.js b/test/jasmine/specs/boilerplate/router.spec.js deleted file mode 100644 index 80e11c1..0000000 --- a/test/jasmine/specs/boilerplate/router.spec.js +++ /dev/null @@ -1,17 +0,0 @@ -define(function(require) { - "use strict"; - - var Backbone = require("backbone"); - var Router = require("router"); - - // Test that the Router exists. - describe("Application Router", function() { - it("exists", function() { - expect(Router).toBeTruthy(); - }); - - it("is a Backbone.Router", function() { - expect(Router.prototype instanceof Backbone.Router).toBe(true); - }); - }); -}); diff --git a/test/jasmine/specs/example.spec.js b/test/jasmine/specs/example.spec.js deleted file mode 100644 index d6375a5..0000000 --- a/test/jasmine/specs/example.spec.js +++ /dev/null @@ -1,77 +0,0 @@ -define(function(require) { - "use strict"; - - describe("one tautology", function() { - it("is a tautology", function() { - expect(true).toBeTruthy(); - }); - - describe("is awesome", function() { - it("is awesome", function() { - expect(1).toBe(1); - }); - }); - }); - - describe("simple tests", function() { - it("increments", function() { - var mike = 0; - - expect(mike++ === 0).toBeTruthy(); - expect(mike === 1).toBeTruthy(); - }); - - it("increments (improved)", function() { - var mike = 0; - - expect(mike++).toBe(0); - expect(mike).toBe(1); - }); - }); - - describe("setUp/tearDown", function() { - beforeEach(function() { - // console.log("Before"); - }); - - afterEach(function() { - // console.log("After"); - }); - - it("example", function() { - // console.log("During"); - }); - - describe("setUp/tearDown", function() { - beforeEach(function() { - // console.log("Before2"); - }); - - afterEach(function() { - // console.log("After2"); - }); - - it("example", function() { - // console.log("During Nested"); - }); - }); - }); - - describe("async", function() { - it("multiple async", function() { - var semaphore = 2; - - setTimeout(function() { - expect(true).toBeTruthy(); - semaphore--; - }, 500); - - setTimeout(function() { - expect(true).toBeTruthy(); - semaphore--; - }, 500); - - waitsFor(function() { return semaphore === 0 }); - }); - }); -}); diff --git a/test/qunit/specs/boilerplate/router.js b/test/qunit/specs/boilerplate/router.js deleted file mode 100644 index 4592381..0000000 --- a/test/qunit/specs/boilerplate/router.js +++ /dev/null @@ -1,17 +0,0 @@ -define(function(require) { - "use strict"; - - var Backbone = require("backbone"); - var Router = require("router"); - - // Specify top level modules so that they don't leak into other modules. - QUnit.module("Router"); - - // Test that the Router exists. - test("Application Router", 2, function() { - ok(Router, "Router constructor exists."); - - ok(Router.prototype instanceof Backbone.Router, - "Router is a Backbone.Router"); - }); -}); diff --git a/test/qunit/specs/example.spec.js b/test/qunit/specs/example.spec.js deleted file mode 100644 index 8c683dd..0000000 --- a/test/qunit/specs/example.spec.js +++ /dev/null @@ -1,60 +0,0 @@ -define(function(require) { - "use strict"; - - test("one tautology", function() { - ok(true); - }); - - module("simple tests"); - - test("increments", function() { - var mike = 0; - - ok(mike++ === 0); - ok(mike === 1); - }); - - test("increments (improved)", function() { - var mike = 0; - - equal(mike++, 0); - equal(mike, 1); - }); - - - module("setUp/tearDown", { - setup: function() { - expect(0); - //console.log("Before"); - }, - - teardown: function() { - expect(0); - //console.log("After"); - } - }); - - test("example", function() { - //console.log("During"); - }); - - module("async"); - - test("multiple async", function() { - expect(2); - - stop(); - - setTimeout( function( ) { - ok(true, "async operation completed"); - start(); - }, 500); - - stop(); - - setTimeout(function() { - ok(true, "async operation completed"); - start(); - }, 500); - }); -}); diff --git a/test/runner.js b/test/runner.js index 29946dd..b8d16bb 100644 --- a/test/runner.js +++ b/test/runner.js @@ -19,7 +19,7 @@ // Set the application endpoint and load the configuration. require.config({ paths: { - underscore: "../vendor/bower/lodash/dist/lodash.underscore" + underscore: "../bower_components/lodash/dist/lodash.underscore" }, baseUrl: "base/app" @@ -31,6 +31,13 @@ ], function(config, _) { + // Ensure templates can be found correctly. + require.config({ + lodashLoader: { + root: "/base/app/templates" + } + }); + var specs = _.chain(karma.files) // Convert the files object to an array of file paths. .map(function(id, file) { return file; }) From 07715d3e04bf1b9e498d342e5a14af0eee2dcd8a Mon Sep 17 00:00:00 2001 From: Tim Branyen Date: Fri, 22 Aug 2014 10:53:32 -0400 Subject: [PATCH 5/5] Add in missing files from previous commits This addds in the new structure for components and all the new build tasks. I've removed the vendor directory as well since we should be promoting Bower/NPM versioned dependencies where possible. --- README.md | 4 +- app/components/commit/item/view.js | 2 +- app/components/commit/list/view.js | 2 +- app/components/repo/item/template.html | 2 +- app/components/repo/item/view.js | 2 +- app/components/repo/list/template.html | 12 +++--- app/components/repo/list/view.js | 2 +- app/components/user/item/template.html | 2 +- app/components/user/item/view.js | 2 +- app/components/user/list/template.html | 10 ++--- app/components/user/list/view.js | 2 +- app/config.js | 46 +++----------------- app/router.js | 5 +-- app/styles/app.styl | 4 ++ app/styles/index.css | 4 +- app/templates/main.html | 2 +- build/tasks/clean.coffee | 8 ++++ build/tasks/copy.coffee | 9 ++++ build/tasks/coveralls.coffee | 7 +++ build/tasks/cssmin.coffee | 8 ++++ build/tasks/jshint.coffee | 7 +++ build/tasks/karma.coffee | 60 ++++++++++++++++++++++++++ build/tasks/processhtml.coffee | 8 ++++ build/tasks/requirejs.coffee | 27 ++++++++++++ build/tasks/server.coffee | 18 ++++++++ build/tasks/styles.coffee | 21 +++++++++ index.html | 3 +- package.json | 30 ++++++------- test/mocha/specs/example.spec.js | 10 ++--- test/runner.js | 21 +-------- vendor/backbone.collectioncache.js | 59 ------------------------- 31 files changed, 231 insertions(+), 168 deletions(-) create mode 100644 build/tasks/clean.coffee create mode 100644 build/tasks/copy.coffee create mode 100644 build/tasks/coveralls.coffee create mode 100644 build/tasks/cssmin.coffee create mode 100644 build/tasks/jshint.coffee create mode 100644 build/tasks/karma.coffee create mode 100644 build/tasks/processhtml.coffee create mode 100644 build/tasks/requirejs.coffee create mode 100644 build/tasks/server.coffee create mode 100644 build/tasks/styles.coffee delete mode 100644 vendor/backbone.collectioncache.js diff --git a/README.md b/README.md index 97ba5a3..3be418b 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Finally, a repository can be clicked and recent commits displayed. ## Running locally ## To run locally you will need to install [Node.js](http://nodejs.org) and -[grunt](http://github.com/gruntjs/grunt). +[Grunt](http://gruntjs.com). ``` bash # Clone the repository. @@ -22,7 +22,7 @@ git clone git://github.com/tbranyen/github-viewer.git cd github-viewer # Install the Node dependencies and Bower dependencies. -npm install -q +npm install # Run the server grunt server diff --git a/app/components/commit/item/view.js b/app/components/commit/item/view.js index c2a886f..17687ea 100644 --- a/app/components/commit/item/view.js +++ b/app/components/commit/item/view.js @@ -4,7 +4,7 @@ define(function(require, exports, module) { var Layout = require("layoutmanager"); var CommitItemView = Layout.extend({ - template: require("ldsh!./template"), + template: require("template!./template"), el: false, diff --git a/app/components/commit/list/view.js b/app/components/commit/list/view.js index 916c274..90a898c 100644 --- a/app/components/commit/list/view.js +++ b/app/components/commit/list/view.js @@ -5,7 +5,7 @@ define(function(require, exports, module) { var Item = require("../item/view"); var Layout = Backbone.Layout.extend({ - template: require("ldsh!./template"), + template: require("template!./template"), beforeRender: function() { this.collection.each(function(commit) { diff --git a/app/components/repo/item/template.html b/app/components/repo/item/template.html index 1009807..b7d1f42 100644 --- a/app/components/repo/item/template.html +++ b/app/components/repo/item/template.html @@ -1 +1 @@ -<%= model.get("name") %> +{{ model.attributes.name }} diff --git a/app/components/repo/item/view.js b/app/components/repo/item/view.js index 0cbe87c..fe49eb3 100644 --- a/app/components/repo/item/view.js +++ b/app/components/repo/item/view.js @@ -4,7 +4,7 @@ define(function(require, exports, module) { var app = require("app"); var Layout = Backbone.Layout.extend({ - template: require("ldsh!./template"), + template: require("template!./template"), tagName: "li", diff --git a/app/components/repo/list/template.html b/app/components/repo/list/template.html index ecf93c4..70a6d5b 100644 --- a/app/components/repo/list/template.html +++ b/app/components/repo/list/template.html @@ -1,12 +1,12 @@ -<% if (repos.isRequest) { %> +{% if repos.isRequest %} -<% } else { %> - <% if (repos.length) { %> +{% else %} + {% if repos.length %}

Repos (<%= repos.length %>)


- <% } else { %> + {% else %}

No repos found.

- <% } %> + {% endif %} -<% } %> +{% endif %} diff --git a/app/components/repo/list/view.js b/app/components/repo/list/view.js index 194b837..8a17b4f 100644 --- a/app/components/repo/list/view.js +++ b/app/components/repo/list/view.js @@ -5,7 +5,7 @@ define(function(require, exports, module) { var Item = require("../item/view"); var Layout = Backbone.Layout.extend({ - template: require("ldsh!./template"), + template: require("template!./template"), className: "repos-wrapper", diff --git a/app/components/user/item/template.html b/app/components/user/item/template.html index 96a4d8b..48daead 100644 --- a/app/components/user/item/template.html +++ b/app/components/user/item/template.html @@ -1 +1 @@ -<%= model.get("login") %> +{{ model.attributes.login }} diff --git a/app/components/user/item/view.js b/app/components/user/item/view.js index 5e63ce7..a00e8b9 100644 --- a/app/components/user/item/view.js +++ b/app/components/user/item/view.js @@ -4,7 +4,7 @@ define(function(require, exports, module) { var app = require("app"); var Layout = Backbone.Layout.extend({ - template: require("ldsh!./template"), + template: require("template!./template"), tagName: "li", diff --git a/app/components/user/list/template.html b/app/components/user/list/template.html index 69f0089..aaa355d 100644 --- a/app/components/user/list/template.html +++ b/app/components/user/list/template.html @@ -1,7 +1,7 @@
- " - name="org" value="<%= users.org || "bocoup" %>"> + @@ -12,9 +12,9 @@
- <% if (users.isRequest) { %> + {% if users.isRequest %} - <% } else { %> + {% else %}
    - <% } %> + {% endif %}
    diff --git a/app/components/user/list/view.js b/app/components/user/list/view.js index df52985..f95142a 100644 --- a/app/components/user/list/view.js +++ b/app/components/user/list/view.js @@ -5,7 +5,7 @@ define(function(require, exports, module) { var Item = require("../item/view"); var Layout = Backbone.Layout.extend({ - template: require("ldsh!./template"), + template: require("template!./template"), serialize: function() { return { users: this.collection }; diff --git a/app/config.js b/app/config.js index 11a4580..48068ad 100644 --- a/app/config.js +++ b/app/config.js @@ -1,43 +1,11 @@ require.config({ paths: { - // Make vendor easier to access. - "vendor": "../vendor", - - // Almond is used to lighten the output filesize. - "almond": "../vendor/bower/almond/almond", - - // Opt for Lo-Dash Underscore compatibility build over Underscore. - "underscore": "../vendor/bower/lodash/dist/lodash.underscore", - - // Map `lodash` to a valid location for the template loader plugin. - "lodash": "../vendor/bower/lodash/dist/lodash", - - // Use the Lo-Dash template loader. - "ldsh": "../vendor/bower/lodash-template-loader/loader", - - // Map remaining vendor dependencies. - "jquery": "../vendor/bower/jquery/jquery", - "backbone": "../vendor/bower/backbone/backbone", - "bootstrap": "../vendor/bower/bootstrap/dist/js/bootstrap", - "layoutmanager": "../vendor/bower/layoutmanager/backbone.layoutmanager", - "collectionCache": "../vendor/backbone.collectioncache" - }, - - shim: { - // This is required to ensure Backbone works as expected within the AMD - // environment. - "backbone": { - // These are the two hard dependencies that will be loaded first. - deps: ["jquery", "underscore"], - - // This maps the global `Backbone` object to `require("backbone")`. - exports: "Backbone" - }, - - // Backbone.CollectionCache depends on Backbone. - "collectionCache": ["backbone"], - - // Twitter Bootstrap depends on jQuery. - "bootstrap": ["jquery"] + "backbone": "../bower_components/backbone/backbone", + "jquery": "../bower_components/jquery/dist/jquery", + "underscore": "../bower_components/lodash/dist/lodash.underscore", + "lodash": "../bower_components/lodash/dist/lodash", + "combyne": "../bower_components/combyne/dist/combyne", + "template": "../bower_components/combyne-amd-loader/loader", + "layoutmanager": "../bower_components/layoutmanager/backbone.layoutmanager" } }); diff --git a/app/router.js b/app/router.js index 79a24fa..e9e2180 100644 --- a/app/router.js +++ b/app/router.js @@ -7,9 +7,6 @@ define(function(require, exports, module) { var User = require("components/user/index"); var Repo = require("components/repo/index"); - require("collectionCache"); - require("bootstrap"); - // Defining the application router, you can attach sub routers here. var Router = Backbone.Router.extend({ initialize: function() { @@ -24,7 +21,7 @@ define(function(require, exports, module) { var Layout = Backbone.Layout.extend({ el: "main", - template: require("ldsh!./templates/main"), + template: require("template!./templates/main"), views: { ".users": new User.Views.List({ collection: this.users }), diff --git a/app/styles/app.styl b/app/styles/app.styl index 6e331b1..91e3ce8 100644 --- a/app/styles/app.styl +++ b/app/styles/app.styl @@ -28,3 +28,7 @@ strong.label border 1px solid #DDD text-overflow ellipsis overflow hidden + cursor pointer + + &:hover + background #EEE diff --git a/app/styles/index.css b/app/styles/index.css index cd08ffc..49dce52 100644 --- a/app/styles/index.css +++ b/app/styles/index.css @@ -1,6 +1,6 @@ -/*-- Bootstrap. -------------------------------------------------------------*/ +/*-- Pure. ------------------------------------------------------------------*/ -@import "../../vendor/bower/bootstrap/dist/css/bootstrap.css"; +@import "../../bower_components/pure/pure.css"; /*-- Application stylesheets. -----------------------------------------------*/ diff --git a/app/templates/main.html b/app/templates/main.html index 3ea5616..8cb485e 100644 --- a/app/templates/main.html +++ b/app/templates/main.html @@ -13,7 +13,7 @@
    diff --git a/build/tasks/clean.coffee b/build/tasks/clean.coffee new file mode 100644 index 0000000..598fbea --- /dev/null +++ b/build/tasks/clean.coffee @@ -0,0 +1,8 @@ +module.exports = -> + @loadNpmTasks "grunt-contrib-clean" + + # Wipe out previous builds and test reporting. + @config "clean", [ + "dist/" + "test/reports" + ] diff --git a/build/tasks/copy.coffee b/build/tasks/copy.coffee new file mode 100644 index 0000000..713e702 --- /dev/null +++ b/build/tasks/copy.coffee @@ -0,0 +1,9 @@ +module.exports = -> + @loadNpmTasks "grunt-contrib-copy" + + # Move vendor and app logic during a build. + @config "copy", + release: + files: [ + src: "bower_components/**", dest: "dist/" + ] diff --git a/build/tasks/coveralls.coffee b/build/tasks/coveralls.coffee new file mode 100644 index 0000000..bfb30e5 --- /dev/null +++ b/build/tasks/coveralls.coffee @@ -0,0 +1,7 @@ +module.exports = -> + @loadNpmTasks "grunt-karma-coveralls" + + # Post code coverage results to Coveralls for tracking. + @config "coveralls", + options: + coverage_dir: "test/coverage" diff --git a/build/tasks/cssmin.coffee b/build/tasks/cssmin.coffee new file mode 100644 index 0000000..b1626c8 --- /dev/null +++ b/build/tasks/cssmin.coffee @@ -0,0 +1,8 @@ +module.exports = -> + @loadNpmTasks "grunt-contrib-cssmin" + + # Minify the distribution CSS. + @config "cssmin", + release: + files: + "dist/styles.min.css": ["dist/styles.css"] diff --git a/build/tasks/jshint.coffee b/build/tasks/jshint.coffee new file mode 100644 index 0000000..18b4551 --- /dev/null +++ b/build/tasks/jshint.coffee @@ -0,0 +1,7 @@ +module.exports = -> + @loadNpmTasks "grunt-contrib-jshint" + + # Run your source code through JSHint's defaults. + @config "jshint", [ + "app/**/*.js" + ] diff --git a/build/tasks/karma.coffee b/build/tasks/karma.coffee new file mode 100644 index 0000000..85b510d --- /dev/null +++ b/build/tasks/karma.coffee @@ -0,0 +1,60 @@ +module.exports = -> + @loadNpmTasks "grunt-karma" + + # Change this to the framework you want to use. + framework = "mocha" + + # Unit testing is provided by Karma. Change the two commented locations + # below to either: mocha, jasmine, or qunit. + @config "karma", + options: + basePath: process.cwd() + singleRun: true + captureTimeout: 7000 + autoWatch: true + logLevel: "ERROR" + + reporters: ["dots", "coverage"] + browsers: ["PhantomJS"] + + frameworks: [framework] + + plugins: [ + "karma-jasmine" + "karma-mocha" + "karma-qunit" + "karma-phantomjs-launcher" + "karma-coverage" + ] + + preprocessors: + "app/**/*.js": "coverage" + + coverageReporter: + type: "lcov" + dir: "test/coverage" + + files: [ + # You can optionally remove this or swap out for a different expect. + "bower_components/assert/assert.js" + "bower_components/requirejs/require.js" + "test/runner.js" + + { pattern: "app/**/*.*", included: false } + { + pattern: "test/#{framework}/**/*.spec.js", + included: false + } + { pattern: "bower_components/**/*.js", included: false } + ] + + # This creates a server that will automatically run your tests when you + # save a file and display results in the terminal. + daemon: + options: + singleRun: false + + # This is useful for running the tests just once. + run: + options: + singleRun: true diff --git a/build/tasks/processhtml.coffee b/build/tasks/processhtml.coffee new file mode 100644 index 0000000..92aabd4 --- /dev/null +++ b/build/tasks/processhtml.coffee @@ -0,0 +1,8 @@ +module.exports = -> + @loadNpmTasks "grunt-processhtml" + + # Convert the development sources to production in the HTML. + @config "processhtml", + release: + files: + "dist/index.html": ["index.html"] diff --git a/build/tasks/requirejs.coffee b/build/tasks/requirejs.coffee new file mode 100644 index 0000000..79bb64a --- /dev/null +++ b/build/tasks/requirejs.coffee @@ -0,0 +1,27 @@ +module.exports = -> + @loadNpmTasks "grunt-contrib-requirejs" + + # This task uses James Burke's excellent r.js AMD builder to take all modules + # and concatenate them into a single file. + @config "requirejs", + release: + options: + mainConfigFile: "app/config.js" + generateSourceMaps: true + include: ["main"] + out: "dist/source.min.js" + optimize: "uglify2" + baseUrl: "app" + + paths: + "almond": "../bower_components/almond/almond" + + # Include a minimal AMD implementation shim. + name: "almond" + + # Wrap everything in an IIFE. + wrap: true + + # Do not preserve any license comments when working with source maps. + # These options are incompatible. + preserveLicenseComments: false diff --git a/build/tasks/server.coffee b/build/tasks/server.coffee new file mode 100644 index 0000000..83aace0 --- /dev/null +++ b/build/tasks/server.coffee @@ -0,0 +1,18 @@ +module.exports = -> + @loadNpmTasks "grunt-bbb-server" + + @config "server", + options: + host: "0.0.0.0" + port: 8000 + + development: {} + + release: + options: + prefix: "dist" + + test: + options: + forever: false + port: 8001 diff --git a/build/tasks/styles.coffee b/build/tasks/styles.coffee new file mode 100644 index 0000000..5d97785 --- /dev/null +++ b/build/tasks/styles.coffee @@ -0,0 +1,21 @@ +module.exports = -> + @loadNpmTasks "grunt-bbb-styles" + + # This task simplifies working with CSS inside Backbone Boilerplate projects. + # Instead of manually specifying your stylesheets inside the HTML, you can + # use `@imports` and this task will concatenate only those paths. + @config "styles", + + # Out the concatenated contents of the following styles into the below + # development file path. + "dist/styles.css": + + # Point this to where your `index.css` file is location. + src: "app/styles/index.css" + + # The relative path to use for the @imports. + paths: ["app/styles"] + + # Rewrite image paths during release to be relative to the `img` + # directory. + forceRelative: "/app/img/" diff --git a/index.html b/index.html index be50bd0..f4fab7b 100644 --- a/index.html +++ b/index.html @@ -19,7 +19,8 @@ - + diff --git a/package.json b/package.json index 19c160b..a876096 100644 --- a/package.json +++ b/package.json @@ -1,32 +1,28 @@ { "name": "github-viewer", "version": "1.0.0", - "devDependencies": { - "grunt": "~0.4.1", - "bbb": "~0.2.0", - "grunt-contrib-jshint": "~0.6.0", - "grunt-contrib-cssmin": "~0.6.1", - "grunt-contrib-copy": "~0.4.1", - "grunt-contrib-clean": "~0.5.0", - "grunt-contrib-compress": "~0.5.2", - "grunt-processhtml": "~0.2.0", + "grunt": "~0.4.5", + "grunt-contrib-jshint": "~0.10.0", + "grunt-contrib-cssmin": "~0.10.0", + "grunt-contrib-copy": "~0.5.0", + "grunt-contrib-clean": "~0.6.0", + "grunt-contrib-requirejs": "~0.4.4", + "grunt-processhtml": "~0.3.3", "grunt-karma": "~0.8.3", - "grunt-karma-coveralls": "~2.0.2", - "karma-jasmine": "~0.1.0", - "karma-mocha": "~0.1.0", - "karma-qunit": "~0.1.0", - "karma-phantomjs-launcher": "~0.1.0", - "karma-coverage": "~0.1.0" + "grunt-karma-coveralls": "~2.5.1", + "grunt-bbb-styles": "~0.1.0-alpha.5", + "grunt-bbb-server": "~0.1.0-alpha.13", + "karma-mocha": "~0.1.6", + "karma-phantomjs-launcher": "~0.1.4", + "karma-coverage": "~0.2.5" }, - "peerDependencies": { "generator-bbb": "*", "bower": "*", "grunt-cli": "*", "coveralls": "*" }, - "scripts": { "test": "grunt karma:run coveralls", "postinstall": "bower install -s" diff --git a/test/mocha/specs/example.spec.js b/test/mocha/specs/example.spec.js index 999f53a..d55bced 100644 --- a/test/mocha/specs/example.spec.js +++ b/test/mocha/specs/example.spec.js @@ -3,21 +3,21 @@ define(function(require) { describe("Simple tests examples", function() { it("should detect true", function() { - expect(true).to.be.true; + assert.toEqual(true, true); }); it("should increments values", function() { var mike = 0; - expect(mike++ === 0).to.be.true; - expect(mike === 1).to.be.true; + assert.toEqual(mike++, 0); + assert.toEqual(mike, 1); }); it("should increments values (improved)", function() { var mike = 0; - expect(mike++).to.equal(0); - expect(mike).to.equal(1); + assert.toEqual(mike++, 0); + assert.toEqual(mike, 1); }); }); diff --git a/test/runner.js b/test/runner.js index b8d16bb..a83c1a1 100644 --- a/test/runner.js +++ b/test/runner.js @@ -7,37 +7,20 @@ // tests. karma.loaded = function() {}; - if (window.QUnit) { - // Disable auto start. We'll call start once the async modules have - // loaded. - window.QUnit.config.autostart = false; - } else if (window.chai) { - // Optionally use chai with Mocha. - window.expect = window.chai.expect; - } - // Set the application endpoint and load the configuration. require.config({ paths: { - underscore: "../bower_components/lodash/dist/lodash.underscore" + combyne: "../bower_components/combyne/dist/combyne" }, baseUrl: "base/app" }); require([ - "config", - "underscore" + "config" ], function(config, _) { - // Ensure templates can be found correctly. - require.config({ - lodashLoader: { - root: "/base/app/templates" - } - }); - var specs = _.chain(karma.files) // Convert the files object to an array of file paths. .map(function(id, file) { return file; }) diff --git a/vendor/backbone.collectioncache.js b/vendor/backbone.collectioncache.js deleted file mode 100644 index 24271a1..0000000 --- a/vendor/backbone.collectioncache.js +++ /dev/null @@ -1,59 +0,0 @@ -/*! - * backbone.collectioncache.js v0.0.1 - * Copyright 2012, Tim Branyen (@tbranyen) - * backbone.layoutmanager.js may be freely distributed under the MIT license. - */ -(function(window) { - -"use strict"; - -// Dependencies -var Backbone = window.Backbone; -var _ = window._; -var $ = window.$; -var sessionStorage = window.sessionStorage; - -// Maintain an in-memory cache. -function Cache() {} -// Set the prototype to sessionStorage. -Cache.prototype = sessionStorage; - -// Create a new Cache. -var cache = new Cache(); - -// Override sync on Collections, allowing them to cache. -Backbone.Collection.prototype.sync = function(method, collection, options) { - // Get the correct URL. - var url = _.isFunction(collection.url) ? collection.url() : collection.url; - - // Call out to Backbone.sync. - if (collection.cache === true && cache[url]) { - // Extract from sessionStroage and place into memory. - if (_.isString(cache[url])) { - cache[url] = JSON.parse(cache[url]); - } - - // Trigger the success with the correct data. - options.success.apply(this, cache[url]); - - // Emulate the jqXHR. - return $.Deferred().resolve(); - } - - // Call out to default implementation. - var jqXHR = Backbone.sync.apply(this, arguments); - - // Wait until complete and if successful, cache! - jqXHR.then(function() { - cache[url] = _.toArray(arguments); - - try { - sessionStorage[url] = JSON.stringify([arguments[0], "success", {}]); - } catch (ex) {} - }); - - // Emulate normal Sync. - return jqXHR; -}; - -})(this);