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,72 @@
|
|
1
|
+
{% comment %}
|
2
|
+
The search.liquid template is not a required template.
|
3
|
+
That search.liquid template is included in the current theme to make it easier for you
|
4
|
+
to customize your /search page.
|
5
|
+
Whether you are using your own template for the search page or not,
|
6
|
+
the {{ content_for_header }} tag in theme.liquid will always output the following on the /search page:
|
7
|
+
<link rel="stylesheet" href="//cdn.shopify.com/s/global/search.css" type="text/css" />
|
8
|
+
So the /search page is always styled by a globally-hosted stylesheet called search.css.
|
9
|
+
You may override and complement that CSS in your theme's stylesheet.
|
10
|
+
We are using a div#searchresults below so that the styles defined in search.css get
|
11
|
+
applied to the elements on this page; the 'searchresults' id is used in the CSS
|
12
|
+
selectors inside search.css.
|
13
|
+
{% endcomment %}
|
14
|
+
|
15
|
+
<div id="searchresults">
|
16
|
+
|
17
|
+
<div class="centered">
|
18
|
+
<form action="/search" method="get" class="search-form" role="search">
|
19
|
+
<input name="q" type="search" id="search-field" placeholder="Search store..." value="{{ search.terms | escape }}" />
|
20
|
+
<input type="submit" id="search-submit" value="Search" />
|
21
|
+
</form>
|
22
|
+
</div>
|
23
|
+
|
24
|
+
{% comment %}
|
25
|
+
search.performed is false when accessing the /search page without a 'q' parameter set
|
26
|
+
in the URL. A shop-owner can link to the /search page from one of his link lists.
|
27
|
+
It is important to show a search form on that page if search.performed is false.
|
28
|
+
{% endcomment %}
|
29
|
+
|
30
|
+
{% if search.performed %}
|
31
|
+
|
32
|
+
{% paginate search.results by 10 %}
|
33
|
+
|
34
|
+
{% comment %}
|
35
|
+
Common pitfall to avoid: search.results should never be accessed before the opening
|
36
|
+
paginate tag. Move the opening and closing paginate tags to the very top and bottom of your
|
37
|
+
search.liquid template if you need to.
|
38
|
+
If you fail to do the above, the pagination of search results will be broken.
|
39
|
+
search.results_count is fine to access in or out of the paginate block.
|
40
|
+
{% endcomment %}
|
41
|
+
|
42
|
+
{% if search.results_count == 0 %}
|
43
|
+
<p class="centered">Your search for "{{ search.terms }}" did not yield any results.</p>
|
44
|
+
{% else %}
|
45
|
+
<ol>
|
46
|
+
{% for item in search.results %}
|
47
|
+
<li class="clearfix">
|
48
|
+
<h3>{{ item.title | link_to: item.url }}</h3>
|
49
|
+
{% if item.vendor %}
|
50
|
+
<div class="result-image">
|
51
|
+
<a href="{{ item.url }}" title="{{ item.title | escape }}">
|
52
|
+
{{ item | img_url: 'small' | img_tag: item.featured_image.alt }}
|
53
|
+
</a>
|
54
|
+
</div>
|
55
|
+
{% endif %}
|
56
|
+
<span>{{ item.content | strip_html | truncatewords: 40 | highlight: search.terms }}</span>
|
57
|
+
</li>
|
58
|
+
{% endfor %}
|
59
|
+
</ol>
|
60
|
+
{% endif %}
|
61
|
+
|
62
|
+
{% if paginate.pages > 1 %}
|
63
|
+
<div id="pagination">
|
64
|
+
{{ paginate | default_pagination }}
|
65
|
+
</div>
|
66
|
+
{% endif %}
|
67
|
+
|
68
|
+
{% endpaginate %}
|
69
|
+
|
70
|
+
{% endif %}
|
71
|
+
|
72
|
+
</div>
|
data/bin/rails
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
|
3
|
+
|
4
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
5
|
+
ENGINE_PATH = File.expand_path('../../lib/solidus_liquid/engine', __FILE__)
|
6
|
+
|
7
|
+
# Set up gems listed in the Gemfile.
|
8
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
9
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
10
|
+
|
11
|
+
require 'rails/all'
|
12
|
+
require 'rails/engine/commands'
|
data/config/app.yml
ADDED
File without changes
|
@@ -0,0 +1,25 @@
|
|
1
|
+
CarrierWave.configure do |config|
|
2
|
+
if Rails.env.production?
|
3
|
+
config.fog_provider = 'fog/aws'
|
4
|
+
|
5
|
+
config.fog_credentials = {
|
6
|
+
provider: 'AWS',
|
7
|
+
aws_access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID'),
|
8
|
+
aws_secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY'),
|
9
|
+
region: ENV.fetch('AWS_S3_REGION')
|
10
|
+
}
|
11
|
+
|
12
|
+
config.fog_directory = ENV.fetch('AWS_S3_BUCKET_NAME')
|
13
|
+
config.fog_authenticated_url_expiration = 120
|
14
|
+
# config.fog_public = true
|
15
|
+
# optional, defaults to {}
|
16
|
+
# config.fog_attributes = { 'Cache-Control' => "max-age=#{365.day.to_i}" }
|
17
|
+
config.storage = :fog
|
18
|
+
else
|
19
|
+
config.ignore_integrity_errors = false
|
20
|
+
config.ignore_processing_errors = false
|
21
|
+
config.ignore_download_errors = false
|
22
|
+
config.storage = :file
|
23
|
+
config.enable_processing = false if Rails.env.test? || Rails.env.cucumber?
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,286 @@
|
|
1
|
+
# Use this hook to configure devise mailer, warden hooks and so forth.
|
2
|
+
# Many of these configuration options can be set straight in your model.
|
3
|
+
Devise.setup do |config|
|
4
|
+
# The secret key used by Devise. Devise uses this key to generate
|
5
|
+
# random tokens. Changing this key will render invalid all existing
|
6
|
+
# confirmation, reset password and unlock tokens in the database.
|
7
|
+
# Devise will use the `secret_key_base` as its `secret_key`
|
8
|
+
# by default. You can change it below and use your own secret key.
|
9
|
+
# config.secret_key = 'e1d145f4dc893bf3d9b11ce44a851d232100bfdbbda64'
|
10
|
+
|
11
|
+
# ==> Mailer Configuration
|
12
|
+
# Configure the e-mail address which will be shown in Devise::Mailer,
|
13
|
+
# note that it will be overwritten if you use your own mailer class
|
14
|
+
# with default "from" parameter.
|
15
|
+
config.mailer_sender = 'change-me-at-config-initializers-devise@example.com'
|
16
|
+
|
17
|
+
# Configure the class responsible to send e-mails.
|
18
|
+
# config.mailer = 'Devise::Mailer'
|
19
|
+
|
20
|
+
# Configure the parent class responsible to send e-mails.
|
21
|
+
# config.parent_mailer = 'ActionMailer::Base'
|
22
|
+
|
23
|
+
# ==> ORM configuration
|
24
|
+
# Load and configure the ORM. Supports :active_record (default) and
|
25
|
+
# :mongoid (bson_ext recommended) by default. Other ORMs may be
|
26
|
+
# available as additional gems.
|
27
|
+
require 'devise/orm/active_record'
|
28
|
+
|
29
|
+
# ==> Configuration for any authentication mechanism
|
30
|
+
# Configure which keys are used when authenticating a user. The default is
|
31
|
+
# just :email. You can configure it to use [:username, :subdomain], so for
|
32
|
+
# authenticating a user, both parameters are required. Remember that those
|
33
|
+
# parameters are used only when authenticating and not when retrieving from
|
34
|
+
# session. If you need permissions, you should implement that in a before
|
35
|
+
# filter.
|
36
|
+
# You can also supply a hash where the value is a boolean determining whether
|
37
|
+
# or not authentication should be aborted when the value is not present.
|
38
|
+
# config.authentication_keys = [:email]
|
39
|
+
|
40
|
+
# Configure parameters from the request object used for authentication. Each
|
41
|
+
# entry given should be a request method and it will automatically be passed
|
42
|
+
# to the find_for_authentication method and considered in your model lookup.
|
43
|
+
# For instance, if you set :request_keys to [:subdomain], :subdomain will be
|
44
|
+
# used on authentication. The same considerations mentioned for
|
45
|
+
# authentication_keys also apply to request_keys.
|
46
|
+
# config.request_keys = []
|
47
|
+
|
48
|
+
# Configure which authentication keys should be case-insensitive.
|
49
|
+
# These keys will be downcased upon creating or modifying a user and when used
|
50
|
+
# to authenticate or find a user. Default is :email.
|
51
|
+
config.case_insensitive_keys = [:email]
|
52
|
+
|
53
|
+
# Configure which authentication keys should have whitespace stripped.
|
54
|
+
# These keys will have whitespace before and after removed upon creating or
|
55
|
+
# modifying a user and when used to authenticate or find a user.
|
56
|
+
# Default is :email.
|
57
|
+
config.strip_whitespace_keys = [:email]
|
58
|
+
|
59
|
+
# Tell if authentication through request.params is enabled. True by default.
|
60
|
+
# It can be set to an array that will enable params authentication only for
|
61
|
+
# the given strategies, for example,
|
62
|
+
# `config.params_authenticatable = [:database]` will enable it only for
|
63
|
+
# database (email + password) authentication.
|
64
|
+
# config.params_authenticatable = true
|
65
|
+
|
66
|
+
# Tell if authentication through HTTP Auth is enabled. False by default.
|
67
|
+
# It can be set to an array that will enable http authentication only for the
|
68
|
+
# given strategies, for example, `config.http_authenticatable = [:database]`
|
69
|
+
# will enable it only for database authentication. The supported strategies
|
70
|
+
# are:
|
71
|
+
# :database = basic authentication with authentication key + password
|
72
|
+
# config.http_authenticatable = false
|
73
|
+
|
74
|
+
# If 401 status code should be returned for AJAX requests. True by default.
|
75
|
+
# config.http_authenticatable_on_xhr = true
|
76
|
+
|
77
|
+
# The realm used in Http Basic Authentication. 'Application' by default.
|
78
|
+
# config.http_authentication_realm = 'Application'
|
79
|
+
|
80
|
+
# It will change confirmation, password recovery and other workflows
|
81
|
+
# to behave the same regardless if the e-mail provided was right or wrong.
|
82
|
+
# Does not affect registerable.
|
83
|
+
# config.paranoid = true
|
84
|
+
|
85
|
+
# By default Devise will store the user in session. You can skip storage for
|
86
|
+
# particular strategies by setting this option.
|
87
|
+
# Notice that if you are skipping storage for all authentication paths, you
|
88
|
+
# may want to disable generating routes to Devise's sessions controller by
|
89
|
+
# passing skip: :sessions to `devise_for` in your config/routes.rb
|
90
|
+
config.skip_session_storage = [:http_auth]
|
91
|
+
|
92
|
+
# By default, Devise cleans up the CSRF token on authentication to
|
93
|
+
# avoid CSRF token fixation attacks. This means that, when using AJAX
|
94
|
+
# requests for sign in and sign up, you need to get a new CSRF token
|
95
|
+
# from the server. You can disable this option at your own risk.
|
96
|
+
# config.clean_up_csrf_token_on_authentication = true
|
97
|
+
|
98
|
+
# When false, Devise will not attempt to reload routes on eager load.
|
99
|
+
# This can reduce the time taken to boot the app but if your application
|
100
|
+
# requires the Devise mappings to be loaded during boot time the application
|
101
|
+
# won't boot properly.
|
102
|
+
# config.reload_routes = true
|
103
|
+
|
104
|
+
# ==> Configuration for :database_authenticatable
|
105
|
+
# For bcrypt, this is the cost for hashing the password and defaults to 11. If
|
106
|
+
# using other algorithms, it sets how many times you want the password to be
|
107
|
+
# hashed.
|
108
|
+
#
|
109
|
+
# Limiting the stretches to just one in testing will increase the performance
|
110
|
+
# of your test suite dramatically. However, it is STRONGLY RECOMMENDED to not
|
111
|
+
# use a value less than 10 in other environments. Note that, for bcrypt (the
|
112
|
+
# default algorithm), the cost increases exponentially with the number of
|
113
|
+
# stretches (e.g. a value of 20 is already extremely slow: approx. 60 seconds
|
114
|
+
# for 1 calculation).
|
115
|
+
config.stretches = Rails.env.test? ? 1 : 11
|
116
|
+
|
117
|
+
# Set up a pepper to generate the hashed password.
|
118
|
+
# config.pepper = '483b5f2f860293409d8a78d8e161cdd09ee5138f536aa11'
|
119
|
+
|
120
|
+
# Send a notification email when the user's password is changed
|
121
|
+
# config.send_password_change_notification = false
|
122
|
+
|
123
|
+
# ==> Configuration for :confirmable
|
124
|
+
# A period that the user is allowed to access the website even without
|
125
|
+
# confirming their account. For instance, if set to 2.days, the user will be
|
126
|
+
# able to access the website for two days without confirming their account,
|
127
|
+
# access will be blocked just in the third day. Default is 0.days, meaning
|
128
|
+
# the user cannot access the website without confirming their account.
|
129
|
+
# config.allow_unconfirmed_access_for = 2.days
|
130
|
+
|
131
|
+
# A period that the user is allowed to confirm their account before their
|
132
|
+
# token becomes invalid. For example, if set to 3.days, the user can confirm
|
133
|
+
# their account within 3 days after the mail was sent, but on the fourth day
|
134
|
+
# their account can't be confirmed with the token any more.
|
135
|
+
# Default is nil, meaning there is no restriction on how long a user can take
|
136
|
+
# before confirming their account.
|
137
|
+
# config.confirm_within = 3.days
|
138
|
+
|
139
|
+
# If true, requires any email changes to be confirmed (exactly the same way as
|
140
|
+
# initial account confirmation) to be applied. Requires additional
|
141
|
+
# unconfirmed_email db field (see migrations). Until confirmed, new email is
|
142
|
+
# stored in unconfirmed_email column, and copied to email column on successful
|
143
|
+
# confirmation.
|
144
|
+
config.reconfirmable = true
|
145
|
+
|
146
|
+
# Defines which key will be used when confirming an account
|
147
|
+
# config.confirmation_keys = [:email]
|
148
|
+
|
149
|
+
# ==> Configuration for :rememberable
|
150
|
+
# The time the user will be remembered without asking for credentials again.
|
151
|
+
# config.remember_for = 2.weeks
|
152
|
+
|
153
|
+
# Invalidates all the remember me tokens when the user signs out.
|
154
|
+
config.expire_all_remember_me_on_sign_out = true
|
155
|
+
|
156
|
+
# If true, extends the user's remember period when remembered via cookie.
|
157
|
+
# config.extend_remember_period = false
|
158
|
+
|
159
|
+
# Options to be passed to the created cookie. For instance, you can set
|
160
|
+
# secure: true in order to force SSL only cookies.
|
161
|
+
# config.rememberable_options = {}
|
162
|
+
|
163
|
+
# ==> Configuration for :validatable
|
164
|
+
# Range for password length.
|
165
|
+
config.password_length = 6..128
|
166
|
+
|
167
|
+
# Email regex used to validate email formats. It simply asserts that
|
168
|
+
# one (and only one) @ exists in the given string. This is mainly
|
169
|
+
# to give user feedback and not to assert the e-mail validity.
|
170
|
+
config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
|
171
|
+
|
172
|
+
# ==> Configuration for :timeoutable
|
173
|
+
# The time you want to timeout the user session without activity. After this
|
174
|
+
# time the user will be asked for credentials again. Default is 30 minutes.
|
175
|
+
# config.timeout_in = 30.minutes
|
176
|
+
|
177
|
+
# ==> Configuration for :lockable
|
178
|
+
# Defines which strategy will be used to lock an account.
|
179
|
+
# :failed_attempts = Locks an account after a number of failed attempts.
|
180
|
+
# :none = No lock strategy. You should handle locking by yourself.
|
181
|
+
# config.lock_strategy = :failed_attempts
|
182
|
+
|
183
|
+
# Defines which key will be used when locking and unlocking an account
|
184
|
+
# config.unlock_keys = [:email]
|
185
|
+
|
186
|
+
# Defines which strategy will be used to unlock an account.
|
187
|
+
# :email = Sends an unlock link to the user email
|
188
|
+
# :time = Re-enables login after a certain amount of time (see :unlock_in)
|
189
|
+
# :both = Enables both strategies
|
190
|
+
# :none = No unlock strategy. You should handle unlocking by yourself.
|
191
|
+
# config.unlock_strategy = :both
|
192
|
+
|
193
|
+
# Number of authentication tries before locking an account if lock_strategy
|
194
|
+
# is failed attempts.
|
195
|
+
# config.maximum_attempts = 20
|
196
|
+
|
197
|
+
# Time interval to unlock the account if :time is enabled as unlock_strategy.
|
198
|
+
# config.unlock_in = 1.hour
|
199
|
+
|
200
|
+
# Warn on the last attempt before the account is locked.
|
201
|
+
# config.last_attempt_warning = true
|
202
|
+
|
203
|
+
# ==> Configuration for :recoverable
|
204
|
+
#
|
205
|
+
# Defines which key will be used when recovering the password for an account
|
206
|
+
# config.reset_password_keys = [:email]
|
207
|
+
|
208
|
+
# Time interval you can reset your password with a reset password key.
|
209
|
+
# Don't put a too small interval or your users won't have the time to
|
210
|
+
# change their passwords.
|
211
|
+
config.reset_password_within = 6.hours
|
212
|
+
|
213
|
+
# When set to false, does not sign a user in automatically after their
|
214
|
+
# password is reset. Defaults to true, so a user is signed in automatically
|
215
|
+
# after a reset.
|
216
|
+
# config.sign_in_after_reset_password = true
|
217
|
+
|
218
|
+
# ==> Configuration for :encryptable
|
219
|
+
# Allow you to use another hashing or encryption algorithm besides bcrypt
|
220
|
+
# (default). You can use :sha1, :sha512 or algorithms from others
|
221
|
+
# authentication tools as :clearance_sha1, :authlogic_sha512 (then you should
|
222
|
+
# set stretches above to 20 for default behavior) and
|
223
|
+
# :restful_authentication_sha1 (then you should set stretches to 10, and copy
|
224
|
+
# REST_AUTH_SITE_KEY to pepper).
|
225
|
+
#
|
226
|
+
# Require the `devise-encryptable` gem when using anything other than bcrypt
|
227
|
+
# config.encryptor = :sha512
|
228
|
+
|
229
|
+
# ==> Scopes configuration
|
230
|
+
# Turn scoped views on. Before rendering "sessions/new", it will first check
|
231
|
+
# for "users/sessions/new". It's turned off by default because it's slower if
|
232
|
+
# you are using only default views.
|
233
|
+
# config.scoped_views = false
|
234
|
+
|
235
|
+
# Configure the default scope given to Warden. By default it's the first
|
236
|
+
# devise role declared in your routes (usually :user).
|
237
|
+
# config.default_scope = :user
|
238
|
+
|
239
|
+
# Set this configuration to false if you want /users/sign_out to sign out
|
240
|
+
# only the current scope. By default, Devise signs out all scopes.
|
241
|
+
# config.sign_out_all_scopes = true
|
242
|
+
|
243
|
+
# ==> Navigation configuration
|
244
|
+
# Lists the formats that should be treated as navigational. Formats like
|
245
|
+
# :html, should redirect to the sign in page when the user does not have
|
246
|
+
# access, but formats like :xml or :json, should return 401.
|
247
|
+
#
|
248
|
+
# If you have any extra navigational formats, like :iphone or :mobile, you
|
249
|
+
# should add them to the navigational formats lists.
|
250
|
+
#
|
251
|
+
# The "*/*" below is required to match Internet Explorer requests.
|
252
|
+
# config.navigational_formats = ['*/*', :html]
|
253
|
+
|
254
|
+
# The default HTTP method used to sign out a resource. Default is :delete.
|
255
|
+
config.sign_out_via = :delete
|
256
|
+
|
257
|
+
# ==> OmniAuth
|
258
|
+
# Add a new OmniAuth provider. Check the wiki for more information on setting
|
259
|
+
# up on your models and hooks.
|
260
|
+
# config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
|
261
|
+
|
262
|
+
# ==> Warden configuration
|
263
|
+
# If you want to use other strategies, that are not supported by Devise, or
|
264
|
+
# change the failure app, you can configure them inside the config.warden
|
265
|
+
# block.
|
266
|
+
#
|
267
|
+
# config.warden do |manager|
|
268
|
+
# manager.intercept_401 = false
|
269
|
+
# manager.default_strategies(scope: :user).unshift :some_external_strategy
|
270
|
+
# end
|
271
|
+
|
272
|
+
# ==> Mountable engine configurations
|
273
|
+
# When using Devise inside an engine, let's call it `MyEngine`, and this
|
274
|
+
# engine is mountable, there are some extra configurations to be taken into
|
275
|
+
# account.
|
276
|
+
# The following options are available, assuming the engine is mounted as:
|
277
|
+
#
|
278
|
+
# mount MyEngine, at: '/my_engine'
|
279
|
+
#
|
280
|
+
# The router that invoked `devise_for`, in the example above, would be:
|
281
|
+
# config.router_name = :my_engine
|
282
|
+
#
|
283
|
+
# When using OmniAuth, Devise cannot automatically set OmniAuth path,
|
284
|
+
# so you need to do it manually. For the users scope, it would be:
|
285
|
+
# config.omniauth_path_prefix = '/my_engine/users/auth'
|
286
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class FormTag < Liquid::Block
|
2
|
+
SYNTAX = /(#{Liquid::QuotedFragment})?/
|
3
|
+
|
4
|
+
def initialize(tag_name, markup, context)
|
5
|
+
super
|
6
|
+
|
7
|
+
if markup =~ SYNTAX
|
8
|
+
@form_name = Regexp.last_match(1).delete('\'')
|
9
|
+
else
|
10
|
+
raise SyntaxError,
|
11
|
+
"Syntax Error in tag '#{tag_name}' - " \
|
12
|
+
"Valid syntax: #{tag_name} '[form_name]'"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# rubocop:disable Lint/EmptyWhen,Metrics/CyclomaticComplexity
|
17
|
+
# rubocop:disable Metrics/MethodLength
|
18
|
+
def render(context)
|
19
|
+
view = context.registers[:view]
|
20
|
+
case @form_name
|
21
|
+
when 'activate_customer_password'
|
22
|
+
# {% form 'activate_customer_password' %}
|
23
|
+
when 'create_customer'
|
24
|
+
view.form_for(:customer, url: view.new_customer_registration_path) do |_f|
|
25
|
+
safe_join[super]
|
26
|
+
end
|
27
|
+
when 'customer_address'
|
28
|
+
# {% form 'customer_address', customer.new_address %}
|
29
|
+
# {% form 'customer_address', address %}
|
30
|
+
when 'customer_login'
|
31
|
+
view.form_for(:customer, url: view.new_customer_session_path) do |_f|
|
32
|
+
safe_join[super]
|
33
|
+
end
|
34
|
+
when 'guest_login'
|
35
|
+
when 'new_comment'
|
36
|
+
# {% form "new_comment", article %}
|
37
|
+
when 'recover_customer_password'
|
38
|
+
when 'reset_customer_password'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
Liquid::Template.register_tag('form', FormTag)
|
@@ -0,0 +1,202 @@
|
|
1
|
+
# Liquid::Template.error_mode = :strict
|
2
|
+
|
3
|
+
module Liquid
|
4
|
+
class LocalFileSystem
|
5
|
+
# rubocop:disable all
|
6
|
+
def full_path(template_path)
|
7
|
+
full_path = if template_path.include?('/'.freeze)
|
8
|
+
File.join(root, File.dirname(template_path), @pattern % File.basename(template_path))
|
9
|
+
else
|
10
|
+
File.join(root, @pattern % template_path)
|
11
|
+
end
|
12
|
+
|
13
|
+
raise FileSystemError, "Illegal template path '#{File.expand_path(full_path)}'" unless File.expand_path(full_path).start_with?(File.expand_path(root))
|
14
|
+
|
15
|
+
full_path
|
16
|
+
end
|
17
|
+
# rubocop:enable all
|
18
|
+
end
|
19
|
+
|
20
|
+
class VariableLookup
|
21
|
+
PERMITTED_NILLABLE = %w(collections linklists setting).freeze
|
22
|
+
|
23
|
+
# rubocop:disable all
|
24
|
+
def evaluate(context)
|
25
|
+
name = context.evaluate(@name)
|
26
|
+
object = context.find_variable(name)
|
27
|
+
|
28
|
+
@lookups.each_index do |i|
|
29
|
+
key = context.evaluate(@lookups[i])
|
30
|
+
|
31
|
+
# If object is a hash- or array-like object we look for the
|
32
|
+
# presence of the key and if its available we return it
|
33
|
+
if object.respond_to?(:[]) &&
|
34
|
+
((object.respond_to?(:key?) && object.key?(key)) ||
|
35
|
+
(object.respond_to?(:fetch) && key.is_a?(Integer)))
|
36
|
+
|
37
|
+
# if its a proc we will replace the entry with the proc
|
38
|
+
res = context.lookup_and_evaluate(object, key)
|
39
|
+
object = res.to_liquid
|
40
|
+
|
41
|
+
# Some special cases. If the part wasn't in square brackets and
|
42
|
+
# no key with the same name was found we interpret following calls
|
43
|
+
# as commands and call them on the current object
|
44
|
+
elsif @command_flags & (1 << i) != 0 && object.respond_to?(key)
|
45
|
+
object = object.send(key).to_liquid
|
46
|
+
|
47
|
+
# No key was present with the desired value and it wasn't one of the directly supported
|
48
|
+
# keywords either. The only thing we got left is to return nil or
|
49
|
+
# raise an exception if `strict_variables` option is set to true
|
50
|
+
else
|
51
|
+
# rubocop:enable all
|
52
|
+
if !context.strict_variables || PERMITTED_NILLABLE.include?(name)
|
53
|
+
return nil
|
54
|
+
end
|
55
|
+
raise Liquid::UndefinedVariable, "undefined variable #{name}.#{key}"
|
56
|
+
end
|
57
|
+
|
58
|
+
# If we are dealing with a drop here we have to
|
59
|
+
object.context = context if object.respond_to?(:context=)
|
60
|
+
end
|
61
|
+
|
62
|
+
object
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
module StandardFilters
|
67
|
+
require 'cgi'
|
68
|
+
def escape(input)
|
69
|
+
CGI.escapeHTML(input.to_s).untaint unless input.nil?
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
module Liquid
|
75
|
+
module Rails
|
76
|
+
class Drop
|
77
|
+
# rubocop:disable all
|
78
|
+
def liquid_method_missing(method)
|
79
|
+
if method.blank?
|
80
|
+
# This prevents for the case like this: collections[nil]
|
81
|
+
# {% assign product_vendor_handle = product.vendor | handle %}
|
82
|
+
# {% assign collection_handle = collections[product_vendor_handle].handle %}
|
83
|
+
::SolidusLiquid::NilDrop.new(nil)
|
84
|
+
else
|
85
|
+
return nil unless @context && @context.strict_variables
|
86
|
+
raise Liquid::UndefinedDropMethod, "undefined method #{method} for #{self.class}"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
# rubocop:enable all
|
90
|
+
end
|
91
|
+
|
92
|
+
class FileSystem < ::Liquid::LocalFileSystem
|
93
|
+
def read_template_file(template_path, context)
|
94
|
+
@pattern = @pattern.gsub(/^_/, '')
|
95
|
+
theme = context.registers[:theme]
|
96
|
+
template_path = "themes/#{theme.id}/snippets/#{template_path}"
|
97
|
+
|
98
|
+
super
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
class TemplateHandler
|
103
|
+
# rubocop:disable all
|
104
|
+
def render(template, local_assigns = {})
|
105
|
+
@view.controller.headers['Content-Type'] ||= 'text/html; charset=utf-8'
|
106
|
+
|
107
|
+
assigns = if @controller.respond_to?(:liquid_assigns, true)
|
108
|
+
@controller.send(:liquid_assigns)
|
109
|
+
else
|
110
|
+
@view.assigns
|
111
|
+
end
|
112
|
+
assigns['content_for_layout'] = @view.content_for(:layout) if @view.content_for?(:layout)
|
113
|
+
assigns.merge!(local_assigns.stringify_keys)
|
114
|
+
|
115
|
+
liquid = Liquid::Template.parse(template)
|
116
|
+
# rubocop:enable all
|
117
|
+
|
118
|
+
rendered_template = liquid.render(
|
119
|
+
assigns,
|
120
|
+
filters: filters,
|
121
|
+
# strict_variables: true,
|
122
|
+
# strict_filters: true,
|
123
|
+
registers: {
|
124
|
+
view: @view, controller: @controller, helper: @helper,
|
125
|
+
theme: @view.assigns['theme']
|
126
|
+
}
|
127
|
+
)
|
128
|
+
|
129
|
+
if liquid.errors.present?
|
130
|
+
if ::Rails.env.development? || ::Rails.env.test?
|
131
|
+
errors_text = liquid.errors.map(&:to_s).join("\n")
|
132
|
+
::Rails.logger.error(errors_text)
|
133
|
+
end
|
134
|
+
|
135
|
+
raise liquid.errors.first
|
136
|
+
end
|
137
|
+
|
138
|
+
rendered_template
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
# rubocop:disable all
|
143
|
+
class PaginateTag < ::Liquid::Block
|
144
|
+
def render(context)
|
145
|
+
@context = context
|
146
|
+
|
147
|
+
context.stack do
|
148
|
+
collection = @context[@collection_name].presence || @context.environments[0][@collection_name]
|
149
|
+
|
150
|
+
if collection.present?
|
151
|
+
if collection.is_a? Array
|
152
|
+
paginated_collection = Kaminari.paginate_array(collection.to_a).page(current_page).per(@page_size)
|
153
|
+
elsif collection.respond_to?(:page)
|
154
|
+
paginated_collection = collection.page(current_page).per(@page_size)
|
155
|
+
end
|
156
|
+
|
157
|
+
page_count = paginated_collection.total_pages
|
158
|
+
pagination = {}
|
159
|
+
pagination['collection'] = paginated_collection
|
160
|
+
pagination['current_offset'] = (current_page - 1) * @page_size
|
161
|
+
pagination['current_page'] = current_page
|
162
|
+
pagination['page_size'] = @page_size
|
163
|
+
pagination['pages'] = page_count
|
164
|
+
pagination['items'] = paginated_collection.total_count
|
165
|
+
pagination['previous'] = link('« Previous'.html_safe, current_page - 1) unless 1 >= current_page
|
166
|
+
pagination['next'] = link('Next »'.html_safe, current_page + 1) unless page_count < current_page + 1
|
167
|
+
pagination['parts'] = []
|
168
|
+
|
169
|
+
hellip_break = false
|
170
|
+
if page_count > 1
|
171
|
+
1.upto(page_count) do |page|
|
172
|
+
if current_page == page
|
173
|
+
pagination['parts'] << no_link(page)
|
174
|
+
elsif page == 1
|
175
|
+
pagination['parts'] << link(page, page)
|
176
|
+
elsif page == page_count - 1
|
177
|
+
pagination['parts'] << link(page, page)
|
178
|
+
elsif (page <= current_page - window_size) || (page >= current_page + window_size)
|
179
|
+
next if hellip_break
|
180
|
+
pagination['parts'] << no_link('…')
|
181
|
+
hellip_break = true
|
182
|
+
next
|
183
|
+
else
|
184
|
+
pagination['parts'] << link(page, page)
|
185
|
+
end
|
186
|
+
|
187
|
+
hellip_break = false
|
188
|
+
end
|
189
|
+
end
|
190
|
+
else
|
191
|
+
pagination = {}
|
192
|
+
pagination['pages'] = 1
|
193
|
+
end
|
194
|
+
|
195
|
+
context['paginate'] = pagination
|
196
|
+
super
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
# rubocop:enable all
|
201
|
+
end
|
202
|
+
end
|