Permalink
Browse files

initial scaffolding for app

  • Loading branch information...
nolanlawson committed Nov 8, 2013
1 parent 153aaf5 commit 35e71e0c07afeacd02c1beee858eb634a6588883
@@ -4,3 +4,4 @@ dist
.sass-cache
app/bower_components
.idea
.DS_Store
@@ -3,7 +3,6 @@
"browser": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
@@ -20,6 +19,7 @@
"trailing": true,
"smarttabs": true,
"globals": {
"angular": false
"angular" : false,
"_" : true
}
}
@@ -13,7 +13,7 @@ html.no-js
meta(http-equiv='X-UA-Compatible', content='IE=edge')
title The Ultimate Crossword
meta(name='description', content='')
meta(name='viewport', content='width=device-width')
meta(name='viewport', content='width=device-width, initial-scale=1.0')
// Place favicon.ico and apple-touch-icon.png in the root directory
// build:css(.tmp) styles/main.css
link(rel='stylesheet', href='styles/main.css')
@@ -44,6 +44,7 @@ html.no-js
//-ga('send', 'pageview');
script(src='bower_components/jquery/jquery.js')
script(src='bower_components/angular/angular.js')
script(src='bower_components/underscore/underscore.js')
// build:js scripts/plugins.js
script(src='bower_components/bootstrap-sass/js/bootstrap-affix.js')
script(src='bower_components/bootstrap-sass/js/bootstrap-alert.js')
@@ -66,6 +67,9 @@ html.no-js
// endbuild
// build:js({.tmp,app}) scripts/scripts.js
script(src='scripts/app.js')
script(src='scripts/services/constants.js')
script(src='scripts/services/blocks.js')
script(src='scripts/controllers/main.js')
script(src='scripts/controllers/navbar.js')

// endbuild
@@ -1,10 +1,27 @@
'use strict';

angular.module('ultimate-crossword')
.controller('MainController', function ($scope) {
$scope.awesomeThings = [
'HTML5 Boilerplate',
'AngularJS',
'Karma'
];
});
.controller('MainController', ['$scope', '$http', 'constants', 'blocks',
function ($scope, $http, constants, blocks) {


$scope.blocks = blocks;

function onError() {
console.log('got an error');
}

$http({method: 'GET',
url: constants.couchdb.url + '/_design/counts_to_blocks/_view/counts_to_blocks/',
params: {limit: constants.pageSize, descending: true, 'include_docs' : true}})
.success(function (data) {
if (!data.rows) {
onError();
}

blocks.loadPage(data.rows);

}).error(onError);


}]);
@@ -0,0 +1,43 @@
'use strict';
/**
* User: nolan
* Date: 11/6/13
* Time: 11:08 PM
*
* Shared singleton that represents "block" data we've fetched from CouchDB.
*
*/
function BlocksService() {

this.currentPage = [];
this.previousPages = [];
this.nextPages = [];

}

function transformOtherBlocks(otherBlocks) {
return _(_.pairs(otherBlocks)).map(function(pair) {
var id = pair[0];
var hints = pair[1];
return {
_id : id,
hints : hints,
joinedHints : _(hints).join(', ')
};
});
}

BlocksService.prototype.loadPage = function (rows) {

this.currentPage = _(rows).map(function(row){
var block = _({count : row.key}).extend(_.pick(row.doc, '_id', 'hints'));

block.joinedHints = _(block.hints).join(', ');
block.precedingBlocks = transformOtherBlocks(row.doc.preceding_blocks);
block.followingBlocks = transformOtherBlocks(row.doc.following_blocks);

return block;
});
};

angular.module('ultimate-crossword').service('blocks', [ BlocksService]);
@@ -0,0 +1,17 @@
'use strict';
/**
* Created with JetBrains WebStorm.
* User: nolan
* Date: 11/6/13
* Time: 11:08 PM
* To change this template use File | Settings | File Templates.
*/
function ConstantsService() {

this.couchdb = {
url : 'http://localhost:5984/block_stats'
};
this.pageSize = 10;
}

angular.module('ultimate-crossword').service('constants', [ConstantsService]);
@@ -0,0 +1,30 @@
@font-face {
font-family: 'Scramble';
src: url('fonts/scramble-webfont.eot');
src: url('fonts/scramble-webfont.eot?#iefix') format('embedded-opentype'),
url('fonts/scramble-webfont.woff') format('woff'),
url('fonts/scramble-webfont.ttf') format('truetype'),
url('fonts/scramble-webfont.svg#scrambleregular') format('svg');
font-weight: normal;
font-style: normal;

}

@font-face {
font-family: 'Pacifico';
src: url('fonts/pacifico-webfont.eot');
src: url('fonts/pacifico-webfont.eot?#iefix') format('embedded-opentype'),
url('fonts/pacifico-webfont.woff') format('woff'),
url('fonts/pacifico-webfont.ttf') format('truetype'),
url('fonts/pacifico-webfont.svg#pacificoregular') format('svg');
font-weight: normal;
font-style: normal;
}

.pacifico-font {
font-family : 'Pacifico'
}

.scramble-font {
font-family : 'Scramble'
}
Binary file not shown.
Oops, something went wrong.

0 comments on commit 35e71e0

Please sign in to comment.