Sha256: bdcd4fc6544dec6d30a11534cde71d14b7d43ceb90de420429e908fa5923577c
Contents?: true
Size: 1.45 KB
Versions: 3
Compression:
Stored size: 1.45 KB
Contents
class SearchController < ApplicationController def index q = params[:term] @searcher = Searcher.search query: q render layout: false end def mentions q = params[:query] delimiter = params[:delimiter] search_group = "pages,attachments" if delimiter == "!" search_group = "attachments" end q = ["title:#{q}", "filename:#{q}", "name:#{q}", "email:#{q}"].join(" OR ") @searcher = Searcher.search q: q, search_group: search_group results = [] @searcher.results_with_hits{|result, hit| results << process_result(result, hit) } render json: results end protected #TODO: dirty. fix. def process_result(result, hit) json = {} json[:type] = result.class.to_s.underscore if ["space", "page"].include?(hit._type) json[:name] = result.title json[:url] = wiki_page_url(result.id) json[:space] = result.root.title if json[:type] == "space" json[:icon] = "fa-bullseye" else json[:icon] = "fa-file" end elsif ["project", "bug", "task", "story"].include?(hit._type) json[:name] = result.title json[:url] = ticket_url(result.id) json[:project] = result.root.title elsif hit._type == "attachment" json[:name] = result.filename json[:url] = attachment_url(result.id) json[:icon] = "fa-paperclip" elsif hit._type == "user" json[:name] = result.name json[:email] = result.email end json end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
tawork-0.0.30 | app/controllers/search_controller.rb |
tawork-0.0.29 | app/controllers/search_controller.rb |
tawork-0.0.28 | app/controllers/search_controller.rb |