From 2d34d9edcfc8bdfc22b8296b9b72df2be4239c68 Mon Sep 17 00:00:00 2001 From: Manson Wang Date: Sun, 23 Mar 2014 12:13:06 +0800 Subject: [PATCH] Update Search Engine --- app/controllers/site_search_controller.rb | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/app/controllers/site_search_controller.rb b/app/controllers/site_search_controller.rb index 9ecb1f9..d730054 100644 --- a/app/controllers/site_search_controller.rb +++ b/app/controllers/site_search_controller.rb @@ -1,5 +1,5 @@ class SiteSearchController < ApplicationController - + include ActionView::Helpers::TextHelper def search startTime = Time.now if params[:keywords].present? @@ -76,14 +76,7 @@ class SiteSearchController < ApplicationController next end - index = res[:content].index '' - 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 + res[:content] = truncate(res[:content], length: 150) end result = result.sort_by { |k| k[:matches] }.reverse rescue []