Navigation Menu

Skip to content

Commit

Permalink
Extract urlForSearch helpter
Browse files Browse the repository at this point in the history
  • Loading branch information
darashi committed Aug 21, 2012
1 parent 38fba4f commit 0af35f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/server.js
Expand Up @@ -64,6 +64,10 @@ function titleToId(title) {
.replace(/^_|_$/g, '');
}

function urlForSearch(options) {
return "/search?"+querystring.stringify(options);
}

// routings
app.get('/', function(request, response){
return response.render('index.jade', {query: ''});
Expand All @@ -79,7 +83,7 @@ app.get('/search', function(request, response, next) {
}

var locals = {
querystring: querystring,
urlForSearch: urlForSearch,
titleToId: titleToId,
query: query,
records: results.hits.hit,
Expand Down
2 changes: 1 addition & 1 deletion views/search.jade
Expand Up @@ -24,7 +24,7 @@ block content
p.path
each title, pathIndex in record.data.path
span
a(href="/search?"+querystring.stringify({query: title}))
a(href=urlForSearch({query: title}))
= title
if pathIndex != record.data.path.length - 1
span »
Expand Down

0 comments on commit 0af35f4

Please sign in to comment.