solidus_liquid 0.0.1.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.rubocop.yml +36 -0
- data/.travis.yml +10 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +3 -0
- data/Guardfile +37 -0
- data/LICENSE.txt +21 -0
- data/README.md +84 -0
- data/Rakefile +35 -0
- data/app/controllers/concerns/solidus_liquid/liquid.rb +26 -0
- data/app/controllers/solidus_liquid/addresses_controller.rb +15 -0
- data/app/controllers/solidus_liquid/carts_controller.rb +15 -0
- data/app/controllers/solidus_liquid/collections_controller.rb +22 -0
- data/app/controllers/solidus_liquid/customers_controller.rb +16 -0
- data/app/controllers/solidus_liquid/home_controller.rb +15 -0
- data/app/controllers/solidus_liquid/liquid_controller.rb +25 -0
- data/app/controllers/solidus_liquid/orders_controller.rb +18 -0
- data/app/controllers/solidus_liquid/pages_controller.rb +22 -0
- data/app/controllers/solidus_liquid/products_controller.rb +30 -0
- data/app/controllers/solidus_liquid/registrations_controller.rb +25 -0
- data/app/controllers/solidus_liquid/responders/solidus_liquid/liquid_responder.rb +29 -0
- data/app/controllers/solidus_liquid/search_controller.rb +41 -0
- data/app/controllers/solidus_liquid/sessions_controller.rb +15 -0
- data/app/drops/rails_settings/scoped_settings_drop.rb +11 -0
- data/app/drops/solidus_liquid/errors_drop.rb +14 -0
- data/app/drops/solidus_liquid/link_drop.rb +15 -0
- data/app/drops/solidus_liquid/link_list_drop.rb +7 -0
- data/app/drops/solidus_liquid/nil_drop.rb +7 -0
- data/app/drops/solidus_liquid/page_drop.rb +7 -0
- data/app/drops/solidus_liquid/search_drop.rb +7 -0
- data/app/drops/spree/address_drop.rb +24 -0
- data/app/drops/spree/image_drop.rb +10 -0
- data/app/drops/spree/line_item_drop.rb +5 -0
- data/app/drops/spree/option_type_drop.rb +4 -0
- data/app/drops/spree/order_drop.rb +18 -0
- data/app/drops/spree/product_drop.rb +92 -0
- data/app/drops/spree/taxon_drop.rb +31 -0
- data/app/drops/spree/user_drop.rb +19 -0
- data/app/drops/spree/variant_drop.rb +80 -0
- data/app/filters/solidus_liquid/additional_filters.rb +22 -0
- data/app/filters/solidus_liquid/html_filters.rb +20 -0
- data/app/filters/solidus_liquid/money_filters.rb +15 -0
- data/app/filters/solidus_liquid/string_filters.rb +11 -0
- data/app/filters/solidus_liquid/url_filters.rb +55 -0
- data/app/helpers/solidus_liquid/liquid_helper.rb +107 -0
- data/app/helpers/solidus_liquid/shop_helper.rb +7 -0
- data/app/models/concerns/solidus_liquid/address.rb +15 -0
- data/app/models/concerns/solidus_liquid/full_name.rb +11 -0
- data/app/models/concerns/solidus_liquid/handle.rb +25 -0
- data/app/models/concerns/solidus_liquid/inventory_policy.rb +7 -0
- data/app/models/solidus_liquid/asset.rb +12 -0
- data/app/models/solidus_liquid/link.rb +10 -0
- data/app/models/solidus_liquid/link_list.rb +7 -0
- data/app/models/solidus_liquid/page.rb +5 -0
- data/app/models/solidus_liquid/setting.rb +8 -0
- data/app/models/solidus_liquid/theme.rb +19 -0
- data/app/models/spree/address_decorator.rb +20 -0
- data/app/models/spree/image_decorator.rb +19 -0
- data/app/models/spree/product_decorator.rb +14 -0
- data/app/models/spree/taxon_decorator.rb +5 -0
- data/app/models/spree/variant_decorator.rb +15 -0
- data/app/poro/solidus_liquid/search.rb +14 -0
- data/app/services/solidus_liquid/app_specific_string_io.rb +15 -0
- data/app/services/solidus_liquid/asset_compiler.rb +11 -0
- data/app/services/solidus_liquid/asset_postprocessor.rb +53 -0
- data/app/services/solidus_liquid/link_list_seeder.rb +26 -0
- data/app/services/solidus_liquid/liquid_asset_compiler.rb +19 -0
- data/app/services/solidus_liquid/scss_asset_compiler.rb +15 -0
- data/app/services/solidus_liquid/shop_settings_seeder.rb +26 -0
- data/app/services/solidus_liquid/theme_mechanic.rb +45 -0
- data/app/uploaders/solidus_liquid/asset_uploader.rb +10 -0
- data/app/views/solidus_liquid/global/content_for_header.html.erb +0 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/README.md +54 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/assets/arrow-down.svg.liquid +3 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/assets/cart.svg.liquid +4 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/assets/shop.js.liquid +75 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/assets/shopify_common.js +14 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/assets/style.scss.liquid +768 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/config/settings.html +217 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/config/settings_data.json +26 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/layout/theme.liquid +181 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/snippets/article-grid-item.liquid +73 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/snippets/collection-grid-item.liquid +46 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/snippets/collection-listing.liquid +46 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/snippets/open-graph-tags.liquid +35 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/snippets/product-grid-item.liquid +70 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/snippets/site-nav.liquid +57 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/snippets/social-links.liquid +42 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/snippets/twitter-card.liquid +41 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/templates/404.liquid +2 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/templates/article.liquid +160 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/templates/blog.grid.liquid +30 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/templates/blog.liquid +92 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/templates/cart.liquid +123 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/templates/collection.liquid +102 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/templates/customers/account.liquid +57 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/templates/customers/activate_account.liquid +26 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/templates/customers/addresses.liquid +173 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/templates/customers/login.liquid +90 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/templates/customers/order.liquid +103 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/templates/customers/register.liquid +32 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/templates/customers/reset_password.liquid +27 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/templates/index.liquid +39 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/templates/list-collections.liquid +19 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/templates/page.liquid +16 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/templates/product.liquid +202 -0
- data/app/views/solidus_liquid/themes/skeleton-theme/templates/search.liquid +72 -0
- data/bin/rails +12 -0
- data/config/app.yml +0 -0
- data/config/initializers/carrierwave.rb +25 -0
- data/config/initializers/devise.rb +286 -0
- data/config/initializers/form_tag.rb +43 -0
- data/config/initializers/liquid.rb +202 -0
- data/config/initializers/sass.rb +15 -0
- data/config/initializers/theme_settings.rb +29 -0
- data/config/routes.rb +48 -0
- data/db/migrate/20170223064316_create_solidus_liquid_assets.solidus_liquid.rb +14 -0
- data/db/migrate/20170223064317_create_solidus_liquid_themes.solidus_liquid.rb +10 -0
- data/db/migrate/20170223064318_create_solidus_liquid_link_lists.solidus_liquid.rb +12 -0
- data/db/migrate/20170223064319_create_solidus_liquid_links.solidus_liquid.rb +13 -0
- data/db/migrate/20170223064320_create_solidus_liquid_settings.solidus_liquid.rb +22 -0
- data/db/migrate/20170223064321_create_solidus_liquid_pages.solidus_liquid.rb +16 -0
- data/db/migrate/20170223064322_add_attributes_to_spree_users.solidus_liquid.rb +7 -0
- data/db/migrate/20170223064323_add_handle_to_spree_taxons.solidus_liquid.rb +7 -0
- data/lib/generators/solidus_liquid/install/install_generator.rb +13 -0
- data/lib/solidus_liquid.rb +11 -0
- data/lib/solidus_liquid/configuration.rb +21 -0
- data/lib/solidus_liquid/engine.rb +24 -0
- data/lib/solidus_liquid/factories.rb +7 -0
- data/lib/solidus_liquid/version.rb +3 -0
- data/lib/tasks/download_theme.rake +18 -0
- data/lib/tasks/seed_default_theme.rake +8 -0
- data/lib/tasks/seed_everything.rake +14 -0
- data/lib/tasks/seed_link_list.rake +8 -0
- data/lib/tasks/seed_shop_settings.rake +8 -0
- data/solidus_liquid.gemspec +56 -0
- metadata +586 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
module Spree
|
2
|
+
class TaxonDrop < ::Liquid::Rails::Drop
|
3
|
+
attributes :handle, :title, :url
|
4
|
+
|
5
|
+
has_many :products
|
6
|
+
|
7
|
+
def all_tags
|
8
|
+
{ 'size' => 0 }
|
9
|
+
end
|
10
|
+
|
11
|
+
def default_sort_by
|
12
|
+
''
|
13
|
+
end
|
14
|
+
|
15
|
+
def description
|
16
|
+
if @object.description.nil?
|
17
|
+
''
|
18
|
+
else
|
19
|
+
@object.description
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def products_count
|
24
|
+
@object.products.count
|
25
|
+
end
|
26
|
+
|
27
|
+
def sort_by
|
28
|
+
''
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Spree
|
2
|
+
class UserDrop < ::Liquid::Rails::Drop
|
3
|
+
attributes :first_name, :last_name, :password, :email, :default_address
|
4
|
+
has_many :orders
|
5
|
+
has_many :addresses
|
6
|
+
|
7
|
+
def addresses_count
|
8
|
+
@object.addresses.count
|
9
|
+
end
|
10
|
+
|
11
|
+
def errors
|
12
|
+
SolidusLiquid::ErrorsDrop.new(@object.errors)
|
13
|
+
end
|
14
|
+
|
15
|
+
def password_needed
|
16
|
+
true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module Spree
|
2
|
+
class VariantDrop < ::Liquid::Rails::Drop
|
3
|
+
include SolidusLiquid::InventoryPolicy
|
4
|
+
|
5
|
+
attributes :id, :available, :barcode, :compare_at_price, :featured_image,
|
6
|
+
:inventory_management, :inventory_policy, :inventory_quantity,
|
7
|
+
:name, :option1, :option2, :option3, :options, :price,
|
8
|
+
:public_title, :requires_shipping, :sku, :taxable, :title,
|
9
|
+
:weight
|
10
|
+
|
11
|
+
# warning
|
12
|
+
def barcode
|
13
|
+
''
|
14
|
+
end
|
15
|
+
|
16
|
+
def compare_at_price
|
17
|
+
nil
|
18
|
+
end
|
19
|
+
|
20
|
+
def inventory_management
|
21
|
+
'shopify'
|
22
|
+
end
|
23
|
+
|
24
|
+
def inventory_policy
|
25
|
+
SolidusLiquid::InventoryPolicy::INVENTORY_POLICY_DENY
|
26
|
+
end
|
27
|
+
|
28
|
+
def inventory_quantity
|
29
|
+
@object.total_on_hand
|
30
|
+
end
|
31
|
+
|
32
|
+
def name
|
33
|
+
"#{@object.name} - #{title}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def option1
|
37
|
+
@object.option_values.first.try(:presentation)
|
38
|
+
end
|
39
|
+
|
40
|
+
def option2
|
41
|
+
@object.option_values.second.try(:presentation)
|
42
|
+
end
|
43
|
+
|
44
|
+
def option3
|
45
|
+
@object.option_values.third.try(:presentation)
|
46
|
+
end
|
47
|
+
|
48
|
+
def options
|
49
|
+
@object.option_values.map(&:presentation)
|
50
|
+
end
|
51
|
+
|
52
|
+
def price
|
53
|
+
(@object.price * 100).to_i
|
54
|
+
end
|
55
|
+
|
56
|
+
def requires_shipping
|
57
|
+
true
|
58
|
+
end
|
59
|
+
|
60
|
+
def taxable
|
61
|
+
true
|
62
|
+
end
|
63
|
+
|
64
|
+
def title
|
65
|
+
# @object.name
|
66
|
+
@object.option_values.map(&:presentation).join(' / ')
|
67
|
+
end
|
68
|
+
|
69
|
+
alias public_title title
|
70
|
+
|
71
|
+
def weight
|
72
|
+
@object.weight.to_i
|
73
|
+
end
|
74
|
+
|
75
|
+
# error
|
76
|
+
def featured_image
|
77
|
+
@object.images.first.try(:attachment).try(:url)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module SolidusLiquid
|
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,20 @@
|
|
1
|
+
module SolidusLiquid
|
2
|
+
module HtmlFilters
|
3
|
+
def img_tag(url, alt = '')
|
4
|
+
%(<img src="#{url}" alt="#{alt}" />)
|
5
|
+
end
|
6
|
+
|
7
|
+
def link_to(link, url, title = '')
|
8
|
+
%(<a href="#{url}" title="#{title}">#{link}</a>)
|
9
|
+
end
|
10
|
+
|
11
|
+
def script_tag(url)
|
12
|
+
%(<script src="#{url}" type="text/javascript"></script>)
|
13
|
+
end
|
14
|
+
|
15
|
+
# rubocop:disable Metrics/LineLength
|
16
|
+
def stylesheet_tag(url, media = 'all')
|
17
|
+
%(<link href="#{url}" rel="stylesheet" type="text/css" media="#{media}" />)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module SolidusLiquid
|
2
|
+
module UrlFilters
|
3
|
+
GLOBAL_ASSET_URLS = {
|
4
|
+
'social/social-icons.css' =>
|
5
|
+
'https://shopify-split.s3.amazonaws.com/global/social/social-icons.css',
|
6
|
+
'shopify_common.js' =>
|
7
|
+
'https://shopify-split.s3.amazonaws.com/global/shopify_common.js',
|
8
|
+
'option_selection.js' =>
|
9
|
+
'https://shopify-split.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
|
+
attachment.url
|
42
|
+
else
|
43
|
+
drop.to_s
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def url_for_vendor(vendor)
|
48
|
+
"/collections/vendors?q=#{vendor}"
|
49
|
+
end
|
50
|
+
|
51
|
+
def within(product_url, collection)
|
52
|
+
"/collections/#{collection.handle}#{product_url}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
module SolidusLiquid
|
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
|
+
def content_for_header
|
21
|
+
ApplicationController.new.render_to_string(
|
22
|
+
template: 'solidus_liquid/global/content_for_header',
|
23
|
+
layout: false
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
def theme
|
28
|
+
active_theme_id = request.cookies['active_theme_id']
|
29
|
+
active_theme_id ||= cookies.try(:[], 'active_theme_id')
|
30
|
+
@theme ||= Theme.find(active_theme_id)
|
31
|
+
end
|
32
|
+
|
33
|
+
def theme_dir
|
34
|
+
"themes/#{theme.id}"
|
35
|
+
end
|
36
|
+
|
37
|
+
def theme_layout_file
|
38
|
+
"../#{theme_dir}/layout/theme"
|
39
|
+
end
|
40
|
+
|
41
|
+
# rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
42
|
+
def liquid_assigns
|
43
|
+
shop = shop_settings.merge(
|
44
|
+
'collections_count' => Spree::Taxon.count,
|
45
|
+
'locale' => I18n.locale.to_s,
|
46
|
+
'permanent_domain' => shop_settings[:domain],
|
47
|
+
'products_count' => Spree::Product.available.count,
|
48
|
+
'secure_url' => "https://#{shop_settings[:domain]}",
|
49
|
+
'types' => [],
|
50
|
+
'url' => "https://#{shop_settings[:domain]}",
|
51
|
+
'vendors' => []
|
52
|
+
)
|
53
|
+
|
54
|
+
{
|
55
|
+
'all_products' => Spree::Product.handle_to_records_array,
|
56
|
+
'cart' => current_customer.try(:cart) || find_order_by_token_or_user,
|
57
|
+
'collections' => Spree::Taxon.handle_to_records_array,
|
58
|
+
'content_for_header' => content_for_header,
|
59
|
+
'current_page' => 1,
|
60
|
+
'current_tags' => nil,
|
61
|
+
'customer' => current_customer,
|
62
|
+
'linklists' => LinkList.handle_to_records_array,
|
63
|
+
'page_description' => nil,
|
64
|
+
'pages' => Page.handle_to_records_array,
|
65
|
+
'powered_by_link' =>
|
66
|
+
%(<a target="_blank" rel="nofollow" href="https://www.splitshop.com">
|
67
|
+
Powered by Split
|
68
|
+
</a>),
|
69
|
+
'search' => Search.new,
|
70
|
+
'settings' => theme_settings,
|
71
|
+
'shop' => shop
|
72
|
+
}
|
73
|
+
end
|
74
|
+
# rubocop:enable Metrics/MethodLength
|
75
|
+
|
76
|
+
def theme_settings
|
77
|
+
@theme_settings ||= JSON.parse(
|
78
|
+
Redis.current.get("solidus_liquid_themes_#{theme.id}")
|
79
|
+
)
|
80
|
+
end
|
81
|
+
|
82
|
+
def liquid_filters
|
83
|
+
[AdditionalFilters, HtmlFilters, MoneyFilters, StringFilters, UrlFilters]
|
84
|
+
end
|
85
|
+
|
86
|
+
def set_active_theme
|
87
|
+
cookies['active_theme_id'] ||= shop_settings['active_theme_id']
|
88
|
+
theme
|
89
|
+
end
|
90
|
+
|
91
|
+
def controller_action_to_liquid_file_path(
|
92
|
+
record = nil, controller_action = nil
|
93
|
+
)
|
94
|
+
# TODO: fallback to default template when template_suffix template missing
|
95
|
+
template_suffix = record.try(:template_suffix)
|
96
|
+
template_suffix = ".#{template_suffix}" if template_suffix.present?
|
97
|
+
|
98
|
+
controller_action ||= "#{controller_name}##{action_name}"
|
99
|
+
template_format =
|
100
|
+
CONTROLLER_ACTION_TO_LIQUID_MAPPING.fetch(controller_action)
|
101
|
+
|
102
|
+
template_path = template_format % ({ template_suffix: template_suffix })
|
103
|
+
|
104
|
+
"#{theme_dir}/#{template_path}"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module SolidusLiquid
|
2
|
+
module Handle
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
include ActionDispatch::Routing::PolymorphicRoutes
|
5
|
+
include SolidusLiquid::Engine.routes.url_helpers
|
6
|
+
|
7
|
+
included do
|
8
|
+
extend FriendlyId
|
9
|
+
friendly_id :name, use: [:finders, :slugged], slug_column: :slug
|
10
|
+
|
11
|
+
def self.handle_to_records_array
|
12
|
+
all.inject({}) do |hash, record|
|
13
|
+
hash.merge(record.handle => record)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def url
|
18
|
+
polymorphic_path(self)
|
19
|
+
end
|
20
|
+
|
21
|
+
alias_attribute :handle, :slug
|
22
|
+
alias_attribute :title, :name
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|