diff --git a/app/controllers/site_search_controller.rb b/app/controllers/site_search_controller.rb index a9ef51c..9ecb1f9 100644 --- a/app/controllers/site_search_controller.rb +++ b/app/controllers/site_search_controller.rb @@ -19,7 +19,7 @@ class SiteSearchController < ApplicationController context = PageContext.where(:page_id=>page.id).first.context rescue nil next if title.nil? and context.nil? - context = context.gsub(/<\/?[^>]*>/, "").gsub(/ /i," ") rescue "" + context = context.gsub(/<\/?[^>]*>/, "").gsub(/ /i,"") rescue "" title_matches = title.match(regex) context_matches = context.match(regex) if title_matches or context_matches @@ -71,8 +71,10 @@ class SiteSearchController < ApplicationController res[:content].gsub!(/(#{k})/i, '\1') rescue "" end - result.delete(res) if res[:matches]==0 - next if res[:matches]==0 + if res[:matches]==0 + result = result - [res] + next + end index = res[:content].index '' unless index.nil? @@ -80,7 +82,7 @@ class SiteSearchController < ApplicationController deadline = 150 res[:content] = res[:content][index, deadline] else - res[:content] = res[:content][0, 150] + res[:content] = res[:content][0, 100] end end