quick_search-core 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 23539ea74f21394249a312b7eabb3931fb9db0ed
4
- data.tar.gz: 2bd211e5230357b90c760babca649e4c4d7b138e
3
+ metadata.gz: 945a512b7b05c32916eac69f31ae23e60cfd8234
4
+ data.tar.gz: 59e982a4f144a577864dc288d76f9540126da661
5
5
  SHA512:
6
- metadata.gz: e71d9c5dbaf542ed012c57906721d8e6558083977b5b671d362711e57aa9268650f26c171ef754e33f30f0066c78e8401315ed35e2d021ffccd092b0dfba2129
7
- data.tar.gz: e7228c8b1cd7d08a63fa0ca3f837bdcf92d986b2e00cd7bb689fd902ead185d939fc53783d98d6e495b11bfda82661981718ec8123f0d57e4be59b541b2f9119
6
+ metadata.gz: 375061e582cdd20159480052993b435759274b0bb2cf25c36deeb5bc48b6eb19e169fbd690b75e7a1b2a70362665c496b76ba4b1c65fae730952acf5fbbf78d8
7
+ data.tar.gz: 37bf50794ae589a11245b7490b99e50d14514a5e97acfa6d468adbea0cb91e050322956bcb0f468b67e481c9be96ee82c8760b3fb7df013daf98097faac901e8
@@ -11,7 +11,21 @@
11
11
  <% end %>
12
12
  <span class='highlight'>Best&nbsp;Bet</span>
13
13
  </h3>
14
- <p><%= best_bets[:description] %></p>
14
+
15
+ <p>
16
+ <% if best_bets[:description].length > 200 %>
17
+ <%= truncate(best_bets[:description], length: 200) %>
18
+ <%= link_to 'Read more', '', class: "read-more" %>
19
+ <script>
20
+ $('.read-more').on('click', function(e) {
21
+ e.preventDefault()
22
+ $(this).parent().html('<%= escape_javascript best_bets[:description] %>')
23
+ })
24
+ </script>
25
+ <% else %>
26
+ <%= best_bets[:description] %>
27
+ <% end %>
28
+ </p>
15
29
  </div>
16
30
  </div>
17
31
  <% end %>
@@ -2,17 +2,45 @@ module QuickSearch
2
2
  class Engine < ::Rails::Engine
3
3
  isolate_namespace QuickSearch
4
4
 
5
+ # quick_search initializer
6
+ #
7
+ # We want to load the quick_search_config file, and set the loading order of the view paths as follows:
8
+ # 1. Application which imports gem engine/theme
9
+ # 2. Theme
10
+ # 3. Engine
11
+ #
12
+ # This way, we can make application specific overrides of views, otherwise fall back to theme,
13
+ # and finally fall back to the QS core if needed.
14
+
5
15
  initializer :quick_search, :after => :add_view_paths do
6
16
  config_file = File.join(Rails.root, "/config/quick_search_config.yml")
7
17
  if File.exist?(config_file)
8
18
  QuickSearch::Engine::APP_CONFIG = YAML.load_file(config_file)[Rails.env]
9
19
  ActiveSupport.on_load(:action_controller) do
20
+ # get theme / core engine classes
10
21
  theme_engine_class = "#{QuickSearch::Engine::APP_CONFIG['theme'].classify}::Engine".constantize
11
- prepend_view_path theme_engine_class.root.join('app', 'views', QuickSearch::Engine::APP_CONFIG['theme'])
22
+ core_engine_class = "QuickSearch::Engine".constantize
23
+
24
+ # get the correct view paths for the application, theme, and engine
25
+ core_view_path = core_engine_class.root.join('app', 'views')
26
+ theme_view_path = theme_engine_class.root.join('app', 'views', QuickSearch::Engine::APP_CONFIG['theme'])
27
+ app_view_path = Rails.root.join('app', 'views')
28
+
29
+ # prepend to the existing view path ordering
30
+ prepend_view_path(core_view_path)
31
+ prepend_view_path(theme_view_path)
32
+ prepend_view_path(app_view_path)
12
33
  end
13
34
  end
14
35
  end
15
36
 
37
+ # best_bets initializer
38
+ #
39
+ # Here we set up Best Bets. If there is a solr_url defined in the config, then we don't need to do anything,
40
+ # as Best Bets will be assumed to be in Solr, and the BestBetsSearcher will look there. Otherwise, load the
41
+ # best_bets.yml file into memory, and search that directly. The latter is only recommended for smaller amounts of
42
+ # Best Bets. The reason for this dual approach is that it removes Solr as an absolute requirement for QuickSearch.
43
+
16
44
  initializer :best_bets, :after => :quick_search do
17
45
  if defined? QuickSearch::Engine::APP_CONFIG and QuickSearch::Engine::APP_CONFIG['best_bets']['solr_url'].empty?
18
46
  best_bets_file = File.join(Rails.root, "/config/best_bets.yml")
@@ -1,3 +1,3 @@
1
1
  module QuickSearch
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quick_search-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Beswick
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-07-19 00:00:00.000000000 Z
14
+ date: 2016-07-25 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails