solidify 0.0.1.alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +40 -0
  5. data/.travis.yml +10 -0
  6. data/CODE_OF_CONDUCT.md +74 -0
  7. data/Gemfile +3 -0
  8. data/Guardfile +51 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +75 -0
  11. data/Rakefile +42 -0
  12. data/app/controllers/concerns/solidify/liquid.rb +26 -0
  13. data/app/controllers/solidify/addresses_controller.rb +15 -0
  14. data/app/controllers/solidify/carts_controller.rb +15 -0
  15. data/app/controllers/solidify/collections_controller.rb +26 -0
  16. data/app/controllers/solidify/customers_controller.rb +16 -0
  17. data/app/controllers/solidify/home_controller.rb +15 -0
  18. data/app/controllers/solidify/liquid_controller.rb +25 -0
  19. data/app/controllers/solidify/orders_controller.rb +19 -0
  20. data/app/controllers/solidify/pages_controller.rb +22 -0
  21. data/app/controllers/solidify/products_controller.rb +34 -0
  22. data/app/controllers/solidify/registrations_controller.rb +25 -0
  23. data/app/controllers/solidify/responders/solidify/liquid_responder.rb +29 -0
  24. data/app/controllers/solidify/search_controller.rb +41 -0
  25. data/app/controllers/solidify/sessions_controller.rb +15 -0
  26. data/app/drops/rails_settings/scoped_settings_drop.rb +11 -0
  27. data/app/drops/solidify/errors_drop.rb +14 -0
  28. data/app/drops/solidify/link_drop.rb +15 -0
  29. data/app/drops/solidify/link_list_drop.rb +7 -0
  30. data/app/drops/solidify/nil_drop.rb +7 -0
  31. data/app/drops/solidify/page_drop.rb +7 -0
  32. data/app/drops/solidify/search_drop.rb +7 -0
  33. data/app/drops/spree/address_drop.rb +28 -0
  34. data/app/drops/spree/image_drop.rb +32 -0
  35. data/app/drops/spree/line_item_drop.rb +98 -0
  36. data/app/drops/spree/option_type_drop.rb +4 -0
  37. data/app/drops/spree/order_drop.rb +64 -0
  38. data/app/drops/spree/product_drop.rb +97 -0
  39. data/app/drops/spree/taxon_drop.rb +53 -0
  40. data/app/drops/spree/user_drop.rb +54 -0
  41. data/app/drops/spree/variant_drop.rb +111 -0
  42. data/app/fields/spree/address_fields.rb +18 -0
  43. data/app/fields/spree/image_fields.rb +12 -0
  44. data/app/fields/spree/line_item_fields.rb +21 -0
  45. data/app/fields/spree/order_fields.rb +22 -0
  46. data/app/fields/spree/product_fields.rb +22 -0
  47. data/app/fields/spree/taxon_fields.rb +18 -0
  48. data/app/fields/spree/user_fields.rb +14 -0
  49. data/app/fields/spree/variant_fields.rb +19 -0
  50. data/app/filters/solidify/additional_filters.rb +22 -0
  51. data/app/filters/solidify/html_filters.rb +16 -0
  52. data/app/filters/solidify/money_filters.rb +39 -0
  53. data/app/filters/solidify/string_filters.rb +47 -0
  54. data/app/filters/solidify/url_filters.rb +59 -0
  55. data/app/helpers/solidify/liquid_helper.rb +111 -0
  56. data/app/helpers/solidify/shop_helper.rb +7 -0
  57. data/app/models/concerns/solidify/address.rb +15 -0
  58. data/app/models/concerns/solidify/full_name.rb +11 -0
  59. data/app/models/concerns/solidify/handle.rb +25 -0
  60. data/app/models/concerns/solidify/inventory_policy.rb +7 -0
  61. data/app/models/concerns/solidify/validation_cancel.rb +33 -0
  62. data/app/models/concerns/spree/order_state.rb +19 -0
  63. data/app/models/solidify/asset.rb +12 -0
  64. data/app/models/solidify/link.rb +10 -0
  65. data/app/models/solidify/link_list.rb +7 -0
  66. data/app/models/solidify/page.rb +5 -0
  67. data/app/models/solidify/setting.rb +8 -0
  68. data/app/models/solidify/theme.rb +19 -0
  69. data/app/models/spree/address_decorator.rb +13 -0
  70. data/app/models/spree/image_decorator.rb +7 -0
  71. data/app/models/spree/line_item_decorator.rb +7 -0
  72. data/app/models/spree/order_decorator.rb +10 -0
  73. data/app/models/spree/product_decorator.rb +8 -0
  74. data/app/models/spree/taxon_decorator.rb +20 -0
  75. data/app/models/spree/user_decorator.rb +9 -0
  76. data/app/models/spree/variant_decorator.rb +11 -0
  77. data/app/poro/solidify/search.rb +14 -0
  78. data/app/services/solidify/app_specific_string_io.rb +15 -0
  79. data/app/services/solidify/asset_compiler.rb +11 -0
  80. data/app/services/solidify/asset_postprocessor.rb +53 -0
  81. data/app/services/solidify/collections_all_builder.rb +12 -0
  82. data/app/services/solidify/link_list_seeder.rb +26 -0
  83. data/app/services/solidify/liquid_asset_compiler.rb +19 -0
  84. data/app/services/solidify/scss_asset_compiler.rb +15 -0
  85. data/app/services/solidify/shop_settings_seeder.rb +26 -0
  86. data/app/services/solidify/theme_mechanic.rb +30 -0
  87. data/app/uploaders/solidify/asset_uploader.rb +10 -0
  88. data/app/views/solidify/global/content_for_header.html.erb +0 -0
  89. data/app/views/solidify/themes/skeleton-theme/README.md +54 -0
  90. data/app/views/solidify/themes/skeleton-theme/assets/arrow-down.svg.liquid +3 -0
  91. data/app/views/solidify/themes/skeleton-theme/assets/cart.svg.liquid +4 -0
  92. data/app/views/solidify/themes/skeleton-theme/assets/shop.js.liquid +75 -0
  93. data/app/views/solidify/themes/skeleton-theme/assets/shopify_common.js +14 -0
  94. data/app/views/solidify/themes/skeleton-theme/assets/style.scss.liquid +768 -0
  95. data/app/views/solidify/themes/skeleton-theme/config/settings.html +217 -0
  96. data/app/views/solidify/themes/skeleton-theme/config/settings_data.json +26 -0
  97. data/app/views/solidify/themes/skeleton-theme/layout/theme.liquid +181 -0
  98. data/app/views/solidify/themes/skeleton-theme/snippets/article-grid-item.liquid +73 -0
  99. data/app/views/solidify/themes/skeleton-theme/snippets/collection-grid-item.liquid +46 -0
  100. data/app/views/solidify/themes/skeleton-theme/snippets/collection-listing.liquid +46 -0
  101. data/app/views/solidify/themes/skeleton-theme/snippets/open-graph-tags.liquid +35 -0
  102. data/app/views/solidify/themes/skeleton-theme/snippets/product-grid-item.liquid +70 -0
  103. data/app/views/solidify/themes/skeleton-theme/snippets/site-nav.liquid +57 -0
  104. data/app/views/solidify/themes/skeleton-theme/snippets/social-links.liquid +42 -0
  105. data/app/views/solidify/themes/skeleton-theme/snippets/twitter-card.liquid +41 -0
  106. data/app/views/solidify/themes/skeleton-theme/templates/404.liquid +2 -0
  107. data/app/views/solidify/themes/skeleton-theme/templates/article.liquid +160 -0
  108. data/app/views/solidify/themes/skeleton-theme/templates/blog.grid.liquid +30 -0
  109. data/app/views/solidify/themes/skeleton-theme/templates/blog.liquid +92 -0
  110. data/app/views/solidify/themes/skeleton-theme/templates/cart.liquid +123 -0
  111. data/app/views/solidify/themes/skeleton-theme/templates/collection.liquid +102 -0
  112. data/app/views/solidify/themes/skeleton-theme/templates/customers/account.liquid +57 -0
  113. data/app/views/solidify/themes/skeleton-theme/templates/customers/activate_account.liquid +26 -0
  114. data/app/views/solidify/themes/skeleton-theme/templates/customers/addresses.liquid +173 -0
  115. data/app/views/solidify/themes/skeleton-theme/templates/customers/login.liquid +90 -0
  116. data/app/views/solidify/themes/skeleton-theme/templates/customers/order.liquid +103 -0
  117. data/app/views/solidify/themes/skeleton-theme/templates/customers/register.liquid +32 -0
  118. data/app/views/solidify/themes/skeleton-theme/templates/customers/reset_password.liquid +27 -0
  119. data/app/views/solidify/themes/skeleton-theme/templates/index.liquid +39 -0
  120. data/app/views/solidify/themes/skeleton-theme/templates/list-collections.liquid +19 -0
  121. data/app/views/solidify/themes/skeleton-theme/templates/page.liquid +16 -0
  122. data/app/views/solidify/themes/skeleton-theme/templates/product.liquid +202 -0
  123. data/app/views/solidify/themes/skeleton-theme/templates/search.liquid +72 -0
  124. data/bin/rails +12 -0
  125. data/config/app.yml +0 -0
  126. data/config/initializers/carrierwave.rb +25 -0
  127. data/config/initializers/devise.rb +286 -0
  128. data/config/initializers/form_tag.rb +43 -0
  129. data/config/initializers/liquid.rb +213 -0
  130. data/config/initializers/sass.rb +15 -0
  131. data/config/initializers/spree.rb +7 -0
  132. data/config/initializers/theme_settings.rb +29 -0
  133. data/config/routes.rb +52 -0
  134. data/config/spring.rb +2 -0
  135. data/db/migrate/20170223064316_create_solidify_assets.solidify.rb +14 -0
  136. data/db/migrate/20170223064317_create_solidify_themes.solidify.rb +10 -0
  137. data/db/migrate/20170223064318_create_solidify_link_lists.solidify.rb +12 -0
  138. data/db/migrate/20170223064319_create_solidify_links.solidify.rb +13 -0
  139. data/db/migrate/20170223064320_create_solidify_settings.solidify.rb +22 -0
  140. data/db/migrate/20170223064321_create_solidify_pages.solidify.rb +16 -0
  141. data/db/migrate/20170223064322_add_attributes_to_spree_users.solidify.rb +7 -0
  142. data/db/migrate/20170223064323_add_handle_to_spree_taxons.solidify.rb +7 -0
  143. data/db/migrate/20170228115149_add_state_and_country_fields_to_spree_addresses.solidify.rb +7 -0
  144. data/lib/generators/solidify/install/install_generator.rb +23 -0
  145. data/lib/solidify.rb +11 -0
  146. data/lib/solidify/configuration.rb +21 -0
  147. data/lib/solidify/engine.rb +24 -0
  148. data/lib/solidify/testing_support/factories.rb +5 -0
  149. data/lib/solidify/testing_support/factories/assets.rb +75 -0
  150. data/lib/solidify/testing_support/factories/solidify_pages.rb +10 -0
  151. data/lib/solidify/testing_support/factories/spree_addresses.rb +9 -0
  152. data/lib/solidify/testing_support/factories/spree_line_items.rb +10 -0
  153. data/lib/solidify/testing_support/factories/spree_orders.rb +9 -0
  154. data/lib/solidify/testing_support/factories/spree_products.rb +8 -0
  155. data/lib/solidify/testing_support/factories/spree_taxons.rb +7 -0
  156. data/lib/solidify/testing_support/factories/spree_variants.rb +7 -0
  157. data/lib/solidify/testing_support/factories/themes.rb +7 -0
  158. data/lib/solidify/version.rb +3 -0
  159. data/lib/tasks/download_theme.rake +18 -0
  160. data/lib/tasks/seed_default_theme.rake +8 -0
  161. data/lib/tasks/seed_everything.rake +12 -0
  162. data/lib/tasks/seed_link_list.rake +8 -0
  163. data/lib/tasks/seed_shop_settings.rake +8 -0
  164. data/solidify.gemspec +61 -0
  165. metadata +668 -0
