Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
The main repo for Comm Lab Web at ITP. See forks for individual teacher repos.
Ruby Java
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples
.gitignore adding image upload example
README.md Update README.md

README.md

Comm Lab Web Syllabus Fall 2012

Week 1: Hello, Sinatra

Readings For This Week

Introduction

  • Introduction and software  we’ll use in this class
  • Map of interaction: User to Client, over Network, to Server, to Datastore, and back.
  • Web / HTTP
    • Basics of client/server/datastore interaction
    • Using the web to allow access to remote resources, to respond to multiple clients, to apply conditional logic, to persist data, to accumulate data.
  • HTTP Requests
  • Examples of clients

HTML

  • Intro to HTML

    • Tags that open and close
    • Mark up content
    • Nested tags
  • Tags

Dynamic HTML with Sinatra and HTML form

Assignment

Part 1

You've got a great idea for the next big thing: it's called Etzy, and it's a place to sell artwork online. You want to drum up interest and get some visitor feedback, so you decide to create a signup form!

For this assignment you must create a page where a visitor can input his or her name and email, and some preferences. We're not worried about doing anything with the form data right now, or even making it pretty. Just focus on getting the markup complete.

Requirements

The page should include the following:

  • a heading for the name of the business
  • a sentence describing what it does
  • a text input for a name
  • a text input for an email address
  • a checkbox for receiving an email newsletter
  • a dropdown menu for "How you heard about us" ("google", "from a friend", "online ad", etc.)
  • a radio button group for choosing a role ("buyer", "seller", or "both")
Reference

Part 2

We will also start looking at Ruby and Sinatra this week too, so we can start building a backend for our signup form.

Week 2: Basics of a Sinatra script

Readings For This Week

Sinatra Up and Running, p. 15-21 (It’s not much, so please read it thoroughly)

Review

  • HTML basics
  • Class Homework

Sinatra

HTML Forms

  • Render HTML with Sinatra
  • Send to route in Sinatra

Setting up a Sinatra app on the ITP server

  1. Open Terminal (Putty for Windows)
  2. run ssh netid@stu.itp.nyu.edu. Remember to put in your netid instead of “netid”
  3. Type in your password when prompted
  4. run ruby /etc/new_sinatra_app.rb nameofapp. Remember to replace “nameofapp” with the name of your application.
  5. Go to your blank Sinatra app here (using your netid and the name of your app):http://itp.nyu.edu/ ~ netID /sinatra/ nameofapp

Homework For Next Week

Create a new Sinatra application on the ITP Server. Create a GET “/form” route that returns an HTML form with a few different input types. Create a POST “/form” route that reads these parameters and sends back a dynamic HTML page.

Week 3: Basics of Datamapper

Readings For This Week

An Introduction to Datamapper  - (Skip “Installing” part)

What is a database?

  • Simplest model: a database can be a file
  • Read and write to a file as a simple model of persistence
  • YAML

Datamapper

Homework For Next Week

For next week, you will use datamapper to save the information from the form you built last week. These are the steps you need to create:

  • A GET route - this route returns a form for the user to fill out. You will need to:
    • Create the get route
    • Create a .erb file with the HTML for the form
    • This form will need an action attribute that points to your post route
  • A POST route - this route saves the values from the form, retrieves all saved values, and inserts them in the HTML response. You will need to:
    • Create the post route
    • Copy/paste the basic datamapper setup code
    • Create a datamapper class, with at least the basic setup and a property (besides the id)
    • Create a new object from your class, and assign values from the params array
    • Call "save" on the object to save it to the database
    • Create a global variable and assign all objects from the database
    • Create a .erb file with the HTML
    • Loop through this global variable in the erb file, and output all values of the objects

Again, all of this code is in the example from the class. You can use it for reference, but please write the assignment code yourself.

Week 4: Advanced Sinatra

Readings For This Week

Sinatra Up and Running, p. 21-30

Creating a Blog in Sinatra

Advanced routes

Homework For Next Week

  • Build a small web application that demonstrates the usage of:
    • get and post routes
    • .erb views
    • datamapper class
    • saving data with datamapper
    • retrieving data with datamapper (.all or .get)
    • :colon in route
  • The application should have:
    • A get route that shows all objects from DB
    • a get route to show form
    • a post route to save new object from form
    • a permalink get route to show each object
  • Start planning your final project. Be prepared to talk about your idea next class.

Week 5: Advanced Datamapper

Readings For This Week

Look at theDatamapper Documentation . See if you can find features that you can use.

Final Project Discussion

What do you want to do? What is preventing you from doing it?

Advanced Datamapper

  • Birthday Registration Example
  • More Datatypes
  • Datatype options
    • Required
    • Default
    • Length
  • Finding Records
    • first
    • all
    • first_or_new
    • Conditions (gt, lt, gte, lte, not, eql, like)
    • Ordering (desc, asc)
    • Counting

Some hints about CSS

Homework For Next Week

Week 6: More Clients and Project Help

Image Upload

Processing

  • loadStrings to your app
  • Making calls fromHTTProcessing
  • Other file formats (XML and JSON)

Ruby

Calling your site with a Ruby script on your machine

APIs

If we have time, let’s use other people’s APIs.

Week 7: Final Project Presentations

Let’s present your sites!

Something went wrong with that request. Please try again.