shoperb_liquid 0.0.1
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/.gitignore +23 -0
- data/.rubocop.yml +131 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +143 -0
- data/Rakefile +4 -0
- data/lib/shoperb_liquid/configuration.rb +169 -0
- data/lib/shoperb_liquid/drops/account_drop.rb +9 -0
- data/lib/shoperb_liquid/drops/address_drop.rb +121 -0
- data/lib/shoperb_liquid/drops/array_drop.rb +18 -0
- data/lib/shoperb_liquid/drops/attribute_drop.rb +21 -0
- data/lib/shoperb_liquid/drops/base.rb +65 -0
- data/lib/shoperb_liquid/drops/blog_category_drop.rb +56 -0
- data/lib/shoperb_liquid/drops/blog_post_drop.rb +46 -0
- data/lib/shoperb_liquid/drops/cart_drop.rb +42 -0
- data/lib/shoperb_liquid/drops/cart_item_drop.rb +111 -0
- data/lib/shoperb_liquid/drops/categories_drop.rb +13 -0
- data/lib/shoperb_liquid/drops/category_drop.rb +110 -0
- data/lib/shoperb_liquid/drops/collection_drop.rb +117 -0
- data/lib/shoperb_liquid/drops/country_drop.rb +37 -0
- data/lib/shoperb_liquid/drops/currency_drop.rb +17 -0
- data/lib/shoperb_liquid/drops/customer_credit_drop.rb +23 -0
- data/lib/shoperb_liquid/drops/customer_credits_drop.rb +18 -0
- data/lib/shoperb_liquid/drops/customer_drop.rb +108 -0
- data/lib/shoperb_liquid/drops/customer_group_drop.rb +17 -0
- data/lib/shoperb_liquid/drops/gift_card_drop.rb +34 -0
- data/lib/shoperb_liquid/drops/image_drop.rb +27 -0
- data/lib/shoperb_liquid/drops/integration_drop.rb +25 -0
- data/lib/shoperb_liquid/drops/integrations_drop.rb +17 -0
- data/lib/shoperb_liquid/drops/language_drop.rb +17 -0
- data/lib/shoperb_liquid/drops/link_drop.rb +53 -0
- data/lib/shoperb_liquid/drops/media_file_drop.rb +29 -0
- data/lib/shoperb_liquid/drops/menu_drop.rb +25 -0
- data/lib/shoperb_liquid/drops/menus_drop.rb +16 -0
- data/lib/shoperb_liquid/drops/meta_drop.rb +21 -0
- data/lib/shoperb_liquid/drops/order_drop.rb +148 -0
- data/lib/shoperb_liquid/drops/order_item_attribute_drop.rb +8 -0
- data/lib/shoperb_liquid/drops/order_item_attributes_drop.rb +19 -0
- data/lib/shoperb_liquid/drops/order_item_drop.rb +159 -0
- data/lib/shoperb_liquid/drops/order_return_drop.rb +43 -0
- data/lib/shoperb_liquid/drops/order_return_item_drop.rb +30 -0
- data/lib/shoperb_liquid/drops/order_return_item_entity_drop.rb +13 -0
- data/lib/shoperb_liquid/drops/order_return_parcel_drop.rb +29 -0
- data/lib/shoperb_liquid/drops/order_returns_drop.rb +13 -0
- data/lib/shoperb_liquid/drops/orders_drop.rb +14 -0
- data/lib/shoperb_liquid/drops/page_drop.rb +26 -0
- data/lib/shoperb_liquid/drops/pages_drop.rb +12 -0
- data/lib/shoperb_liquid/drops/payment_card_drop.rb +29 -0
- data/lib/shoperb_liquid/drops/payment_method_drop.rb +41 -0
- data/lib/shoperb_liquid/drops/payment_provider_drop.rb +23 -0
- data/lib/shoperb_liquid/drops/product_attribute_drop.rb +14 -0
- data/lib/shoperb_liquid/drops/product_collection_drop.rb +41 -0
- data/lib/shoperb_liquid/drops/product_collections_drop.rb +12 -0
- data/lib/shoperb_liquid/drops/product_drop.rb +195 -0
- data/lib/shoperb_liquid/drops/product_type_drop.rb +25 -0
- data/lib/shoperb_liquid/drops/product_types_drop.rb +15 -0
- data/lib/shoperb_liquid/drops/products_drop.rb +44 -0
- data/lib/shoperb_liquid/drops/refund_drop.rb +22 -0
- data/lib/shoperb_liquid/drops/refund_item_drop.rb +18 -0
- data/lib/shoperb_liquid/drops/review_drop.rb +37 -0
- data/lib/shoperb_liquid/drops/search_drop.rb +45 -0
- data/lib/shoperb_liquid/drops/shipping_item_drop.rb +29 -0
- data/lib/shoperb_liquid/drops/shipping_method_drop.rb +25 -0
- data/lib/shoperb_liquid/drops/shipping_parcel_drop.rb +25 -0
- data/lib/shoperb_liquid/drops/shop_drop.rb +81 -0
- data/lib/shoperb_liquid/drops/subscription_drop.rb +51 -0
- data/lib/shoperb_liquid/drops/subscription_plan_drop.rb +63 -0
- data/lib/shoperb_liquid/drops/theme_section_blocks_drop.rb +19 -0
- data/lib/shoperb_liquid/drops/theme_section_drop.rb +30 -0
- data/lib/shoperb_liquid/drops/theme_section_image_drop.rb +11 -0
- data/lib/shoperb_liquid/drops/theme_section_settings_drop.rb +40 -0
- data/lib/shoperb_liquid/drops/theme_settings_drop.rb +60 -0
- data/lib/shoperb_liquid/drops/url_drop.rb +218 -0
- data/lib/shoperb_liquid/drops/variant_attribute_drop.rb +8 -0
- data/lib/shoperb_liquid/drops/variant_drop.rb +206 -0
- data/lib/shoperb_liquid/drops/variants_drop.rb +13 -0
- data/lib/shoperb_liquid/drops/vendor_drop.rb +77 -0
- data/lib/shoperb_liquid/drops/vendors_drop.rb +13 -0
- data/lib/shoperb_liquid/errors.rb +6 -0
- data/lib/shoperb_liquid/ext/array.rb +7 -0
- data/lib/shoperb_liquid/ext/context.rb +12 -0
- data/lib/shoperb_liquid/ext/models.rb +55 -0
- data/lib/shoperb_liquid/ext/template.rb +13 -0
- data/lib/shoperb_liquid/filters/asset_filters.rb +57 -0
- data/lib/shoperb_liquid/filters/collection_filters.rb +26 -0
- data/lib/shoperb_liquid/filters/datum_filters.rb +150 -0
- data/lib/shoperb_liquid/filters/extension_filters.rb +35 -0
- data/lib/shoperb_liquid/filters/html_filters.rb +46 -0
- data/lib/shoperb_liquid/filters/theme_filters.rb +22 -0
- data/lib/shoperb_liquid/filters/translate_filters.rb +16 -0
- data/lib/shoperb_liquid/filters/url_filters.rb +60 -0
- data/lib/shoperb_liquid/registers.rb +76 -0
- data/lib/shoperb_liquid/tags/cache_tag.rb +45 -0
- data/lib/shoperb_liquid/tags/form_tag.rb +47 -0
- data/lib/shoperb_liquid/tags/layout_tag.rb +21 -0
- data/lib/shoperb_liquid/tags/paginate_tag.rb +134 -0
- data/lib/shoperb_liquid/tags/products_filter_tag.rb +106 -0
- data/lib/shoperb_liquid/tags/section_tag.rb +113 -0
- data/lib/shoperb_liquid.rb +46 -0
- data/shoperb_liquid.gemspec +24 -0
- metadata +223 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8541bd02f53f35ef50ce7447e69d16aa77d320261acd78d4f28d105b23f56c94
|
4
|
+
data.tar.gz: b3443c0b6e0b69861d33588ed40e3ee2319873efb1241d26da0b478705cc35e4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 63793d3bcc3c6516f956d9807814149684d453df92242a882fec7bcec903cf75df70162097cdbfafefc2e716e7cbf764c68ab56d57ae33f93d199467c24ed6f0
|
7
|
+
data.tar.gz: 208e27a4d4d8768076026677f00016e669f00c239ccece2d12259d131bc351bf91efaa170e0dae7b80dda62d7ff0e87ee202fb4fc47feb9ca3c5b2d9aa79874e
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
.idea/*
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
Rails:
|
2
|
+
Enabled: true
|
3
|
+
AllCops:
|
4
|
+
DisplayCopNames: true
|
5
|
+
TargetRubyVersion: 2.4
|
6
|
+
Exclude:
|
7
|
+
- 'tmp/**/*'
|
8
|
+
- 'spec/**/*'
|
9
|
+
- 'db/**/*'
|
10
|
+
- 'bin/**/*'
|
11
|
+
- 'vendor/**/*'
|
12
|
+
- 'lib/tasks/**/*'
|
13
|
+
- '**/*.rake'
|
14
|
+
- 'config.ru'
|
15
|
+
- 'Gemfile'
|
16
|
+
- 'Rakefile'
|
17
|
+
Style/Documentation:
|
18
|
+
Enabled: false
|
19
|
+
Style/Alias:
|
20
|
+
EnforcedStyle: prefer_alias_method
|
21
|
+
Style/RescueModifier:
|
22
|
+
Enabled: false
|
23
|
+
Style/DotPosition:
|
24
|
+
EnforcedStyle: trailing
|
25
|
+
Style/ModuleFunction:
|
26
|
+
EnforcedStyle: extend_self
|
27
|
+
Style/UnneededInterpolation:
|
28
|
+
Enabled: false
|
29
|
+
Style/TernaryParentheses:
|
30
|
+
Enabled: false
|
31
|
+
Style/NumericPredicate:
|
32
|
+
Enabled: false
|
33
|
+
Lint/IneffectiveAccessModifier:
|
34
|
+
Enabled: false
|
35
|
+
Lint/AssignmentInCondition:
|
36
|
+
Enabled: false
|
37
|
+
Lint/RescueException:
|
38
|
+
Enabled: false
|
39
|
+
Lint/UnusedBlockArgument:
|
40
|
+
Enabled: false
|
41
|
+
Lint/UnusedMethodArgument:
|
42
|
+
Enabled: false
|
43
|
+
Lint/UselessAssignment:
|
44
|
+
Enabled: true
|
45
|
+
Metrics/LineLength:
|
46
|
+
Max: 192
|
47
|
+
Style/MultilineTernaryOperator:
|
48
|
+
Enabled: false
|
49
|
+
Style/AlignHash:
|
50
|
+
EnforcedHashRocketStyle: key
|
51
|
+
EnforcedColonStyle: key
|
52
|
+
Style/AlignParameters:
|
53
|
+
EnforcedStyle: with_fixed_indentation
|
54
|
+
Style/BracesAroundHashParameters:
|
55
|
+
Enabled: false
|
56
|
+
Style/ClosingParenthesisIndentation:
|
57
|
+
Enabled: false
|
58
|
+
Style/MultilineMethodDefinitionBraceLayout:
|
59
|
+
EnforcedStyle: new_line
|
60
|
+
Style/IfUnlessModifierOfIfUnless:
|
61
|
+
Enabled: true
|
62
|
+
Style/ClassVars:
|
63
|
+
Enabled: false
|
64
|
+
Style/Documentation:
|
65
|
+
Enabled: true
|
66
|
+
Style/DoubleNegation:
|
67
|
+
Enabled: false
|
68
|
+
Style/FrozenStringLiteralComment:
|
69
|
+
Enabled: true
|
70
|
+
Style/CaseIndentation:
|
71
|
+
IndentOneStep: true
|
72
|
+
EnforcedStyle: end
|
73
|
+
Style/ParallelAssignment:
|
74
|
+
Enabled: false
|
75
|
+
Style/TrailingCommaInLiteral:
|
76
|
+
EnforcedStyleForMultiline: comma
|
77
|
+
Style/FormatString:
|
78
|
+
Enabled: false
|
79
|
+
Style/GuardClause:
|
80
|
+
Enabled: false
|
81
|
+
Style/PredicateName:
|
82
|
+
Enabled: false
|
83
|
+
Style/NestedTernaryOperator:
|
84
|
+
Enabled: false
|
85
|
+
Style/FrozenStringLiteralComment:
|
86
|
+
Enabled: true
|
87
|
+
EnforcedStyle: always
|
88
|
+
Style/SpaceAroundEqualsInParameterDefault:
|
89
|
+
EnforcedStyle: no_space
|
90
|
+
Style/StringLiterals:
|
91
|
+
EnforcedStyle: double_quotes
|
92
|
+
Style/StringLiteralsInInterpolation:
|
93
|
+
EnforcedStyle: double_quotes
|
94
|
+
Style/WordArray:
|
95
|
+
Enabled: false
|
96
|
+
Style/SafeNavigation:
|
97
|
+
Enabled: false
|
98
|
+
Metrics/BlockNesting:
|
99
|
+
Enabled: false
|
100
|
+
Performance/TimesMap:
|
101
|
+
Enabled: false
|
102
|
+
Performance/CaseWhenSplat:
|
103
|
+
Enabled: false
|
104
|
+
Rails/Delegate:
|
105
|
+
Enabled: false
|
106
|
+
Style/MultilineBlockChain:
|
107
|
+
Enabled: false
|
108
|
+
Style/Lambda:
|
109
|
+
Enabled: false
|
110
|
+
Style/CaseEquality:
|
111
|
+
Enabled: false
|
112
|
+
Style/SpaceInLambdaLiteral:
|
113
|
+
EnforcedStyle: require_space
|
114
|
+
Style/MultilineAssignmentLayout:
|
115
|
+
EnforcedStyle: same_line
|
116
|
+
Style/MultilineMethodCallIndentation:
|
117
|
+
EnforcedStyle: indented
|
118
|
+
Style/LambdaCall:
|
119
|
+
EnforcedStyle: braces
|
120
|
+
Style/FormatString:
|
121
|
+
EnforcedStyle: percent
|
122
|
+
Style/Encoding:
|
123
|
+
EnforcedStyle: always
|
124
|
+
Style/CommandLiteral:
|
125
|
+
AllowInnerBackticks: true
|
126
|
+
Style/ClassCheck:
|
127
|
+
Enabled: false
|
128
|
+
Style/IndentArray:
|
129
|
+
EnforcedStyle: consistent
|
130
|
+
Style/IndentHash:
|
131
|
+
EnforcedStyle: consistent
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c)
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
# ShoperbLiquid
|
2
|
+
|
3
|
+
ShoperbLiquid gem provides all the necessary filters, tags and drops for Liquid part of Shoperb and RTE.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'shoperb_liquid'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install shoperb_liquid
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
You can configure the gem the following way:
|
22
|
+
|
23
|
+
```
|
24
|
+
ShoperbLiquid.configure do |config|
|
25
|
+
config.cache = MyCacheClass.new
|
26
|
+
config.translator = I18n
|
27
|
+
config.assets_remote_host = "https://cdn.my-assets.com"
|
28
|
+
config.routes = Rails.application.routes.url_helpers
|
29
|
+
config.environment = :development
|
30
|
+
config.models_namespace = nil
|
31
|
+
conifg.file_system = MyFileSystem.new
|
32
|
+
config.error_mode = :strict
|
33
|
+
config.error_notify = lambda { |error, template, line| }
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
### cache
|
38
|
+
|
39
|
+
Accepts an instance of class, respondible to caching, which implements methods "fetch", "read", "write". Cache is used for Cache liquid tag.
|
40
|
+
|
41
|
+
Example: ActiveSupport::Cache::MemoryStore.new, ActiveSupport::Cache::FileStore.new, ActiveSupport::Cache::MemCacheStore.new, etc.
|
42
|
+
|
43
|
+
### translator
|
44
|
+
|
45
|
+
Translator is expecting to recieve an instance of class, which is responsible for translating strings inside the theme. It should implement methods "translate" and "locale". It can be I18n or it can be any other custom class, which reads translation strings from some other places (database).
|
46
|
+
|
47
|
+
### assets_remote_host
|
48
|
+
|
49
|
+
This configuration defines the remote host for assets (if any) and is used in such liquid filters, like theme_filters#customize.
|
50
|
+
|
51
|
+
### routes
|
52
|
+
|
53
|
+
This config is expecting a class, which is responsible for building urls. It should work a lot like rails routes helper and implement following methods:
|
54
|
+
|
55
|
+
* store_root_path
|
56
|
+
* store_cart_path
|
57
|
+
* store_signup_path
|
58
|
+
* store_login_path
|
59
|
+
* store_logout_path
|
60
|
+
* store_account_path
|
61
|
+
* add_store_account_billing_payment_methods_path
|
62
|
+
* store_account_billing_payment_method_path
|
63
|
+
* delete_store_account_billing_payment_method_path
|
64
|
+
* store_address_path
|
65
|
+
* store_addresses_path
|
66
|
+
* store_blog_post_path
|
67
|
+
* store_blog_posts_path
|
68
|
+
* store_brand_path
|
69
|
+
* store_brands_path
|
70
|
+
* store_category_path
|
71
|
+
* store_categories_path
|
72
|
+
* store_checkout_order_url
|
73
|
+
* store_collection_path
|
74
|
+
* store_collections_path
|
75
|
+
* store_order_path
|
76
|
+
* store_orders_path
|
77
|
+
* store_page_path
|
78
|
+
* store_pages_path
|
79
|
+
* store_product_path
|
80
|
+
* store_products_path
|
81
|
+
* store_variants_path
|
82
|
+
* store_subscribers_add_path
|
83
|
+
* store_search_path
|
84
|
+
* store_recover_password_path
|
85
|
+
* store_reset_password_path
|
86
|
+
* new_store_address_path
|
87
|
+
* add_store_cart_path
|
88
|
+
* checkout_store_cart_path
|
89
|
+
* update_store_cart_path
|
90
|
+
* store_new_login_path
|
91
|
+
* store_upd_reset_password_path
|
92
|
+
* store_account_subscriptions_path
|
93
|
+
* store_account_subscription_plans_path
|
94
|
+
* store_account_create_subscription_path
|
95
|
+
* store_order_returns_path
|
96
|
+
* new_store_order_return_path
|
97
|
+
* store_order_return_path
|
98
|
+
* store_order_return_generate_parcel_path
|
99
|
+
|
100
|
+
### environment
|
101
|
+
|
102
|
+
Accepts values: products, development, test, (any other) + theme_development, which would rather by used by RTE.
|
103
|
+
|
104
|
+
### models_namespace
|
105
|
+
|
106
|
+
In case if your models are namespaced, you can provide the namespace name in this config.
|
107
|
+
|
108
|
+
### file_system
|
109
|
+
|
110
|
+
File System is a class, responsible for fetching theme files (for example from the file system or database). It should implement following methods:
|
111
|
+
|
112
|
+
* __read_template_file__: (should fetch template or fragment)
|
113
|
+
* __read_section_file__: (should fetch section)
|
114
|
+
* __absolute_asset_path__: (should return absolute path of an asset by its relative (or basename) path). For instance Shoperb side needs to print correct pathname with a digest, taken from database.
|
115
|
+
|
116
|
+
### error_mode
|
117
|
+
|
118
|
+
Liquid error mode. Values: strict, :warn, lax (default).
|
119
|
+
|
120
|
+
## Liquid template options
|
121
|
+
|
122
|
+
Options, provided to the template, are passed by __shoperb_liquid__ gem. However, options should be built in the appropriate context. In order for them to be built correctly, context should have following variables:
|
123
|
+
|
124
|
+
* __params__: hash
|
125
|
+
* __options__: hash
|
126
|
+
* __flash__: hash
|
127
|
+
* __shop__: object
|
128
|
+
* __request__: object
|
129
|
+
* __template__: string
|
130
|
+
* __current_cart__: object
|
131
|
+
* __current_carts__: array
|
132
|
+
* __current_customer__: object
|
133
|
+
* __current_settings__: hash
|
134
|
+
* __ResourceHints__: object (optional)
|
135
|
+
|
136
|
+
## Contributing
|
137
|
+
|
138
|
+
1. Fork it ( https://github.com/[my-github-username]/shoperb_liquid/fork )
|
139
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
140
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
141
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
142
|
+
5. Create a new Pull Request
|
143
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ShoperbLiquid
|
4
|
+
class Configuration
|
5
|
+
attr_accessor :cache, :file_system, :translator,
|
6
|
+
:assets_remote_host, :environment, :routes,
|
7
|
+
:models_namespace, :error_mode, :error_notify
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@cache = default_cache
|
11
|
+
@file_system = default_file_system
|
12
|
+
@translator = default_translator
|
13
|
+
@routes = default_routes
|
14
|
+
@error_mode = Liquid::Environment.default.error_mode = :lax
|
15
|
+
@error_notify = default_error_notify
|
16
|
+
@models_namespace = nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def file_system=(value)
|
20
|
+
@file_system = Liquid::Environment.default.file_system = value
|
21
|
+
end
|
22
|
+
|
23
|
+
def environment=(value)
|
24
|
+
@environment = value.to_s.inquiry
|
25
|
+
end
|
26
|
+
|
27
|
+
def error_mode=(value)
|
28
|
+
@error_mode = Liquid::Environment.default.error_mode = value
|
29
|
+
end
|
30
|
+
|
31
|
+
def models_namespace=(namespace)
|
32
|
+
if namespace != @models_namespace
|
33
|
+
@models_namespace = namespace
|
34
|
+
ShoperbLiquid::Models.shadow
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def error_notify(*args)
|
39
|
+
@error_notify.call(*args)
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def default_cache
|
45
|
+
ActiveSupport::Cache::MemoryStore.new
|
46
|
+
end
|
47
|
+
|
48
|
+
def default_translator
|
49
|
+
AbstractTranslator.new
|
50
|
+
end
|
51
|
+
|
52
|
+
def default_file_system
|
53
|
+
AbstractFileReader.new
|
54
|
+
end
|
55
|
+
|
56
|
+
def default_routes
|
57
|
+
AbstractRoutesHelper.new
|
58
|
+
end
|
59
|
+
|
60
|
+
def default_error_notify
|
61
|
+
lambda { |error, template, line| }
|
62
|
+
end
|
63
|
+
|
64
|
+
#
|
65
|
+
# File reader class should implement following methods
|
66
|
+
# so liquid knew where to fetch files from
|
67
|
+
#
|
68
|
+
class AbstractFileReader
|
69
|
+
def read_template_file(*args)
|
70
|
+
raise ShoperbLiquid::Error, "No file system given to read template file"
|
71
|
+
end
|
72
|
+
|
73
|
+
def read_section_file(*args)
|
74
|
+
raise ShoperbLiquid::Error, "No file system given to read section file"
|
75
|
+
end
|
76
|
+
|
77
|
+
def absolute_asset_path(*args)
|
78
|
+
raise ShoperbLiquid::Error, "No file system given to detect absolute asset path"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
#
|
83
|
+
# Class, which is reponsible for fetching transltions
|
84
|
+
# should implement following methods
|
85
|
+
#
|
86
|
+
class AbstractTranslator
|
87
|
+
def translate(string, **args)
|
88
|
+
string
|
89
|
+
end
|
90
|
+
|
91
|
+
def locale
|
92
|
+
:en
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
#
|
97
|
+
# Class, which is reponsible for building urls
|
98
|
+
# should implement following methods
|
99
|
+
#
|
100
|
+
class AbstractRoutesHelper
|
101
|
+
PATHS = [
|
102
|
+
:store_root_path,
|
103
|
+
:store_cart_path,
|
104
|
+
:store_carts_path,
|
105
|
+
:store_signup_path,
|
106
|
+
:store_login_path,
|
107
|
+
:store_logout_path,
|
108
|
+
:store_account_path,
|
109
|
+
:add_store_account_billing_payment_methods_path,
|
110
|
+
:store_account_billing_payment_method_path,
|
111
|
+
:delete_store_account_billing_payment_method_path,
|
112
|
+
:store_address_path,
|
113
|
+
:store_addresses_path,
|
114
|
+
:store_blog_post_path,
|
115
|
+
:store_blog_posts_path,
|
116
|
+
:store_brand_path,
|
117
|
+
:store_brands_path,
|
118
|
+
:store_category_path,
|
119
|
+
:store_categories_path,
|
120
|
+
:store_checkout_order_url,
|
121
|
+
:store_collection_path,
|
122
|
+
:store_collections_path,
|
123
|
+
:store_order_path,
|
124
|
+
:store_orders_path,
|
125
|
+
:store_page_path,
|
126
|
+
:store_pages_path,
|
127
|
+
:store_product_path,
|
128
|
+
:store_products_path,
|
129
|
+
:store_variants_path,
|
130
|
+
:store_subscribers_add_path,
|
131
|
+
:store_search_path,
|
132
|
+
:store_recover_password_path,
|
133
|
+
:store_reset_password_path,
|
134
|
+
:new_store_address_path,
|
135
|
+
:add_store_cart_path,
|
136
|
+
:checkout_store_cart_path,
|
137
|
+
:update_store_cart_path,
|
138
|
+
:add_store_multi_cart_path,
|
139
|
+
:checkout_store_multi_cart_path,
|
140
|
+
:update_store_multi_cart_path,
|
141
|
+
:store_new_login_path,
|
142
|
+
:store_upd_reset_password_path,
|
143
|
+
:store_account_subscriptions_path,
|
144
|
+
:store_account_subscription_plans_path,
|
145
|
+
:store_account_create_subscription_path,
|
146
|
+
:store_order_returns_path,
|
147
|
+
:store_order_return_path,
|
148
|
+
:new_store_order_return_path,
|
149
|
+
:store_order_return_generate_parcel_path,
|
150
|
+
].freeze
|
151
|
+
|
152
|
+
PATHS.each do |path|
|
153
|
+
define_method path do |*_|
|
154
|
+
raise_not_implemented(path)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
def url_for(*_)
|
159
|
+
raise_not_implemented(:url_for)
|
160
|
+
end
|
161
|
+
|
162
|
+
private
|
163
|
+
|
164
|
+
def raise_not_implemented(path)
|
165
|
+
raise ShoperbLiquid::Error, "Cannot build url #{path} with given routes helper"
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ShoperbLiquid
|
4
|
+
class AddressDrop < Base
|
5
|
+
def id
|
6
|
+
record.id
|
7
|
+
end
|
8
|
+
|
9
|
+
def name
|
10
|
+
record.name
|
11
|
+
end
|
12
|
+
|
13
|
+
def first_name
|
14
|
+
record.first_name
|
15
|
+
end
|
16
|
+
|
17
|
+
def last_name
|
18
|
+
record.last_name
|
19
|
+
end
|
20
|
+
|
21
|
+
def full_name
|
22
|
+
record.full_name
|
23
|
+
end
|
24
|
+
|
25
|
+
def company
|
26
|
+
record.company
|
27
|
+
end
|
28
|
+
|
29
|
+
def company?
|
30
|
+
record.account_type == "company"
|
31
|
+
end
|
32
|
+
|
33
|
+
# def email
|
34
|
+
# record.email
|
35
|
+
# end
|
36
|
+
|
37
|
+
def phone
|
38
|
+
record.phone
|
39
|
+
end
|
40
|
+
|
41
|
+
def full_address
|
42
|
+
record.full_address
|
43
|
+
end
|
44
|
+
|
45
|
+
def company_with_phone
|
46
|
+
record.company_with_phone
|
47
|
+
end
|
48
|
+
|
49
|
+
def city_state_with_zip
|
50
|
+
record.city_state_with_zip
|
51
|
+
end
|
52
|
+
|
53
|
+
def state_with_country
|
54
|
+
record.state_with_country
|
55
|
+
end
|
56
|
+
|
57
|
+
def zip_with_city
|
58
|
+
record.zip_with_city
|
59
|
+
end
|
60
|
+
|
61
|
+
def street
|
62
|
+
record.full_address
|
63
|
+
end
|
64
|
+
|
65
|
+
def address1
|
66
|
+
record.address1
|
67
|
+
end
|
68
|
+
|
69
|
+
def address2
|
70
|
+
record.address2
|
71
|
+
end
|
72
|
+
|
73
|
+
def city
|
74
|
+
record.city
|
75
|
+
end
|
76
|
+
|
77
|
+
def state
|
78
|
+
record.state_name
|
79
|
+
end
|
80
|
+
|
81
|
+
def country
|
82
|
+
record.country_name
|
83
|
+
end
|
84
|
+
|
85
|
+
def state_code
|
86
|
+
record.state&.code
|
87
|
+
end
|
88
|
+
|
89
|
+
def country_code
|
90
|
+
record.country&.code
|
91
|
+
end
|
92
|
+
|
93
|
+
def zip
|
94
|
+
record.zip
|
95
|
+
end
|
96
|
+
|
97
|
+
def vat_number
|
98
|
+
record.vat_number
|
99
|
+
end
|
100
|
+
|
101
|
+
# return only for address customer
|
102
|
+
# if have id then showing edit/update path
|
103
|
+
# if id not present, then create path.
|
104
|
+
# This is for simplicity of theme creators
|
105
|
+
def url
|
106
|
+
if record&.type == "AddressCustomer"
|
107
|
+
if record.id
|
108
|
+
controller.store_address_path(record)
|
109
|
+
else
|
110
|
+
controller.store_addresses_path
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def delete_url
|
116
|
+
if record&.type == "AddressCustomer" && id
|
117
|
+
controller.delete_store_address_path(id)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ShoperbLiquid
|
4
|
+
class ArrayDrop < CollectionDrop
|
5
|
+
def [](attr)
|
6
|
+
return super unless attr.is_a?(Integer)
|
7
|
+
collection[attr]
|
8
|
+
end
|
9
|
+
|
10
|
+
def include?(other)
|
11
|
+
collection.include?(other)
|
12
|
+
end
|
13
|
+
|
14
|
+
def inspect
|
15
|
+
collection.inspect
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ShoperbLiquid
|
4
|
+
class AttributeDrop < Base
|
5
|
+
def id
|
6
|
+
record.id
|
7
|
+
end
|
8
|
+
|
9
|
+
def handle
|
10
|
+
record.handle
|
11
|
+
end
|
12
|
+
|
13
|
+
def name
|
14
|
+
record.name
|
15
|
+
end
|
16
|
+
|
17
|
+
def value
|
18
|
+
record.value
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|