From 77db6a3d255ad2baa457e76272063e04a7ce927c Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 6 Jan 2014 12:22:39 -0300 Subject: [PATCH 01/21] package.json added --- package.json | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 package.json diff --git a/package.json b/package.json new file mode 100644 index 0000000..477fe83 --- /dev/null +++ b/package.json @@ -0,0 +1,33 @@ +{ + "name": "mystery", + "version": "0.0.1", + "private": true, + "dependencies": { + }, + "author": { + "name": "Ryan X Charles", + "email": "ryan@bitpay.com" + }, + "repository": "git://github.com/bitpay/mystery.git", + "contributors": [{ + "name": "Matias Alejo Garcia", + "email": "ematiu@gmail.com" + }], + "bugs": { + "url": "https://github.com/bitpay/mystery/issues" + }, + "homepage": "https://github.com/bitpay/mystery", + "license": "MIT", + "keywords": [ + "mystery", + "secret", + "enigma", + "riddle", + "mystification", + "puzzle", + "conundrum" + ], + "engines": { + "node": "*" + } +} From 0d84b855edf82e377e88d9e365643352aaca095a Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Mon, 6 Jan 2014 12:28:10 -0300 Subject: [PATCH 02/21] git ignore for node --- .gitignore | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9ad72e0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,19 @@ +lib-cov +*.seed +*.log +*.csv +*.dat +*.out +*.pid +*.gz +*.swp + +pids +logs +results + +npm-debug.log +node_modules + +.DS_Store + From da455b49645503746e07d7210a3a7aba43556f11 Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Mon, 6 Jan 2014 13:33:58 -0300 Subject: [PATCH 03/21] added mongo dependency. basic skel --- app/controllers/index.js | 5 +++ app/views/404.jade | 13 +++++++ app/views/500.jade | 12 ++++++ app/views/includes/foot.jade | 0 app/views/includes/head.jade | 12 ++++++ app/views/index.jade | 4 ++ app/views/layouts/default.jade | 8 ++++ config/config.js | 9 +++++ config/env/all.js | 10 +++++ config/env/development.js | 8 ++++ config/env/production.js | 8 ++++ config/env/test.js | 9 +++++ config/express.js | 69 ++++++++++++++++++++++++++++++++++ config/routes.js | 9 +++++ package.json | 8 +++- server.js | 55 +++++++++++++++++++++++++++ 16 files changed, 238 insertions(+), 1 deletion(-) create mode 100644 app/controllers/index.js create mode 100755 app/views/404.jade create mode 100755 app/views/500.jade create mode 100755 app/views/includes/foot.jade create mode 100755 app/views/includes/head.jade create mode 100755 app/views/index.jade create mode 100755 app/views/layouts/default.jade create mode 100644 config/config.js create mode 100755 config/env/all.js create mode 100755 config/env/development.js create mode 100755 config/env/production.js create mode 100755 config/env/test.js create mode 100644 config/express.js create mode 100644 config/routes.js create mode 100644 server.js diff --git a/app/controllers/index.js b/app/controllers/index.js new file mode 100644 index 0000000..1e34bd9 --- /dev/null +++ b/app/controllers/index.js @@ -0,0 +1,5 @@ +'use strict'; + +exports.render = function(req, res) { + res.render('index'); +}; diff --git a/app/views/404.jade b/app/views/404.jade new file mode 100755 index 0000000..2f0d9e8 --- /dev/null +++ b/app/views/404.jade @@ -0,0 +1,13 @@ +extends layouts/default + +block main + h1 Oops something went wrong + br + span 404 + +block content + #error-message-box + #error-stack-trace + pre + code!= error + diff --git a/app/views/500.jade b/app/views/500.jade new file mode 100755 index 0000000..491b000 --- /dev/null +++ b/app/views/500.jade @@ -0,0 +1,12 @@ +extends layouts/default + +block main + h1 Oops something went wrong + br + span 500 + +block content + #error-message-box + #error-stack-trace + pre + code!= error diff --git a/app/views/includes/foot.jade b/app/views/includes/foot.jade new file mode 100755 index 0000000..e69de29 diff --git a/app/views/includes/head.jade b/app/views/includes/head.jade new file mode 100755 index 0000000..08e4f44 --- /dev/null +++ b/app/views/includes/head.jade @@ -0,0 +1,12 @@ +head + meta(charset='utf-8') + meta(http-equiv='X-UA-Compatible', content='IE=edge,chrome=1') + meta(name='viewport', content='width=device-width,initial-scale=1') + + title BitPay + meta(http-equiv='Content-type', content='text/html;charset=UTF-8') + meta(name="keywords", content="node.js, express, mongoose, mongodb, angularjs") + meta(name="description", content="Mystery") + + link(href='/img/icons/favicon.ico', rel='shortcut icon', type='image/x-icon') + diff --git a/app/views/index.jade b/app/views/index.jade new file mode 100755 index 0000000..874b042 --- /dev/null +++ b/app/views/index.jade @@ -0,0 +1,4 @@ +extends layouts/default + +block content + h1 Hello BitPay! diff --git a/app/views/layouts/default.jade b/app/views/layouts/default.jade new file mode 100755 index 0000000..3c47dc2 --- /dev/null +++ b/app/views/layouts/default.jade @@ -0,0 +1,8 @@ +doctype html +html(lang='en', xmlns='http://www.w3.org/1999/xhtml') + include ../includes/head + body + section.content + section.container + block content + include ../includes/foot diff --git a/config/config.js b/config/config.js new file mode 100644 index 0000000..b4b4230 --- /dev/null +++ b/config/config.js @@ -0,0 +1,9 @@ +'use strict'; + +var _ = require('lodash'); + +// Load app configuration + +module.exports = _.extend( + require(__dirname + '/../config/env/all.js'), + require(__dirname + '/../config/env/' + process.env.NODE_ENV + '.js') || {}); diff --git a/config/env/all.js b/config/env/all.js new file mode 100755 index 0000000..22d15f7 --- /dev/null +++ b/config/env/all.js @@ -0,0 +1,10 @@ +'use strict'; + +var path = require('path'), +rootPath = path.normalize(__dirname + '/../..'); + +module.exports = { + root: rootPath, + port: process.env.PORT || 3000, + db: process.env.MONGOHQ_URL +} diff --git a/config/env/development.js b/config/env/development.js new file mode 100755 index 0000000..b0a4665 --- /dev/null +++ b/config/env/development.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = { + db: "mongodb://localhost/mystery-dev", + app: { + name: "Mystery - Development" + } +} \ No newline at end of file diff --git a/config/env/production.js b/config/env/production.js new file mode 100755 index 0000000..9bc30bc --- /dev/null +++ b/config/env/production.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = { + db: "mongodb://localhost/mystery", + app: { + name: "Mystery - Production" + } +} \ No newline at end of file diff --git a/config/env/test.js b/config/env/test.js new file mode 100755 index 0000000..7b30a47 --- /dev/null +++ b/config/env/test.js @@ -0,0 +1,9 @@ +'use strict'; + +module.exports = { + db: "mongodb://localhost/mystery-test", + port: 3001, + app: { + name: "Mystery - Test" + } +} \ No newline at end of file diff --git a/config/express.js b/config/express.js new file mode 100644 index 0000000..08343fe --- /dev/null +++ b/config/express.js @@ -0,0 +1,69 @@ +'use strict'; + +/** + * Module dependencies. + */ +var express = require('express'), + config = require('./config'); + +module.exports = function(app, passport, db) { + app.set('showStackError', true); + + //Prettify HTML + app.locals.pretty = true; + + //Should be placed before express.static + app.use(express.compress({ + filter: function(req, res) { + return (/json|text|javascript|css/).test(res.getHeader('Content-Type')); + }, + level: 9 + })); + + //Set views path, template engine and default layout + app.set('views', config.root + '/app/views'); + app.set('view engine', 'jade'); + + //Enable jsonp + app.enable("jsonp callback"); + + app.configure(function() { + //cookieParser should be above session + app.use(express.cookieParser()); + + // request body parsing middleware should be above methodOverride + app.use(express.urlencoded()); + app.use(express.json()); + app.use(express.methodOverride()); + + //routes should be at the last + app.use(app.router); + + //Setting the fav icon and static folder + app.use(express.favicon()); + app.use(express.static(config.root + '/public')); + + //Assume "not found" in the error msgs is a 404. this is somewhat silly, but valid, you can do whatever you like, set properties, use instanceof etc. + app.use(function(err, req, res, next) { + //Treat as 404 + if (~err.message.indexOf('not found')) return next(); + + //Log it + console.error(err.stack); + + //Error page + res.status(500).render('500', { + error: err.stack + }); + }); + + //Assume 404 since no middleware responded + app.use(function(req, res, next) { + res.status(404).render('404', { + url: req.originalUrl, + error: 'Not found' + }); + }); + + }); +}; \ No newline at end of file diff --git a/config/routes.js b/config/routes.js new file mode 100644 index 0000000..9fbf748 --- /dev/null +++ b/config/routes.js @@ -0,0 +1,9 @@ +'use strict'; + +module.exports = function(app) { + + //Home route + var index = require('../app/controllers/index'); + app.get('/', index.render); + +}; diff --git a/package.json b/package.json index 477fe83..68b8253 100644 --- a/package.json +++ b/package.json @@ -29,5 +29,11 @@ ], "engines": { "node": "*" - } + }, + "dependencies": { + "express": "~3.4.7", + "jade": "~1.0.2", + "mongoose": "~3.8.3", + "lodash": "~2.4.1" + } } diff --git a/server.js b/server.js new file mode 100644 index 0000000..68bb10f --- /dev/null +++ b/server.js @@ -0,0 +1,55 @@ +'use strict'; + +/** + * Module dependencies. + */ +var express = require('express'), + fs = require('fs'); + +/** + * Main application entry file. + */ + +//Load configurations +//Set the node enviornment variable if not set before +process.env.NODE_ENV = process.env.NODE_ENV || 'development'; + +//Initializing system variables +var config = require('./config/config'), + mongoose = require('mongoose'); + +//Bootstrap db connection +var db = mongoose.connect(config.db); + +//Bootstrap models +var models_path = __dirname + '/app/models'; +var walk = function(path) { + fs.readdirSync(path).forEach(function(file) { + var newPath = path + '/' + file; + var stat = fs.statSync(newPath); + if (stat.isFile()) { + if (/(.*)\.(js$|coffee$)/.test(file)) { + require(newPath); + } + } else if (stat.isDirectory()) { + walk(newPath); + } + }); +}; +walk(models_path); + +var app = express(); + +//express settings +require('./config/express')(app, db); + +//Bootstrap routes +require('./config/routes')(app); + +//Start the app by listening on +var port = process.env.PORT || config.port; +app.listen(port); +console.log('Express app started on port ' + port); + +//expose app +exports = module.exports = app; From 79e6cdfffdeb4f7ff9973e9eea14116400a6693a Mon Sep 17 00:00:00 2001 From: Mario Colque Date: Mon, 6 Jan 2014 14:21:52 -0300 Subject: [PATCH 04/21] dependencies removed --- package.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/package.json b/package.json index 68b8253..d44870a 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,6 @@ "name": "mystery", "version": "0.0.1", "private": true, - "dependencies": { - }, "author": { "name": "Ryan X Charles", "email": "ryan@bitpay.com" From e33ee06cc615eba11abc403549ec4ad2fee7b770 Mon Sep 17 00:00:00 2001 From: Mario Colque Date: Mon, 6 Jan 2014 14:37:32 -0300 Subject: [PATCH 05/21] using two spaces for tabs --- app/controllers/index.js | 2 +- config/config.js | 4 +- config/env/all.js | 6 +-- config/env/development.js | 8 ++-- config/env/production.js | 8 ++-- config/env/test.js | 10 ++-- config/express.js | 96 +++++++++++++++++++-------------------- config/routes.js | 6 +-- server.js | 28 ++++++------ 9 files changed, 84 insertions(+), 84 deletions(-) diff --git a/app/controllers/index.js b/app/controllers/index.js index 1e34bd9..f71d55c 100644 --- a/app/controllers/index.js +++ b/app/controllers/index.js @@ -1,5 +1,5 @@ 'use strict'; exports.render = function(req, res) { - res.render('index'); + res.render('index'); }; diff --git a/config/config.js b/config/config.js index b4b4230..2f0e7c9 100644 --- a/config/config.js +++ b/config/config.js @@ -5,5 +5,5 @@ var _ = require('lodash'); // Load app configuration module.exports = _.extend( - require(__dirname + '/../config/env/all.js'), - require(__dirname + '/../config/env/' + process.env.NODE_ENV + '.js') || {}); + require(__dirname + '/../config/env/all.js'), + require(__dirname + '/../config/env/' + process.env.NODE_ENV + '.js') || {}); diff --git a/config/env/all.js b/config/env/all.js index 22d15f7..7f53a56 100755 --- a/config/env/all.js +++ b/config/env/all.js @@ -4,7 +4,7 @@ var path = require('path'), rootPath = path.normalize(__dirname + '/../..'); module.exports = { - root: rootPath, - port: process.env.PORT || 3000, - db: process.env.MONGOHQ_URL + root: rootPath, + port: process.env.PORT || 3000, + db: process.env.MONGOHQ_URL } diff --git a/config/env/development.js b/config/env/development.js index b0a4665..0ef298c 100755 --- a/config/env/development.js +++ b/config/env/development.js @@ -1,8 +1,8 @@ 'use strict'; module.exports = { - db: "mongodb://localhost/mystery-dev", - app: { - name: "Mystery - Development" - } + db: "mongodb://localhost/mystery-dev", + app: { + name: "Mystery - Development" + } } \ No newline at end of file diff --git a/config/env/production.js b/config/env/production.js index 9bc30bc..5d2c3b4 100755 --- a/config/env/production.js +++ b/config/env/production.js @@ -1,8 +1,8 @@ 'use strict'; module.exports = { - db: "mongodb://localhost/mystery", - app: { - name: "Mystery - Production" - } + db: "mongodb://localhost/mystery", + app: { + name: "Mystery - Production" + } } \ No newline at end of file diff --git a/config/env/test.js b/config/env/test.js index 7b30a47..dabf602 100755 --- a/config/env/test.js +++ b/config/env/test.js @@ -1,9 +1,9 @@ 'use strict'; module.exports = { - db: "mongodb://localhost/mystery-test", - port: 3001, - app: { - name: "Mystery - Test" - } + db: "mongodb://localhost/mystery-test", + port: 3001, + app: { + name: "Mystery - Test" + } } \ No newline at end of file diff --git a/config/express.js b/config/express.js index 08343fe..1abe190 100644 --- a/config/express.js +++ b/config/express.js @@ -4,66 +4,66 @@ * Module dependencies. */ var express = require('express'), - config = require('./config'); + config = require('./config'); module.exports = function(app, passport, db) { - app.set('showStackError', true); + app.set('showStackError', true); - //Prettify HTML - app.locals.pretty = true; + //Prettify HTML + app.locals.pretty = true; - //Should be placed before express.static - app.use(express.compress({ - filter: function(req, res) { - return (/json|text|javascript|css/).test(res.getHeader('Content-Type')); - }, - level: 9 - })); + //Should be placed before express.static + app.use(express.compress({ + filter: function(req, res) { + return (/json|text|javascript|css/).test(res.getHeader('Content-Type')); + }, + level: 9 + })); - //Set views path, template engine and default layout - app.set('views', config.root + '/app/views'); - app.set('view engine', 'jade'); + //Set views path, template engine and default layout + app.set('views', config.root + '/app/views'); + app.set('view engine', 'jade'); - //Enable jsonp - app.enable("jsonp callback"); + //Enable jsonp + app.enable("jsonp callback"); - app.configure(function() { - //cookieParser should be above session - app.use(express.cookieParser()); + app.configure(function() { + //cookieParser should be above session + app.use(express.cookieParser()); - // request body parsing middleware should be above methodOverride - app.use(express.urlencoded()); - app.use(express.json()); - app.use(express.methodOverride()); + // request body parsing middleware should be above methodOverride + app.use(express.urlencoded()); + app.use(express.json()); + app.use(express.methodOverride()); - //routes should be at the last - app.use(app.router); - - //Setting the fav icon and static folder - app.use(express.favicon()); - app.use(express.static(config.root + '/public')); + //routes should be at the last + app.use(app.router); - //Assume "not found" in the error msgs is a 404. this is somewhat silly, but valid, you can do whatever you like, set properties, use instanceof etc. - app.use(function(err, req, res, next) { - //Treat as 404 - if (~err.message.indexOf('not found')) return next(); + //Setting the fav icon and static folder + app.use(express.favicon()); + app.use(express.static(config.root + '/public')); - //Log it - console.error(err.stack); + //Assume "not found" in the error msgs is a 404. this is somewhat silly, but valid, you can do whatever you like, set properties, use instanceof etc. + app.use(function(err, req, res, next) { + //Treat as 404 + if (~err.message.indexOf('not found')) return next(); - //Error page - res.status(500).render('500', { - error: err.stack - }); - }); - - //Assume 404 since no middleware responded - app.use(function(req, res, next) { - res.status(404).render('404', { - url: req.originalUrl, - error: 'Not found' - }); - }); + //Log it + console.error(err.stack); + //Error page + res.status(500).render('500', { + error: err.stack + }); }); + + //Assume 404 since no middleware responded + app.use(function(req, res, next) { + res.status(404).render('404', { + url: req.originalUrl, + error: 'Not found' + }); + }); + + }); }; \ No newline at end of file diff --git a/config/routes.js b/config/routes.js index 9fbf748..af9c691 100644 --- a/config/routes.js +++ b/config/routes.js @@ -2,8 +2,8 @@ module.exports = function(app) { - //Home route - var index = require('../app/controllers/index'); - app.get('/', index.render); + //Home route + var index = require('../app/controllers/index'); + app.get('/', index.render); }; diff --git a/server.js b/server.js index 68bb10f..de2a349 100644 --- a/server.js +++ b/server.js @@ -4,7 +4,7 @@ * Module dependencies. */ var express = require('express'), - fs = require('fs'); + fs = require('fs'); /** * Main application entry file. @@ -14,9 +14,9 @@ var express = require('express'), //Set the node enviornment variable if not set before process.env.NODE_ENV = process.env.NODE_ENV || 'development'; -//Initializing system variables +//Initializing system variables var config = require('./config/config'), - mongoose = require('mongoose'); + mongoose = require('mongoose'); //Bootstrap db connection var db = mongoose.connect(config.db); @@ -24,17 +24,17 @@ var db = mongoose.connect(config.db); //Bootstrap models var models_path = __dirname + '/app/models'; var walk = function(path) { - fs.readdirSync(path).forEach(function(file) { - var newPath = path + '/' + file; - var stat = fs.statSync(newPath); - if (stat.isFile()) { - if (/(.*)\.(js$|coffee$)/.test(file)) { - require(newPath); - } - } else if (stat.isDirectory()) { - walk(newPath); - } - }); + fs.readdirSync(path).forEach(function(file) { + var newPath = path + '/' + file; + var stat = fs.statSync(newPath); + if (stat.isFile()) { + if (/(.*)\.(js$|coffee$)/.test(file)) { + require(newPath); + } + } else if (stat.isDirectory()) { + walk(newPath); + } + }); }; walk(models_path); From 91ea1d23bc065a1236be37b212f73024c7f8317e Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 6 Jan 2014 15:00:28 -0300 Subject: [PATCH 06/21] index page --- app/views/includes/head.jade | 2 +- app/views/index.jade | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/views/includes/head.jade b/app/views/includes/head.jade index 08e4f44..f286985 100755 --- a/app/views/includes/head.jade +++ b/app/views/includes/head.jade @@ -3,7 +3,7 @@ head meta(http-equiv='X-UA-Compatible', content='IE=edge,chrome=1') meta(name='viewport', content='width=device-width,initial-scale=1') - title BitPay + title Mystery meta(http-equiv='Content-type', content='text/html;charset=UTF-8') meta(name="keywords", content="node.js, express, mongoose, mongodb, angularjs") meta(name="description", content="Mystery") diff --git a/app/views/index.jade b/app/views/index.jade index 874b042..02348b3 100755 --- a/app/views/index.jade +++ b/app/views/index.jade @@ -1,4 +1,24 @@ extends layouts/default block content - h1 Hello BitPay! + h1 mystery + p ˈmɪst(ə)ri/' + | noun + audio(src="https://ssl.gstatic.com/dictionary/static/sounds/de/0/mystery.mp3",preload="auto",data-dobid="aud",id="aud") + button(onclick="document.getElementById('aud').play()") Play + + ol + li + strong something that is difficult or impossible to understand or explain. + p "the mysteries of outer space" + | synonyms: puzzle, enigma, conundrum, riddle, secret, unsolved problem, problem, question, question mark, closed book; secrecy or obscurity. + p "much of her past is shrouded in mystery" + | synonyms: secrecy, darkness, obscurity, ambiguity, ambiguousness, uncertainty, impenetrability, vagueness, nebulousness; More + li + strong a person or thing whose identity or nature is puzzling or unknown. + p "‘He's a bit of a mystery,’ said Nina" + li + strong a novel, play, or film dealing with a puzzling crime, especially a murder. + p "the 1920s murder mystery, The Ghost Train" + | synonyms: thriller, detective story/novel, murder story; More + From af8ce3e4941fc671b7928936ad7bf203a569d6d8 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 6 Jan 2014 15:51:44 -0300 Subject: [PATCH 07/21] bitcoind configuration sample --- etc/bitcoind/bitcoin.conf | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 etc/bitcoind/bitcoin.conf diff --git a/etc/bitcoind/bitcoin.conf b/etc/bitcoind/bitcoin.conf new file mode 100644 index 0000000..50bac19 --- /dev/null +++ b/etc/bitcoind/bitcoin.conf @@ -0,0 +1,12 @@ +rpcuser=mystery +rpcpassword=real_mystery +server=1 +rpcallowip=127.0.0.1 +rpcport=8332 +testnet=1 +txindex=1 + + + + + From 6bf3b4f0537c328aac188024af99f1df2db7fe66 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 6 Jan 2014 15:55:45 -0300 Subject: [PATCH 08/21] markdown updated --- README.md | 8 ++++++++ config/routes.js | 3 +++ 2 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 17e46ba..96ff245 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,10 @@ mystery ======= + + +## bitcoind configuration + + There is a bitcoind configuration sample at: +``` + etc/mystery/bitcoin.conf +```: diff --git a/config/routes.js b/config/routes.js index af9c691..182a216 100644 --- a/config/routes.js +++ b/config/routes.js @@ -6,4 +6,7 @@ module.exports = function(app) { var index = require('../app/controllers/index'); app.get('/', index.render); + //TX routes + // + }; From 5a6979a91124afb322ba758d897636ebaa96341c Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 6 Jan 2014 16:06:56 -0300 Subject: [PATCH 09/21] bitcore dependency added --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index d44870a..e364609 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "express": "~3.4.7", "jade": "~1.0.2", "mongoose": "~3.8.3", - "lodash": "~2.4.1" + "lodash": "~2.4.1", + "bitcore": "*" } } From 0341f8f691d79b025adead4489e90ddb03cdb644 Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Mon, 6 Jan 2014 16:12:14 -0300 Subject: [PATCH 10/21] bootstrap ready! --- .bowerrc | 3 ++ .gitignore | 1 + app/views/includes/foot.jade | 6 +++ app/views/includes/head.jade | 5 ++- app/views/includes/navbar.jade | 17 ++++++++ app/views/index.jade | 3 +- app/views/layouts/default.jade | 3 +- bower.json | 7 ++++ package.json | 74 ++++++++++++++++++---------------- public/css/common.css | 45 +++++++++++++++++++++ public/img/.gitignore | 0 11 files changed, 126 insertions(+), 38 deletions(-) create mode 100644 .bowerrc create mode 100644 app/views/includes/navbar.jade create mode 100644 bower.json create mode 100644 public/css/common.css create mode 100755 public/img/.gitignore diff --git a/.bowerrc b/.bowerrc new file mode 100644 index 0000000..47ad667 --- /dev/null +++ b/.bowerrc @@ -0,0 +1,3 @@ +{ + "directory": "public/lib" +} diff --git a/.gitignore b/.gitignore index 9ad72e0..bb726e2 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,5 @@ npm-debug.log node_modules .DS_Store +public/lib/* diff --git a/app/views/includes/foot.jade b/app/views/includes/foot.jade index e69de29..b2a61b6 100755 --- a/app/views/includes/foot.jade +++ b/app/views/includes/foot.jade @@ -0,0 +1,6 @@ +#footer + .container + p.text-muted Place sticky footer content here. + +script(type='text/javascript', src='/lib/jquery/jquery.min.js') +script(type='text/javascript', src='/lib/bootstrap/dist/js/bootstrap.min.js') diff --git a/app/views/includes/head.jade b/app/views/includes/head.jade index 08e4f44..939021f 100755 --- a/app/views/includes/head.jade +++ b/app/views/includes/head.jade @@ -1,7 +1,7 @@ head meta(charset='utf-8') meta(http-equiv='X-UA-Compatible', content='IE=edge,chrome=1') - meta(name='viewport', content='width=device-width,initial-scale=1') + meta(name='viewport', content='width=device-width,initial-scale=1.0') title BitPay meta(http-equiv='Content-type', content='text/html;charset=UTF-8') @@ -10,3 +10,6 @@ head link(href='/img/icons/favicon.ico', rel='shortcut icon', type='image/x-icon') + link(rel='stylesheet', href='/lib/bootstrap/dist/css/bootstrap.min.css') + link(rel='stylesheet', href='/css/common.css') + \ No newline at end of file diff --git a/app/views/includes/navbar.jade b/app/views/includes/navbar.jade new file mode 100644 index 0000000..eabfbb9 --- /dev/null +++ b/app/views/includes/navbar.jade @@ -0,0 +1,17 @@ +.navbar.navbar-default.navbar-fixed-top(role='navigation') + .container + .navbar-header + button.navbar-toggle(type='button', data-toggle='collapse', data-target='.navbar-collapse') + span.sr-only Toggle navigation + span.icon-bar + span.icon-bar + span.icon-bar + a.navbar-brand(href='#') Mystery + .collapse.navbar-collapse + ul.nav.navbar-nav + li.active + a(href='#') Home + li + a(href='#about') About + li + a(href='#contact') Contact diff --git a/app/views/index.jade b/app/views/index.jade index 874b042..53ad530 100755 --- a/app/views/index.jade +++ b/app/views/index.jade @@ -1,4 +1,5 @@ extends layouts/default block content - h1 Hello BitPay! + .page-header + h1 Hello BitPay! diff --git a/app/views/layouts/default.jade b/app/views/layouts/default.jade index 3c47dc2..186b81c 100755 --- a/app/views/layouts/default.jade +++ b/app/views/layouts/default.jade @@ -2,7 +2,8 @@ doctype html html(lang='en', xmlns='http://www.w3.org/1999/xhtml') include ../includes/head body - section.content + #wrap + include ../includes/navbar section.container block content include ../includes/foot diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..62688af --- /dev/null +++ b/bower.json @@ -0,0 +1,7 @@ +{ + "name": "Mystery", + "version": "0.0.1", + "dependencies": { + "bootstrap": "3.0.3" + } +} \ No newline at end of file diff --git a/package.json b/package.json index d44870a..6a3cbc6 100644 --- a/package.json +++ b/package.json @@ -1,37 +1,41 @@ { - "name": "mystery", - "version": "0.0.1", - "private": true, - "author": { - "name": "Ryan X Charles", - "email": "ryan@bitpay.com" - }, - "repository": "git://github.com/bitpay/mystery.git", - "contributors": [{ - "name": "Matias Alejo Garcia", - "email": "ematiu@gmail.com" - }], - "bugs": { - "url": "https://github.com/bitpay/mystery/issues" - }, - "homepage": "https://github.com/bitpay/mystery", - "license": "MIT", - "keywords": [ - "mystery", - "secret", - "enigma", - "riddle", - "mystification", - "puzzle", - "conundrum" - ], - "engines": { - "node": "*" - }, - "dependencies": { - "express": "~3.4.7", - "jade": "~1.0.2", - "mongoose": "~3.8.3", - "lodash": "~2.4.1" - } + "name": "mystery", + "version": "0.0.1", + "private": true, + "author": { + "name": "Ryan X Charles", + "email": "ryan@bitpay.com" + }, + "repository": "git://github.com/bitpay/mystery.git", + "contributors": [{ + "name": "Matias Alejo Garcia", + "email": "ematiu@gmail.com" + }], + "bugs": { + "url": "https://github.com/bitpay/mystery/issues" + }, + "homepage": "https://github.com/bitpay/mystery", + "license": "MIT", + "keywords": [ + "mystery", + "secret", + "enigma", + "riddle", + "mystification", + "puzzle", + "conundrum" + ], + "engines": { + "node": "*" + }, + "scripts": { + "postinstall": "node node_modules/bower/bin/bower install" + }, + "dependencies": { + "express": "~3.4.7", + "jade": "~1.0.2", + "mongoose": "~3.8.3", + "lodash": "~2.4.1", + "bower": "~1.2.8" + } } diff --git a/public/css/common.css b/public/css/common.css new file mode 100644 index 0000000..7ca093a --- /dev/null +++ b/public/css/common.css @@ -0,0 +1,45 @@ +/* Sticky footer styles +-------------------------------------------------- */ + +html, +body { + height: 100%; + /* The html and body elements cannot have any padding or margin. */ +} + +/* Wrapper for page content to push down footer */ +#wrap { + min-height: 100%; + height: auto; + /* Negative indent footer by its height */ + margin: 0 auto -60px; + /* Pad bottom by footer height */ + padding: 0 0 60px; +} + +/* Set the fixed height of the footer here */ +#footer { + height: 60px; + background-color: #f5f5f5; +} + + +/* Custom page CSS +-------------------------------------------------- */ +/* Not required for template or sticky footer method. */ + +#wrap > .container { + padding: 60px 15px 0; +} +.container .text-muted { + margin: 20px 0; +} + +#footer > .container { + padding-left: 15px; + padding-right: 15px; +} + +code { + font-size: 80%; +} diff --git a/public/img/.gitignore b/public/img/.gitignore new file mode 100755 index 0000000..e69de29 From 6f0a6d8b069a02784bc242397495ba0cf1ffc8af Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 6 Jan 2014 17:19:14 -0300 Subject: [PATCH 11/21] sample CLi to get a block using the RPC interfase + Bitcore --- README.md | 2 +- etc/bitcoind/bitcoin.conf | 5 +++-- util/get_block.js | 27 +++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100755 util/get_block.js diff --git a/README.md b/README.md index 96ff245..69bc9c9 100644 --- a/README.md +++ b/README.md @@ -7,4 +7,4 @@ mystery There is a bitcoind configuration sample at: ``` etc/mystery/bitcoin.conf -```: +``` diff --git a/etc/bitcoind/bitcoin.conf b/etc/bitcoind/bitcoin.conf index 50bac19..062c09e 100644 --- a/etc/bitcoind/bitcoin.conf +++ b/etc/bitcoind/bitcoin.conf @@ -1,11 +1,12 @@ rpcuser=mystery rpcpassword=real_mystery server=1 -rpcallowip=127.0.0.1 rpcport=8332 -testnet=1 +testnet=3 txindex=1 +# Allow connections outsite localhost? +# rpcallowip=192.168.0.* diff --git a/util/get_block.js b/util/get_block.js new file mode 100755 index 0000000..27880d8 --- /dev/null +++ b/util/get_block.js @@ -0,0 +1,27 @@ +#!/usr/bin/env node + + + +var RpcClient = require('../node_modules/bitcore/RpcClient').class(); + + +var block_hash = process.argv[2] || '0000000000b6288775bbd326bedf324ca8717a15191da58391535408205aada4'; + +var rpc = new RpcClient({ + user: 'mystery', + pass: 'real_mystery', + protocol: 'http', +}); + +var block = rpc.getBlock(block_hash, function(err, block) { + + console.log("Err:"); + console.log(err); + + + console.log("Block info:"); + console.log(block); +}); + + + From 3216cadac9084cd0f7ee892550153ff4d10fc320 Mon Sep 17 00:00:00 2001 From: Mario Colque Date: Mon, 6 Jan 2014 17:32:22 -0300 Subject: [PATCH 12/21] added .nodemonignore to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index bb726e2..e322bd9 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ results npm-debug.log node_modules +.nodemonignore .DS_Store public/lib/* From fab9d62df6e8add327946ad461ea5f787d3aa319 Mon Sep 17 00:00:00 2001 From: Mario Colque Date: Mon, 6 Jan 2014 17:32:58 -0300 Subject: [PATCH 13/21] added .editorconfig --- .editorconfig | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c2cdfb8 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + +root = true + + +[*] + +# Change these settings to your own preference +indent_style = space +indent_size = 2 + +# We recommend you to keep these unchanged +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false From f73586d49fc3f3744ce97f5ee0f95d5175b9f664 Mon Sep 17 00:00:00 2001 From: Mario Colque Date: Mon, 6 Jan 2014 17:33:44 -0300 Subject: [PATCH 14/21] Added Grunt and jsint --- .jshintrc | 40 +++++++++++++++++++++++++ Gruntfile.js | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 .jshintrc create mode 100644 Gruntfile.js diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..66eeef6 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,40 @@ +{ + "node": true, // Enable globals available when code is running inside of the NodeJS runtime environment. + "browser": true, // Standard browser globals e.g. `window`, `document`. + "esnext": true, // Allow ES.next specific features such as `const` and `let`. + "bitwise": false, // Prohibit bitwise operators (&, |, ^, etc.). + "camelcase": false, // Permit only camelcase for `var` and `object indexes`. + "curly": false, // Require {} for every new block or scope. + "eqeqeq": true, // Require triple equals i.e. `===`. + "immed": true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );` + "latedef": true, // Prohibit variable use before definition. + "newcap": true, // Require capitalization of all constructor functions e.g. `new F()`. + "noarg": true, // Prohibit use of `arguments.caller` and `arguments.callee`. + "quotmark": "single", // Define quotes to string values. + "regexp": true, // Prohibit `.` and `[^...]` in regular expressions. + "undef": true, // Require all non-global variables be declared before they are used. + "unused": true, // Warn unused variables. + "strict": true, // Require `use strict` pragma in every file. + "trailing": true, // Prohibit trailing whitespaces. + "smarttabs": false, // Suppresses warnings about mixed tabs and spaces + "globals": { // Globals variables. + "angular": true + }, + "predef": [ // Extra globals. + "define", + "require", + "exports", + "module", + "describe", + "before", + "beforeEach", + "after", + "afterEach", + "it", + "inject", + "expect" + ], + "indent": 4, // Specify indentation spacing + "devel": true, // Allow development statements e.g. `console.log();`. + "noempty": true // Prohibit use of empty blocks. +} \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..9a93a60 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,83 @@ +'use strict'; + +module.exports = function(grunt) { + // Project Configuration + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + watch: { + jade: { + files: ['app/views/**'], + options: { + livereload: true, + }, + }, + js: { + files: ['Gruntfile.js', 'server.js', 'app/**/*.js', 'public/js/**'], + tasks: ['jshint'], + options: { + livereload: true, + }, + }, + html: { + files: ['public/views/**'], + options: { + livereload: true, + }, + }, + css: { + files: ['public/css/**'], + options: { + livereload: true + } + } + }, + jshint: { + all: { + src: ['Gruntfile.js', 'server.js', 'app/**/*.js', 'public/js/**'], + options: { + jshintrc: true + } + } + }, + nodemon: { + dev: { + options: { + file: 'server.js', + args: [], + ignoredFiles: ['public/**'], + watchedExtensions: ['js'], + nodeArgs: ['--debug'], + delayTime: 1, + env: { + PORT: 3000 + }, + cwd: __dirname + } + } + }, + concurrent: { + tasks: ['nodemon', 'watch'], + options: { + logConcurrentOutput: true + } + }, + env: { + test: { + NODE_ENV: 'test' + } + } + }); + + //Load NPM tasks + grunt.loadNpmTasks('grunt-contrib-watch'); + grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-nodemon'); + grunt.loadNpmTasks('grunt-concurrent'); + grunt.loadNpmTasks('grunt-env'); + + //Making grunt default to force in order not to break the project. + grunt.option('force', true); + + //Default task(s). + grunt.registerTask('default', ['jshint', 'concurrent']); +}; From cbc7a6773a6118a004abbb2d8e37b46f1191e59c Mon Sep 17 00:00:00 2001 From: Mario Colque Date: Mon, 6 Jan 2014 17:34:17 -0300 Subject: [PATCH 15/21] package.json updated --- package.json | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index be95e6e..b17b04a 100644 --- a/package.json +++ b/package.json @@ -7,10 +7,12 @@ "email": "ryan@bitpay.com" }, "repository": "git://github.com/bitpay/mystery.git", - "contributors": [{ - "name": "Matias Alejo Garcia", - "email": "ematiu@gmail.com" - }], + "contributors": [ + { + "name": "Matias Alejo Garcia", + "email": "ematiu@gmail.com" + } + ], "bugs": { "url": "https://github.com/bitpay/mystery/issues" }, @@ -29,6 +31,7 @@ "node": "*" }, "scripts": { + "start": "node node_modules/grunt-cli/bin/grunt", "postinstall": "node node_modules/bower/bin/bower install" }, "dependencies": { @@ -37,6 +40,19 @@ "mongoose": "~3.8.3", "lodash": "~2.4.1", "bower": "~1.2.8", - "bitcore": "*" + "bitcore": "*", + "grunt": "~0.4.2", + "grunt-cli": "~0.1.11", + "grunt-env": "~0.4.1", + "grunt-contrib-jshint": "~0.8.0", + "grunt-contrib-watch": "~0.5.3", + "grunt-concurrent": "~0.4.2", + "grunt-nodemon": "~0.1.2" + }, + "devDependencies": { + "grunt-contrib-watch": "~0.5.3", + "grunt-contrib-jshint": "~0.8.0", + "grunt-nodemon": "~0.1.2", + "grunt-concurrent": "~0.4.2" } } From cf1deca94ff8ae5f2165662fdb717e05cd9df404 Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Mon, 6 Jan 2014 17:34:25 -0300 Subject: [PATCH 16/21] angular js supported! --- app/views/includes/foot.jade | 29 ++++++++++++++++++++-- app/views/includes/navbar.jade | 18 +------------- app/views/index.jade | 43 +++++++++++++++++---------------- app/views/layouts/default.jade | 3 +-- bower.json | 9 ++++++- public/js/app.js | 5 ++++ public/js/config.js | 21 ++++++++++++++++ public/js/controllers/header.js | 15 ++++++++++++ public/js/controllers/index.js | 5 ++++ public/js/directives.js | 1 + public/js/filters.js | 1 + public/js/init.js | 9 +++++++ public/js/services/global.js | 14 +++++++++++ public/views/header.html | 18 ++++++++++++++ public/views/index.html | 5 ++++ 15 files changed, 153 insertions(+), 43 deletions(-) create mode 100755 public/js/app.js create mode 100755 public/js/config.js create mode 100755 public/js/controllers/header.js create mode 100755 public/js/controllers/index.js create mode 100755 public/js/directives.js create mode 100755 public/js/filters.js create mode 100755 public/js/init.js create mode 100755 public/js/services/global.js create mode 100755 public/views/header.html create mode 100644 public/views/index.html diff --git a/app/views/includes/foot.jade b/app/views/includes/foot.jade index b2a61b6..f7cc3e6 100755 --- a/app/views/includes/foot.jade +++ b/app/views/includes/foot.jade @@ -2,5 +2,30 @@ .container p.text-muted Place sticky footer content here. -script(type='text/javascript', src='/lib/jquery/jquery.min.js') -script(type='text/javascript', src='/lib/bootstrap/dist/js/bootstrap.min.js') +//script(type='text/javascript', src='/lib/jquery/jquery.min.js') +//script(type='text/javascript', src='/lib/bootstrap/dist/js/bootstrap.min.js') + +//AngularJS +script(type='text/javascript', src='/lib/angular/angular.js') +script(type='text/javascript', src='/lib/angular-cookies/angular-cookies.js') +script(type='text/javascript', src='/lib/angular-resource/angular-resource.js') +script(type='text/javascript', src='/lib/angular-route/angular-route.js') + +//Angular UI +script(type='text/javascript', src='/lib/angular-bootstrap/ui-bootstrap.js') +script(type='text/javascript', src='/lib/angular-bootstrap/ui-bootstrap-tpls.js') +script(type='text/javascript', src='/lib/angular-ui-utils/ui-utils.js') + +//Application Init +script(type='text/javascript', src='/js/app.js') +script(type='text/javascript', src='/js/config.js') +script(type='text/javascript', src='/js/directives.js') +script(type='text/javascript', src='/js/filters.js') + +//Application Services +script(type='text/javascript', src='/js/services/global.js') + +//Application Controllers +script(type='text/javascript', src='/js/controllers/index.js') +script(type='text/javascript', src='/js/controllers/header.js') +script(type='text/javascript', src='/js/init.js') diff --git a/app/views/includes/navbar.jade b/app/views/includes/navbar.jade index eabfbb9..a1b2b1c 100644 --- a/app/views/includes/navbar.jade +++ b/app/views/includes/navbar.jade @@ -1,17 +1 @@ -.navbar.navbar-default.navbar-fixed-top(role='navigation') - .container - .navbar-header - button.navbar-toggle(type='button', data-toggle='collapse', data-target='.navbar-collapse') - span.sr-only Toggle navigation - span.icon-bar - span.icon-bar - span.icon-bar - a.navbar-brand(href='#') Mystery - .collapse.navbar-collapse - ul.nav.navbar-nav - li.active - a(href='#') Home - li - a(href='#about') About - li - a(href='#contact') Contact +.navbar.navbar-default.navbar-fixed-top(data-ng-include="'views/header.html'", role='navigation') diff --git a/app/views/index.jade b/app/views/index.jade index cd0eb69..7f33718 100755 --- a/app/views/index.jade +++ b/app/views/index.jade @@ -1,24 +1,25 @@ extends layouts/default block content - .page-header - h1 Hello BitPay! - p ˈmɪst(ə)ri/' - | noun - audio(src="https://ssl.gstatic.com/dictionary/static/sounds/de/0/mystery.mp3",preload="auto",data-dobid="aud",id="aud") - button(onclick="document.getElementById('aud').play()") Play - - ol - li - strong something that is difficult or impossible to understand or explain. - p "the mysteries of outer space" - | synonyms: puzzle, enigma, conundrum, riddle, secret, unsolved problem, problem, question, question mark, closed book; secrecy or obscurity. - p "much of her past is shrouded in mystery" - | synonyms: secrecy, darkness, obscurity, ambiguity, ambiguousness, uncertainty, impenetrability, vagueness, nebulousness; More - li - strong a person or thing whose identity or nature is puzzling or unknown. - p "‘He's a bit of a mystery,’ said Nina" - li - strong a novel, play, or film dealing with a puzzling crime, especially a murder. - p "the 1920s murder mystery, The Ghost Train" - | synonyms: thriller, detective story/novel, murder story; More + section.container(data-ng-view) + + section.container + p ˈmɪst(ə)ri/' + | noun + audio(src="https://ssl.gstatic.com/dictionary/static/sounds/de/0/mystery.mp3",preload="auto",data-dobid="aud",id="aud") + button(onclick="document.getElementById('aud').play()") Play + + ol + li + strong something that is difficult or impossible to understand or explain. + p "the mysteries of outer space" + | synonyms: puzzle, enigma, conundrum, riddle, secret, unsolved problem, problem, question, question mark, closed book; secrecy or obscurity. + p "much of her past is shrouded in mystery" + | synonyms: secrecy, darkness, obscurity, ambiguity, ambiguousness, uncertainty, impenetrability, vagueness, nebulousness; More + li + strong a person or thing whose identity or nature is puzzling or unknown. + p "‘He's a bit of a mystery,’ said Nina" + li + strong a novel, play, or film dealing with a puzzling crime, especially a murder. + p "the 1920s murder mystery, The Ghost Train" + | synonyms: thriller, detective story/novel, murder story; More diff --git a/app/views/layouts/default.jade b/app/views/layouts/default.jade index 186b81c..64e2713 100755 --- a/app/views/layouts/default.jade +++ b/app/views/layouts/default.jade @@ -4,6 +4,5 @@ html(lang='en', xmlns='http://www.w3.org/1999/xhtml') body #wrap include ../includes/navbar - section.container - block content + block content include ../includes/foot diff --git a/bower.json b/bower.json index 62688af..46be4c5 100644 --- a/bower.json +++ b/bower.json @@ -2,6 +2,13 @@ "name": "Mystery", "version": "0.0.1", "dependencies": { - "bootstrap": "3.0.3" + "angular": "latest", + "angular-resource": "latest", + "angular-cookies": "latest", + "angular-mocks": "latest", + "angular-route": "latest", + "bootstrap": "3.0.3", + "angular-bootstrap": "0.9.0", + "angular-ui-utils": "0.1.0" } } \ No newline at end of file diff --git a/public/js/app.js b/public/js/app.js new file mode 100755 index 0000000..77b64cb --- /dev/null +++ b/public/js/app.js @@ -0,0 +1,5 @@ +'use strict'; + +angular.module('mystery', ['ngCookies', 'ngResource', 'ngRoute', 'ui.bootstrap', 'ui.route', 'mystery.system']); + +angular.module('mystery.system', []); \ No newline at end of file diff --git a/public/js/config.js b/public/js/config.js new file mode 100755 index 0000000..b86700b --- /dev/null +++ b/public/js/config.js @@ -0,0 +1,21 @@ +'use strict'; + +//Setting up route +angular.module('mystery').config(['$routeProvider', + function($routeProvider) { + $routeProvider. + when('/', { + templateUrl: 'views/index.html' + }). + otherwise({ + redirectTo: '/' + }); + } +]); + +//Setting HTML5 Location Mode +angular.module('mystery').config(['$locationProvider', + function($locationProvider) { + $locationProvider.hashPrefix('!'); + } +]); \ No newline at end of file diff --git a/public/js/controllers/header.js b/public/js/controllers/header.js new file mode 100755 index 0000000..512cb00 --- /dev/null +++ b/public/js/controllers/header.js @@ -0,0 +1,15 @@ +'use strict'; + +angular.module('mystery.system').controller('HeaderController', ['$scope', 'Global', function ($scope, Global) { + $scope.global = Global; + + $scope.menu = [{ + 'title': 'Articles', + 'link': 'articles' + }, { + 'title': 'Create New Article', + 'link': 'articles/create' + }]; + + $scope.isCollapsed = false; +}]); \ No newline at end of file diff --git a/public/js/controllers/index.js b/public/js/controllers/index.js new file mode 100755 index 0000000..503829c --- /dev/null +++ b/public/js/controllers/index.js @@ -0,0 +1,5 @@ +'use strict'; + +angular.module('mystery.system').controller('IndexController', ['$scope', 'Global', function ($scope, Global) { + $scope.global = Global; +}]); \ No newline at end of file diff --git a/public/js/directives.js b/public/js/directives.js new file mode 100755 index 0000000..a726efc --- /dev/null +++ b/public/js/directives.js @@ -0,0 +1 @@ +'use strict'; \ No newline at end of file diff --git a/public/js/filters.js b/public/js/filters.js new file mode 100755 index 0000000..a726efc --- /dev/null +++ b/public/js/filters.js @@ -0,0 +1 @@ +'use strict'; \ No newline at end of file diff --git a/public/js/init.js b/public/js/init.js new file mode 100755 index 0000000..d7c9428 --- /dev/null +++ b/public/js/init.js @@ -0,0 +1,9 @@ +'use strict'; + +angular.element(document).ready(function() { + //Fixing facebook bug with redirect + if (window.location.hash === '#_=_') window.location.hash = '#!'; + + //Then init the app + angular.bootstrap(document, ['mystery']); +}); \ No newline at end of file diff --git a/public/js/services/global.js b/public/js/services/global.js new file mode 100755 index 0000000..8dc532e --- /dev/null +++ b/public/js/services/global.js @@ -0,0 +1,14 @@ +'use strict'; + +//Global service for global variables +angular.module('mystery.system').factory('Global', [ + function() { + var _this = this; + _this._data = { + user: window.user, + authenticated: !! window.user + }; + + return _this._data; + } +]); diff --git a/public/views/header.html b/public/views/header.html new file mode 100755 index 0000000..70189e7 --- /dev/null +++ b/public/views/header.html @@ -0,0 +1,18 @@ +
+ + +
diff --git a/public/views/index.html b/public/views/index.html new file mode 100644 index 0000000..b92fe02 --- /dev/null +++ b/public/views/index.html @@ -0,0 +1,5 @@ +
+ +
From 86e11424d8735d19ccb228cf86c6c3983c2450d7 Mon Sep 17 00:00:00 2001 From: Mario Colque Date: Mon, 6 Jan 2014 17:54:32 -0300 Subject: [PATCH 17/21] removed spaces --- .jshintrc | 4 +- Gruntfile.js | 144 ++++++++++++++++---------------- public/js/config.js | 26 +++--- public/js/controllers/header.js | 22 ++--- public/js/init.js | 10 +-- public/js/services/global.js | 16 ++-- 6 files changed, 111 insertions(+), 111 deletions(-) diff --git a/.jshintrc b/.jshintrc index 66eeef6..bd532c2 100644 --- a/.jshintrc +++ b/.jshintrc @@ -34,7 +34,7 @@ "inject", "expect" ], - "indent": 4, // Specify indentation spacing + "indent": 2, // Specify indentation spacing "devel": true, // Allow development statements e.g. `console.log();`. "noempty": true // Prohibit use of empty blocks. -} \ No newline at end of file +} diff --git a/Gruntfile.js b/Gruntfile.js index 9a93a60..6d397b7 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,83 +1,83 @@ 'use strict'; module.exports = function(grunt) { - // Project Configuration - grunt.initConfig({ - pkg: grunt.file.readJSON('package.json'), - watch: { - jade: { - files: ['app/views/**'], - options: { - livereload: true, - }, - }, - js: { - files: ['Gruntfile.js', 'server.js', 'app/**/*.js', 'public/js/**'], - tasks: ['jshint'], - options: { - livereload: true, - }, - }, - html: { - files: ['public/views/**'], - options: { - livereload: true, - }, - }, - css: { - files: ['public/css/**'], - options: { - livereload: true - } - } + // Project Configuration + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + watch: { + jade: { + files: ['app/views/**'], + options: { + livereload: true, }, - jshint: { - all: { - src: ['Gruntfile.js', 'server.js', 'app/**/*.js', 'public/js/**'], - options: { - jshintrc: true - } - } + }, + js: { + files: ['Gruntfile.js', 'server.js', 'app/**/*.js', 'public/js/**'], + tasks: ['jshint'], + options: { + livereload: true, }, - nodemon: { - dev: { - options: { - file: 'server.js', - args: [], - ignoredFiles: ['public/**'], - watchedExtensions: ['js'], - nodeArgs: ['--debug'], - delayTime: 1, - env: { - PORT: 3000 - }, - cwd: __dirname - } - } + }, + html: { + files: ['public/views/**'], + options: { + livereload: true, }, - concurrent: { - tasks: ['nodemon', 'watch'], - options: { - logConcurrentOutput: true - } - }, - env: { - test: { - NODE_ENV: 'test' - } + }, + css: { + files: ['public/css/**'], + options: { + livereload: true } - }); + } + }, + jshint: { + all: { + src: ['Gruntfile.js', 'server.js', 'app/**/*.js', 'public/js/**'], + options: { + jshintrc: true + } + } + }, + nodemon: { + dev: { + options: { + file: 'server.js', + args: [], + ignoredFiles: ['public/**'], + watchedExtensions: ['js'], + nodeArgs: ['--debug'], + delayTime: 1, + env: { + PORT: 3000 + }, + cwd: __dirname + } + } + }, + concurrent: { + tasks: ['nodemon', 'watch'], + options: { + logConcurrentOutput: true + } + }, + env: { + test: { + NODE_ENV: 'test' + } + } + }); - //Load NPM tasks - grunt.loadNpmTasks('grunt-contrib-watch'); - grunt.loadNpmTasks('grunt-contrib-jshint'); - grunt.loadNpmTasks('grunt-nodemon'); - grunt.loadNpmTasks('grunt-concurrent'); - grunt.loadNpmTasks('grunt-env'); + //Load NPM tasks + grunt.loadNpmTasks('grunt-contrib-watch'); + grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-nodemon'); + grunt.loadNpmTasks('grunt-concurrent'); + grunt.loadNpmTasks('grunt-env'); - //Making grunt default to force in order not to break the project. - grunt.option('force', true); + //Making grunt default to force in order not to break the project. + grunt.option('force', true); - //Default task(s). - grunt.registerTask('default', ['jshint', 'concurrent']); + //Default task(s). + grunt.registerTask('default', ['jshint', 'concurrent']); }; diff --git a/public/js/config.js b/public/js/config.js index b86700b..fe68006 100755 --- a/public/js/config.js +++ b/public/js/config.js @@ -2,20 +2,20 @@ //Setting up route angular.module('mystery').config(['$routeProvider', - function($routeProvider) { - $routeProvider. - when('/', { - templateUrl: 'views/index.html' - }). - otherwise({ - redirectTo: '/' - }); - } + function($routeProvider) { + $routeProvider. + when('/', { + templateUrl: 'views/index.html' + }). + otherwise({ + redirectTo: '/' + }); + } ]); //Setting HTML5 Location Mode angular.module('mystery').config(['$locationProvider', - function($locationProvider) { - $locationProvider.hashPrefix('!'); - } -]); \ No newline at end of file + function($locationProvider) { + $locationProvider.hashPrefix('!'); + } +]); diff --git a/public/js/controllers/header.js b/public/js/controllers/header.js index 512cb00..039a5ac 100755 --- a/public/js/controllers/header.js +++ b/public/js/controllers/header.js @@ -1,15 +1,15 @@ 'use strict'; angular.module('mystery.system').controller('HeaderController', ['$scope', 'Global', function ($scope, Global) { - $scope.global = Global; + $scope.global = Global; - $scope.menu = [{ - 'title': 'Articles', - 'link': 'articles' - }, { - 'title': 'Create New Article', - 'link': 'articles/create' - }]; - - $scope.isCollapsed = false; -}]); \ No newline at end of file + $scope.menu = [{ + 'title': 'Articles', + 'link': 'articles' + }, { + 'title': 'Create New Article', + 'link': 'articles/create' + }]; + + $scope.isCollapsed = false; +}]); diff --git a/public/js/init.js b/public/js/init.js index d7c9428..b226e6f 100755 --- a/public/js/init.js +++ b/public/js/init.js @@ -1,9 +1,9 @@ 'use strict'; angular.element(document).ready(function() { - //Fixing facebook bug with redirect - if (window.location.hash === '#_=_') window.location.hash = '#!'; + //Fixing facebook bug with redirect + if (window.location.hash === '#_=_') window.location.hash = '#!'; - //Then init the app - angular.bootstrap(document, ['mystery']); -}); \ No newline at end of file + //Then init the app + angular.bootstrap(document, ['mystery']); +}); diff --git a/public/js/services/global.js b/public/js/services/global.js index 8dc532e..7900652 100755 --- a/public/js/services/global.js +++ b/public/js/services/global.js @@ -2,13 +2,13 @@ //Global service for global variables angular.module('mystery.system').factory('Global', [ - function() { - var _this = this; - _this._data = { - user: window.user, - authenticated: !! window.user - }; + function() { + var _this = this; + _this._data = { + user: window.user, + authenticated: !! window.user + }; - return _this._data; - } + return _this._data; + } ]); From be497058fc87598b66e2aabd4bccea4adedb4aae Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Mon, 6 Jan 2014 18:01:23 -0300 Subject: [PATCH 18/21] little fix in tab spaces --- public/js/controllers/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/controllers/index.js b/public/js/controllers/index.js index 503829c..4cb2b6f 100755 --- a/public/js/controllers/index.js +++ b/public/js/controllers/index.js @@ -1,5 +1,5 @@ 'use strict'; angular.module('mystery.system').controller('IndexController', ['$scope', 'Global', function ($scope, Global) { - $scope.global = Global; + $scope.global = Global; }]); \ No newline at end of file From 075f86ba43fd8fbdf4c0ccba291b674f8d9158a4 Mon Sep 17 00:00:00 2001 From: Mario Colque Date: Mon, 6 Jan 2014 18:16:28 -0300 Subject: [PATCH 19/21] added installation steps --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 69bc9c9..35ff00c 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,13 @@ mystery ======= +## Install + +- sudo npm -g i grunt-cli +- npm i +- grunt + + ## bitcoind configuration There is a bitcoind configuration sample at: From ade4053e010bbe6cd2395422cc6ffd8f61d9c55d Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Mon, 6 Jan 2014 18:38:30 -0300 Subject: [PATCH 20/21] mocha support! --- Gruntfile.js | 11 +++++++++++ package.json | 12 +++++++----- test/test.js | 9 +++++++++ 3 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 test/test.js diff --git a/Gruntfile.js b/Gruntfile.js index 6d397b7..743d984 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -61,6 +61,13 @@ module.exports = function(grunt) { logConcurrentOutput: true } }, + mochaTest: { + options: { + reporter: 'spec', + require: 'server.js' + }, + src: ['test/*.js'] + }, env: { test: { NODE_ENV: 'test' @@ -71,6 +78,7 @@ module.exports = function(grunt) { //Load NPM tasks grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-mocha-test'); grunt.loadNpmTasks('grunt-nodemon'); grunt.loadNpmTasks('grunt-concurrent'); grunt.loadNpmTasks('grunt-env'); @@ -80,4 +88,7 @@ module.exports = function(grunt) { //Default task(s). grunt.registerTask('default', ['jshint', 'concurrent']); + + //Test task. + grunt.registerTask('test', ['env:test', 'mochaTest']); }; diff --git a/package.json b/package.json index b17b04a..b407613 100644 --- a/package.json +++ b/package.json @@ -47,12 +47,14 @@ "grunt-contrib-jshint": "~0.8.0", "grunt-contrib-watch": "~0.5.3", "grunt-concurrent": "~0.4.2", - "grunt-nodemon": "~0.1.2" + "grunt-nodemon": "~0.1.2", + "grunt-mocha-test": "~0.8.1" }, "devDependencies": { - "grunt-contrib-watch": "~0.5.3", - "grunt-contrib-jshint": "~0.8.0", - "grunt-nodemon": "~0.1.2", - "grunt-concurrent": "~0.4.2" + "grunt-contrib-watch": "latest", + "grunt-contrib-jshint": "latest", + "grunt-nodemon": "latest", + "grunt-concurrent": "latest", + "grunt-mocha-test": "latest" } } diff --git a/test/test.js b/test/test.js new file mode 100644 index 0000000..bab25b6 --- /dev/null +++ b/test/test.js @@ -0,0 +1,9 @@ +var assert = require("assert") +describe('Array', function(){ + describe('#indexOf()', function(){ + it('should return -1 when the value is not present', function(){ + assert.equal(-1, [1,2,3].indexOf(5)); + assert.equal(-1, [1,2,3].indexOf(0)); + }) + }) +}) From 6c4e476555d853ce1ea5b652f55685a576257573 Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Mon, 6 Jan 2014 19:36:47 -0300 Subject: [PATCH 21/21] mocha testing --- package.json | 6 ++++-- test/mocha.opts | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 test/mocha.opts diff --git a/package.json b/package.json index b407613..110c3e0 100644 --- a/package.json +++ b/package.json @@ -48,13 +48,15 @@ "grunt-contrib-watch": "~0.5.3", "grunt-concurrent": "~0.4.2", "grunt-nodemon": "~0.1.2", - "grunt-mocha-test": "~0.8.1" + "grunt-mocha-test": "~0.8.1", + "should": "~2.1.1" }, "devDependencies": { "grunt-contrib-watch": "latest", "grunt-contrib-jshint": "latest", "grunt-nodemon": "latest", "grunt-concurrent": "latest", - "grunt-mocha-test": "latest" + "grunt-mocha-test": "latest", + "should": "latest" } } diff --git a/test/mocha.opts b/test/mocha.opts new file mode 100644 index 0000000..74590dc --- /dev/null +++ b/test/mocha.opts @@ -0,0 +1,4 @@ +--require should +-R spec +--ui bdd +