workarea-content_search 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.editorconfig +20 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
- data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.gitignore +13 -0
- data/CHANGELOG.md +131 -0
- data/CODE_OF_CONDUCT.md +3 -0
- data/CONTRIBUTING.md +3 -0
- data/Gemfile +9 -0
- data/LICENSE +52 -0
- data/README.md +45 -0
- data/Rakefile +31 -0
- data/app/controllers/workarea/.keep +0 -0
- data/app/controllers/workarea/storefront/searches_controller.decorator +17 -0
- data/app/models/workarea/search/storefront/content.rb +55 -0
- data/app/models/workarea/search/storefront.decorator +10 -0
- data/app/queries/workarea/search/content_search.rb +96 -0
- data/app/queries/workarea/search/search_suggestions.decorator +9 -0
- data/app/queries/workarea/search/storefront_search/response.decorator +24 -0
- data/app/queries/workarea/search/storefront_search/spelling_correction_with_content.rb +20 -0
- data/app/queries/workarea/search/storefront_search/template_with_content.rb +28 -0
- data/app/view_models/workarea/storefront/content_search_results.rb +21 -0
- data/app/view_models/workarea/storefront/content_search_view_model.rb +49 -0
- data/app/views/workarea/storefront/searches/_search_type_toggle.html.haml +8 -0
- data/app/views/workarea/storefront/searches/content.html.haml +71 -0
- data/app/workers/workarea/bulk_index_content.rb +29 -0
- data/app/workers/workarea/clean_content.rb +35 -0
- data/app/workers/workarea/index_content.rb +46 -0
- data/bin/rails +16 -0
- data/config/initializers/appends.rb +4 -0
- data/config/initializers/configuration.rb +19 -0
- data/config/locales/en.yml +7 -0
- data/config/routes.rb +9 -0
- data/lib/tasks/content_search_tasks.rake +8 -0
- data/lib/workarea/content_search/engine.rb +15 -0
- data/lib/workarea/content_search/version.rb +5 -0
- data/lib/workarea/content_search.rb +11 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/config/manifest.js +4 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/jobs/application_job.rb +2 -0
- data/test/dummy/app/mailers/application_mailer.rb +4 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +34 -0
- data/test/dummy/bin/update +29 -0
- data/test/dummy/config/application.rb +18 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/cable.yml +9 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +54 -0
- data/test/dummy/config/environments/production.rb +83 -0
- data/test/dummy/config/environments/test.rb +43 -0
- data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +5 -0
- data/test/dummy/config/initializers/workarea.rb +5 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/puma.rb +47 -0
- data/test/dummy/config/routes.rb +5 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config.ru +5 -0
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/test/dummy/public/apple-touch-icon.png +0 -0
- data/test/dummy/public/favicon.ico +1 -0
- data/test/models/workarea/search/storefront/content_test.rb +28 -0
- data/test/queries/workarea/search/content_search_test.rb +74 -0
- data/test/system/workarea/storefront/content_search_system_test.rb +103 -0
- data/test/test_helper.rb +10 -0
- data/test/view_models/workarea/storefront/content_search_results_test.rb +35 -0
- data/test/view_models/workarea/storefront/content_search_view_model_test.rb +63 -0
- data/test/workers/workarea/bulk_index_content_test.rb +18 -0
- data/test/workers/workarea/clean_content_test.rb +42 -0
- data/test/workers/workarea/index_content_test.rb +51 -0
- data/workarea-content_search.gemspec +21 -0
- metadata +153 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Workarea
|
|
2
|
+
module Storefront
|
|
3
|
+
module ContentSearchResults
|
|
4
|
+
def multiple_result_types?
|
|
5
|
+
product_total > 0 && content_total > 0
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def product_total
|
|
9
|
+
model.total
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def result_type
|
|
13
|
+
if model.template == 'content'
|
|
14
|
+
'content'
|
|
15
|
+
else
|
|
16
|
+
super
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module Workarea
|
|
2
|
+
module Storefront
|
|
3
|
+
class ContentSearchViewModel < ApplicationViewModel
|
|
4
|
+
include Pagination
|
|
5
|
+
include SearchCustomizationContent
|
|
6
|
+
include ContentSearchResults
|
|
7
|
+
|
|
8
|
+
ContentResult = Struct.new(:name, :resource_name, :summary, :to_param)
|
|
9
|
+
|
|
10
|
+
def search_query
|
|
11
|
+
content_query
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def content
|
|
15
|
+
@content ||=
|
|
16
|
+
begin
|
|
17
|
+
results = content_query.results.map do |result|
|
|
18
|
+
ContentResult.new(
|
|
19
|
+
result['content']['name'],
|
|
20
|
+
result['cache']['resource_name'],
|
|
21
|
+
result['content']['summary'],
|
|
22
|
+
result['slug']
|
|
23
|
+
)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
PagedArray.from(results, page, per_page, total)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def query_suggestions
|
|
31
|
+
@query_suggestions ||=
|
|
32
|
+
begin
|
|
33
|
+
all = Recommendation::Searches.find(options[:q]) +
|
|
34
|
+
model.query_suggestions
|
|
35
|
+
|
|
36
|
+
all.take(3)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def sort
|
|
41
|
+
content_query.class.available_sorts.find(options[:sort])
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def sorts
|
|
45
|
+
content_query.class.available_sorts.map { |s| [s.name, s.slug] }
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
- if @search.multiple_result_types?
|
|
2
|
+
.grid.grid--auto
|
|
3
|
+
.grid__cell
|
|
4
|
+
%span.search-results__type= pluralize(@search.total, t('workarea.storefront.searches.product_result'))
|
|
5
|
+
|
|
6
|
+
- if @search.content_total > 0
|
|
7
|
+
.grid__cell
|
|
8
|
+
%span.search-results__type= link_to pluralize(@search.content_total, t('workarea.storefront.searches.content_result')), content_search_path(q: @search.query_string, type: 'content')
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
- @title = t('workarea.storefront.searches.title')
|
|
2
|
+
|
|
3
|
+
- content_for :head do
|
|
4
|
+
%meta{ property: 'recent-view', content: recent_view_content(search: @search.query_string) }
|
|
5
|
+
= append_partials('storefront.search_head', search: @search)
|
|
6
|
+
|
|
7
|
+
- if @search.first_page?
|
|
8
|
+
%link{ href: search_path(q: @search.query_string), rel: 'canonical' }
|
|
9
|
+
%meta{ name: 'robots', content: 'noindex, follow' }
|
|
10
|
+
- unless @search.last_page?
|
|
11
|
+
%link{ href: url_for(q: @search.query_string, page: @search.next_page), rel: 'next' }
|
|
12
|
+
- unless @search.first_page?
|
|
13
|
+
%link{ href: url_for(q: @search.query_string, page: @search.prev_page), rel: 'prev' }
|
|
14
|
+
|
|
15
|
+
%meta{ property: 'og:url', content: url_for }
|
|
16
|
+
%meta{ property: 'og:title', content: page_title }
|
|
17
|
+
%meta{ property: 'og:type', content: 'website' }
|
|
18
|
+
%meta{ property: 'og:image', content: root_path + image_path('workarea/storefront/logo.png') }
|
|
19
|
+
|
|
20
|
+
- content_for :breadcrumbs do
|
|
21
|
+
%p.breadcrumbs__node-group
|
|
22
|
+
%span.breadcrumbs__node{ itemprop: 'breadcrumb' }
|
|
23
|
+
= link_to t('workarea.storefront.layouts.home'), root_path, rel: 'home'
|
|
24
|
+
%span.breadcrumbs__node{ itemprop: 'breadcrumb' }
|
|
25
|
+
%span= t('workarea.storefront.searches.title')
|
|
26
|
+
%span.breadcrumbs__node{ itemprop: 'breadcrumb' }
|
|
27
|
+
%span= @search.query_string
|
|
28
|
+
|
|
29
|
+
.view{ data: { analytics: search_results_view_analytics_data(@search).to_json } }
|
|
30
|
+
|
|
31
|
+
- if @search.customization_content_blocks_for('above_results').present?
|
|
32
|
+
.search-query-content= render_content_blocks(@search.customization_content_blocks_for('above_results'))
|
|
33
|
+
|
|
34
|
+
- if @search.multiple_result_types?
|
|
35
|
+
%h1.visually-hidden= pluralize(@search.total, t('workarea.storefront.searches.content_result'))
|
|
36
|
+
|
|
37
|
+
%ul.search-result-types
|
|
38
|
+
- if @search.product_total > 0
|
|
39
|
+
%li= link_to pluralize(@search.product_total, t('workarea.storefront.searches.product_result')), search_path(q: @search.query_string, type: 'show')
|
|
40
|
+
%li= pluralize(@search.content_total, t('workarea.storefront.searches.content_result'))
|
|
41
|
+
- else
|
|
42
|
+
%h1= pluralize(@search.total, t('workarea.storefront.searches.result'))
|
|
43
|
+
|
|
44
|
+
- if @search.query_suggestions.any?
|
|
45
|
+
.related-searches
|
|
46
|
+
%p= t('workarea.storefront.searches.suggestions')
|
|
47
|
+
%ul
|
|
48
|
+
- @search.query_suggestions.each do |search|
|
|
49
|
+
%li= link_to search, content_search_path(q: search)
|
|
50
|
+
|
|
51
|
+
.grid.grid--auto.grid--middle
|
|
52
|
+
.grid__cell
|
|
53
|
+
= form_tag content_search_path, method: 'get' do
|
|
54
|
+
= hidden_field_tag :q, @search.query_string
|
|
55
|
+
.property.property--responsive
|
|
56
|
+
= label_tag 'sort_top', nil, class: 'property__name' do
|
|
57
|
+
%span.property__text= t('workarea.storefront.searches.sort_by')
|
|
58
|
+
%span.value= select_tag :sort, options_for_select(@search.sorts, selected: @search.sort), id: 'sort_top', data: { form_submitting_control: '' }
|
|
59
|
+
.hidden-if-js-enabled= button_tag t('workarea.storefront.searches.sort'), value: 'sort_content_top', class: 'button'
|
|
60
|
+
|
|
61
|
+
= append_partials('storefront.search_browse_controls', search: @search)
|
|
62
|
+
|
|
63
|
+
.pagination{ data: { pagination: pagination_data(@search.content) } }
|
|
64
|
+
%ul
|
|
65
|
+
- @search.content.each do |result|
|
|
66
|
+
%li{ data: { pagination_item: '' } }
|
|
67
|
+
= link_to result.name, send("#{result.resource_name}_path", result)
|
|
68
|
+
%p= truncate(result.summary, length: 100)
|
|
69
|
+
- if show_pagination?(@search.content)
|
|
70
|
+
.pagination__button
|
|
71
|
+
= link_to t('workarea.storefront.pagination.next_page'), pagination_path_for(page: @search.next_page), class: 'button button--large', data: { pagination_button: '' }
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Workarea
|
|
2
|
+
class BulkIndexContent
|
|
3
|
+
include Sidekiq::Worker
|
|
4
|
+
|
|
5
|
+
sidekiq_options unique: :until_and_while_executing
|
|
6
|
+
|
|
7
|
+
class << self
|
|
8
|
+
def perform(ids = Content.pluck(:id))
|
|
9
|
+
ids.each_slice(100) do |group|
|
|
10
|
+
perform_by_models(Content.in(id: group).to_a)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def perform_by_models(content)
|
|
15
|
+
documents = content.map do |model|
|
|
16
|
+
search_model = Search::Storefront::Content.new(model)
|
|
17
|
+
next unless search_model.should_be_indexed?
|
|
18
|
+
search_model.as_bulk_document
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
Search::Storefront.bulk(documents.compact)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def perform(ids)
|
|
26
|
+
self.class.perform(ids)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module Workarea
|
|
2
|
+
class CleanContent
|
|
3
|
+
include Sidekiq::Worker
|
|
4
|
+
include Sidekiq::CallbacksWorker
|
|
5
|
+
|
|
6
|
+
sidekiq_options(
|
|
7
|
+
enqueue_on: {
|
|
8
|
+
Contentable => [:save, :destroy],
|
|
9
|
+
with: -> { [id, self.class.name] }
|
|
10
|
+
}
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
def perform(id, type)
|
|
14
|
+
object_id = BSON::ObjectId.from_string(id.to_s) rescue nil
|
|
15
|
+
content =
|
|
16
|
+
if object_id.present?
|
|
17
|
+
Content.where(contentable_type: type)
|
|
18
|
+
.any_of({ contentable_id: id }, { contentable_id: object_id })
|
|
19
|
+
else
|
|
20
|
+
Content.where(contentable_type: type, contentable_id: id)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
content.each do |model|
|
|
24
|
+
search_model = Search::Storefront::Content.new(model)
|
|
25
|
+
contentable = model.contentable
|
|
26
|
+
|
|
27
|
+
if contentable&.active? && search_model.should_be_indexed?
|
|
28
|
+
search_model.save
|
|
29
|
+
else
|
|
30
|
+
search_model.destroy rescue nil
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
module Workarea
|
|
2
|
+
class IndexContent
|
|
3
|
+
include Sidekiq::Worker
|
|
4
|
+
include Sidekiq::CallbacksWorker
|
|
5
|
+
|
|
6
|
+
sidekiq_options(
|
|
7
|
+
enqueue_on: {
|
|
8
|
+
Content => [:save, :destroy],
|
|
9
|
+
Content::Block => [:save, :destroy],
|
|
10
|
+
with: -> { respond_to?(:content) ? content.id : id }
|
|
11
|
+
},
|
|
12
|
+
unique: :until_executing
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
class << self
|
|
16
|
+
def perform(content)
|
|
17
|
+
search_model = Search::Storefront::Content.new(content)
|
|
18
|
+
|
|
19
|
+
if content.persisted? && search_model.should_be_indexed?
|
|
20
|
+
search_model.save
|
|
21
|
+
else
|
|
22
|
+
begin
|
|
23
|
+
search_model.try(:destroy)
|
|
24
|
+
rescue
|
|
25
|
+
nil # It's OK if it doesn't exist
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Test whether this content model should be indexed.
|
|
31
|
+
#
|
|
32
|
+
# @param [Workarea::Content] content - Model to be tested
|
|
33
|
+
# @return [Boolean] +true+ if the model should skip the index.
|
|
34
|
+
# @deprecated Use +Workarea::Search::Storefront::Content#should_be_indexed?+
|
|
35
|
+
# instead.
|
|
36
|
+
def skip_index?(content)
|
|
37
|
+
!Search::Storefront::Content.new(content).should_be_indexed?
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def perform(id)
|
|
42
|
+
model = Content.find_or_initialize_by(id: id)
|
|
43
|
+
self.class.perform(model)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
data/bin/rails
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# This command will automatically be run when you run "rails" with Rails gems
|
|
3
|
+
# installed from the root of your application.
|
|
4
|
+
|
|
5
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
|
6
|
+
ENGINE_PATH = File.expand_path('../../lib/content_search/engine', __FILE__)
|
|
7
|
+
|
|
8
|
+
# Set up gems listed in the Gemfile.
|
|
9
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
|
10
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
|
11
|
+
|
|
12
|
+
require 'action_controller/railtie'
|
|
13
|
+
require 'action_mailer/railtie'
|
|
14
|
+
require 'sprockets/railtie'
|
|
15
|
+
require 'rails/test_unit/railtie'
|
|
16
|
+
require 'rails/engine/commands'
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Workarea.configure do |config|
|
|
2
|
+
config.storefront_search_middleware.swap(
|
|
3
|
+
'Workarea::Search::StorefrontSearch::Template',
|
|
4
|
+
'Workarea::Search::StorefrontSearch::TemplateWithContent'
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
config.storefront_search_middleware.swap(
|
|
8
|
+
'Workarea::Search::StorefrontSearch::SpellingCorrection',
|
|
9
|
+
'Workarea::Search::StorefrontSearch::SpellingCorrectionWithContent'
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
# Exclude content related to the list of classes from being index for
|
|
13
|
+
# search. They will not show up in content search results.
|
|
14
|
+
config.exclude_from_content_search_index = %w(
|
|
15
|
+
Workarea::Catalog::Category
|
|
16
|
+
Workarea::Search::Customization
|
|
17
|
+
Workarea::Navigation::Menu
|
|
18
|
+
)
|
|
19
|
+
end
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Workarea
|
|
2
|
+
module ContentSearch
|
|
3
|
+
class Engine < ::Rails::Engine
|
|
4
|
+
include Workarea::Plugin
|
|
5
|
+
isolate_namespace Workarea::ContentSearch
|
|
6
|
+
|
|
7
|
+
config.to_prepare do
|
|
8
|
+
Storefront::SearchViewModel.send(
|
|
9
|
+
:include,
|
|
10
|
+
Storefront::ContentSearchResults
|
|
11
|
+
)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
data/test/dummy/Rakefile
ADDED
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
|
2
|
+
// listed below.
|
|
3
|
+
//
|
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
|
6
|
+
//
|
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
|
9
|
+
//
|
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
|
11
|
+
// about supported directives.
|
|
12
|
+
//
|
|
13
|
+
//= require_tree .
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
|
3
|
+
* listed below.
|
|
4
|
+
*
|
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
|
7
|
+
*
|
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
|
11
|
+
* It is generally better to create a new file per style scope.
|
|
12
|
+
*
|
|
13
|
+
*= require_tree .
|
|
14
|
+
*= require_self
|
|
15
|
+
*/
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Dummy</title>
|
|
5
|
+
<%= csrf_meta_tags %>
|
|
6
|
+
|
|
7
|
+
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
|
|
8
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
|
|
9
|
+
</head>
|
|
10
|
+
|
|
11
|
+
<body>
|
|
12
|
+
<%= yield %>
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= yield %>
|
data/test/dummy/bin/rake
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'pathname'
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
include FileUtils
|
|
5
|
+
|
|
6
|
+
# path to your application root.
|
|
7
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
|
8
|
+
|
|
9
|
+
def system!(*args)
|
|
10
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
chdir APP_ROOT do
|
|
14
|
+
# This script is a starting point to setup your application.
|
|
15
|
+
# Add necessary setup steps to this file.
|
|
16
|
+
|
|
17
|
+
puts '== Installing dependencies =='
|
|
18
|
+
system! 'gem install bundler --conservative'
|
|
19
|
+
system('bundle check') || system!('bundle install')
|
|
20
|
+
|
|
21
|
+
# puts "\n== Copying sample files =="
|
|
22
|
+
# unless File.exist?('config/database.yml')
|
|
23
|
+
# cp 'config/database.yml.sample', 'config/database.yml'
|
|
24
|
+
# end
|
|
25
|
+
|
|
26
|
+
puts "\n== Preparing database =="
|
|
27
|
+
system! 'bin/rails db:setup'
|
|
28
|
+
|
|
29
|
+
puts "\n== Removing old logs and tempfiles =="
|
|
30
|
+
system! 'bin/rails log:clear tmp:clear'
|
|
31
|
+
|
|
32
|
+
puts "\n== Restarting application server =="
|
|
33
|
+
system! 'bin/rails restart'
|
|
34
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'pathname'
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
include FileUtils
|
|
5
|
+
|
|
6
|
+
# path to your application root.
|
|
7
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
|
8
|
+
|
|
9
|
+
def system!(*args)
|
|
10
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
chdir APP_ROOT do
|
|
14
|
+
# This script is a way to update your development environment automatically.
|
|
15
|
+
# Add necessary update steps to this file.
|
|
16
|
+
|
|
17
|
+
puts '== Installing dependencies =='
|
|
18
|
+
system! 'gem install bundler --conservative'
|
|
19
|
+
system('bundle check') || system!('bundle install')
|
|
20
|
+
|
|
21
|
+
puts "\n== Updating database =="
|
|
22
|
+
system! 'bin/rails db:migrate'
|
|
23
|
+
|
|
24
|
+
puts "\n== Removing old logs and tempfiles =="
|
|
25
|
+
system! 'bin/rails log:clear tmp:clear'
|
|
26
|
+
|
|
27
|
+
puts "\n== Restarting application server =="
|
|
28
|
+
system! 'bin/rails restart'
|
|
29
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require_relative 'boot'
|
|
2
|
+
|
|
3
|
+
require 'action_controller/railtie'
|
|
4
|
+
require 'action_mailer/railtie'
|
|
5
|
+
require 'sprockets/railtie'
|
|
6
|
+
|
|
7
|
+
require 'workarea'
|
|
8
|
+
require 'workarea/content_search'
|
|
9
|
+
|
|
10
|
+
Bundler.require(*Rails.groups)
|
|
11
|
+
|
|
12
|
+
module Dummy
|
|
13
|
+
class Application < Rails::Application
|
|
14
|
+
# Settings in config/environments/* take precedence over those specified here.
|
|
15
|
+
# Application configuration should go into files in config/initializers
|
|
16
|
+
# -- all .rb files in that directory are automatically loaded.
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
Rails.application.configure do
|
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
|
3
|
+
|
|
4
|
+
# In the development environment your application's code is reloaded on
|
|
5
|
+
# every request. This slows down response time but is perfect for development
|
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
|
7
|
+
config.cache_classes = false
|
|
8
|
+
|
|
9
|
+
# Do not eager load code on boot.
|
|
10
|
+
config.eager_load = false
|
|
11
|
+
|
|
12
|
+
# Show full error reports.
|
|
13
|
+
config.consider_all_requests_local = true
|
|
14
|
+
|
|
15
|
+
# Enable/disable caching. By default caching is disabled.
|
|
16
|
+
if Rails.root.join('tmp/caching-dev.txt').exist?
|
|
17
|
+
config.action_controller.perform_caching = true
|
|
18
|
+
|
|
19
|
+
config.cache_store = :memory_store
|
|
20
|
+
config.public_file_server.headers = {
|
|
21
|
+
'Cache-Control' => 'public, max-age=172800'
|
|
22
|
+
}
|
|
23
|
+
else
|
|
24
|
+
config.action_controller.perform_caching = false
|
|
25
|
+
|
|
26
|
+
config.cache_store = :null_store
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Don't care if the mailer can't send.
|
|
30
|
+
config.action_mailer.raise_delivery_errors = false
|
|
31
|
+
|
|
32
|
+
config.action_mailer.perform_caching = false
|
|
33
|
+
|
|
34
|
+
# Print deprecation notices to the Rails logger.
|
|
35
|
+
config.active_support.deprecation = :log
|
|
36
|
+
|
|
37
|
+
# Raise an error on page load if there are pending migrations.
|
|
38
|
+
# config.active_record.migration_error = :page_load
|
|
39
|
+
|
|
40
|
+
# Debug mode disables concatenation and preprocessing of assets.
|
|
41
|
+
# This option may cause significant delays in view rendering with a large
|
|
42
|
+
# number of complex assets.
|
|
43
|
+
config.assets.debug = true
|
|
44
|
+
|
|
45
|
+
# Suppress logger output for asset requests.
|
|
46
|
+
config.assets.quiet = true
|
|
47
|
+
|
|
48
|
+
# Raises error for missing translations
|
|
49
|
+
# config.action_view.raise_on_missing_translations = true
|
|
50
|
+
|
|
51
|
+
# Use an evented file watcher to asynchronously detect changes in source code,
|
|
52
|
+
# routes, locales, etc. This feature depends on the listen gem.
|
|
53
|
+
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
|
54
|
+
end
|