solidify 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 +40 -0
- data/.travis.yml +10 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +3 -0
- data/Guardfile +51 -0
- data/LICENSE.txt +21 -0
- data/README.md +75 -0
- data/Rakefile +42 -0
- data/app/controllers/concerns/solidify/liquid.rb +26 -0
- data/app/controllers/solidify/addresses_controller.rb +15 -0
- data/app/controllers/solidify/carts_controller.rb +15 -0
- data/app/controllers/solidify/collections_controller.rb +26 -0
- data/app/controllers/solidify/customers_controller.rb +16 -0
- data/app/controllers/solidify/home_controller.rb +15 -0
- data/app/controllers/solidify/liquid_controller.rb +25 -0
- data/app/controllers/solidify/orders_controller.rb +19 -0
- data/app/controllers/solidify/pages_controller.rb +22 -0
- data/app/controllers/solidify/products_controller.rb +34 -0
- data/app/controllers/solidify/registrations_controller.rb +25 -0
- data/app/controllers/solidify/responders/solidify/liquid_responder.rb +29 -0
- data/app/controllers/solidify/search_controller.rb +41 -0
- data/app/controllers/solidify/sessions_controller.rb +15 -0
- data/app/drops/rails_settings/scoped_settings_drop.rb +11 -0
- data/app/drops/solidify/errors_drop.rb +14 -0
- data/app/drops/solidify/link_drop.rb +15 -0
- data/app/drops/solidify/link_list_drop.rb +7 -0
- data/app/drops/solidify/nil_drop.rb +7 -0
- data/app/drops/solidify/page_drop.rb +7 -0
- data/app/drops/solidify/search_drop.rb +7 -0
- data/app/drops/spree/address_drop.rb +28 -0
- data/app/drops/spree/image_drop.rb +32 -0
- data/app/drops/spree/line_item_drop.rb +98 -0
- data/app/drops/spree/option_type_drop.rb +4 -0
- data/app/drops/spree/order_drop.rb +64 -0
- data/app/drops/spree/product_drop.rb +97 -0
- data/app/drops/spree/taxon_drop.rb +53 -0
- data/app/drops/spree/user_drop.rb +54 -0
- data/app/drops/spree/variant_drop.rb +111 -0
- data/app/fields/spree/address_fields.rb +18 -0
- data/app/fields/spree/image_fields.rb +12 -0
- data/app/fields/spree/line_item_fields.rb +21 -0
- data/app/fields/spree/order_fields.rb +22 -0
- data/app/fields/spree/product_fields.rb +22 -0
- data/app/fields/spree/taxon_fields.rb +18 -0
- data/app/fields/spree/user_fields.rb +14 -0
- data/app/fields/spree/variant_fields.rb +19 -0
- data/app/filters/solidify/additional_filters.rb +22 -0
- data/app/filters/solidify/html_filters.rb +16 -0
- data/app/filters/solidify/money_filters.rb +39 -0
- data/app/filters/solidify/string_filters.rb +47 -0
- data/app/filters/solidify/url_filters.rb +59 -0
- data/app/helpers/solidify/liquid_helper.rb +111 -0
- data/app/helpers/solidify/shop_helper.rb +7 -0
- data/app/models/concerns/solidify/address.rb +15 -0
- data/app/models/concerns/solidify/full_name.rb +11 -0
- data/app/models/concerns/solidify/handle.rb +25 -0
- data/app/models/concerns/solidify/inventory_policy.rb +7 -0
- data/app/models/concerns/solidify/validation_cancel.rb +33 -0
- data/app/models/concerns/spree/order_state.rb +19 -0
- data/app/models/solidify/asset.rb +12 -0
- data/app/models/solidify/link.rb +10 -0
- data/app/models/solidify/link_list.rb +7 -0
- data/app/models/solidify/page.rb +5 -0
- data/app/models/solidify/setting.rb +8 -0
- data/app/models/solidify/theme.rb +19 -0
- data/app/models/spree/address_decorator.rb +13 -0
- data/app/models/spree/image_decorator.rb +7 -0
- data/app/models/spree/line_item_decorator.rb +7 -0
- data/app/models/spree/order_decorator.rb +10 -0
- data/app/models/spree/product_decorator.rb +8 -0
- data/app/models/spree/taxon_decorator.rb +20 -0
- data/app/models/spree/user_decorator.rb +9 -0
- data/app/models/spree/variant_decorator.rb +11 -0
- data/app/poro/solidify/search.rb +14 -0
- data/app/services/solidify/app_specific_string_io.rb +15 -0
- data/app/services/solidify/asset_compiler.rb +11 -0
- data/app/services/solidify/asset_postprocessor.rb +53 -0
- data/app/services/solidify/collections_all_builder.rb +12 -0
- data/app/services/solidify/link_list_seeder.rb +26 -0
- data/app/services/solidify/liquid_asset_compiler.rb +19 -0
- data/app/services/solidify/scss_asset_compiler.rb +15 -0
- data/app/services/solidify/shop_settings_seeder.rb +26 -0
- data/app/services/solidify/theme_mechanic.rb +30 -0
- data/app/uploaders/solidify/asset_uploader.rb +10 -0
- data/app/views/solidify/global/content_for_header.html.erb +0 -0
- data/app/views/solidify/themes/skeleton-theme/README.md +54 -0
- data/app/views/solidify/themes/skeleton-theme/assets/arrow-down.svg.liquid +3 -0
- data/app/views/solidify/themes/skeleton-theme/assets/cart.svg.liquid +4 -0
- data/app/views/solidify/themes/skeleton-theme/assets/shop.js.liquid +75 -0
- data/app/views/solidify/themes/skeleton-theme/assets/shopify_common.js +14 -0
- data/app/views/solidify/themes/skeleton-theme/assets/style.scss.liquid +768 -0
- data/app/views/solidify/themes/skeleton-theme/config/settings.html +217 -0
- data/app/views/solidify/themes/skeleton-theme/config/settings_data.json +26 -0
- data/app/views/solidify/themes/skeleton-theme/layout/theme.liquid +181 -0
- data/app/views/solidify/themes/skeleton-theme/snippets/article-grid-item.liquid +73 -0
- data/app/views/solidify/themes/skeleton-theme/snippets/collection-grid-item.liquid +46 -0
- data/app/views/solidify/themes/skeleton-theme/snippets/collection-listing.liquid +46 -0
- data/app/views/solidify/themes/skeleton-theme/snippets/open-graph-tags.liquid +35 -0
- data/app/views/solidify/themes/skeleton-theme/snippets/product-grid-item.liquid +70 -0
- data/app/views/solidify/themes/skeleton-theme/snippets/site-nav.liquid +57 -0
- data/app/views/solidify/themes/skeleton-theme/snippets/social-links.liquid +42 -0
- data/app/views/solidify/themes/skeleton-theme/snippets/twitter-card.liquid +41 -0
- data/app/views/solidify/themes/skeleton-theme/templates/404.liquid +2 -0
- data/app/views/solidify/themes/skeleton-theme/templates/article.liquid +160 -0
- data/app/views/solidify/themes/skeleton-theme/templates/blog.grid.liquid +30 -0
- data/app/views/solidify/themes/skeleton-theme/templates/blog.liquid +92 -0
- data/app/views/solidify/themes/skeleton-theme/templates/cart.liquid +123 -0
- data/app/views/solidify/themes/skeleton-theme/templates/collection.liquid +102 -0
- data/app/views/solidify/themes/skeleton-theme/templates/customers/account.liquid +57 -0
- data/app/views/solidify/themes/skeleton-theme/templates/customers/activate_account.liquid +26 -0
- data/app/views/solidify/themes/skeleton-theme/templates/customers/addresses.liquid +173 -0
- data/app/views/solidify/themes/skeleton-theme/templates/customers/login.liquid +90 -0
- data/app/views/solidify/themes/skeleton-theme/templates/customers/order.liquid +103 -0
- data/app/views/solidify/themes/skeleton-theme/templates/customers/register.liquid +32 -0
- data/app/views/solidify/themes/skeleton-theme/templates/customers/reset_password.liquid +27 -0
- data/app/views/solidify/themes/skeleton-theme/templates/index.liquid +39 -0
- data/app/views/solidify/themes/skeleton-theme/templates/list-collections.liquid +19 -0
- data/app/views/solidify/themes/skeleton-theme/templates/page.liquid +16 -0
- data/app/views/solidify/themes/skeleton-theme/templates/product.liquid +202 -0
- data/app/views/solidify/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 +213 -0
- data/config/initializers/sass.rb +15 -0
- data/config/initializers/spree.rb +7 -0
- data/config/initializers/theme_settings.rb +29 -0
- data/config/routes.rb +52 -0
- data/config/spring.rb +2 -0
- data/db/migrate/20170223064316_create_solidify_assets.solidify.rb +14 -0
- data/db/migrate/20170223064317_create_solidify_themes.solidify.rb +10 -0
- data/db/migrate/20170223064318_create_solidify_link_lists.solidify.rb +12 -0
- data/db/migrate/20170223064319_create_solidify_links.solidify.rb +13 -0
- data/db/migrate/20170223064320_create_solidify_settings.solidify.rb +22 -0
- data/db/migrate/20170223064321_create_solidify_pages.solidify.rb +16 -0
- data/db/migrate/20170223064322_add_attributes_to_spree_users.solidify.rb +7 -0
- data/db/migrate/20170223064323_add_handle_to_spree_taxons.solidify.rb +7 -0
- data/db/migrate/20170228115149_add_state_and_country_fields_to_spree_addresses.solidify.rb +7 -0
- data/lib/generators/solidify/install/install_generator.rb +23 -0
- data/lib/solidify.rb +11 -0
- data/lib/solidify/configuration.rb +21 -0
- data/lib/solidify/engine.rb +24 -0
- data/lib/solidify/testing_support/factories.rb +5 -0
- data/lib/solidify/testing_support/factories/assets.rb +75 -0
- data/lib/solidify/testing_support/factories/solidify_pages.rb +10 -0
- data/lib/solidify/testing_support/factories/spree_addresses.rb +9 -0
- data/lib/solidify/testing_support/factories/spree_line_items.rb +10 -0
- data/lib/solidify/testing_support/factories/spree_orders.rb +9 -0
- data/lib/solidify/testing_support/factories/spree_products.rb +8 -0
- data/lib/solidify/testing_support/factories/spree_taxons.rb +7 -0
- data/lib/solidify/testing_support/factories/spree_variants.rb +7 -0
- data/lib/solidify/testing_support/factories/themes.rb +7 -0
- data/lib/solidify/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 +12 -0
- data/lib/tasks/seed_link_list.rake +8 -0
- data/lib/tasks/seed_shop_settings.rake +8 -0
- data/solidify.gemspec +61 -0
- metadata +668 -0
@@ -0,0 +1,25 @@
|
|
1
|
+
module Solidify
|
2
|
+
module Handle
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
include ActionDispatch::Routing::PolymorphicRoutes
|
5
|
+
include Solidify::Engine.routes.url_helpers
|
6
|
+
|
7
|
+
included do
|
8
|
+
extend FriendlyId
|
9
|
+
friendly_id :name, use: %i(finders slugged)
|
10
|
+
|
11
|
+
def self.handle_to_records_array
|
12
|
+
all.each_with_object({}) do |record, hash|
|
13
|
+
hash[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
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Solidify
|
2
|
+
module ValidationCancel
|
3
|
+
def cancel_validates(*attributes)
|
4
|
+
klass = self
|
5
|
+
attributes.each do |attribute|
|
6
|
+
cancel_single_validates(attribute, klass)
|
7
|
+
cancel_array_validates(attribute)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def cancel_single_validates(attribute, klass)
|
14
|
+
# validates :country_id, presence: true
|
15
|
+
ary = [attribute]
|
16
|
+
callbacks = _validate_callbacks.select do |callback|
|
17
|
+
callback.raw_filter.try(:attributes) == ary
|
18
|
+
end
|
19
|
+
callbacks.each do |callback|
|
20
|
+
ifs = callback.instance_variable_get(:@if)
|
21
|
+
ifs << proc { !is_a?(klass) }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def cancel_array_validates(attribute)
|
26
|
+
# validates :firstname, :address1, :city, :country_id, presence: true
|
27
|
+
callbacks = _validate_callbacks.select do |callback|
|
28
|
+
callback.raw_filter.try(:attributes).try(:include?, attribute)
|
29
|
+
end
|
30
|
+
callbacks.map { |cb| cb.raw_filter.attributes.delete(attribute) }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Spree
|
2
|
+
module OrderState
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
# https://github.com/solidusio/solidus/blob/master/core/app/models/spree/order/checkout.rb
|
5
|
+
# checkout flow
|
6
|
+
CART = 'cart'.freeze
|
7
|
+
ADDRESS = 'address'.freeze
|
8
|
+
DELIVERY = 'delivery'.freeze
|
9
|
+
PAYMENT = 'payment'.freeze
|
10
|
+
CONFIRM = 'confirm'.freeze
|
11
|
+
COMPLETE = 'complete'.freeze
|
12
|
+
|
13
|
+
# other states
|
14
|
+
AWAITING_RETURN = 'awaiting_return'.freeze
|
15
|
+
CANCELED = 'canceled'.freeze
|
16
|
+
RESUMED = 'resumed'.freeze
|
17
|
+
RETURNED = 'returned'.freeze
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Solidify
|
2
|
+
class Theme < ActiveRecord::Base
|
3
|
+
has_many :assets
|
4
|
+
|
5
|
+
def settings
|
6
|
+
settings = Redis.current.get("solidify_themes_#{id}")
|
7
|
+
settings ||= Redis.current.get('solidify_themes_')
|
8
|
+
JSON.parse(settings)
|
9
|
+
end
|
10
|
+
|
11
|
+
def previewable
|
12
|
+
true
|
13
|
+
end
|
14
|
+
|
15
|
+
def processing
|
16
|
+
false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Spree
|
2
|
+
Address.class_eval do
|
3
|
+
extend Solidify::ValidationCancel
|
4
|
+
cancel_validates :country_id
|
5
|
+
|
6
|
+
has_many :user_addresses, -> { active }
|
7
|
+
has_many :users, through: :user_addresses
|
8
|
+
|
9
|
+
def postal_code_validate; end
|
10
|
+
|
11
|
+
alias_attribute :country, :country_name
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Spree
|
2
|
+
Taxon.class_eval do
|
3
|
+
include ::Solidify::Handle
|
4
|
+
|
5
|
+
has_one :image,
|
6
|
+
as: :viewable, dependent: :destroy, class_name: 'Spree::Image'
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def find_or_create_collections_all
|
10
|
+
collection = Spree::Taxon.find_by(handle: 'all')
|
11
|
+
|
12
|
+
if collection.blank?
|
13
|
+
collection = ::Solidify::CollectionsAllBuilder.create!
|
14
|
+
end
|
15
|
+
|
16
|
+
collection
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Solidify
|
2
|
+
class Search
|
3
|
+
include ::Liquid::Rails::Droppable
|
4
|
+
|
5
|
+
attr_accessor :performed, :results, :results_count, :terms
|
6
|
+
|
7
|
+
def initialize(performed: nil, results: nil, results_count: nil, terms: nil)
|
8
|
+
@performed = performed
|
9
|
+
@results = results
|
10
|
+
@results_count = results_count
|
11
|
+
@terms = terms
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# copied from: https://github.com/carrierwaveuploader/carrierwave/wiki/How-to:-Upload-from-a-string-in-Rails-3-or-later
|
2
|
+
module Solidify
|
3
|
+
class AppSpecificStringIO < StringIO
|
4
|
+
attr_accessor :filepath
|
5
|
+
|
6
|
+
def initialize(*args)
|
7
|
+
super(*args[1..-1])
|
8
|
+
@filepath = args[0]
|
9
|
+
end
|
10
|
+
|
11
|
+
def original_filename
|
12
|
+
File.basename(@filepath)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Solidify
|
2
|
+
class AssetPostprocessor
|
3
|
+
def initialize(asset)
|
4
|
+
@asset = asset
|
5
|
+
end
|
6
|
+
|
7
|
+
def process
|
8
|
+
process_for_key(
|
9
|
+
asset: @asset,
|
10
|
+
key: @asset.key,
|
11
|
+
template: File.read(@asset.file.path),
|
12
|
+
settings: @asset.theme.settings
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def process_for_key(asset:, key:, template:, settings:)
|
19
|
+
return unless key.start_with?('assets/')
|
20
|
+
if key.end_with?('.liquid')
|
21
|
+
process_liquid(asset: asset, key: key.gsub(/.liquid$/, ''),
|
22
|
+
template: template, settings: settings)
|
23
|
+
elsif key.end_with?('.scss')
|
24
|
+
process_scss(asset: asset, key: key, template: template)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def process_liquid(asset:, key:, template:, settings:)
|
29
|
+
rendered_liquid = LiquidAssetCompiler.new(template, settings,
|
30
|
+
asset.theme).compile
|
31
|
+
if key.end_with?('.scss')
|
32
|
+
process_scss(asset: asset, key: key, template: rendered_liquid)
|
33
|
+
else
|
34
|
+
update_or_create_asset(key: key,
|
35
|
+
theme: asset.theme, contents: rendered_liquid)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def process_scss(asset:, key:, template:)
|
40
|
+
rendered_css = ScssAssetCompiler.new(template).compile
|
41
|
+
new_asset = Asset.where(key: "#{key}.css",
|
42
|
+
theme: asset.theme).first_or_initialize
|
43
|
+
new_asset.update_attributes(
|
44
|
+
file: AppSpecificStringIO.new("#{key}.css", rendered_css)
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
def update_or_create_asset(key:, theme:, contents:)
|
49
|
+
new_asset = Asset.where(key: key, theme: theme).first_or_initialize
|
50
|
+
new_asset.update_attributes(file: AppSpecificStringIO.new(key, contents))
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Solidify
|
2
|
+
class LinkListSeeder
|
3
|
+
# rubocop:disable Metrics/MethodLength
|
4
|
+
def seed
|
5
|
+
LinkList.create(
|
6
|
+
[
|
7
|
+
{
|
8
|
+
title: 'Main menu',
|
9
|
+
handle: 'main-menu',
|
10
|
+
links: [
|
11
|
+
Link.new(title: 'Home', url: '/'),
|
12
|
+
Link.new(title: 'Catalog', url: '/collections/all')
|
13
|
+
]
|
14
|
+
},
|
15
|
+
{
|
16
|
+
title: 'Footer',
|
17
|
+
handle: 'footer',
|
18
|
+
links: [
|
19
|
+
Link.new(title: 'Search', url: '/search')
|
20
|
+
]
|
21
|
+
}
|
22
|
+
]
|
23
|
+
)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Solidify
|
2
|
+
class LiquidAssetCompiler
|
3
|
+
include AssetCompiler
|
4
|
+
|
5
|
+
def initialize(template, settings, theme)
|
6
|
+
super(template)
|
7
|
+
@settings = settings
|
8
|
+
@theme = theme
|
9
|
+
end
|
10
|
+
|
11
|
+
def compile
|
12
|
+
liquid = ::Liquid::Template.parse(@template)
|
13
|
+
assigns = { 'settings' => @settings }
|
14
|
+
liquid.render(assigns,
|
15
|
+
filters: [UrlFilters],
|
16
|
+
registers: { theme: @theme })
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|