From d6b9a2799b8de02c7f6be78f7fa87770ab3ad693 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Sat, 3 Aug 2013 20:54:16 -0400 Subject: [PATCH] full text search using reds, issue #142 --- package.json | 3 +- public/css/style.less | 24 ++++++++++ public/src/app.js | 7 +++ public/templates/config.json | 3 +- public/templates/header.tpl | 5 +++ public/templates/search.tpl | 36 +++++++++++++++ src/postTools.js | 13 +++++- src/posts.js | 87 ++++++++++++++++++++---------------- src/routes/api.js | 31 +++++++++++++ src/webserver.js | 12 +++++ 10 files changed, 179 insertions(+), 42 deletions(-) create mode 100644 public/templates/search.tpl diff --git a/package.json b/package.json index f28afd245b..73bed5a3fc 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,8 @@ "nconf": "~0.6.7", "sitemap": "~0.6.0", "cheerio": "~0.12.0", - "request": "~2.25.0" + "request": "~2.25.0", + "reds": "0.2.3" }, "bugs": { "url": "https://github.com/designcreateplay/NodeBB/issues" diff --git a/public/css/style.less b/public/css/style.less index c857495090..a60ba220b3 100644 --- a/public/css/style.less +++ b/public/css/style.less @@ -823,3 +823,27 @@ body .navbar .nodebb-inline-block { -webkit-animation: scroll-0 6s ease 0.5s infinite normal; animation: scroll-0 6s ease 0.5s infinite normal;/* Safari and Chrome: */ } + +.form-search { + float: left; + margin-top: 5px; + margin-bottom:0px; +} + +.search-result-post { + width: 100%; + height: 50px; + line-height: 16px; + padding: 5px; + overflow:hidden; + img { + display: block; + float: left; + width:48px; + height:48px; + padding-right:10px; + } + span { + padding-left:10px; + } +} \ No newline at end of file diff --git a/public/src/app.js b/public/src/app.js index 971dc686ac..f28a25af5e 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -362,6 +362,13 @@ var socket, jQuery('document').ready(function() { addTouchEvents(); + + $('#search-form').on('submit', function() { + var input = $(this).find('input'); + ajaxify.go("search/"+input.val(), null, "search"); + input.val(''); + return false; + }) }); loadConfig(); diff --git a/public/templates/config.json b/public/templates/config.json index 2020f85848..643fdfa9fb 100644 --- a/public/templates/config.json +++ b/public/templates/config.json @@ -30,7 +30,8 @@ "recent": "recent", "unread": "unread", "popular": "category", - "active": "category" + "active": "category", + "search": "search" }, "force_refresh": { "logout": true diff --git a/public/templates/header.tpl b/public/templates/header.tpl index b46b579ccd..5ab116229e 100644 --- a/public/templates/header.tpl +++ b/public/templates/header.tpl @@ -57,6 +57,11 @@