forked from nko2/website
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Visnu Pitiyanuvath
committed
Jul 12, 2011
1 parent
be7d537
commit 3079165
Showing
9 changed files
with
65 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = (app) -> | ||
app.helpers | ||
gravatar_url: (person, size = 30) -> | ||
"http://gravatar.com/avatar/#{person.github.gravatarId}?s=#{size}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
h1 | ||
img.avatar( src: gravatar_url(person, 80) ) | ||
= person.github.login |