workarea-cart_sharing 1.0.0.pre → 1.0.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +21 -0
- data/Gemfile +17 -0
- data/LICENSE +52 -0
- data/README.md +40 -0
- data/Rakefile +56 -0
- data/app/assets/javascripts/workarea/storefront/cart_sharing/copy_text.js +37 -0
- data/app/assets/stylesheets/workarea/storefront/cart_sharing/_cart_sharing.scss +27 -0
- data/app/controllers/workarea/storefront/carts_controller.decorator +14 -0
- data/app/controllers/workarea/storefront/shares_controller.decorator +16 -0
- data/app/models/workarea/order.decorator +7 -0
- data/app/view_models/workarea/storefront/cart_view_model.decorator +7 -0
- data/app/views/workarea/storefront/carts/_sharable.html.haml +22 -0
- data/bin/rails +25 -0
- data/config/initializers/appends.rb +14 -0
- data/config/initializers/sharable_token.rb +24 -0
- data/config/initializers/workarea.rb +3 -0
- data/config/locales/en.yml +9 -0
- data/config/routes.rb +8 -0
- data/lib/workarea/cart_sharing.rb +8 -0
- data/lib/workarea/cart_sharing/engine.rb +10 -0
- data/lib/workarea/cart_sharing/version.rb +5 -0
- data/test/dummy/.ruby-version +1 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/config/manifest.js +2 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +2 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/javascript/packs/application.js +14 -0
- data/test/dummy/app/jobs/application_job.rb +7 -0
- data/test/dummy/app/mailers/application_mailer.rb +4 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +25 -0
- data/test/dummy/config.ru +5 -0
- data/test/dummy/config/application.rb +33 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +53 -0
- data/test/dummy/config/environments/production.rb +101 -0
- data/test/dummy/config/environments/test.rb +47 -0
- data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/test/dummy/config/initializers/assets.rb +12 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/content_security_policy.rb +28 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/workarea.rb +5 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +9 -0
- data/test/dummy/config/locales/en.yml +33 -0
- data/test/dummy/config/puma.rb +38 -0
- data/test/dummy/config/routes.rb +5 -0
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/db/seeds.rb +2 -0
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/teaspoon_env.rb +6 -0
- data/test/test_helper.rb +10 -0
- data/workarea-cart_sharing.gemspec +19 -0
- metadata +68 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4ba3d216ce9bf1d7af95162a75dcfd962c386a76b17a2078645cc6a52d63315
|
4
|
+
data.tar.gz: cd0d2215153750fef71738302811f7d4251cb39dfc0e8c6a94aaa16a29389f20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 053bb7c79ec1a2065455337a43d13ca4566b9c05e1903fad9ac66aefd71dbafcf7b09576f71ea7f54e56fd930559fb5046061787ac5cdcc51ac01ed9adf5077c
|
7
|
+
data.tar.gz: 611e36e00ba7a8d13e210c17aeb4eec6a7e6a73025ba4cbd50a34e599bbe2fe7ef188c867e133fb2b734b0f87e1cb315c09277a3acb5e63e53b654de4a387a9e
|
data/.gitignore
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
.bundle/
|
2
|
+
log/*.log
|
3
|
+
pkg/
|
4
|
+
test/dummy/log/*.log
|
5
|
+
test/dummy/tmp/
|
6
|
+
.DS_Store
|
7
|
+
.byebug_history
|
8
|
+
.bundle/
|
9
|
+
.sass-cache/
|
10
|
+
Gemfile.lock
|
11
|
+
pkg/
|
12
|
+
test/dummy/tmp/
|
13
|
+
test/dummy/public/
|
14
|
+
log/*.log
|
15
|
+
test/dummy/log/*.log
|
16
|
+
test/dummy/db/*.sqlite3
|
17
|
+
test/dummy/db/*.sqlite3-journal
|
18
|
+
node_modules
|
19
|
+
yarn.lock
|
20
|
+
yarn-error.log
|
21
|
+
package-lock.json
|
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
3
|
+
|
4
|
+
# Declare your gem's dependencies in cart_sharing.gemspec.
|
5
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
6
|
+
# development dependencies will be added by default to the :development group.
|
7
|
+
gemspec
|
8
|
+
|
9
|
+
# Declare any dependencies that are still in development here instead of in
|
10
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
11
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
12
|
+
# your gem to rubygems.org.
|
13
|
+
|
14
|
+
# To use a debugger
|
15
|
+
# gem 'byebug', group: [:development, :test]
|
16
|
+
|
17
|
+
gem 'workarea', github: 'workarea-commerce/workarea'
|
data/LICENSE
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
WebLinc
|
2
|
+
Business Source License
|
3
|
+
|
4
|
+
Licensor: WebLinc Corporation, 22 S. 3rd Street, 2nd Floor, Philadelphia PA 19106
|
5
|
+
|
6
|
+
Licensed Work: Workarea Commerce Platform
|
7
|
+
The Licensed Work is (c) 2019 WebLinc Corporation
|
8
|
+
|
9
|
+
Additional Use Grant:
|
10
|
+
You may make production use of the Licensed Work without an additional license agreement with WebLinc so long as you do not use the Licensed Work for a Commerce Service.
|
11
|
+
|
12
|
+
A "Commerce Service" is a commercial offering that allows third parties (other than your employees and contractors) to access the functionality of the Licensed Work by creating or managing commerce functionality, the products, taxonomy, assets and/or content of which are controlled by such third parties.
|
13
|
+
|
14
|
+
For information about obtaining an additional license agreement with WebLinc, contact licensing@workarea.com.
|
15
|
+
|
16
|
+
Change Date: 2019-08-20
|
17
|
+
|
18
|
+
Change License: Version 2.0 or later of the GNU General Public License as published by the Free Software Foundation
|
19
|
+
|
20
|
+
Terms
|
21
|
+
|
22
|
+
The Licensor hereby grants you the right to copy, modify, create derivative works, redistribute, and make non-production use of the Licensed Work. The Licensor may make an Additional Use Grant, above, permitting limited production use.
|
23
|
+
|
24
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly available distribution of a specific version of the Licensed Work under this License, whichever comes first, the Licensor hereby grants you rights under the terms of the Change License, and the rights granted in the paragraph above terminate.
|
25
|
+
|
26
|
+
If your use of the Licensed Work does not comply with the requirements currently in effect as described in this License, you must purchase a commercial license from the Licensor, its affiliated entities, or authorized resellers, or you must refrain from using the Licensed Work.
|
27
|
+
|
28
|
+
All copies of the original and modified Licensed Work, and derivative works of the Licensed Work, are subject to this License. This License applies separately for each version of the Licensed Work and the Change Date may vary for each version of the Licensed Work released by Licensor.
|
29
|
+
|
30
|
+
You must conspicuously display this License on each original or modified copy of the Licensed Work. If you receive the Licensed Work in original or modified form from a third party, the terms and conditions set forth in this License apply to your use of that work.
|
31
|
+
|
32
|
+
Any use of the Licensed Work in violation of this License will automatically terminate your rights under this License for the current and all other versions of the Licensed Work.
|
33
|
+
|
34
|
+
This License does not grant you any right in any trademark or logo of Licensor or its affiliates (provided that you may use a trademark or logo of Licensor as expressly required by this License). TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND TITLE. MariaDB hereby grants you permission to use this License’s text to license your works and to refer to it using the trademark "Business Source License" as long as you comply with the Covenants of Licensor below.
|
35
|
+
|
36
|
+
Covenants of Licensor
|
37
|
+
In consideration of the right to use this License’s text and the "Business Source License" name and trademark, Licensor covenants to MariaDB, and to all other recipients of the licensed work to be provided by Licensor:
|
38
|
+
|
39
|
+
To specify as the Change License the GPL Version 2.0 or any later version, or a license that is compatible with GPL Version 2.0 or a later version, where "compatible" means that software provided under the Change License can be included in a program with software provided under GPL Version 2.0 or a later version. Licensor may specify additional Change Licenses without limitation.
|
40
|
+
|
41
|
+
To either: (a) specify an additional grant of rights to use that does not impose any additional restriction on the right granted in this License, as the Additional Use Grant; or (b) insert the text "None."
|
42
|
+
|
43
|
+
To specify a Change Date.
|
44
|
+
|
45
|
+
Not to modify this License in any other way.
|
46
|
+
|
47
|
+
Notice
|
48
|
+
The Business Source License (this document, or the "License") is not an Open Source license. However, the Licensed Work will eventually be made available under an Open Source License, as stated in this License.
|
49
|
+
|
50
|
+
For more information on the use of the Business Source License generally, please visit the Adopting and Developing Business Source License FAQ.
|
51
|
+
|
52
|
+
License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved. "Business Source License" is a trademark of MariaDB Corporation Ab.
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
Workarea Cart Sharing
|
2
|
+
================================================================================
|
3
|
+
|
4
|
+
Cart Sharing plugin for the Workarea platform.
|
5
|
+
|
6
|
+
Overview
|
7
|
+
--------------------------------------------------------------------------------
|
8
|
+
|
9
|
+
1. TODO
|
10
|
+
|
11
|
+
Getting Started
|
12
|
+
--------------------------------------------------------------------------------
|
13
|
+
|
14
|
+
This gem contains a Rails engine that must be mounted onto a host Rails application.
|
15
|
+
|
16
|
+
Then add the gem to your application's Gemfile specifying the source:
|
17
|
+
|
18
|
+
# ...
|
19
|
+
gem 'workarea-cart_sharing'
|
20
|
+
# ...
|
21
|
+
|
22
|
+
Update your application's bundle.
|
23
|
+
|
24
|
+
cd path/to/application
|
25
|
+
bundle
|
26
|
+
|
27
|
+
Features
|
28
|
+
--------------------------------------------------------------------------------
|
29
|
+
|
30
|
+
### TODO
|
31
|
+
|
32
|
+
Workarea Platform Documentation
|
33
|
+
--------------------------------------------------------------------------------
|
34
|
+
|
35
|
+
See [https://developer.workarea.com](https://developer.workarea.com) for Workarea platform documentation.
|
36
|
+
|
37
|
+
License
|
38
|
+
--------------------------------------------------------------------------------
|
39
|
+
|
40
|
+
Workarea Cart Sharing is released under the [Business Software License](LICENSE)
|
data/Rakefile
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
9
|
+
rdoc.rdoc_dir = 'rdoc'
|
10
|
+
rdoc.title = 'Cart Sharing'
|
11
|
+
rdoc.options << '--line-numbers'
|
12
|
+
rdoc.rdoc_files.include('README.md')
|
13
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
14
|
+
end
|
15
|
+
|
16
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
17
|
+
load 'rails/tasks/engine.rake'
|
18
|
+
load 'rails/tasks/statistics.rake'
|
19
|
+
load 'workarea/changelog.rake'
|
20
|
+
|
21
|
+
require 'rake/testtask'
|
22
|
+
Rake::TestTask.new(:test) do |t|
|
23
|
+
t.libs << 'lib'
|
24
|
+
t.libs << 'test'
|
25
|
+
t.pattern = 'test/**/*_test.rb'
|
26
|
+
t.verbose = false
|
27
|
+
end
|
28
|
+
task default: :test
|
29
|
+
|
30
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
31
|
+
require 'workarea/cart_sharing/version'
|
32
|
+
|
33
|
+
desc "Release version #{Workarea::CartSharing::VERSION} of the gem"
|
34
|
+
task :release do
|
35
|
+
Rake::Task['workarea:changelog'].execute
|
36
|
+
system 'git add CHANGELOG.md'
|
37
|
+
system 'git commit -m "Update CHANGELOG"'
|
38
|
+
|
39
|
+
system "git tag -a v#{Workarea::CartSharing::VERSION} -m 'Tagging #{Workarea::CartSharing::VERSION}'"
|
40
|
+
system 'git push origin HEAD --follow-tags'
|
41
|
+
|
42
|
+
system "gem build workarea-cart_sharing.gemspec"
|
43
|
+
system "gem push workarea-cart_sharing-#{Workarea::CartSharing::VERSION}.gem"
|
44
|
+
system "rm workarea-cart_sharing-#{Workarea::CartSharing::VERSION}.gem"
|
45
|
+
end
|
46
|
+
|
47
|
+
desc 'Run the JavaScript tests'
|
48
|
+
ENV['TEASPOON_RAILS_ENV'] = File.expand_path('../test/dummy/config/environment', __FILE__)
|
49
|
+
task teaspoon: 'app:teaspoon'
|
50
|
+
|
51
|
+
desc 'Start a server at http://localhost:3000/teaspoon for JavaScript tests'
|
52
|
+
task :teaspoon_server do
|
53
|
+
Dir.chdir("test/dummy")
|
54
|
+
teaspoon_env = File.expand_path('../test/teaspoon_env.rb', __FILE__)
|
55
|
+
system "RAILS_ENV=test TEASPOON_ENV=#{teaspoon_env} rails s"
|
56
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
/**
|
2
|
+
* @namespace WORKAREA.copyText
|
3
|
+
*/
|
4
|
+
WORKAREA.registerModule('copyText', (function () {
|
5
|
+
'use strict';
|
6
|
+
|
7
|
+
var
|
8
|
+
|
9
|
+
/**
|
10
|
+
* @method
|
11
|
+
* @name init
|
12
|
+
* @memberof WORKAREA.copyText
|
13
|
+
*/
|
14
|
+
handleCopyText = function(e) {
|
15
|
+
var elem = $(e.target),
|
16
|
+
source = elem.attr('data-copy-text'),
|
17
|
+
sourceElem = $(source)[0];
|
18
|
+
|
19
|
+
/* Select the text field */
|
20
|
+
sourceElem.select();
|
21
|
+
sourceElem.setSelectionRange(0, 99999); /*For mobile devices*/
|
22
|
+
|
23
|
+
document.execCommand("copy");
|
24
|
+
|
25
|
+
elem.fadeOut();
|
26
|
+
elem.fadeIn();
|
27
|
+
elem.html("Copied!");
|
28
|
+
|
29
|
+
},
|
30
|
+
init = function ($scope) {
|
31
|
+
$('[data-copy-text]',$scope).on("click", handleCopyText);
|
32
|
+
};
|
33
|
+
|
34
|
+
return {
|
35
|
+
init: init
|
36
|
+
};
|
37
|
+
}()));
|
@@ -0,0 +1,27 @@
|
|
1
|
+
$cart-share-bg: #f8f8f8 !default;
|
2
|
+
|
3
|
+
.cart-sharing {
|
4
|
+
background-color: $cart-share-bg;
|
5
|
+
.share-buttons {
|
6
|
+
&__items {
|
7
|
+
margin-right: $horizontal-margin;
|
8
|
+
display: inline-block;
|
9
|
+
vertical-align: middle;
|
10
|
+
}
|
11
|
+
}
|
12
|
+
.cart-sharing__copy {
|
13
|
+
text-decoration: underline;
|
14
|
+
margin-left: $spacing-unit;
|
15
|
+
}
|
16
|
+
.cart-sharing__link {
|
17
|
+
color: $black;
|
18
|
+
cursor: auto;
|
19
|
+
white-space: nowrap;
|
20
|
+
overflow: hidden;
|
21
|
+
text-overflow: ellipsis;
|
22
|
+
}
|
23
|
+
.share-buttons__list {
|
24
|
+
text-align: left;
|
25
|
+
padding: 0;
|
26
|
+
}
|
27
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Workarea
|
2
|
+
decorate Storefront::CartsController, with: :cart_sharing do
|
3
|
+
def from
|
4
|
+
if order = Order.find_by(sharable_token: params[:token]) rescue nil
|
5
|
+
self.current_order = order
|
6
|
+
flash[:success] = t('workarea.storefront.cart_sharing.success')
|
7
|
+
else
|
8
|
+
flash[:error] = t('workarea.storefront.cart_sharing.failure')
|
9
|
+
end
|
10
|
+
|
11
|
+
redirect_to cart_path
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Workarea
|
2
|
+
decorate Storefront::SharesController, with: :cart_sharing do
|
3
|
+
def create
|
4
|
+
if verify_recaptcha(model: @share, env: Rails.env) && @share.save
|
5
|
+
flash[:success] = t(
|
6
|
+
'workarea.storefront.flash_messages.share_message_sent',
|
7
|
+
recipient: @share.friendly_to
|
8
|
+
)
|
9
|
+
Storefront::ShareMailer.share(@share.id.to_s).deliver_later
|
10
|
+
redirect_to @share.url.include?("cart/from") ? cart_url : @share.url
|
11
|
+
else
|
12
|
+
render :new
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
- if @cart.sharable_cart_token.present?
|
2
|
+
.grid__cell.grid__cell--50-at-wide.grid__cell--70-at-medium
|
3
|
+
.cart-sharing.data-card
|
4
|
+
- share_url = from_cart_url(@cart.sharable_cart_token)
|
5
|
+
- message = t('workarea.storefront.cart_sharing.message')
|
6
|
+
%h4.heading.heading--4.cart-sharing__heading= t('workarea.storefront.cart_sharing.title')
|
7
|
+
%p
|
8
|
+
= text_field_tag "Sharable URL", share_url, class: 'cart-sharing__link', readonly: true, id: nil, data: {sharable_url:""}
|
9
|
+
= link_to "Copy Link", "javascript:;", class: "text-button cart-sharing__copy", id: nil, data: {copy_text:"[data-sharable-url]"}
|
10
|
+
|
11
|
+
%ul.share-buttons__list
|
12
|
+
%li.share-buttons__items
|
13
|
+
= link_to new_share_path(url: share_url, message: message, title: share_url, source: cart_url), class: 'button button--secondary', rel: 'nofollow', title: t('workarea.storefront.shares.share_by_email'), data: { dialog_button: '', analytics: share_analytics_data('email', share_url).to_json } do
|
14
|
+
= inline_svg('workarea/storefront/share/icons/email.svg', class: 'svg-icon svg-icon--large')
|
15
|
+
= t('workarea.storefront.cart_sharing.email')
|
16
|
+
%li.share-buttons__items= "(or)"
|
17
|
+
%li.share-buttons__items.share-buttons__item
|
18
|
+
= link_to "https://www.facebook.com/sharer/sharer.php?#{facebook_query_string(share_url)}", class: 'share-buttons__button', title: t('workarea.storefront.shares.share_on_facebook'), target: '_blank', data: { popup_button: '', analytics: share_analytics_data('facebook', share_url).to_json } do
|
19
|
+
= inline_svg('workarea/storefront/icons/facebook.svg', class: 'share-buttons__social-icon')
|
20
|
+
%li.share-buttons__items.share-buttons__item
|
21
|
+
= link_to "https://twitter.com/intent/tweet?#{twitter_query_string(share_url, message)}", class: 'share-buttons__button', title: t('workarea.storefront.shares.share_on_twitter'), target: '_blank', data: { popup_button: '', analytics: share_analytics_data('twitter', share_url).to_json } do
|
22
|
+
= inline_svg('workarea/storefront/icons/twitter.svg', class: 'share-buttons__social-icon')
|
data/bin/rails
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails gems
|
3
|
+
# installed from the root of your application.
|
4
|
+
|
5
|
+
ENGINE_ROOT = File.expand_path('..', __dir__)
|
6
|
+
ENGINE_PATH = File.expand_path('../lib/workarea/cart_sharing/engine', __dir__)
|
7
|
+
APP_PATH = File.expand_path('../test/dummy/config/application', __dir__)
|
8
|
+
|
9
|
+
# Set up gems listed in the Gemfile.
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
|
11
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
12
|
+
|
13
|
+
require "rails"
|
14
|
+
# Pick the frameworks you want:
|
15
|
+
require "active_model/railtie"
|
16
|
+
require "active_job/railtie"
|
17
|
+
# require "active_record/railtie"
|
18
|
+
# require "active_storage/engine"
|
19
|
+
require "action_controller/railtie"
|
20
|
+
require "action_mailer/railtie"
|
21
|
+
require "action_view/railtie"
|
22
|
+
# require "action_cable/engine"
|
23
|
+
require "sprockets/railtie"
|
24
|
+
require "rails/test_unit/railtie"
|
25
|
+
require 'rails/engine/commands'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Workarea
|
2
|
+
Plugin.append_partials(
|
3
|
+
"storefront.cart_additional_information",
|
4
|
+
"workarea/storefront/carts/sharable"
|
5
|
+
)
|
6
|
+
Plugin.append_javascripts(
|
7
|
+
'storefront.modules',
|
8
|
+
'workarea/storefront/cart_sharing/copy_text'
|
9
|
+
)
|
10
|
+
Plugin.append_stylesheets(
|
11
|
+
'storefront.components',
|
12
|
+
'workarea/storefront/cart_sharing/cart_sharing'
|
13
|
+
)
|
14
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Workarea::SharableToken
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
include ActiveRecord::SecureToken
|
5
|
+
|
6
|
+
included do
|
7
|
+
field :sharable_token, type: String
|
8
|
+
index({ sharable_token: 1 }, { unique: true })
|
9
|
+
has_secure_token
|
10
|
+
before_validation :ensure_token_exists
|
11
|
+
end
|
12
|
+
|
13
|
+
module ClassMethods
|
14
|
+
def find_by_token(sharable_token)
|
15
|
+
find_by(sharable_token: sharable_token) rescue nil
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def ensure_token_exists
|
22
|
+
self.sharable_token = self.class.generate_unique_secure_token if sharable_token.blank?
|
23
|
+
end
|
24
|
+
end
|
data/config/routes.rb
ADDED