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,25 @@
|
|
1
|
+
module SolidusLiquid
|
2
|
+
class LiquidController < ApplicationController
|
3
|
+
include ::Spree::Core::ControllerHelpers::Auth
|
4
|
+
include ::Spree::Core::ControllerHelpers::Order
|
5
|
+
include ::Spree::Core::ControllerHelpers::Pricing
|
6
|
+
include ::Spree::Core::ControllerHelpers::Store
|
7
|
+
|
8
|
+
# rescue_from ActiveRecord::RecordNotFound, with: :render_404_page
|
9
|
+
|
10
|
+
include SolidusLiquid::Liquid
|
11
|
+
|
12
|
+
def set_liquid_assigns
|
13
|
+
raise 'Need to call this from subclass'
|
14
|
+
end
|
15
|
+
|
16
|
+
def render_404_page(_exception = nil)
|
17
|
+
render(
|
18
|
+
status: :not_found,
|
19
|
+
template: controller_action_to_liquid_file_path(nil, 'home#missing'),
|
20
|
+
formats: [:html],
|
21
|
+
layout: theme_layout_file
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module SolidusLiquid
|
2
|
+
class OrdersController < LiquidController
|
3
|
+
# Adds a new item to the order (creating a new order if none already exists)
|
4
|
+
def populate
|
5
|
+
order = current_order(create_order_if_necessary: true)
|
6
|
+
variant = Spree::Variant.find(params[:id])
|
7
|
+
quantity = params[:quantity].present? ? params[:quantity].to_i : 1
|
8
|
+
|
9
|
+
order.contents.add(variant, quantity)
|
10
|
+
|
11
|
+
redirect_to cart_path
|
12
|
+
end
|
13
|
+
|
14
|
+
def set_liquid_assigns
|
15
|
+
@liquid_assigns = {}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module SolidusLiquid
|
2
|
+
class PagesController < LiquidController
|
3
|
+
def show
|
4
|
+
render controller_action_to_liquid_file_path(page)
|
5
|
+
end
|
6
|
+
|
7
|
+
def set_liquid_assigns
|
8
|
+
@liquid_assigns = {
|
9
|
+
'canonical_url' => "#{request.base_url}#{page.url}",
|
10
|
+
'page' => page,
|
11
|
+
'page_title' => page.title,
|
12
|
+
'template' => 'page'
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def page
|
19
|
+
@page ||= Page.find(params[:id])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module SolidusLiquid
|
2
|
+
class ProductsController < LiquidController
|
3
|
+
before_action :load_collection
|
4
|
+
|
5
|
+
def show
|
6
|
+
render controller_action_to_liquid_file_path(product)
|
7
|
+
end
|
8
|
+
|
9
|
+
def set_liquid_assigns
|
10
|
+
@liquid_assigns = {
|
11
|
+
'canonical_url' => "#{request.base_url}#{product.url}",
|
12
|
+
'collection' => @collection,
|
13
|
+
'page_title' => product.title,
|
14
|
+
'product' => product,
|
15
|
+
'template' => 'product'
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def product
|
22
|
+
@product ||= Spree::Product.available.friendly.find(params[:id])
|
23
|
+
end
|
24
|
+
|
25
|
+
def load_collection
|
26
|
+
return unless params[:taxon_id].present?
|
27
|
+
@collection ||= Spree::Taxon.where(handle: params[:taxon_id]).first
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module SolidusLiquid
|
2
|
+
class RegistrationsController < ::Devise::RegistrationsController
|
3
|
+
include SolidusLiquid::Liquid
|
4
|
+
|
5
|
+
self.responder = SolidusLiquid::LiquidResponder
|
6
|
+
|
7
|
+
# rubocop:disable Metrics/LineLength
|
8
|
+
def set_liquid_assigns
|
9
|
+
@liquid_assigns = {
|
10
|
+
'canonical_url' => "#{request.base_url}#{new_customer_registration_path}",
|
11
|
+
'page_title' => 'Create Account',
|
12
|
+
'template' => 'page'
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
before_action :configure_sign_up_params, only: [:create]
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def configure_sign_up_params
|
21
|
+
devise_parameter_sanitizer.permit(:sign_up,
|
22
|
+
keys: [:first_name, :last_name])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module SolidusLiquid
|
2
|
+
class LiquidResponder < ::ActionController::Responder
|
3
|
+
DEFAULT_ACTIONS_FOR_VERBS = {
|
4
|
+
post: :new, patch: :edit, put: :edit, get: :new
|
5
|
+
}.freeze
|
6
|
+
|
7
|
+
include LiquidHelper
|
8
|
+
|
9
|
+
def to_html
|
10
|
+
liquid_assigns = controller.instance_variable_get(:@liquid_assigns)
|
11
|
+
liquid_assigns['form'] = resource
|
12
|
+
|
13
|
+
if options[:location].present?
|
14
|
+
redirect_to(options[:location])
|
15
|
+
else
|
16
|
+
render_liquid_from_controller_action
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def render_liquid_from_controller_action
|
23
|
+
controller_name = controller.controller_name
|
24
|
+
action_name = DEFAULT_ACTIONS_FOR_VERBS[request.request_method_symbol]
|
25
|
+
controller_action = "#{controller_name}##{action_name}"
|
26
|
+
render controller_action_to_liquid_file_path(resource, controller_action)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module SolidusLiquid
|
2
|
+
class SearchController < LiquidController
|
3
|
+
def index
|
4
|
+
render controller_action_to_liquid_file_path
|
5
|
+
end
|
6
|
+
|
7
|
+
def set_liquid_assigns
|
8
|
+
@liquid_assigns = {
|
9
|
+
'canonical_url' => "#{request.base_url}#{search_path}",
|
10
|
+
'page_title' => '',
|
11
|
+
'search' => search,
|
12
|
+
'template' => 'page'
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def search
|
19
|
+
return @search if @search.present?
|
20
|
+
|
21
|
+
@search = if params[:q].blank?
|
22
|
+
Search.new
|
23
|
+
else
|
24
|
+
perform_search
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def perform_search
|
29
|
+
product_scope = Spree::Product.accessible_by(
|
30
|
+
Spree::Ability.new(current_spree_user), :read
|
31
|
+
)
|
32
|
+
search_result = product_scope.ransack(params[:q]).result
|
33
|
+
Search.new(
|
34
|
+
performed: true,
|
35
|
+
results: search_result,
|
36
|
+
results_count: search_result.count,
|
37
|
+
terms: params[:q]
|
38
|
+
)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module SolidusLiquid
|
2
|
+
class SessionsController < ::Devise::SessionsController
|
3
|
+
include SolidusLiquid::Liquid
|
4
|
+
|
5
|
+
self.responder = SolidusLiquid::LiquidResponder
|
6
|
+
|
7
|
+
def set_liquid_assigns
|
8
|
+
@liquid_assigns = {
|
9
|
+
'canonical_url' => "#{request.base_url}#{new_customer_session_path}",
|
10
|
+
'page_title' => 'Log in',
|
11
|
+
'template' => 'page'
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Spree
|
2
|
+
class AddressDrop < ::Liquid::Rails::Drop
|
3
|
+
attributes :id, :address1, :address2, :city, :company, :country,
|
4
|
+
:country_code, :default, :first_name, :last_name, :latitude,
|
5
|
+
:longitude, :name, :phone, :province, :province_code, :street,
|
6
|
+
:zip
|
7
|
+
|
8
|
+
def country
|
9
|
+
@object.country.name
|
10
|
+
end
|
11
|
+
|
12
|
+
def country_code
|
13
|
+
@object.country.iso
|
14
|
+
end
|
15
|
+
|
16
|
+
def latitude
|
17
|
+
0
|
18
|
+
end
|
19
|
+
|
20
|
+
def longitude
|
21
|
+
0
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Spree
|
2
|
+
class OrderDrop < ::Liquid::Rails::Drop
|
3
|
+
attributes :item_count, :total
|
4
|
+
|
5
|
+
belongs_to :customer
|
6
|
+
|
7
|
+
def attributes
|
8
|
+
{}
|
9
|
+
end
|
10
|
+
|
11
|
+
def items
|
12
|
+
@object.line_items
|
13
|
+
end
|
14
|
+
|
15
|
+
# TODO: make sure solidus total shows the same as shopfiy's total_price
|
16
|
+
alias total_price total
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module Spree
|
2
|
+
class ProductDrop < ::Liquid::Rails::Drop
|
3
|
+
attributes :id, :available, :content, :compare_at_price,
|
4
|
+
:compare_at_price_max, :compare_at_price_min,
|
5
|
+
:compare_at_price_varies, :created_at, :description,
|
6
|
+
:featured_image, :handle, :images, :options, :price, :price_max,
|
7
|
+
:price_min, :price_varies, :published_at, :tags, :title, :type,
|
8
|
+
:variants, :vendor
|
9
|
+
|
10
|
+
def available
|
11
|
+
@object.available?
|
12
|
+
end
|
13
|
+
|
14
|
+
def collections
|
15
|
+
@object.taxons
|
16
|
+
end
|
17
|
+
|
18
|
+
alias content description
|
19
|
+
|
20
|
+
def url
|
21
|
+
@object.url
|
22
|
+
end
|
23
|
+
|
24
|
+
def variants
|
25
|
+
@object.variants.to_a.map do |v|
|
26
|
+
Spree::VariantDrop.new(v)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# warning
|
31
|
+
def compare_at_price
|
32
|
+
nil
|
33
|
+
end
|
34
|
+
|
35
|
+
def compare_at_price_max
|
36
|
+
0
|
37
|
+
end
|
38
|
+
|
39
|
+
def compare_at_price_min
|
40
|
+
0
|
41
|
+
end
|
42
|
+
|
43
|
+
def compare_at_price_varies
|
44
|
+
false
|
45
|
+
end
|
46
|
+
|
47
|
+
def price
|
48
|
+
(@object.price * 100).to_i
|
49
|
+
end
|
50
|
+
|
51
|
+
alias price_max price
|
52
|
+
alias price_min price
|
53
|
+
|
54
|
+
def price_varies
|
55
|
+
false
|
56
|
+
end
|
57
|
+
|
58
|
+
def tags
|
59
|
+
[]
|
60
|
+
end
|
61
|
+
|
62
|
+
def type
|
63
|
+
''
|
64
|
+
end
|
65
|
+
|
66
|
+
def vendor
|
67
|
+
SolidusLiquid::Setting['name']
|
68
|
+
end
|
69
|
+
|
70
|
+
# shopify json returns datetime in shop's timezone
|
71
|
+
alias published_at created_at
|
72
|
+
|
73
|
+
# error
|
74
|
+
# TODO: check if shopify returns variant images as well
|
75
|
+
# Spree::Product.images delegates to master variant
|
76
|
+
def images
|
77
|
+
@object.images.map(&:attachment).map(&:url)
|
78
|
+
end
|
79
|
+
|
80
|
+
def metafields
|
81
|
+
::RailsSettings::ScopedSettingsDrop.new(@object.settings)
|
82
|
+
end
|
83
|
+
|
84
|
+
def options
|
85
|
+
@object.option_types.map(&:presentation)
|
86
|
+
end
|
87
|
+
|
88
|
+
def selected_or_first_available_variant
|
89
|
+
@object.variants.first
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|