Permalink
Browse files

Changed from a POST to a GET for the search page. Makes the result pa…

…ge refreshable, also fits in with where I want to go with the API
  • Loading branch information...
1 parent e369d9b commit bfda944508f097ebfb7fbeab9bddca62b35d6cd0 @csainty csainty committed Apr 6, 2012
Showing with 6 additions and 6 deletions.
  1. +1 −1 app.js
  2. +4 −4 routes/search.js
  3. +1 −1 views/index.jade
View
2 app.js
@@ -56,7 +56,7 @@ app.get('/ask', require('./routes/ask.js'));
app.get('/create', require('./routes/create.js'));
app.get('/wat/:id', require('./routes/wat.js'));
-app.post('/search', require('./routes/search.js'));
+app.get('/search', require('./routes/search.js'));
app.listen(port, address);
View
8 routes/search.js
@@ -4,14 +4,14 @@ var mongoose = require('mongoose')
;
module.exports = function (req, res) {
- if (!req.body.q || req.body.q.length === 0) { return res.redirect('/'); }
+ if (!req.query.q || req.query.q.length === 0) { return res.redirect('/'); }
Wat
- .find({ phrase: req.body.q })
+ .find({ phrase: req.query.q })
.populate('_user')
.run(function (err, results) {
if (err) { return res.redirect('/error'); }
- if (results.length === 0) { return res.redirect(url.format({ pathname: '/create', query: { phrase: req.body.q } })); }
- res.render('search', { title: 'say wat?', results: results, query: req.body.q });
+ if (results.length === 0) { return res.redirect(url.format({ pathname: '/create', query: { phrase: req.query.q } })); }
+ res.render('search', { title: 'say wat?', results: results, query: req.query.q });
});
};
View
2 views/index.jade
@@ -5,7 +5,7 @@ div.row-fluid
div.row-fluid
div.search
- form(method='POST', action='/search')
+ form(method='GET', action='/search')
div.span8
input(type='text', name='q')
div.span3

0 comments on commit bfda944

Please sign in to comment.