Skip to content

Commit

Permalink
Merge branch 'master' of github.com:SlexAxton/rhokgho
Browse files Browse the repository at this point in the history
* 'master' of github.com:SlexAxton/rhokgho:
  More pledge api.
  Post pledges.
  looking good
  presentation
  • Loading branch information
alexzelenak committed Jun 3, 2012
2 parents 8d32c34 + 58648f6 commit d3cd898
Show file tree
Hide file tree
Showing 26 changed files with 3,812 additions and 14 deletions.
53 changes: 53 additions & 0 deletions app/routes/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var db = new mongo.Db('goh', mongoServer);
db.open(function (err, db) {});
var challenges = db.collection('challenges');
var usersCollection = db.collection('users');
var pledgesCollection = db.collection('pledges');

// only supports get and post... probably good enough
function router(prefix, app) {
Expand Down Expand Up @@ -62,6 +63,58 @@ exports.routes = function (prefix, app) {
// make all api routes start with prefix
app = router(prefix, app);

app.get('/pledge', function (req, res) {
pledgesCollection.find({}).sort({ created : -1 }).limit(100).toArray(function (err, items) {
res.json({
results : items
});
});
});

app.post('/pledge', function (req, res) {
pledgesCollection.insert({
created : moment().valueOf(),
amount : req.param('amount'),
total : req.param('total'),
email : req.param('email'),
anonymous : req.param('anonymous') === 'on',
reminder : req.param('reminder') === 'on',
phone : req.param('phone')
},
{ safe : true },
function (err, items) {
res.json({
error : false,
results : items
})
});
});

app.get('/pledge/:id', function (req, res) {
pledgesCollection.find({ _id : new ObjectID(req.params.id) }).toArray(function (err, items) {
var pledge = items[0];
if (pledge) {
res.json({
error : !!err,
data : {
created : moment().valueOf(),
amount : pledge.amount,
total : pledge.total,
email : pledge.email,
anonymous : pledge.anonymous,
reminder : pledge.reminder,
phone : pledge.phone
}
});
} else {
res.json({
error : true,
data : {}
});
}
});
});

// get a list of challenges, limited to 100, sorted by create time desc
app.get('/challenge', function (req, res) {
challenges.find({}).sort({ created : -1 }).limit(100).toArray(function (err, items) {
Expand Down
3 changes: 3 additions & 0 deletions public/presentation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# MVC Module Magic

The talk that I gave at BackboneConf 2012
2 changes: 2 additions & 0 deletions public/presentation/assets/fonts/leaguegothic/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SIL Open Font License (OFL)
http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL
Binary file not shown.
24 changes: 24 additions & 0 deletions public/presentation/css/fonts.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@font-face {
font-family: 'Lato';
font-style: italic;
font-weight: 400;
src: local('Lato Italic'), local('Lato-Italic'), url('RYyZNoeFgb0l7W3Vu1aSWOvvDin1pK8aKteLpeZ5c0A.woff') format('woff');
}
@font-face {
font-family: 'Lato';
font-style: normal;
font-weight: 400;
src: local('Lato Regular'), local('Lato-Regular'), url('qIIYRU-oROkIk8vfvxw6QvesZW2xOQ-xsNqO47m55DA.woff') format('woff');
}
@font-face {
font-family: 'Lato';
font-style: normal;
font-weight: 700;
src: local('Lato Bold'), local('Lato-Bold'), url('qdgUG4U09HnJwhYI-uK18wLUuEpTyoUstqEm5AMlJo4.woff') format('woff');
}
@font-face {
font-family: 'Lato';
font-style: italic;
font-weight: 700;
src: local('Lato Bold Italic'), local('Lato-BoldItalic'), url('HkF_qI1x_noxlxhrhMQYELO3LdcAZYWl9Si6vvxL-qU.woff') format('woff');
}
Loading

0 comments on commit d3cd898

Please sign in to comment.