tb_search 1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YzNmMzI1OTA0Mzc1ODJmMDIxMjQ1N2VhMDA4OGJmNThlMWM3YmRkZA==
5
+ data.tar.gz: !binary |-
6
+ NWUyNmNkYjliMTI1NjU4YjAxMjU4NzM5Njk1NzM5NDJjZjFkYmZkMg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ OTZhNDg3ZTM5OTYwOTg3ZDBkYTkzMzk0NjgxMTdlMGE5N2QwYTQxMTg5ZmY4
10
+ MDk4Y2RiOGUwZTAxMTMzYzAzZjI0MjQ5ZmM1MDhkNDJiZDQzMjE4YTI5OTRk
11
+ YzVhM2UwYjE2MGFmZjVhY2VhNGYzOGZkZmE0MzM4MGIwODUzZWY=
12
+ data.tar.gz: !binary |-
13
+ ZTBiMzI4NWYwZWNlNTBiZTFkNWE3ZjNkZTBiNmExM2Y2NDg3MmQ4YmRkZmYy
14
+ MWVlYjI1OGUyNGYyZTUxODNhZTYxN2I1YzdmNzUwZjYzNTYwMDhkZjg1ZjFl
15
+ ZjdhMWRiNDg2MWI1YTZkYzE2NmRmNGFiNjU0NjdmZjU0OGYxZjM=
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2012 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,21 @@
1
+ Insert Readme Information Here
2
+
3
+ Testing
4
+ -----------------
5
+
6
+ Spud uses RSpec for testing. Get the tests running with a few short commands:
7
+
8
+ 1. Create and migrate the databases:
9
+
10
+ rake db:create
11
+ rake db:migrate
12
+
13
+ 2. Load the schema in to the test database:
14
+
15
+ rake app:db:test:prepare
16
+
17
+ 3. Run the tests with RSpec
18
+
19
+ rspec spec
20
+
21
+ After the tests have completed the current code coverage stats is available by opening ```/coverage/index.html``` in a browser.
data/Rakefile ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'SpudSearch'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+ Bundler::GemHelper.install_tasks
27
+
28
+ require 'rake'
@@ -0,0 +1,27 @@
1
+ class SearchController < ApplicationController
2
+ layout Spud::Search.base_layout
3
+ require 'will_paginate/array'
4
+ def index
5
+ @results = []
6
+ if params[:phrase].blank?
7
+ return
8
+ end
9
+ @pages = []
10
+ @posts = []
11
+ begin
12
+ @pages = SpudPage.find_with_index(params[:phrase])
13
+ rescue
14
+ end
15
+
16
+ begin
17
+ @posts = SpudPost.find_with_index(params[:phrase])
18
+ rescue
19
+
20
+ end
21
+
22
+ @results += @pages
23
+ @results += @posts
24
+
25
+ @results = @results.paginate :page => params[:page]
26
+ end
27
+ end
@@ -0,0 +1,25 @@
1
+ <h3>Search Results</h3>
2
+ <div class="results">
3
+ <%if @results.blank?%>
4
+ <p>No Results Found.</p>
5
+ <%else%>
6
+ <%@results.each do |result|%>
7
+ <div class="result">
8
+ <%if result.class.name == 'SpudPost'%>
9
+ <%if result.is_news == true%>
10
+ <h4><%=link_to result.title,news_post_path(result.url_name)%></h4>
11
+ <%else%>
12
+ <h4><%=link_to result.title,blog_post_path(result.url_name)%></h4>
13
+ <%end%>
14
+ <p><%=truncate(strip_tags(result.content),:length => 200, :separator => ' ')%></p>
15
+ <%elsif result.class.name == 'SpudPage'%>
16
+ <h4><%=link_to result.name,page_path(:id => result.url_name)%></h4>
17
+
18
+ <p><%=truncate(strip_tags(result.meta_description),:length => 200, :separator => ' ')%></p>
19
+
20
+ <%end%>
21
+ </div>
22
+ <%end%>
23
+ <%=will_paginate @results%>
24
+ <%end%>
25
+ </div>
@@ -0,0 +1,7 @@
1
+ <%if Spud::Search.content_for.blank? == false%>
2
+ <%=content_for Spud::Search.content_for do%>
3
+ <%=render "index"%>
4
+ <%end%>
5
+ <%else%>
6
+ <%=render "index"%>
7
+ <%end%>
data/config/routes.rb ADDED
@@ -0,0 +1,4 @@
1
+ Rails.application.routes.draw do
2
+ match "search" => "search#index", :as => :search
3
+ end
4
+
@@ -0,0 +1,9 @@
1
+ module Spud
2
+ module Search
3
+ include ActiveSupport::Configurable
4
+
5
+ config_accessor :base_layout,:content_for
6
+ self.base_layout = "application"
7
+ self.content_for = nil
8
+ end
9
+ end
@@ -0,0 +1,23 @@
1
+ require 'tb_core'
2
+
3
+ require 'acts_as_indexed'
4
+ module Spud
5
+ module Search
6
+
7
+ class Engine < Rails::Engine
8
+ engine_name :tb_search
9
+
10
+ initializer :assets do |config|
11
+ Rails.application.config.assets.precompile += [
12
+ "spud/admin/search*"
13
+ ]
14
+ end
15
+
16
+ initializer :model_overrides do |config|
17
+ ActiveRecord::Base.class_eval do
18
+ include Spud::Searchable
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,20 @@
1
+ module Spud::Searchable
2
+ extend ActiveSupport::Concern
3
+ included do
4
+ extend ClassMethods
5
+ end
6
+ module ClassMethods
7
+ def spud_searchable
8
+ if self.name == 'SpudPage'
9
+ self.instance_eval do
10
+ acts_as_indexed :fields => [:name,:meta_keywords,:meta_description,:full_content_processed], :if => Proc.new { |page| page.published == true && page.visibility == 0 }
11
+ end
12
+ end
13
+ if self.name == 'SpudPost'
14
+ self.instance_eval do
15
+ acts_as_indexed :fields => [:title,:content_processed], :if => Proc.new { |post| post.published_at <= Time.now.utc && post.visible == true }
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ module Spud
2
+ module Search
3
+ VERSION = "1.0"
4
+ end
5
+ end
data/lib/tb_search.rb ADDED
@@ -0,0 +1,7 @@
1
+ module Spud
2
+ module Search
3
+ require 'spud_search/configuration'
4
+ require 'spud_search/searchable'
5
+ require 'spud_search/engine' if defined?(Rails)
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,209 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tb_search
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ platform: ruby
6
+ authors:
7
+ - David Estes
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-06-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 3.2.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 3.2.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: tb_core
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: acts_as_indexed
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: 0.7.7
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.7.7
55
+ - !ruby/object:Gem::Dependency
56
+ name: mysql2
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.3.11
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 0.3.11
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 2.8.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 2.8.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec-rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 2.8.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 2.8.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: shoulda
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: 3.0.1
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: 3.0.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: factory_girl
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 2.5.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '='
123
+ - !ruby/object:Gem::Version
124
+ version: 2.5.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: mocha
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 0.10.3
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 0.10.3
139
+ - !ruby/object:Gem::Dependency
140
+ name: database_cleaner
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '='
144
+ - !ruby/object:Gem::Version
145
+ version: 0.7.1
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '='
151
+ - !ruby/object:Gem::Version
152
+ version: 0.7.1
153
+ - !ruby/object:Gem::Dependency
154
+ name: simplecov
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ~>
158
+ - !ruby/object:Gem::Version
159
+ version: 0.6.4
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ~>
165
+ - !ruby/object:Gem::Version
166
+ version: 0.6.4
167
+ description: Spud Search is a base search interface for use on tb core
168
+ email:
169
+ - destes@redwindsw.com
170
+ executables: []
171
+ extensions: []
172
+ extra_rdoc_files: []
173
+ files:
174
+ - app/controllers/search_controller.rb
175
+ - app/views/search/_index.html.erb
176
+ - app/views/search/index.html.erb
177
+ - config/routes.rb
178
+ - lib/spud_search/configuration.rb
179
+ - lib/spud_search/engine.rb
180
+ - lib/spud_search/searchable.rb
181
+ - lib/spud_search/version.rb
182
+ - lib/tb_search.rb
183
+ - MIT-LICENSE
184
+ - Rakefile
185
+ - README.markdown
186
+ homepage: https://bitbucket.org/westlakedesign/tb_search
187
+ licenses: []
188
+ metadata: {}
189
+ post_install_message:
190
+ rdoc_options: []
191
+ require_paths:
192
+ - lib
193
+ required_ruby_version: !ruby/object:Gem::Requirement
194
+ requirements:
195
+ - - ! '>='
196
+ - !ruby/object:Gem::Version
197
+ version: '0'
198
+ required_rubygems_version: !ruby/object:Gem::Requirement
199
+ requirements:
200
+ - - ! '>='
201
+ - !ruby/object:Gem::Version
202
+ version: '0'
203
+ requirements: []
204
+ rubyforge_project:
205
+ rubygems_version: 2.0.3
206
+ signing_key:
207
+ specification_version: 4
208
+ summary: Acts as indexed adapter for tb core for quick searches of pages and blogs
209
+ test_files: []