diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb
index 872a1ca..43d2835 100644
--- a/app/controllers/documents_controller.rb
+++ b/app/controllers/documents_controller.rb
@@ -151,5 +151,23 @@ class DocumentsController < ApplicationController
end
end
+ def search
+
+ unless params['query'].nil? || params['query'].empty?
+ @results = Document.search do
+ fulltext params['query'] do
+ highlight :name, :text
+ end
+ end
+ @res=[]
+ @results.results.each do |r|
+ @res << r if can?(:show,r)
+ end
+ end
+ respond_to do |format|
+ format.html
+ format.js
+ end
+ end
end
diff --git a/app/models/document.rb b/app/models/document.rb
index b935a25..aa0158d 100644
--- a/app/models/document.rb
+++ b/app/models/document.rb
@@ -93,10 +93,10 @@ class Document < ActiveRecord::Base
Document.ether.group(Document::TYPS[t])
end
searchable do
- text :text
- text :name, :boost=>4.0
+ text :text, stored: true
+ text :name, :boost=>4.0, :stored=> true
if typ = 10 || typ=11
- text :meeting do
+ text :meeting, stored: true do
parent.text unless parent.nil?
end
end
diff --git a/app/views/documents/_search_results.html.erb b/app/views/documents/_search_results.html.erb
new file mode 100644
index 0000000..6a498de
--- /dev/null
+++ b/app/views/documents/_search_results.html.erb
@@ -0,0 +1,12 @@
+
+ <% search_results.hits.each do |hit| %>
+ -
+ <% hit.highlights(:name).each do |hlgt| %>
+ <%=puts hlgt.format {|word|} "#{word}" %>
+ <% end %>
+ <% hit.highlights(:text).each do |hlgt| %>
+ <%=%> puts hlgt.format {|word|} "#{word}" %>
+ <% end %>
+
+ <% end %>
+
diff --git a/app/views/documents/search.js.erb b/app/views/documents/search.js.erb
new file mode 100644
index 0000000..d704082
--- /dev/null
+++ b/app/views/documents/search.js.erb
@@ -0,0 +1 @@
+$("#searchresults").html("<%=escape_javascript( render :partial=>'documents/search_results', :object=>@results )%>")
diff --git a/app/views/themes/blue2/home/intern.html.erb b/app/views/themes/blue2/home/intern.html.erb
new file mode 100644
index 0000000..a4d7cc9
--- /dev/null
+++ b/app/views/themes/blue2/home/intern.html.erb
@@ -0,0 +1,45 @@
+ FET Intern NEU
+
+
+
+
+ -
+ <%= link_to "Adressliste", internlist_fetprofiles_path ,class: :linkbox %>
+ - <%= link_to "Admin" , admin_home_index_path, class: :linkbox if current_user.has_role?(:fetadmin) %>
+
+
+
+ <%= semantic_form_for :search,:remote=>true, :url=>search_documents_index_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 %>
+ <% f.action :submit, :as => :input %>
+ <% end %>
+ <% end %>
+
+ <%= render :partial=>"documents/search_results" %>
+
+
+
+
+ <%= link_to "Users", users_path %>
+
+
+
Neuigkeiten
+
+ <% @neuigkeiten.each do |n| %>
+ - <%= render n if can?(:show, n) %>
+ <% end %>
+
+
+
+
+
+
diff --git a/config/routes.rb b/config/routes.rb
index 94a086e..75fc02b 100755
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -172,7 +172,7 @@
get :documents
get :meetings
end
- resources :attachments do
+ resources :attachments do
member do
get :set_titlepic
end
@@ -198,6 +198,9 @@
get :read_from_etherpad
get :dump_to_etherpad
end
+ collection do
+ get :search
+ end
end
resources :meetings do
member do