Navigation Menu

Skip to content

Commit

Permalink
Show the number of records found
Browse files Browse the repository at this point in the history
  • Loading branch information
darashi committed Aug 9, 2012
1 parent 8bdfef0 commit 93063e4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/server.js
Expand Up @@ -64,11 +64,16 @@ app.get('/', function(request, response, next){
if (error) {
return next(error);
}
var records = results.hits.hit;
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',
{records: records, query: query}
);
return response.render('search.jade', locals);
});
} else {
return response.render('index.jade',
Expand Down
3 changes: 3 additions & 0 deletions views/search.jade
Expand Up @@ -2,6 +2,9 @@ extends layout

block content
if records
.alert.alert-info
= "Found " + num_found + " entries. Showing " + from + " - " + to + " (" + num_showing + " entries)."

each record, index in records
.record
h2 #{record.data.title}
Expand Down

0 comments on commit 93063e4

Please sign in to comment.