Skip to content

Commit

Permalink
better login
Browse files Browse the repository at this point in the history
  • Loading branch information
Visnu Pitiyanuvath committed Jul 12, 2011
1 parent be7d537 commit 3079165
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 13 deletions.
11 changes: 7 additions & 4 deletions config/app.js
@@ -1,9 +1,10 @@
var express = require('express')
, auth = require('mongoose-auth')
, assets = require('connect-assetmanager')
, io = require('socket.io')
, env = require('./env')
, auth = require('mongoose-auth')
, coffee = require('coffee-script')
, cookieSession = require('connect-cookie-session')
, env = require('./env')
, io = require('socket.io')
, mongoose = require('mongoose')
, port = env.port
, secrets = env.secrets;
Expand Down Expand Up @@ -33,7 +34,7 @@ app.configure(function() {
app.use(express.cookieParser());
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.session({ secret: secrets.session }));
app.use(cookieSession({ secret: secrets.session }));
app.use(assets({
js: {
route: /\/javascripts\/all\.js/,
Expand Down Expand Up @@ -77,7 +78,9 @@ app.configure('production', function() {
app.set('view options', { scope: { development: false }});
});

// helpers
auth.helpExpress(app);
require('../helpers')(app);

app.listen(port);
app.ws = io.listen(app); // socket.io
Expand Down
29 changes: 29 additions & 0 deletions controllers/people.coffee
@@ -0,0 +1,29 @@
app = require '../config/app'
Person = app.db.model 'Person'

# index
app.get '/people', (req, res) ->
Person.find (err, people) ->
res.render2 'people', people: people

# show
app.get '/people/:id', (req, res, next) ->
Person.findById req.params.id, (err, person) ->
return next '404' unless person
res.render2 'people/show', person: person

# edit
app.get '/people/:id/edit', (req, res, next) ->
Person.findById req.params.id, (err, person) ->
return next '404' unless person
res.render2 'people/edit', person: person

# update
app.put '/people/:id', (req, res) ->
Person.findById req.params.id, (err, person) ->
_.extend person, req.body
person.save (err) ->
if err
res.render2 'people/edit', person: person, errors: err.errors
else
res.redirect "/people/#{person.id}"
4 changes: 4 additions & 0 deletions helpers/index.coffee
@@ -0,0 +1,4 @@
module.exports = (app) ->
app.helpers
gravatar_url: (person, size = 30) ->
"http://gravatar.com/avatar/#{person.github.gravatarId}?s=#{size}"
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -22,6 +22,7 @@
"coffee-script": "1.1.1",
"connect": "1.4.3",
"connect-assetmanager": "0.0.20",
"connect-cookie-session": "0.0.1",
"express": "2.4.2",
"jade": "0.11.0",
"markdown": "0.2.1",
Expand Down
6 changes: 3 additions & 3 deletions public/javascripts/application.js
Expand Up @@ -274,7 +274,7 @@ $(function() {
arguments: [ pos ]
}));

$window.scrollLeft(left).scrollTop(top)
//$window.scrollLeft(left).scrollTop(top)
}
nko.goTo = function goTo(selector) {
var page = $(selector)
Expand Down Expand Up @@ -479,8 +479,8 @@ $(function() {
//// page specific stuff

$('#page.index-index').each(function() {
new nko.Thing({ name: 'streetlamp', pos: new nko.Vector(-10, 100) });
new nko.Thing({ name: 'livetree', pos: new nko.Vector(-80, 30) });
new nko.Thing({ name: 'streetlamp', pos: new nko.Vector(-10, 160) });
new nko.Thing({ name: 'livetree', pos: new nko.Vector(-80, 120) });

new nko.Thing({ name: 'livetree', pos: new nko.Vector(-60, 870) });
new nko.Thing({ name: 'deadtree', pos: new nko.Vector(0, 900) });
Expand Down
13 changes: 10 additions & 3 deletions public/stylesheets/application.styl
Expand Up @@ -51,11 +51,18 @@ button, a.button
p
line-height 150%

img.avatar
vertical-align middle
margin-right 5px
border-radius 3px

aside
display block
float right
width 260px
margin-top 50px
margin-top 20px
.login
text-align center
table.important-dates
width 100%
border-collapse collapse
Expand Down Expand Up @@ -89,7 +96,7 @@ aside
#page
position relative
width 900px
margin 100px auto 0
margin 30px auto 0
text-align left
#inner
background-color hsla(0, 0%, 100%, 0.6)
Expand All @@ -98,7 +105,7 @@ aside
box-shadow 0 0 5px hsla(0, 0%, 0%, 0.1)
z-index 10000
position relative
padding 10px
padding 10px 20px
width 580px

.thing
Expand Down
6 changes: 4 additions & 2 deletions server.js
@@ -1,8 +1,10 @@
require('coffee-script');

[ 'index',
'teams',
[
'index',
'people',
'redirect',
'teams',
'websocket'
].forEach(function(controller) {
require('./controllers/' + controller);
Expand Down
5 changes: 4 additions & 1 deletion views/layout.jade
Expand Up @@ -13,7 +13,10 @@ html
aside
.login
- if (user)
= user.github.login
img.avatar( src: gravatar_url(user) )
a( href: '/people/' + user.id )= user.github.login
| |
a( href: '/logout' ) Sign out
- else
a.button( href: '/auth/github' ) Sign in

Expand Down
3 changes: 3 additions & 0 deletions views/people/show.jade
@@ -0,0 +1,3 @@
h1
img.avatar( src: gravatar_url(person, 80) )
= person.github.login

0 comments on commit 3079165

Please sign in to comment.