[Groonga-commit] nroonga/norema [master] Use different path for search

Back to archive index

null+****@clear***** null+****@clear*****
2012年 8月 9日 (木) 15:50:28 JST


Yoji SHIDARA	2012-08-09 15:50:28 +0900 (Thu, 09 Aug 2012)

  New Revision: 76bd2243db3eaaebc4132fd1637456e570f02552
  https://github.com/nroonga/norema/commit/76bd2243db3eaaebc4132fd1637456e570f02552

  Log:
    Use different path for search

  Modified files:
    lib/server.js
    views/layout.jade

  Modified: lib/server.js (+21 -22)
===================================================================
--- lib/server.js    2012-08-09 15:44:56 +0900 (059b9c5)
+++ lib/server.js    2012-08-09 15:50:28 +0900 (00d815d)
@@ -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);

  Modified: views/layout.jade (+1 -1)
===================================================================
--- views/layout.jade    2012-08-09 15:44:56 +0900 (82fb630)
+++ views/layout.jade    2012-08-09 15:50:28 +0900 (26d0158)
@@ -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
-------------- next part --------------
HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...
Download 



Groonga-commit メーリングリストの案内
Back to archive index