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? unless params['query'].nil? || params['query'].empty?
@results = Document.search do @results = Document.search do
fulltext params['query'] do fulltext params['query'] do
highlight :name, :text fields :name, :text, :meeting
highlight :text
end end
end end
@res=[] @res=[]

View File

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

View File

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

View File

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

View File

@@ -9,8 +9,11 @@
<li> <li>
<%= link_to "Admin" , admin_home_index_path, class: :linkbox if current_user.has_role?(:fetadmin) %> <%= link_to "Admin" , admin_home_index_path, class: :linkbox if current_user.has_role?(:fetadmin) %>
</li> </li>
<li>
<%= link_to "Treeview" , treeview_home_index_path, class: :linkbox if current_user.has_role?(:fetadmin) %>
</li>
</ul> </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| %> <%= 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.input :query, :input_html => { :name => 'query' } , :label=>false, :class=>"search-query" %>
<% f.actions do %> <% f.actions do %>