Navigation Menu

Skip to content

Commit

Permalink
Use different path for search
Browse files Browse the repository at this point in the history
  • Loading branch information
darashi committed Aug 9, 2012
1 parent a81d0ac commit 76bd224
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
43 changes: 21 additions & 22 deletions lib/server.js
Expand Up @@ -56,30 +56,29 @@ function search(query, callback) {
};

// routings
app.get('/', function(request, response, next){
app.get('/', function(request, response){
return response.render('index.jade', {query: ''});
});

app.get('/search', function(request, response, next) {
var query = request.query.query;
if (query) {
console.log('QUERY <' + query + '>');
search(query, function(error, results) {
if (error) {
return next(error);
}
var locals = {
query: query,
records: results.hits.hit,
num_found: results.hits.found,
from: results.hits.start + 1,
to: results.hits.start + results.hits.hit.length,
num_showing: results.hits.hit.length
};

return response.render('search.jade', locals);
});
} else {
return response.render('index.jade',
{query: ''}
);
}
console.log('QUERY <' + query + '>');
search(query, function(error, results) {
if (error) {
return next(error);
}
var locals = {
query: query,
records: results.hits.hit,
num_found: results.hits.found,
from: results.hits.start + 1,
to: results.hits.start + results.hits.hit.length,
num_showing: results.hits.hit.length
};

return response.render('search.jade', locals);
});
});

console.log('Search node is ' + searchNode);
Expand Down
2 changes: 1 addition & 1 deletion views/layout.jade
Expand Up @@ -12,7 +12,7 @@ html
.navbar-inner
.container
a.brand(href="/") norema
form.navbar-search.pull-right#domain
form(action="search").navbar-search.pull-right#domain
input(type="text", value=query, name="query", placeholder="search")#query
.container
block content
Expand Down

0 comments on commit 76bd224

Please sign in to comment.