@@ -0,0 +1,22 @@
1
+ module Spree
2
+ class OrderFields
3
+ # cart fields
4
+ JSON = %w(
5
+ item_count items note original_total_price requires_shipping
6
+ token total_discount total_price total_weight
7
+ ).freeze
8
+
9
+ METHODS = %w(
10
+ attributes billing_address cancel_reason cancel_reason_label cancelled
11
+ cancelled_at created_at customer customer_url discounts email
12
+ financial_status financial_status_label fulfillment_status
13
+ fulfillment_status_label item_count items line_items location name note
14
+ order_number original_total_price shipping_address shipping_methods
15
+ shipping_price subtotal_price tags tax_lines tax_price total_price
16
+ total_weight transactions
17
+ ).freeze
18
+
19
+ PARAMS = %w(
20
+ ).freeze
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ module Spree
2
+ class ProductFields
3
+ JSON = %w(
4
+ id available compare_at_price compare_at_price_max compare_at_price_min
5
+ compare_at_price_varies content created_at description featured_image
6
+ handle images options price price_max price_min price_varies published_at
7
+ tags title type variants vendor
8
+ ).freeze
9
+
10
+ METHODS = %w(
11
+ id available collections compare_at_price_max compare_at_price_min
12
+ compare_at_price_varies content description featured_image
13
+ first_available_variant handle images options options_with_values price
14
+ price_max price_min price_varies selected_variant
15
+ selected_or_first_available_variant tags template_suffix title type url
16
+ variants vendor
17
+ ).freeze
18
+
19
+ PARAMS = %w(
20
+ ).freeze
21
+ end
22
+ end
@@ -0,0 +1,18 @@
1
+ module Spree
2
+ class TaxonFields
3
+ JSON = %w(
4
+ id body_html handle published_at published_scope sort_order
5
+ template_suffix title updated_at
6
+ ).freeze
7
+
8
+ METHODS = %w(
9
+ id all_tags all_types all_products_count all_vendors current_type
10
+ current_vendor default_sort_by description handle image next_product
11
+ previous_product products products_count published_at template_suffix
12
+ title tags url
13
+ ).freeze
14
+
15
+ PARAMS = %w(
16
+ ).freeze
17
+ end
18
+ end
@@ -0,0 +1,14 @@
1
+ module Spree
2
+ class UserFields
3
+ JSON = nil
4
+
5
+ METHODS = %w(
6
+ id accepts_marketing addresses addresses_count default_address email
7
+ first_name has_account last_name last_order name orders orders_count tags
8
+ total_spent
9
+ ).freeze
10
+
11
+ PARAMS = %w(
12
+ ).freeze
13
+ end
14
+ end
@@ -0,0 +1,19 @@
1
+ module Spree
2
+ class VariantFields
3
+ JSON = %w(
4
+ id available barcode compare_at_price featured_image inventory_management
5
+ inventory_policy inventory_quantity name option1 option2 option3 options
6
+ price public_title requires_shipping sku taxable title weight
7
+ ).freeze
8
+
9
+ METHODS = %w(
10
+ id available barcode compare_at_price image incoming inventory_management
11
+ inventory_policy inventory_quantity next_incoming_date option1 option2
12
+ option3 price requires_shipping selected sku taxable title url weight
13
+ weight_unit weight_in_unit
14
+ ).freeze
15
+
16
+ PARAMS = %w(
17
+ ).freeze
18
+ end
19
+ end
@@ -0,0 +1,22 @@
1
+ module Solidify
2
+ module AdditionalFilters
3
+ def default_errors(errors)
4
+ view = @context.registers[:view]
5
+ view.content_tag :div, class: 'errors' do
6
+ view.content_tag :ul do
7
+ view.safe_join(
8
+ errors.map do |error|
9
+ view.content_tag(:li, error)
10
+ end
11
+ )
12
+ end
13
+ end
14
+ end
15
+
16
+ def format_address(address); end
17
+
18
+ def json(resource)
19
+ JSON.dump(resource)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,16 @@
1
+ module Solidify
2
+ module HtmlFilters
3
+ def img_tag(url, alt = '')
4
+ %(<img src="#{url}" alt="#{alt}" />)
5
+ end
6
+
7
+ def script_tag(url)
8
+ %(<script src="#{url}" type="text/javascript"></script>)
9
+ end
10
+
11
+ # rubocop:disable Metrics/LineLength
12
+ def stylesheet_tag(url, media = 'all')
13
+ %(<link href="#{url}" rel="stylesheet" type="text/css" media="#{media}" />)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,39 @@
1
+ module Solidify
2
+ module MoneyFilters
3
+ include ShopHelper
4
+
5
+ def money(price_in_cents)
6
+ render_money(price_in_cents, shop_settings['money_format'])
7
+ end
8
+
9
+ def money_with_currency(price_in_cents)
10
+ render_money(price_in_cents, shop_settings['money_with_currency_format'])
11
+ end
12
+
13
+ def money_without_currency(price_in_cents)
14
+ price_in_cents.to_f / 100
15
+ end
16
+
17
+ def money_without_trailing_zeros(price_in_cents)
18
+ render_money(price_in_cents,
19
+ shop_settings['money_with_currency_format'],
20
+ strip_insignificant_zeros: true)
21
+ end
22
+
23
+ private
24
+
25
+ def render_money(price_in_cents, template, options = {})
26
+ price = price_in_cents.to_f / 100
27
+ formatter = ActionController::Base.helpers.method(:number_with_precision)
28
+
29
+ ::Liquid::Template.parse(template).render(
30
+ 'amount' => formatter.call(price, options.merge(precision: 2)),
31
+ 'amount_no_decimals' =>
32
+ formatter.call(price, options.merge(precision: 0)),
33
+ 'amount_with_comma_separator' =>
34
+ formatter.call(price, options.merge(precision: 2,
35
+ delimiter: '.', separator: ','))
36
+ )
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,47 @@
1
+ module Solidify
2
+ module StringFilters
3
+ def camelcase(string)
4
+ string.underscore.camelize
5
+ end
6
+
7
+ def handle(string)
8
+ string.try(:parameterize)
9
+ end
10
+
11
+ alias handleize handle
12
+
13
+ def md5(string)
14
+ Digest::MD5.hexdigest(string)
15
+ end
16
+
17
+ def sha1(string)
18
+ Digest::SHA1.hexdigest(string)
19
+ end
20
+
21
+ def sha256(string)
22
+ Digest::SHA256.hexdigest(string)
23
+ end
24
+
25
+ def hmac_sha1(data, secret)
26
+ OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'),
27
+ secret.encode('ASCII'), data.encode('ASCII'))
28
+ end
29
+
30
+ def hmac_sha256(data, secret)
31
+ OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'),
32
+ secret.encode('ASCII'), data.encode('ASCII'))
33
+ end
34
+
35
+ def pluralize(input, singular, plural)
36
+ input.try(:to_i) == 1 ? singular : plural
37
+ end
38
+
39
+ def url_escape(input)
40
+ URI.escape(input)
41
+ end
42
+
43
+ def url_param_escape(input)
44
+ ERB::Util.url_encode(input)
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,59 @@
1
+ module Solidify
2
+ module UrlFilters
3
+ GLOBAL_ASSET_URLS = {
4
+ 'social/social-icons.css' =>
5
+ 'https://solidify.s3.amazonaws.com/global/social/font-awesome.min.css',
6
+ 'shopify_common.js' =>
7
+ 'https://solidify.s3.amazonaws.com/global/shopify_common.js',
8
+ 'option_selection.js' =>
9
+ 'https://solidify.s3.amazonaws.com/global/option_selection.js'
10
+ }.freeze
11
+
12
+ def asset_url(asset_name)
13
+ theme = @context.registers[:theme]
14
+ 'https://' + ENV.fetch('AWS_S3_BUCKET_NAME') +
15
+ ".s3.amazonaws.com/themes/#{theme.id}/assets/#{asset_name}"
16
+ end
17
+
18
+ def customer_login_link(text)
19
+ link_to(text, '/account/login')
20
+ end
21
+
22
+ def customer_logout_link(text)
23
+ link_to(text, '/account/logout')
24
+ end
25
+
26
+ def customer_register_link(text)
27
+ link_to(text, '/account/register')
28
+ end
29
+
30
+ def global_asset_url(asset_name)
31
+ GLOBAL_ASSET_URLS[asset_name]
32
+ end
33
+
34
+ alias shopify_asset_url global_asset_url
35
+
36
+ def img_url(drop, _size)
37
+ case drop
38
+ when ::Spree::ProductDrop
39
+ drop.featured_image.try(:attachment).try(:url)
40
+ when ::Spree::ImageDrop
41
+ drop.attachment.url
42
+ else
43
+ drop.to_s
44
+ end
45
+ end
46
+
47
+ def link_to(link, url, title = '')
48
+ %(<a href="#{url}" title="#{title}">#{link}</a>)
49
+ end
50
+
51
+ def url_for_vendor(vendor)
52
+ "/collections/vendors?q=#{vendor}"
53
+ end
54
+
55
+ def within(product_url, collection)
56
+ "/collections/#{collection.handle}#{product_url}"
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,111 @@
1
+ module Solidify
2
+ module LiquidHelper
3
+ CONTROLLER_ACTION_TO_LIQUID_MAPPING = {
4
+ 'addresses#index' => 'templates/customers/addresses.liquid',
5
+ 'home#missing' => 'templates/404.liquid',
6
+ 'articles#show' => 'templates/article.liquid',
7
+ 'blogs#show' => 'templates/blog.liquid',
8
+ 'carts#show' => 'templates/cart.liquid',
9
+ 'customers#show' => 'templates/customers/account.liquid',
10
+ 'collections#index' => 'templates/list-collections.liquid',
11
+ 'collections#show' => 'templates/collection%{template_suffix}.liquid',
12
+ 'home#index' => 'templates/index.liquid',
13
+ 'pages#show' => 'templates/page%{template_suffix}.liquid',
14
+ 'products#show' => 'templates/product.liquid',
15
+ 'registrations#new' => 'templates/customers/register.liquid',
16
+ 'search#index' => 'templates/search.liquid',
17
+ 'sessions#new' => 'templates/customers/login.liquid'
18
+ }.freeze
19
+
20
+ LIQUID_FILTERS = [
21
+ AdditionalFilters, HtmlFilters, MoneyFilters, StringFilters, UrlFilters
22
+ ].freeze
23
+
24
+ def content_for_header
25
+ ApplicationController.new.render_to_string(
26
+ template: 'solidify/global/content_for_header',
27
+ layout: false
28
+ )
29
+ end
30
+
31
+ def theme
32
+ active_theme_id = request.cookies['active_theme_id']
33
+ active_theme_id ||= cookies.try(:[], 'active_theme_id')
34
+ @theme ||= Theme.find(active_theme_id)
35
+ end
36
+
37
+ def theme_dir
38
+ "themes/#{theme.id}"
39
+ end
40
+
41
+ def theme_layout_file
42
+ "../#{theme_dir}/layout/theme"
43
+ end
44
+
45
+ # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
46
+ def liquid_assigns
47
+ shop = shop_settings.merge(
48
+ 'collections_count' => Spree::Taxon.count,
49
+ 'locale' => I18n.locale.to_s,
50
+ 'permanent_domain' => shop_settings[:domain],
51
+ 'products_count' => Spree::Product.available.count,
52
+ 'secure_url' => "https://#{shop_settings[:domain]}",
53
+ 'types' => [],
54
+ 'url' => "https://#{shop_settings[:domain]}",
55
+ 'vendors' => []
56
+ )
57
+
58
+ {
59
+ 'all_products' => Spree::Product.handle_to_records_array,
60
+ 'cart' => current_order(create_order_if_necessary: true),
61
+ 'collections' => Spree::Taxon.handle_to_records_array,
62
+ 'content_for_header' => content_for_header,
63
+ 'current_page' => 1,
64
+ 'current_tags' => nil,
65
+ 'customer' => current_customer,
66
+ 'linklists' => LinkList.handle_to_records_array,
67
+ 'page_description' => nil,
68
+ 'pages' => Page.handle_to_records_array,
69
+ 'powered_by_link' =>
70
+ %(<a target="_blank" rel="nofollow" href="https://www.splitshop.com">
71
+ Powered by Split
72
+ </a>),
73
+ 'search' => Search.new,
74
+ 'settings' => theme_settings,
75
+ 'shop' => shop
76
+ }
77
+ end
78
+ # rubocop:enable Metrics/MethodLength
79
+
80
+ def theme_settings
81
+ @theme_settings ||= JSON.parse(
82
+ Redis.current.get("solidify_themes_#{theme.id}")
83
+ )
84
+ end
85
+
86
+ def liquid_filters
87
+ LIQUID_FILTERS
88
+ end
89
+
90
+ def set_active_theme
91
+ cookies['active_theme_id'] ||= shop_settings['active_theme_id']
92
+ theme
93
+ end
94
+
95
+ def controller_action_to_liquid_file_path(
96
+ record = nil, controller_action = nil
97
+ )
98
+ # TODO: fallback to default template when template_suffix template missing
99
+ template_suffix = record.try(:template_suffix)
100
+ template_suffix = ".#{template_suffix}" if template_suffix.present?
101
+
102
+ controller_action ||= "#{controller_name}##{action_name}"
103
+ template_format =
104
+ CONTROLLER_ACTION_TO_LIQUID_MAPPING.fetch(controller_action)
105
+
106
+ template_path = format(template_format, template_suffix: template_suffix)
107
+
108
+ "#{theme_dir}/#{template_path}"
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,7 @@
1
+ module Solidify
2
+ module ShopHelper
3
+ def shop_settings
4
+ @shop_settings ||= Setting.get_all
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ module Solidify
2
+ module Address
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ def street
7
+ if address1.present? && address2.present?
8
+ "#{address1}, #{address2}"
9
+ else
10
+ address1 || address2 || ''
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ module Solidify
2
+ module FullName
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ def name
7
+ "#{first_name} #{last_name}".strip
8
+ end
9
+ end
10
+ end
11
+ end