Checked all the examples

This commit is contained in:
sakateka 2012-10-07 21:51:50 +04:00 committed by TJ Holowaychuk
parent fee0f0dce0
commit 8e12dd9c17
19 changed files with 103 additions and 88 deletions

View File

@ -2,10 +2,10 @@
* Module dependencies.
*/
var express = require('../../lib/express')
var express = require('../..')
, hash = require('./pass').hash;
var app = module.exports = express();
var app = express();
// config
@ -78,7 +78,7 @@ app.get('/', function(req, res){
});
app.get('/restricted', restrict, function(req, res){
res.send('Wahoo! restricted area');
res.send('Wahoo! restricted area, click to <a href="/logout">logout</a>');
});
app.get('/logout', function(req, res){
@ -120,4 +120,4 @@ app.post('/login', function(req, res){
if (!module.parent) {
app.listen(3000);
console.log('Express started on port 3000');
}
}

View File

@ -1,21 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Authentication Example</title>
<style>
body {
padding: 50px;
font: 13px Helvetica, Arial, sans-serif;
}
.error {
color: red
}
.success {
color: green;
}
</style>
</head>
<body>
<%- body %>
</body>
</html>

View File

@ -1,16 +1,36 @@
<h1>Login</h1>
<%- message %>
Try accessing <a href="/restricted">/restricted</a>, then authenticate with "tj" and "foobar".
<form method="post" action="/login">
<p>
<label>Username:</label>
<input type="text" name="username">
</p>
<p>
<label>Password:</label>
<input type="text" name="password">
</p>
<p>
<input type="submit" value="Login">
</p>
</form>
<!DOCTYPE html>
<html>
<head>
<title>Authentication Example</title>
<style>
body {
padding: 50px;
font: 13px Helvetica, Arial, sans-serif;
}
.error {
color: red
}
.success {
color: green;
}
</style>
</head>
<body>
<h1>Login</h1>
<%- message %>
Try accessing <a href="/restricted">/restricted</a>, then authenticate with "tj" and "foobar".
<form method="post" action="/login">
<p>
<label>Username:</label>
<input type="text" name="username">
</p>
<p>
<label>Password:</label>
<input type="text" name="password">
</p>
<p>
<input type="submit" value="Login">
</p>
</form>
</body>
</html>

View File

@ -1,3 +1,4 @@
body {
padding: 50px 80px;
font: 14px "Helvetica Nueue", "Lucida Grande", Arial, sans-serif;}
font: 14px "Helvetica Nueue", "Lucida Grande", Arial, sans-serif;
}

View File

@ -11,7 +11,7 @@ var express = require('../..')
// Config
app.set('view engine', 'ejs');
app.set('view engine', 'jade');
app.set('views', __dirname + '/views');
app.use(express.cookieParser());
app.use(express.methodOverride());
@ -35,4 +35,4 @@ app.put('/user/:id/edit', user.update);
app.get('/posts', post.list);
app.listen(3000);
console.log('Express app started on port 3000');
console.log('Express app started on port 3000');

View File

@ -1,4 +0,0 @@
<ul>
<li>Visit the <a href="/users">users</a> page</li>
<li>Visit the <a href="/posts">posts</a> page</li>
</ul>

View File

@ -0,0 +1,6 @@
extends layout
block content
ul
li Visit the <a href="/users">users</a> page
li Visit the <a href="/posts">posts</a> page

View File

@ -1,9 +0,0 @@
<html>
<head>
<title><%= title %></title>
<link href="/style.css" rel="stylesheet" />
</head>
<body>
<%- body %>
</body>
</html>

View File

@ -0,0 +1,6 @@
html
head
title= title
link(href="/style.css", rel="stylesheet")
body
block content

View File

@ -1,7 +0,0 @@
<h1>Posts</h1>
<dl id="posts">
<% posts.forEach(function(post){ %>
<dt><%= post.title %></dt>
<dd><%= post.body %></dd>
<% }) %>
</dl>

View File

@ -0,0 +1,8 @@
extends ../layout
block content
h1 Posts
dl#posts
for post in posts
dt= post.title
dd= post.body

View File

@ -1,9 +0,0 @@
<h1>Editing <%= user.name %></h1>
<div id="user">
<form method="post">
<input type="hidden" value="put" name="_method" />
<p>Name: <input type="text" value="<%= user.name %>" name="user[name]"/></p>
<p>Email: <input type="text" value="<%= user.email %>" name="user[email]"/></p>
<p><input type="submit" value="Save" /></p>
</form>
</div>

View File

@ -0,0 +1,14 @@
extends ../layout
block content
h1 Editing #{user.name}
#user
form(method="post")
input(type="hidden", value="put", name="_method")
p Name:
input(type="text", value= user.name, name="user[name]")
p Email:
input(type="text", value= user.email, name="user[email]")
p
input(type="submit", value="Save")

View File

@ -1,9 +0,0 @@
<h1>Users</h1>
<ul id="users">
<% users.forEach(function(user, id){ %>
<li>
<a href="/user/<%= id %>"><%= user.name %></a>
<a class="edit" href="/user/<%= id %>/edit">edit</a>
</li>
<% }) %>
</ul>

View File

@ -0,0 +1,9 @@
extends ../layout
block content
h1 Users
#users
for user, i in users
li
a(href="/user/#{i}")= user.name
a.edit(href="/user/#{i}/edit") edit

View File

@ -1,4 +0,0 @@
<h1><%= user.name %></h1>
<div id="user">
<p>Email: <%= user.email %></p>
</div>

View File

@ -0,0 +1,6 @@
extends ../layout
block content
h1= user.name
#user
p Email: #{user.email}

View File

@ -1,4 +1,8 @@
// first:
// $ npm install redis
// $ redis-server
/**
* Module dependencies.
*/
@ -54,4 +58,4 @@ app.get('/client.js', function(req, res){
});
app.listen(3000);
console.log('app listening on port 3000');
console.log('app listening on port 3000');

View File

@ -1,4 +1,8 @@
// first:
// $ npm install redis
// $ redis-server
var express = require('../..');
var app = express();
@ -25,4 +29,4 @@ app.get('/', function(req, res){
});
app.listen(3000);
console.log('Express app started on port 3000');
console.log('Express app started on port 3000');