document search

This commit is contained in:
Andreas Stephanides
2015-06-11 11:36:36 +02:00
parent 34659014df
commit 090e2ad72a
5 changed files with 17 additions and 6 deletions

View File

@@ -156,7 +156,8 @@ class DocumentsController < ApplicationController
unless params['query'].nil? || params['query'].empty?
@results = Document.search do
fulltext params['query'] do
highlight :name, :text
fields :name, :text, :meeting
highlight :text
end
end
@res=[]

View File

@@ -26,7 +26,9 @@ class HomeController < ApplicationController
end
def treeview
authorize! :doadmin, User
@themengruppen = Themengruppe.intern.order(:priority).reverse
@themengruppen = Themengruppe.order(:priority).reverse
@themengruppen += Themengruppe.intern.order(:priority).reverse
end
def intern
authorize! :seeintern, User

View File

@@ -1,13 +1,18 @@
<% unless search_results.nil? %>
<ul>
<% search_results.each_hit_with_result do |hit,result| %>
<li> <%= result.name %>
<li> <%= link_to result.parent.title+": " + result.name, document_path(result) %>
<% hit.highlights(:name).each do |hlgt| %>
<%= hlgt.format{|word|"<b>#{word}</b>" } %>
<%= raw(hlgt.format{|word|"<b>#{word}</b>" } ) %>
<% end %>
<% %>
<% hit.highlights(:text).each do |hlgt| %>
<%= "text:" + raw(hlgt.format {|word| "*#{word}*" })%>
<% end %>
<% hit.highlights(:meeting).each do |hlgt| %>
<%= "text:" + raw(hlgt.format {|word| "*#{word}*" })%>
<% end %>
</li>
<% end %>
</ul>

View File

@@ -1,4 +1,4 @@
Intern
<ul>
<% @themengruppen.each do |tg| %>
<li><%= tg.title %>

View File

@@ -9,8 +9,11 @@
<li>
<%= link_to "Admin" , admin_home_index_path, class: :linkbox if current_user.has_role?(:fetadmin) %>
</li>
<li>
<%= link_to "Treeview" , treeview_home_index_path, class: :linkbox if current_user.has_role?(:fetadmin) %>
</li>
</ul>
<div>Suche
<div>Suche nach Protokollen
<%= semantic_form_for :search,:remote=>true, :url=>search_documents_path, :html=>{:id=>"search_form",:class=>"", :method=>'get'} do |f| %>
<%= f.input :query, :input_html => { :name => 'query' } , :label=>false, :class=>"search-query" %>
<% f.actions do %>