Skip to content

Commit

Permalink
Adds initial search stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
straleyb committed Oct 12, 2018
1 parent ac31bef commit f945c99
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/controllers/search_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class SearchController < ApplicationController
def index
end

def search_results
Vocabulary.search{ fulltext params[:search_value]}
end
end
5 changes: 5 additions & 0 deletions app/models/vocabulary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ class Vocabulary < Term
property :range, :predicate => RDF::RDFS.range
property :domain, :predicate => RDF::RDFS.domain


searchable do
text :title
text :publisher
end
def self.option_text
"Vocabulary"
end
Expand Down
7 changes: 7 additions & 0 deletions app/views/search/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class='lunr_search'>
</div>

<%= form_tag(search_results_path, method: :get) do %>
<%= text_field_tag :value %>
<%= submit_tag 'Search' %>
<% end %>
1 change: 1 addition & 0 deletions app/views/shared/_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<ul class="nav navbar-nav">
<li><%= link_to "Vocabularies", vocabularies_path %></li>
<li><%= link_to "Predicates", predicates_path %></li>
<li><%= link_to "Search", search_path %></li>
<%# @skip_render aids in page_caching all but the dynamic/user related content which gets loaded by update_user_data_on_cached_page.js ajax %>
<% if current_user && current_user.administrative? && !@skip_render %>
<li><%= link_to "Review", review_queue_path %></li>
Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

# You can have the root of your site routed with "root"
root 'home#index'
get "/search", :to => "search#index", :as => "search"
get "/search_results(/:value)", :to => "search#search_results", :as => "search_results"

get "/admin", :to => "admin#index", :as => "admin"

Expand Down

0 comments on commit f945c99

Please sign in to comment.