Сабж. :)

Халявная виртуальная машина запущена на сервисах Амазона: aws.amazon.com.
Все файлы связаны с www.github.com + тестовый-сайт запущен через www.heroku.com.
Есть лекции в pdf и видео.

У меня не получается сделать третью часть домашки.

Part 3: Write SSJS headless grader

Свернутый текст

- Now that you have an extremely basic crowdfunding site up and running, we are going to write a simple node.js command line application which takes your crowdfunding URL as an input and returns a list of boolean flags in JSON format that check for the presence of HTML tags.

- Use npm at the command line to install two new node libraries, like we did last time with restler:

Код:
$ npm install cheerio
$ npm install commander

- We are going to call this script grader.js. Start with the following skeleton. Note that we are using a new node.js library for developing a command line application, and that we express the main routine as a function of the arguments given on the command line.

- You should read the code closely and use the emacs SSJS REPL to interact with it and figure out what the snippets do. In particular, reading a bit about JSON (1, 2) may be helpful.

- This is the initial checks.json file:

Код:
["h1",
 ".navigation"]

- You will modify this to add more checks (see below). Here is a sample use case:

Код:
[balajis@jiunit:~]$head -n3 index.html 
<!DOCTYPE html>
<html lang="en">
  <head>

[balajis@jiunit:~]$cat checks.json 
["h1",
 ".navigation"]

[balajis@jiunit:~]$./grader.js --checks checks.json --file index.html
{
    ".navigation": true,
    "h1": true
}

Задание №1:

Его я сделал:

- Update checks.json to include checks for all the following classes in the wireframe. Here's the list of checks; make sure to encode as JSON in checks.json.

Код:
h1
.navigation
.logo
.blank
.about
.heading
.subheading
.pitch
.video
.thermometer
.order
.social
.section1
.section2
.faq
.footer

You can probably figure out how to encode these in checks.json from context, but in a bit more detail: The idea here is that in the checkHtmlFile function, with the current checks.json we are only confirming that there is at least one <h1> tag (see here) and at least one HTML element with a .navigation CSS class (see here) in our index.html document. However, we want to test that the index.html file also has .thermometer, .pitch, and all the other classes depicted in the wireframe. So we need to add more rules to checks.json. (This really isn't a hard problem; just explaining what the idea is). We'll cover HTML/CSS in far greater detail soon, but try messing around with cheerio in your Emacs node REPL to get a sense of how this testing process works programmatically.

Так выглядит изменённый файл со всеми проверками:

Код:
[ubuntu@ip-172-31-28-104:~/bitstarter]$cat checks.json
["h1",
 ".navigation",
 ".logo",
 ".blank",
 ".about",
 ".heading",
 ".subheading",
 ".pitch",
 ".video",
 ".thermometer",
 ".order",
 ".social",
 ".section1",
 ".section2",
 ".faq",
 ".footer"]

Задание №2:

Его я не сделал:

- Update grader.js to take either a file or a URL as an input on the command line. Use the restler library from the previous HW to download the URL. Your final output should look like this, except it should include all the checks and not just the one for navigation.

Код:
[balajis@jiunit:~]$./grader.js --checks checks.json --url http://mighty-harbor-9416.herokuapp.com
{
    ".navigation": true,
    "h1": true
}

Т.к. на этом курсе учатся несколько десятков тысяч студентов со всего мира, вся домашняя работа проверяется автоматически.
Для того, чтобы отправить выполненную домашнюю работу на проверку, нужно:

- Submit the JSON output from running it on your sample URL (Output Submission) and your revised grader.js (Additional Submission).

- Yes, we know there are ways you can game this, but we're trying to be nice :)

- However, we'll look into setting up external automated graders for the next assignment.