This repository has been archived by the owner on Apr 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic Entity search using pg_search. Ongoing #2
- Loading branch information
Showing
13 changed files
with
127 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* Taken from http://bootsnipp.com/snipps/stylish-search-form */ | ||
#custom-search-form { | ||
margin:0; | ||
margin-top: 10px; | ||
padding: 0; | ||
} | ||
|
||
#custom-search-form .search-query { | ||
padding-right: 3px; | ||
padding-right: 4px \9; | ||
padding-left: 3px; | ||
padding-left: 4px \9; | ||
/* IE7-8 doesn't have border-radius, so don't indent the padding */ | ||
margin-bottom: 0; | ||
-webkit-border-radius: 3px; | ||
-moz-border-radius: 3px; | ||
border-radius: 3px; | ||
} | ||
|
||
#custom-search-form button { | ||
border: 0; | ||
background: none; | ||
/** belows styles are working good */ | ||
padding: 2px 5px; | ||
margin-top: 2px; | ||
position: relative; | ||
left: -28px; | ||
/* IE7-8 doesn't have border-radius, so don't indent the padding */ | ||
margin-bottom: 0; | ||
-webkit-border-radius: 3px; | ||
-moz-border-radius: 3px; | ||
border-radius: 3px; | ||
} | ||
|
||
.search-query:focus + button { | ||
z-index: 3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class SearchController < ApplicationController | ||
def search | ||
@query = params[:q] | ||
|
||
@results = PgSearch.multisearch(@query).page(params[:page]).per(15) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!--start: Wrapper--> | ||
<div id="wrapper" class="full"> | ||
|
||
<!--start: Row --> | ||
<div class="row-fluid"> | ||
|
||
<div class="span8 separate"> | ||
<h3>Resultados para '<%= @query %>'</h3> | ||
|
||
<ul> | ||
<% @results.each do |result| %> | ||
<li><%= result.searchable.name %></li> | ||
<% end %> | ||
</ul> | ||
|
||
<%= paginate @results %> | ||
</div> | ||
|
||
</div> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# TODO: Configure search. See https://github.com/casecommons/pg_search |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class CreatePgSearchDocuments < ActiveRecord::Migration | ||
def self.up | ||
say_with_time("Creating table for pg_search multisearch") do | ||
create_table :pg_search_documents do |t| | ||
t.text :content | ||
t.belongs_to :searchable, :polymorphic => true | ||
t.timestamps | ||
end | ||
end | ||
end | ||
|
||
def self.down | ||
say_with_time("Dropping table for pg_search multisearch") do | ||
drop_table :pg_search_documents | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require 'spec_helper' | ||
|
||
describe SearchController do | ||
|
||
end |