diff --git a/app/assets/javascripts/discourse/controllers/discovery/topics.js.es6 b/app/assets/javascripts/discourse/controllers/discovery/topics.js.es6
index a69daece73e..1dc52170ca3 100644
--- a/app/assets/javascripts/discourse/controllers/discovery/topics.js.es6
+++ b/app/assets/javascripts/discourse/controllers/discovery/topics.js.es6
@@ -16,37 +16,15 @@ const controllerOpts = {
expandGloballyPinned: false,
expandAllPinned: false,
- isSearch: Em.computed.equal('model.filter', 'search'),
-
- searchTerm: function(){
- return this.get('model.params.q');
- }.property('isSearch,model.params,model'),
-
actions: {
changeSort(sortBy) {
- if (this.get('isSearch')) {
- let term = this.get('searchTerm');
- let order;
-
- if (sortBy === 'activity') { order = 'latest'; }
- if (sortBy === 'views') { order = 'views'; }
-
- if (order && term.indexOf("order:" + order) === -1) {
- term = term.replace(/order:[a-z]+/, '');
- term = term.trim() + " order:" + order;
- this.set('model.params.q', term);
- this.get('model').refreshSort();
- }
-
+ if (sortBy === this.get('order')) {
+ this.toggleProperty('ascending');
} else {
- if (sortBy === this.get('order')) {
- this.toggleProperty('ascending');
- } else {
- this.setProperties({ order: sortBy, ascending: false });
- }
- this.get('model').refreshSort(sortBy, this.get('ascending'));
+ this.setProperties({ order: sortBy, ascending: false });
}
+ this.get('model').refreshSort(sortBy, this.get('ascending'));
},
// Show newly inserted topics
diff --git a/app/assets/javascripts/discourse/controllers/full-page-search.js.es6 b/app/assets/javascripts/discourse/controllers/full-page-search.js.es6
index 7deae7bd20b..a763a94c3db 100644
--- a/app/assets/javascripts/discourse/controllers/full-page-search.js.es6
+++ b/app/assets/javascripts/discourse/controllers/full-page-search.js.es6
@@ -24,7 +24,7 @@ export default DiscourseController.extend({
this.set('q', this.get('searchTerm'));
this.set('model', null);
- Discourse.ajax('/search2', {data: {q: this.get('searchTerm')}}).then(function(results) {
+ Discourse.ajax('/search', {data: {q: this.get('searchTerm')}}).then(function(results) {
self.set('model', translateResults(results) || {});
self.set('model.q', self.get('q'));
});
diff --git a/app/assets/javascripts/discourse/controllers/navigation/default.js.es6 b/app/assets/javascripts/discourse/controllers/navigation/default.js.es6
index 79fb9561bfc..7832d4ab51a 100644
--- a/app/assets/javascripts/discourse/controllers/navigation/default.js.es6
+++ b/app/assets/javascripts/discourse/controllers/navigation/default.js.es6
@@ -9,18 +9,6 @@ export default DiscourseController.extend({
navItems: function() {
return Discourse.NavItem.buildList(null, {filterMode: this.get('filterMode')});
- }.property('filterMode'),
+ }.property('filterMode')
- isSearch: Em.computed.equal('filterMode', 'search'),
-
- searchTerm: Em.computed.alias('controllers.discovery/topics.model.params.q'),
-
- actions: {
- search: function(){
- var discovery = this.get('controllers.discovery/topics');
- var model = discovery.get('model');
- discovery.set('q', this.get('searchTerm'));
- model.refreshSort();
- }
- }
});
diff --git a/app/assets/javascripts/discourse/routes/app-route-map.js.es6 b/app/assets/javascripts/discourse/routes/app-route-map.js.es6
index 530f4845eb3..779822ee39a 100644
--- a/app/assets/javascripts/discourse/routes/app-route-map.js.es6
+++ b/app/assets/javascripts/discourse/routes/app-route-map.js.es6
@@ -100,5 +100,5 @@ export default function() {
this.resource('queued-posts', { path: '/queued-posts' });
- this.route('full-page-search', {path: '/search2'});
+ this.route('full-page-search', {path: '/search'});
}
diff --git a/app/assets/javascripts/discourse/routes/full-page-search.js.es6 b/app/assets/javascripts/discourse/routes/full-page-search.js.es6
index 93543740458..b092136ee51 100644
--- a/app/assets/javascripts/discourse/routes/full-page-search.js.es6
+++ b/app/assets/javascripts/discourse/routes/full-page-search.js.es6
@@ -7,7 +7,7 @@ export default Discourse.Route.extend({
},
model: function(params) {
return PreloadStore.getAndRemove("search", function() {
- return Discourse.ajax('/search2', {data: {q: params.q}});
+ return Discourse.ajax('/search', {data: {q: params.q}});
}).then(function(results){
var model = translateResults(results) || {};
model.q = params.q;
diff --git a/app/assets/javascripts/discourse/templates/components/basic-topic-list.hbs b/app/assets/javascripts/discourse/templates/components/basic-topic-list.hbs
index 341d355d472..6d323d7aabe 100644
--- a/app/assets/javascripts/discourse/templates/components/basic-topic-list.hbs
+++ b/app/assets/javascripts/discourse/templates/components/basic-topic-list.hbs
@@ -5,7 +5,6 @@
hideCategory=hideCategory
topics=topics
expandExcerpts=expandExcerpts
- searchTerm=searchTerm
}}
{{else}}
diff --git a/app/assets/javascripts/discourse/templates/discovery/topics.hbs b/app/assets/javascripts/discourse/templates/discovery/topics.hbs
index 0b6f9735df8..f3e452a4ab0 100644
--- a/app/assets/javascripts/discourse/templates/discovery/topics.hbs
+++ b/app/assets/javascripts/discourse/templates/discovery/topics.hbs
@@ -46,8 +46,6 @@
selected=selected
expandGloballyPinned=expandGloballyPinned
expandAllPinned=expandAllPinned
- expandExcerpts=isSearch
- searchTerm=searchTerm
topics=model.topics}}
{{/if}}
diff --git a/app/assets/javascripts/discourse/templates/navigation/default.hbs b/app/assets/javascripts/discourse/templates/navigation/default.hbs
index 529dae55879..b02c503fd8e 100644
--- a/app/assets/javascripts/discourse/templates/navigation/default.hbs
+++ b/app/assets/javascripts/discourse/templates/navigation/default.hbs
@@ -1,9 +1,3 @@
-{{#if isSearch}}
-
- {{input type="text" value=searchTerm class="input-xxlarge search" action="search"}}
-
-
-{{else}}
{{bread-crumbs categories=categories}}
{{navigation-bar navItems=navItems filterMode=filterMode}}
@@ -11,4 +5,3 @@
{{#if canCreateTopic}}
{{/if}}
-{{/if}}
diff --git a/app/assets/javascripts/discourse/views/full-page-search.js.es6 b/app/assets/javascripts/discourse/views/full-page-search.js.es6
index 2312034700e..19619892fcc 100644
--- a/app/assets/javascripts/discourse/views/full-page-search.js.es6
+++ b/app/assets/javascripts/discourse/views/full-page-search.js.es6
@@ -9,7 +9,8 @@ export default Ember.View.extend(ScrollTop, {
if(!_.isEmpty(term)) {
Em.run.next(function(){
self.$('.blurb').highlight(term.split(/\s+/), {className: 'search-highlight'});
- self.$('.topic-title').highlight(term.split(/\s+/), {className: 'search-highlight'} );
+ // we can highlight title, but I feel its a bit too much
+ // self.$('.topic-title').highlight(term.split(/\s+/), {className: 'search-highlight'} );
});
}
}.observes('controller.model').on('didInsertElement')
diff --git a/app/assets/javascripts/discourse/views/topic-list-item.js.es6 b/app/assets/javascripts/discourse/views/topic-list-item.js.es6
index 64073d65dcd..d1d0ca7e6d5 100644
--- a/app/assets/javascripts/discourse/views/topic-list-item.js.es6
+++ b/app/assets/javascripts/discourse/views/topic-list-item.js.es6
@@ -65,10 +65,6 @@ export default Discourse.View.extend(StringBuffer, {
},
expandPinned: function() {
- if (this.get('controller.searchTerm')) {
- return true;
- }
-
const pinned = this.get('topic.pinned');
if (!pinned) {
return false;
@@ -134,22 +130,6 @@ export default Discourse.View.extend(StringBuffer, {
this.set('topic.highlight', false);
this.highlight();
}
-
- var term = this.get('controller.searchTerm');
- const self = this;
- if (term) {
- var terms = term.split(/\s+/);
- // .main-link a is omitted cause a bit clowny
- var excerpt = self.$('.topic-excerpt');
- // some sane wrapping
- excerpt.text(excerpt.text().replace(/\S{40,}/g, function(match){
- return match.replace(/(\S)/g, "$1\u200B");
- }));
-
- terms.forEach(function(word) {
- excerpt.highlight(word, {element: 'b', className: 'search-highlight'});
- });
- }
}.on('didInsertElement')
});
diff --git a/app/models/topic.rb b/app/models/topic.rb
index b3904cac7a0..0d8e1e664a2 100644
--- a/app/models/topic.rb
+++ b/app/models/topic.rb
@@ -106,7 +106,6 @@ class Topic < ActiveRecord::Base
has_one :first_post, -> {where post_number: 1}, class_name: Post
# When we want to temporarily attach some data to a forum topic (usually before serialization)
- attr_accessor :search_data
attr_accessor :user_data
attr_accessor :posters # TODO: can replace with posters_summary once we remove old list code
diff --git a/app/serializers/listable_topic_serializer.rb b/app/serializers/listable_topic_serializer.rb
index 79ffae02ff9..94963913e22 100644
--- a/app/serializers/listable_topic_serializer.rb
+++ b/app/serializers/listable_topic_serializer.rb
@@ -11,7 +11,6 @@ class ListableTopicSerializer < BasicTopicSerializer
:bumped_at,
:unseen,
:last_read_post_number,
- :linked_post_number,
:unread,
:new_posts,
:pinned,
@@ -79,19 +78,7 @@ class ListableTopicSerializer < BasicTopicSerializer
end
def excerpt
- if object.search_data
- object.search_data[:excerpt]
- else
- object.excerpt
- end
- end
-
- def include_linked_post_number?
- object.search_data
- end
-
- def linked_post_number
- object.search_data[:post_number]
+ object.excerpt
end
alias :include_last_read_post_number? :has_user_data
@@ -107,7 +94,7 @@ class ListableTopicSerializer < BasicTopicSerializer
alias :include_new_posts? :has_user_data
def include_excerpt?
- pinned || object.search_data
+ pinned
end
def pinned
diff --git a/config/routes.rb b/config/routes.rb
index 7a26597a045..98fc8396234 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -405,7 +405,7 @@ Discourse::Application.routes.draw do
get "top" => "list#top"
get "search/query" => "search#query"
- get "search2" => "search#show"
+ get "search" => "search#show"
# Topics resource
get "t/:id" => "topics#show"
diff --git a/lib/discourse.rb b/lib/discourse.rb
index 8f141ec8bc3..b32fcf736aa 100644
--- a/lib/discourse.rb
+++ b/lib/discourse.rb
@@ -61,7 +61,7 @@ module Discourse
class CSRF < StandardError; end
def self.filters
- @filters ||= [:latest, :unread, :new, :read, :posted, :bookmarks, :search]
+ @filters ||= [:latest, :unread, :new, :read, :posted, :bookmarks]
end
def self.feed_filters
@@ -69,7 +69,7 @@ module Discourse
end
def self.anonymous_filters
- @anonymous_filters ||= [:latest, :top, :categories, :search]
+ @anonymous_filters ||= [:latest, :top, :categories]
end
def self.logged_in_filters
diff --git a/lib/search/grouped_search_results.rb b/lib/search/grouped_search_results.rb
index fe594cf1e05..387696c300c 100644
--- a/lib/search/grouped_search_results.rb
+++ b/lib/search/grouped_search_results.rb
@@ -19,7 +19,7 @@ class Search
@term = term
@search_context = search_context
@include_blurbs = include_blurbs
- @blurb_length = blurb_length
+ @blurb_length = blurb_length || 200
@posts = []
@categories = []
@users = []
@@ -40,7 +40,7 @@ class Search
end
- def self.blurb_for(cooked, term, blurb_length)
+ def self.blurb_for(cooked, term=nil, blurb_length=200)
cooked = SearchObserver::HtmlScrubber.scrub(cooked).squish
blurb = nil
diff --git a/lib/topic_query.rb b/lib/topic_query.rb
index 958fb6da7da..9ffa5d8b598 100644
--- a/lib/topic_query.rb
+++ b/lib/topic_query.rb
@@ -71,53 +71,6 @@ class TopicQuery
create_list(:latest, {}, latest_results)
end
- def list_search
-
- results = nil
- if @options[:q].present?
- search = Search.execute(@options[:q],
- type_filter: 'topic',
- guardian: Guardian.new(@user))
-
- topic_ids = search.posts.map(&:topic_id)
-
- if topic_ids.present?
- sql = topic_ids.each_with_index.map do |id, idx|
- "SELECT #{idx} pos, #{id} id"
- end.join(" UNION ALL ")
-
- results = Topic
- .unscoped
- .joins("JOIN (#{sql}) X on X.id = topics.id")
- .order("X.pos")
-
- posts_map = {}
- search.posts.each do |p|
- (posts_map[p.topic_id] ||= []) << p
- end
- end
- end
-
- results ||= Topic.where("1=0")
-
- if @user
- results = results.joins("LEFT OUTER JOIN topic_users AS tu ON (topics.id = tu.topic_id AND tu.user_id = #{@user.id.to_i})")
- .references('tu')
- end
-
- list = create_list(:search, {unordered: true}, results)
-
- list.topics.each do |topic|
- if posts = posts_map[topic.id]
- if post = posts.shift
- topic.search_data = {excerpt: search.blurb(post), post_number: post.post_number}
- end
- end
- end
-
- list
- end
-
def list_read
create_list(:read, unordered: true) do |topics|
topics.order('COALESCE(tu.last_visited_at, topics.bumped_at) DESC')
diff --git a/spec/components/topic_query_spec.rb b/spec/components/topic_query_spec.rb
index 8bd9c5a11d9..a961665bafc 100644
--- a/spec/components/topic_query_spec.rb
+++ b/spec/components/topic_query_spec.rb
@@ -48,28 +48,10 @@ describe TopicQuery do
expect(TopicQuery.new(nil).list_topics_by(user).topics.count).to eq(1)
expect(TopicQuery.new(user).list_topics_by(user).topics.count).to eq(2)
-
- # search should return nothing normally
- expect(TopicQuery.new(nil).list_search.topics.count).to eq(0)
end
end
- context 'search' do
- it 'can correctly search' do
- # got to enable indexing
- ActiveRecord::Base.observers.enable :all
-
- p = create_post(raw: "I am super awesome and search will find me")
- create_post(topic_id: p.topic_id, raw: "I am super spectacular post of doom")
-
- results = TopicQuery.new(nil, q: "doom").list_search
-
- expect(results.topics.count).to eq(1)
-
- end
- end
-
context 'bookmarks' do
it "filters and returns bookmarks correctly" do
post = Fabricate(:post)