Added Searching Features

* Added Thread Search Feature

* Added User Search Feature

* Re-organized searching, added @mention support to author search
This commit is contained in:
MrYummy
2017-05-28 18:08:57 -04:00
parent e7463524af
commit 1316d7ca03
20 changed files with 293 additions and 27 deletions

View File

@@ -3,9 +3,14 @@ class ForumthreadsController < ApplicationController
before_filter :check_permission, only: [:show, :edit, :update, :destroy]
def index
redirect_to forum_path(@thread.forum.forumgroup, f)
if params[:label] && !Label.where("lower(name) = ?", params[:label].downcase).try(:first) && params[:label].downcase != "no label"
flash[:alert] = "'#{params[:label]}' is not a valid label."
redirect_to forumthreads_path(params.except(:label, :controller, :action))
return
end
@threads = Forumthread.filter(current_user, params[:title], params[:content], params[:reply], params[:label], User.where("lower(ign) = ?", params[:author].to_s.downcase).try(:first), params[:query], Forum.where(id: params[:id]).try(:first))
.page(params[:page]).per(30)
end
def show
if params[:reverse]
@replies = @thread.replies.reverse_order.page(params[:page])
@@ -80,6 +85,20 @@ class ForumthreadsController < ApplicationController
redirect_to @thread.forum
end
def search
end
def search_redirect
params.each do |key, value|
params[key] = nil if params[key] == ""
end
params[:id] = nil if params[:id] == "Search All Threads"
params[:label] = nil if params[:label] && params[:label].downcase == "label"
params[:author] = params[:author].tr("@ ", "") if params[:author]
params_list = Hash[params.except(:commit, :utf8, :authenticity_token)]
redirect_to forumthreads_path(params_list)
end
private
def check_permission