WebFund 2013F: Assignment 1: Difference between revisions

From Soma-notes
No edit summary
Line 83: Line 83:
==views/index.jade==
==views/index.jade==


<source line lang="jade">
<source line lang="html4strict">
h1= title
h1= title


div.well
div
   p Fill out your info
   p Fill out your info
   form(method="post", action="/add")
   form(method="post", action="/add")
     div.control-group.input-append
     div
       input#name(type="text", name="name", data-required)
       input#name(type="text", name="name")
       label.add-on(for="name")  
       label.add-on(for="name")
        span.icon-asterisk
         | Name
         | Name
     div.control-group.input-append
     div
       input#country(type="text", name="country", data-required)
       input#country(type="text", name="country")
       label.add-on(for="country")
       label.add-on(for="country")
        span.icon-asterisk
         | Country
         | Country
     div.control-group.input-append
     div
       input#birthday(type="text", name="birthday", data-required)
       input#birthday(type="text", name="birthday")
       label.add-on(for="birthday")
       label.add-on(for="birthday")
        span.icon-asterisk
         | Birthday
         | Birthday
     div.control-group.input-append
     div
       label.checkbox
       label.checkbox
         input#send-email(type="checkbox", name="send-email")
         input#send-email(type="checkbox", name="send-email")
         | Email Me
         | Email Me
     div#email-info.control-group.input-append
     div
       input#email(type="text", name="email")
       input#email(type="text", name="email")
       label.add-on(for="email")
       label.add-on(for="email")
        span.icon-asterisk
         | Email
         | Email
     button(type="submit") Submit
     button(type="submit") Submit
Line 119: Line 115:
==views/add.jade==
==views/add.jade==


<source line lang="jade">
<source line lang="html4strict">
h1 Info Added
h1 Info Added
p Name: #{name}
p Name: #{name}

Revision as of 04:29, 20 September 2013

In this assignment you are to examine, modify, and answer questions regarding the form-demo sample node application. For reference, the key files are included below.

package.json

{
    "name": "application-name"
  , "version": "0.0.1"
  , "private": true
  , "dependencies": {
      "express": "2.5.8"
    , "jade": ">= 0.0.1"
  }
}

app.js

/**
 * Module dependencies.
 */

var express = require('express')
  , routes = require('./routes');

var app = module.exports = express.createServer();

// Configuration

app.configure(function(){
  app.set('views', __dirname + '/views');
  app.set('view engine', 'jade');
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(app.router);
  app.use(express.static(__dirname + '/public'));
});

app.configure('development', function(){
  app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});

app.configure('production', function(){
  app.use(express.errorHandler());
});

// Routes

app.get('/', routes.index);
app.post('/add', routes.add);

app.listen(3010, function(){
  console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
});

public/stylesheets/style.css


routes/index.js


views/layout.jade

!!!
html
  head
    title= title
    link(rel='stylesheet', href='/stylesheets/style.css')
  body!= body

views/index.jade

h1= title

div
  p Fill out your info
  form(method="post", action="/add")
    div
      input#name(type="text", name="name")
      label.add-on(for="name")
        | Name
    div
      input#country(type="text", name="country")
      label.add-on(for="country")
        | Country
    div
      input#birthday(type="text", name="birthday")
      label.add-on(for="birthday")
        | Birthday
    div
      label.checkbox
        input#send-email(type="checkbox", name="send-email")
        | Email Me
    div
      input#email(type="text", name="email")
      label.add-on(for="email")
        | Email
    button(type="submit") Submit


views/add.jade

h1 Info Added
p Name: #{name}
p Country: #{country}
p Date: #{date}
p Email: #{email}