added keywords filteration for index pages
This commit is contained in:
parent
2983b2b691
commit
e0d0a2aaa6
|
@ -20,9 +20,21 @@ class AnnouncementsController < ApplicationController
|
|||
announcements = announcements.concat(feeds_anns)
|
||||
sorted = announcements.sort{ |k,v| v["postdate"] <=> k["postdate"] }
|
||||
sorted = top_anns + sorted
|
||||
if params["keywords"].present?
|
||||
sorted = sorted.find_all{|anns|
|
||||
if anns["source-site"].present?
|
||||
/#{params[:keywords].to_s}/i.match anns["title"]
|
||||
else
|
||||
/#{params[:keywords].to_s}/i.match anns.title
|
||||
end
|
||||
}
|
||||
end
|
||||
sorted = Kaminari.paginate_array(sorted).page(OrbitHelper.page_number).per(OrbitHelper.page_data_count) rescue []
|
||||
else
|
||||
announcements = top_anns + announcements
|
||||
if params["keywords"].present?
|
||||
announcements = announcements.find_all{|anns| /#{params[:keywords].to_s}/i.match anns.title}
|
||||
end
|
||||
sorted = Kaminari.paginate_array(announcements).page(OrbitHelper.page_number).per(OrbitHelper.page_data_count) rescue []
|
||||
end
|
||||
total_pages = sorted.total_pages
|
||||
|
|
Loading…
Reference in New Issue