-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from sascha-karnatz/rearrange-page-search
Rearrange page search
- Loading branch information
Showing
13 changed files
with
155 additions
and
296 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,14 @@ | ||
module Alchemy::Search::IngredientExtension | ||
def searchable_content | ||
send(Alchemy.searchable_ingredients[type.to_sym])&.squish | ||
end | ||
|
||
def searchable? | ||
Alchemy.searchable_ingredients.has_key?(type.to_sym) && | ||
(definition.key?(:searchable) ? definition[:searchable] : true) && | ||
!!element&.searchable? | ||
end | ||
end | ||
|
||
# add the PgSearch model to all ingredients | ||
Alchemy::Ingredient.prepend(Alchemy::Search::IngredientExtension) |
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,10 @@ | ||
# Enable Postgresql full text indexing. | ||
# | ||
module Alchemy::Search::PageExtension | ||
def searchable? | ||
(definition.key?(:searchable) ? definition[:searchable] : true) && | ||
searchable && public? && !layoutpage? | ||
end | ||
end | ||
|
||
Alchemy::Page.prepend(Alchemy::Search::PageExtension) |
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 |
---|---|---|
@@ -1,12 +1,6 @@ | ||
<li class="search_result"> | ||
<% page = result.page %> | ||
<% page = result.searchable %> | ||
<h3><%= link_to page.name, show_alchemy_page_path(page) %></h3> | ||
<% if result.excerpts.any? %> | ||
<% result.excerpts.each do |excerpt| %> | ||
<p><%= highlighted_excerpt(excerpt, params[:query]) %></p> | ||
<% end %> | ||
<% else %> | ||
<p><%= page.meta_description %></p> | ||
<% end %> | ||
<p><%= highlighted_excerpt(result.content, params[:query]) %></p> | ||
<p><%= link_to page.urlname, show_alchemy_page_path(page) %></p> | ||
</li> |
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
Oops, something went wrong.