Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ubuntu committed Jul 7, 2013
1 parent 55e5e9f commit d45a1d5
Show file tree
Hide file tree
Showing 525 changed files with 38,830 additions and 6,700 deletions.
16 changes: 16 additions & 0 deletions checker/checks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
["h1",
".navigation",
".logo",
".blank",
".about",
".heading",
".subheading",
".pitch",
".video",
".thermometer",
".order",
".social",
".section1",
".section2",
".faq",
".footer"]
74 changes: 74 additions & 0 deletions checker/grader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env node
/*
Automatically grade files for the presence of specified HTML tags/attributes.
Uses commander.js and cheerio. Teaches command line application development
and basic DOM parsing.
References:
+ cheerio
- https://github.com/MatthewMueller/cheerio
- http://encosia.com/cheerio-faster-windows-friendly-alternative-jsdom/
- http://maxogden.com/scraping-with-node.html
+ commander.js
- https://github.com/visionmedia/commander.js
- http://tjholowaychuk.com/post/9103188408/commander-js-nodejs-command-line-interfaces-made-easy
+ JSON
- http://en.wikipedia.org/wiki/JSON
- https://developer.mozilla.org/en-US/docs/JSON
- https://developer.mozilla.org/en-US/docs/JSON#JSON_in_Firefox_2
*/

var fs = require('fs');
var program = require('commander');
var cheerio = require('cheerio');
var HTMLFILE_DEFAULT = "index.html";
var CHECKSFILE_DEFAULT = "checks.json";

var assertFileExists = function(infile) {
var instr = infile.toString();
if(!fs.existsSync(instr)) {
console.log("%s does not exist. Exiting.", instr);
process.exit(1); // http://nodejs.org/api/process.html#process_process_exit_code
}
return instr;
};

var cheerioHtmlFile = function(htmlfile) {
return cheerio.load(fs.readFileSync(htmlfile));
};

var loadChecks = function(checksfile) {
return JSON.parse(fs.readFileSync(checksfile));
};

var checkHtmlFile = function(htmlfile, checksfile) {
$ = cheerioHtmlFile(htmlfile);
var checks = loadChecks(checksfile).sort();
var out = {};
for(var ii in checks) {
var present = $(checks[ii]).length > 0;
out[checks[ii]] = present;
}
return out;
};

var clone = function(fn) {
// Workaround for commander.js issue.
// http://stackoverflow.com/a/6772648
return fn.bind({});
};

if(require.main == module) {
program
.option('-c, --checks <check_file>', 'Path to checks.json', clone(assertFileExists), CHECKSFILE_DEFAULT)
.option('-f, --file <html_file>', 'Path to index.html', clone(assertFileExists), HTMLFILE_DEFAULT)
.parse(process.argv);
var checkJson = checkHtmlFile(program.file, program.checks);
var outJson = JSON.stringify(checkJson, null, 4);
console.log(outJson);
} else {
exports.checkHtmlFile = checkHtmlFile;
}
8 changes: 4 additions & 4 deletions index.html → client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset = "utf-8">
<title>My First Bitstarter</title>
<link type="text/css" rel="stylesheet"
href = "bootstrap/css/bootstrap.css">
href = "vendor/bootstrap/css/bootstrap.css">
<style type="text/css">
body {
padding-top: 20px;
Expand Down Expand Up @@ -65,13 +65,13 @@
Video
</div>
<div class = "span6">
<div class = "thermometer">
<div class = " thermometer">
Thermometer
</div>
<div class = "order">
<div class = " order">
Order
</div>
<div class= "social">
<div class = " social">
Social
</div>
</div>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
106 changes: 106 additions & 0 deletions client/views/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<!DOCTYPE>
<html lang="en">
<head>
<meta charset = "utf-8">
<title>My First Bitstarter</title>
<link type="text/css" rel="stylesheet"
href = "vendor/bootstrap/css/bootstrap.css">
<style type="text/css">
body {
padding-top: 20px;
padding-bottom: 40px;
}.container {
width: 960px;
}
p.lead{
padding-top: 15px;
}
.navigation, .pitch, .section1, .section2, .faq, .footer{
padding: 10px 0px 10px 0px;
}
.video, .thermometer, .order, .social {
border: 1px dotted;
text-align: center;
}
.video {
/* Internal boarder have 1px eidth, thus we need to add 4 x 1px to 120px */
height : 124px;
line-height: 124px;
}
.thermometer, .order, .social {
/* line height to vertically center : http://phrogz.net/css/vertical-align/index.html*/
height: 40px;
line-height: 40px;
}
div.row {
border: 1px solid;
}
</style>
</head>

<body>
<div class="container">
<div class="row navigation">
<div class = "span2 logo">
Logo
</div>
<div class = "span6 blank">
Blank
</div>
<div class = "span4 about">
About
</div>
</div>

<div class = "row heading">
<div class = "span12"> <h1>Bitstarter Title</h1></div>
</div>
<div class = "row subheading">
<div class="span12">
<p class = "lead">This is my first bitstarter project</p>
</div>
</div>
<div class = "row pitch">
<div class = "span6 video">
Video
</div>
<div class = "span6">
<div class = " thermometer">
Thermometer
</div>
<div class = " order">
Order
</div>
<div class = " social">
Social
</div>
</div>
</div>

<div class = "row section1">
<div class = "span12">
Makreting Section 1
</div>
</div>

<div class = "row section2">
<div class = "span12">
Makreting Section 2
</div>
</div>

<div class = "row faq">
<div class = "span12">
FAQ
</div>
</div>

<div class = "row footer">
<div class = "span12">
Footer
</div>
</div>
</div>
</div>
</body>
</html>
1 change: 1 addition & 0 deletions node_modules/.bin/jade

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions node_modules/cheerio/.npmignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions node_modules/cheerio/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d45a1d5

Please sign in to comment.