solidify 0.0.1.alpha

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.
Files changed (165) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +40 -0
  5. data/.travis.yml +10 -0
  6. data/CODE_OF_CONDUCT.md +74 -0
  7. data/Gemfile +3 -0
  8. data/Guardfile +51 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +75 -0
  11. data/Rakefile +42 -0
  12. data/app/controllers/concerns/solidify/liquid.rb +26 -0
  13. data/app/controllers/solidify/addresses_controller.rb +15 -0
  14. data/app/controllers/solidify/carts_controller.rb +15 -0
  15. data/app/controllers/solidify/collections_controller.rb +26 -0
  16. data/app/controllers/solidify/customers_controller.rb +16 -0
  17. data/app/controllers/solidify/home_controller.rb +15 -0
  18. data/app/controllers/solidify/liquid_controller.rb +25 -0
  19. data/app/controllers/solidify/orders_controller.rb +19 -0
  20. data/app/controllers/solidify/pages_controller.rb +22 -0
  21. data/app/controllers/solidify/products_controller.rb +34 -0
  22. data/app/controllers/solidify/registrations_controller.rb +25 -0
  23. data/app/controllers/solidify/responders/solidify/liquid_responder.rb +29 -0
  24. data/app/controllers/solidify/search_controller.rb +41 -0
  25. data/app/controllers/solidify/sessions_controller.rb +15 -0
  26. data/app/drops/rails_settings/scoped_settings_drop.rb +11 -0
  27. data/app/drops/solidify/errors_drop.rb +14 -0
  28. data/app/drops/solidify/link_drop.rb +15 -0
  29. data/app/drops/solidify/link_list_drop.rb +7 -0
  30. data/app/drops/solidify/nil_drop.rb +7 -0
  31. data/app/drops/solidify/page_drop.rb +7 -0
  32. data/app/drops/solidify/search_drop.rb +7 -0
  33. data/app/drops/spree/address_drop.rb +28 -0
  34. data/app/drops/spree/image_drop.rb +32 -0
  35. data/app/drops/spree/line_item_drop.rb +98 -0
  36. data/app/drops/spree/option_type_drop.rb +4 -0
  37. data/app/drops/spree/order_drop.rb +64 -0
  38. data/app/drops/spree/product_drop.rb +97 -0
  39. data/app/drops/spree/taxon_drop.rb +53 -0
  40. data/app/drops/spree/user_drop.rb +54 -0
  41. data/app/drops/spree/variant_drop.rb +111 -0
  42. data/app/fields/spree/address_fields.rb +18 -0
  43. data/app/fields/spree/image_fields.rb +12 -0
  44. data/app/fields/spree/line_item_fields.rb +21 -0
  45. data/app/fields/spree/order_fields.rb +22 -0
  46. data/app/fields/spree/product_fields.rb +22 -0
  47. data/app/fields/spree/taxon_fields.rb +18 -0
  48. data/app/fields/spree/user_fields.rb +14 -0
  49. data/app/fields/spree/variant_fields.rb +19 -0
  50. data/app/filters/solidify/additional_filters.rb +22 -0
  51. data/app/filters/solidify/html_filters.rb +16 -0
  52. data/app/filters/solidify/money_filters.rb +39 -0
  53. data/app/filters/solidify/string_filters.rb +47 -0
  54. data/app/filters/solidify/url_filters.rb +59 -0
  55. data/app/helpers/solidify/liquid_helper.rb +111 -0
  56. data/app/helpers/solidify/shop_helper.rb +7 -0
  57. data/app/models/concerns/solidify/address.rb +15 -0
  58. data/app/models/concerns/solidify/full_name.rb +11 -0
  59. data/app/models/concerns/solidify/handle.rb +25 -0
  60. data/app/models/concerns/solidify/inventory_policy.rb +7 -0
  61. data/app/models/concerns/solidify/validation_cancel.rb +33 -0
  62. data/app/models/concerns/spree/order_state.rb +19 -0
  63. data/app/models/solidify/asset.rb +12 -0
  64. data/app/models/solidify/link.rb +10 -0
  65. data/app/models/solidify/link_list.rb +7 -0
  66. data/app/models/solidify/page.rb +5 -0
  67. data/app/models/solidify/setting.rb +8 -0
  68. data/app/models/solidify/theme.rb +19 -0
  69. data/app/models/spree/address_decorator.rb +13 -0
  70. data/app/models/spree/image_decorator.rb +7 -0
  71. data/app/models/spree/line_item_decorator.rb +7 -0
  72. data/app/models/spree/order_decorator.rb +10 -0
  73. data/app/models/spree/product_decorator.rb +8 -0
  74. data/app/models/spree/taxon_decorator.rb +20 -0
  75. data/app/models/spree/user_decorator.rb +9 -0
  76. data/app/models/spree/variant_decorator.rb +11 -0
  77. data/app/poro/solidify/search.rb +14 -0
  78. data/app/services/solidify/app_specific_string_io.rb +15 -0
  79. data/app/services/solidify/asset_compiler.rb +11 -0
  80. data/app/services/solidify/asset_postprocessor.rb +53 -0
  81. data/app/services/solidify/collections_all_builder.rb +12 -0
  82. data/app/services/solidify/link_list_seeder.rb +26 -0
  83. data/app/services/solidify/liquid_asset_compiler.rb +19 -0
  84. data/app/services/solidify/scss_asset_compiler.rb +15 -0
  85. data/app/services/solidify/shop_settings_seeder.rb +26 -0
  86. data/app/services/solidify/theme_mechanic.rb +30 -0
  87. data/app/uploaders/solidify/asset_uploader.rb +10 -0
  88. data/app/views/solidify/global/content_for_header.html.erb +0 -0
  89. data/app/views/solidify/themes/skeleton-theme/README.md +54 -0
  90. data/app/views/solidify/themes/skeleton-theme/assets/arrow-down.svg.liquid +3 -0
  91. data/app/views/solidify/themes/skeleton-theme/assets/cart.svg.liquid +4 -0
  92. data/app/views/solidify/themes/skeleton-theme/assets/shop.js.liquid +75 -0
  93. data/app/views/solidify/themes/skeleton-theme/assets/shopify_common.js +14 -0
  94. data/app/views/solidify/themes/skeleton-theme/assets/style.scss.liquid +768 -0
  95. data/app/views/solidify/themes/skeleton-theme/config/settings.html +217 -0
  96. data/app/views/solidify/themes/skeleton-theme/config/settings_data.json +26 -0
  97. data/app/views/solidify/themes/skeleton-theme/layout/theme.liquid +181 -0
  98. data/app/views/solidify/themes/skeleton-theme/snippets/article-grid-item.liquid +73 -0
  99. data/app/views/solidify/themes/skeleton-theme/snippets/collection-grid-item.liquid +46 -0
  100. data/app/views/solidify/themes/skeleton-theme/snippets/collection-listing.liquid +46 -0
  101. data/app/views/solidify/themes/skeleton-theme/snippets/open-graph-tags.liquid +35 -0
  102. data/app/views/solidify/themes/skeleton-theme/snippets/product-grid-item.liquid +70 -0
  103. data/app/views/solidify/themes/skeleton-theme/snippets/site-nav.liquid +57 -0
  104. data/app/views/solidify/themes/skeleton-theme/snippets/social-links.liquid +42 -0
  105. data/app/views/solidify/themes/skeleton-theme/snippets/twitter-card.liquid +41 -0
  106. data/app/views/solidify/themes/skeleton-theme/templates/404.liquid +2 -0
  107. data/app/views/solidify/themes/skeleton-theme/templates/article.liquid +160 -0
  108. data/app/views/solidify/themes/skeleton-theme/templates/blog.grid.liquid +30 -0
  109. data/app/views/solidify/themes/skeleton-theme/templates/blog.liquid +92 -0
  110. data/app/views/solidify/themes/skeleton-theme/templates/cart.liquid +123 -0
  111. data/app/views/solidify/themes/skeleton-theme/templates/collection.liquid +102 -0
  112. data/app/views/solidify/themes/skeleton-theme/templates/customers/account.liquid +57 -0
  113. data/app/views/solidify/themes/skeleton-theme/templates/customers/activate_account.liquid +26 -0
  114. data/app/views/solidify/themes/skeleton-theme/templates/customers/addresses.liquid +173 -0
  115. data/app/views/solidify/themes/skeleton-theme/templates/customers/login.liquid +90 -0
  116. data/app/views/solidify/themes/skeleton-theme/templates/customers/order.liquid +103 -0
  117. data/app/views/solidify/themes/skeleton-theme/templates/customers/register.liquid +32 -0
  118. data/app/views/solidify/themes/skeleton-theme/templates/customers/reset_password.liquid +27 -0
  119. data/app/views/solidify/themes/skeleton-theme/templates/index.liquid +39 -0
  120. data/app/views/solidify/themes/skeleton-theme/templates/list-collections.liquid +19 -0
  121. data/app/views/solidify/themes/skeleton-theme/templates/page.liquid +16 -0
  122. data/app/views/solidify/themes/skeleton-theme/templates/product.liquid +202 -0
  123. data/app/views/solidify/themes/skeleton-theme/templates/search.liquid +72 -0
  124. data/bin/rails +12 -0
  125. data/config/app.yml +0 -0
  126. data/config/initializers/carrierwave.rb +25 -0
  127. data/config/initializers/devise.rb +286 -0
  128. data/config/initializers/form_tag.rb +43 -0
  129. data/config/initializers/liquid.rb +213 -0
  130. data/config/initializers/sass.rb +15 -0
  131. data/config/initializers/spree.rb +7 -0
  132. data/config/initializers/theme_settings.rb +29 -0
  133. data/config/routes.rb +52 -0
  134. data/config/spring.rb +2 -0
  135. data/db/migrate/20170223064316_create_solidify_assets.solidify.rb +14 -0
  136. data/db/migrate/20170223064317_create_solidify_themes.solidify.rb +10 -0
  137. data/db/migrate/20170223064318_create_solidify_link_lists.solidify.rb +12 -0
  138. data/db/migrate/20170223064319_create_solidify_links.solidify.rb +13 -0
  139. data/db/migrate/20170223064320_create_solidify_settings.solidify.rb +22 -0
  140. data/db/migrate/20170223064321_create_solidify_pages.solidify.rb +16 -0
  141. data/db/migrate/20170223064322_add_attributes_to_spree_users.solidify.rb +7 -0
  142. data/db/migrate/20170223064323_add_handle_to_spree_taxons.solidify.rb +7 -0
  143. data/db/migrate/20170228115149_add_state_and_country_fields_to_spree_addresses.solidify.rb +7 -0
  144. data/lib/generators/solidify/install/install_generator.rb +23 -0
  145. data/lib/solidify.rb +11 -0
  146. data/lib/solidify/configuration.rb +21 -0
  147. data/lib/solidify/engine.rb +24 -0
  148. data/lib/solidify/testing_support/factories.rb +5 -0
  149. data/lib/solidify/testing_support/factories/assets.rb +75 -0
  150. data/lib/solidify/testing_support/factories/solidify_pages.rb +10 -0
  151. data/lib/solidify/testing_support/factories/spree_addresses.rb +9 -0
  152. data/lib/solidify/testing_support/factories/spree_line_items.rb +10 -0
  153. data/lib/solidify/testing_support/factories/spree_orders.rb +9 -0
  154. data/lib/solidify/testing_support/factories/spree_products.rb +8 -0
  155. data/lib/solidify/testing_support/factories/spree_taxons.rb +7 -0
  156. data/lib/solidify/testing_support/factories/spree_variants.rb +7 -0
  157. data/lib/solidify/testing_support/factories/themes.rb +7 -0
  158. data/lib/solidify/version.rb +3 -0
  159. data/lib/tasks/download_theme.rake +18 -0
  160. data/lib/tasks/seed_default_theme.rake +8 -0
  161. data/lib/tasks/seed_everything.rake +12 -0
  162. data/lib/tasks/seed_link_list.rake +8 -0
  163. data/lib/tasks/seed_shop_settings.rake +8 -0
  164. data/solidify.gemspec +61 -0
  165. metadata +668 -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/solidify/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,213 @@
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 pages settings).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
+
56
+ variable_name = if @lookups.blank?
57
+ "#{name}.#{key}"
58
+ else
59
+ "#{name}.#{@lookups.join('.')}"
60
+ end
61
+ raise Liquid::UndefinedVariable, "undefined variable #{variable_name}"
62
+ end
63
+
64
+ # If we are dealing with a drop here we have to
65
+ object.context = context if object.respond_to?(:context=)
66
+ end
67
+
68
+ object
69
+ end
70
+ end
71
+
72
+ module StandardFilters
73
+ require 'cgi'
74
+ def escape(input)
75
+ CGI.escapeHTML(input.to_s).untaint unless input.nil?
76
+ end
77
+ end
78
+ end
79
+
80
+ module Liquid
81
+ module Rails
82
+ class Drop
83
+ # rubocop:disable all
84
+ def liquid_method_missing(method)
85
+ if method.blank?
86
+ # This prevents for the case like this: collections[nil]
87
+ # {% assign product_vendor_handle = product.vendor | handle %}
88
+ # {% assign collection_handle = collections[product_vendor_handle].handle %}
89
+ ::Solidify::NilDrop.new(nil)
90
+ else
91
+ return nil unless @context && @context.strict_variables
92
+ raise Liquid::UndefinedDropMethod, "undefined method #{method} for #{self.class}"
93
+ end
94
+ end
95
+ # rubocop:enable all
96
+
97
+ def to_s
98
+ self.class.name.demodulize
99
+ end
100
+ end
101
+
102
+ class FileSystem < ::Liquid::LocalFileSystem
103
+ def read_template_file(template_path, context)
104
+ @pattern = @pattern.gsub(/^_/, '')
105
+ theme = context.registers[:theme]
106
+ template_path = "themes/#{theme.id}/snippets/#{template_path}"
107
+
108
+ super
109
+ end
110
+ end
111
+
112
+ class TemplateHandler
113
+ # rubocop:disable all
114
+ def render(template, local_assigns = {})
115
+ @view.controller.headers['Content-Type'] ||= 'text/html; charset=utf-8'
116
+
117
+ assigns = if @controller.respond_to?(:liquid_assigns, true)
118
+ @controller.send(:liquid_assigns)
119
+ else
120
+ @view.assigns
121
+ end
122
+ assigns['content_for_layout'] = @view.content_for(:layout) if @view.content_for?(:layout)
123
+ assigns.merge!(local_assigns.stringify_keys)
124
+
125
+ liquid = Liquid::Template.parse(template)
126
+ # rubocop:enable all
127
+ render_method = :render
128
+ rendered_template = liquid.public_send(
129
+ render_method,
130
+ assigns,
131
+ filters: filters,
132
+ # strict_variables: true,
133
+ # strict_filters: true,
134
+ registers: {
135
+ view: @view, controller: @controller, helper: @helper,
136
+ theme: @view.assigns['theme']
137
+ }
138
+ )
139
+
140
+ if liquid.errors.present?
141
+ if ::Rails.env.development? || ::Rails.env.test?
142
+ errors_text = liquid.errors.map(&:to_s).join("\n")
143
+ ::Rails.logger.error(errors_text)
144
+ end
145
+
146
+ raise liquid.errors.first
147
+ end
148
+
149
+ rendered_template
150
+ end
151
+ end
152
+
153
+ # rubocop:disable all
154
+ class PaginateTag < ::Liquid::Block
155
+ def render(context)
156
+ @context = context
157
+
158
+ context.stack do
159
+ collection = @context[@collection_name].presence || @context.environments[0][@collection_name]
160
+
161
+ if collection.present?
162
+ if collection.is_a? Array
163
+ paginated_collection = Kaminari.paginate_array(collection.to_a).page(current_page).per(@page_size)
164
+ elsif collection.respond_to?(:page)
165
+ paginated_collection = collection.page(current_page).per(@page_size)
166
+ end
167
+
168
+ page_count = paginated_collection.total_pages
169
+ pagination = {}
170
+ pagination['collection'] = paginated_collection
171
+ pagination['current_offset'] = (current_page - 1) * @page_size
172
+ pagination['current_page'] = current_page
173
+ pagination['page_size'] = @page_size
174
+ pagination['pages'] = page_count
175
+ pagination['items'] = paginated_collection.total_count
176
+ pagination['previous'] = link('&laquo; Previous'.html_safe, current_page - 1) unless 1 >= current_page
177
+ pagination['next'] = link('Next &raquo;'.html_safe, current_page + 1) unless page_count < current_page + 1
178
+ pagination['parts'] = []
179
+
180
+ hellip_break = false
181
+ if page_count > 1
182
+ 1.upto(page_count) do |page|
183
+ if current_page == page
184
+ pagination['parts'] << no_link(page)
185
+ elsif page == 1
186
+ pagination['parts'] << link(page, page)
187
+ elsif page == page_count - 1
188
+ pagination['parts'] << link(page, page)
189
+ elsif (page <= current_page - window_size) || (page >= current_page + window_size)
190
+ next if hellip_break
191
+ pagination['parts'] << no_link('&hellip;')
192
+ hellip_break = true
193
+ next
194
+ else
195
+ pagination['parts'] << link(page, page)
196
+ end
197
+
198
+ hellip_break = false
199
+ end
200
+ end
201
+ else
202
+ pagination = {}
203
+ pagination['pages'] = 1
204
+ end
205
+
206
+ context['paginate'] = pagination
207
+ super
208
+ end
209
+ end
210
+ end
211
+ # rubocop:enable all
212
+ end
213
+ end