Update Search Engine

This commit is contained in:
Manson Wang 2014-03-23 12:13:06 +08:00
parent e8b273ee74
commit 2d34d9edcf
1 changed files with 2 additions and 9 deletions

View File

@ -1,5 +1,5 @@
class SiteSearchController < ApplicationController class SiteSearchController < ApplicationController
include ActionView::Helpers::TextHelper
def search def search
startTime = Time.now startTime = Time.now
if params[:keywords].present? if params[:keywords].present?
@ -76,14 +76,7 @@ class SiteSearchController < ApplicationController
next next
end end
index = res[:content].index '<b>' res[:content] = truncate(res[:content], length: 150)
unless index.nil?
index = index>50 ? index-50 : 0
deadline = 150
res[:content] = res[:content][index, deadline]
else
res[:content] = res[:content][0, 100]
end
end end
result = result.sort_by { |k| k[:matches] }.reverse rescue [] result = result.sort_by { |k| k[:matches] }.reverse rescue []