Skip to content

Node.js based forum software built for the modern web

closes #205

Baris Soner Usakli0db599a47879
diff --git a/public/templates/search.tpl b/public/templates/search.tpl
index 7dec88da87..b7408291d2 100644
--- a/public/templates/search.tpl
+++ b/public/templates/search.tpl
@@ -5,14 +5,11 @@
</ul>
</div>
-
-<div class="alert alert-warning {show_no_results}" id="no-search-results">
- <strong>No search results for {search_query}.</strong>
-</div>
-
<div class="category row">
<div class="span12">
<ul id="topics-container" data-search-query="{search_query}">
+ <h3>Topics</h3>
+ <div class="alert alert-info {show_no_topics}">No topics found!</div>
<!-- BEGIN topics -->
<a href="../../topic/{topics.slug}" id="tid-{topics.tid}">
<li class="category-item">
@@ -28,6 +25,8 @@
</li>
</a>
<!-- END topics -->
+ <h3>Posts</h3>
+ <div class="alert alert-info {show_no_posts}">No posts found!</div>
<!-- BEGIN posts -->
<a href="../../topic/{posts.topicSlug}#{posts.pid}" id="tid-{posts.tid}">
<li class="category-item">
diff --git a/src/routes/api.js b/src/routes/api.js
index 88cc74495b..739b6a7e6f 100644
--- a/src/routes/api.js
+++ b/src/routes/api.js
@@ -183,9 +183,11 @@ var user = require('./../user.js'),
app.get('/api/search', function(req, res) {
return res.json({
- show_no_results:'hide',
+ show_no_topics:'hide',
+ show_no_posts:'hide',
search_query:'',
- posts:[]
+ posts:[],
+ topics:[]
});
});
@@ -228,9 +230,10 @@ var user = require('./../user.js'),
async.parallel([searchPosts, searchTopics], function(err, results) {
if (err)
return next();
- var noresults = !results[0].length && !results[1].length;
+
return res.json({
- show_no_results: noresults?'show':'hide',
+ show_no_topics: results[1].length? 'hide':'',
+ show_no_posts: results[0].length? 'hide':'',
search_query:req.params.term,
posts:results[0],
topics:results[1]