forked from heroku/node-js-sample
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ubuntu
committed
Jul 7, 2013
1 parent
55e5e9f
commit d45a1d5
Showing
525 changed files
with
38,830 additions
and
6,700 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.