Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

1

  • Loading branch information...
commit 96c90737e4d5574e291db7349a969376c193cfb5 1 parent d06600d
Stefan Gebhardt authored
7 nodepad/app.js
@@ -134,9 +134,16 @@ var fireWall = [loadUser, updateGranted];
134 134 // UI routes
135 135 app.get('/', loadUser, routes.index);
136 136 app.get('/you', loadUser, routes.you);
  137 +app.get('/all', loadUser, routes.all);
137 138 // app.get('/documents', loadUser, routes.index);
138 139
139 140 // Service routes
  141 +app.get('/users', loadUser, function(req, res) {
  142 + User.find(function(error, users) {
  143 + if( error ) res.json({msg: "Failed listing users"}, 500);
  144 + else res.json(users, 200);
  145 + });
  146 +});
140 147 app.get('/users/:id', loadUser, function(req, res) {
141 148 res.json( req.user, 200 );
142 149 });
2  nodepad/public/javascripts/application.js
@@ -18,7 +18,7 @@ var ccd = {
18 18 }(),
19 19 templates: {
20 20 you: '<div class="plate <%= colorClass %>" date-phase="<%= data.phase %>" id="<%= data._id %>" style="background: <%= data.phase %>;">\
21   - <div class="name"><%= data.name %></div>\
  21 + <div class="name"><%= data.login %></div>\
22 22 <div class="day"><%= data.day %></div>\
23 23 <button data-role="increase-day">+</button>\
24 24 </div>'
4 nodepad/routes/index.js
@@ -11,3 +11,7 @@ exports.index = function(req, res){
11 11 exports.you = function( req, res ) {
12 12 res.render ( 'user/you', {user: req.user} );
13 13 }
  14 +exports.all = function( req, res ) {
  15 + res.render ( 'user/all', {user: req.user} );
  16 +}
  17 +
12 nodepad/views/user/all.jade
... ... @@ -0,0 +1,12 @@
  1 +h1= 'Brave nerds of our time'
  2 +div(id='main')
  3 +a(href='/logout') Logout
  4 +a(href='/you') You
  5 +script(type='text/javascript')
  6 + jQuery(function($) {
  7 + // Initialize your application here.
  8 + var module_user = ccd.module('user');
  9 + var users = new module_user.List;
  10 + var listview = new module_user.Listview({ 'el': $('#main'), collection: users });
  11 + users.fetch();
  12 + });
1  nodepad/views/user/you.jade
@@ -3,6 +3,7 @@ p Welcome to #{user.login}
3 3 p Your id is #{user.id}
4 4 div(id='main')
5 5 a(href='/logout') Logout
  6 +a(href='/all') See who is also using ccd
6 7 script(type='text/javascript')
7 8 jQuery(function($) {
8 9 // Initialize your application here.

0 comments on commit 96c9073

Please sign in to comment.
Something went wrong with that request. Please try again.