middleman-foxycart 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +7 -0
- data/Gemfile +16 -0
- data/LICENSE.txt +21 -0
- data/README.md +64 -0
- data/Rakefile +14 -0
- data/features/support/env.rb +4 -0
- data/lib/middleman-foxycart.rb +43 -0
- data/lib/middleman_extension.rb +1 -0
- data/middleman-foxycart.gemspec +23 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 092361e5e4d5be93e2d186fd9b3c0aa6b71bc424
|
4
|
+
data.tar.gz: 32848fd8874a566f35771caa2ca368dafd5cb925
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 89003066c6cd0d63c526e59d6e288a766843d9944fdad819d7d744cf1129968eb086bbc5d5421a996f97bcb35e90f6c26f2f4c9b6db1a8dbb456b3ad7a1e13b6
|
7
|
+
data.tar.gz: 17ee7518c968b5528ab4064b7059623a066b8234f1f2acf279f48987be0d37bfcd3ccc7cb86f678798d3a989b8d9469e4c261121a3d7e81908ffecf76af9e8f8
|
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in middleman-foxycart.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
group :development do
|
7
|
+
gem 'rake'
|
8
|
+
gem 'rdoc'
|
9
|
+
gem 'yard'
|
10
|
+
end
|
11
|
+
|
12
|
+
group :test do
|
13
|
+
gem 'cucumber'
|
14
|
+
gem 'aruba'
|
15
|
+
gem 'rspec'
|
16
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Robert Coleman
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# middleman-foxycart
|
2
|
+
|
3
|
+
A [Middleman](https://middlemanapp.com) extension for use with [FoxyCart](http://www.foxycart.com/).
|
4
|
+
|
5
|
+
__Features__
|
6
|
+
|
7
|
+
* HMAC Product Verification - https://wiki.foxycart.com/v/2.0/hmac_validation
|
8
|
+
* Link href builder (with support for Product Verification)
|
9
|
+
* Generation of the store `loader.js` Javascript URL and HTML.
|
10
|
+
|
11
|
+
|
12
|
+
## Setup and Configuration
|
13
|
+
|
14
|
+
In `config.rb`
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
activate :foxycart do |foxycart|
|
18
|
+
foxycart.api_key = 'your foxycart api key' # also as `ENV['FOXYCART_API_KEY']`
|
19
|
+
foxycart.url = 'https://mystoreurl.foxycart.com' # also as `ENV['FOXYCART_URL']`
|
20
|
+
foxycart.auto_encode_hrefs = true # (default) Use HMAC Product Verification when generating links
|
21
|
+
end
|
22
|
+
```
|
23
|
+
|
24
|
+
## Helper and Usage
|
25
|
+
|
26
|
+
Examples for ERB templates:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
# JS helper, e.g. use in layout.erb
|
30
|
+
<%= foxycart_loader_js %>
|
31
|
+
# => "<script src=\"https://cdn.foxycart.com/example/loader.js\" async defer></script>"
|
32
|
+
|
33
|
+
# URL Helper
|
34
|
+
<%= foxycart_url_for('Cool Example', '10', 'sku123') %>
|
35
|
+
# => "https://example.foxycart.com/cart?name=Cool+Example&price=10&color=red"
|
36
|
+
<%= link_to 'Click the Link', foxycart_url_for('Cool Example', '10', 'sku123') %>
|
37
|
+
# => "<a href=\"https://example.foxycart.com/cart?name=Cool+Example&price=10&color=red\">Click the Link</a>"
|
38
|
+
|
39
|
+
# Product Verification link payloads
|
40
|
+
<%= foxycart_encode 'sku123', 'name', 'Cool Example' %>
|
41
|
+
# => "54a534ba0afef1b4589c2f77f9011e27089c0030a8876ec8f06fca281fedeb89"
|
42
|
+
<%= foxycart_encoded_name 'sku123', 'name', 'Cool Example' %>
|
43
|
+
# => "name||54a534ba0afef1b4589c2f77f9011e27089c0030a8876ec8f06fca281fedeb89"
|
44
|
+
```
|
45
|
+
|
46
|
+
`foxycart_url_for` and the Product Verification helpers arguments are:
|
47
|
+
|
48
|
+
* `code` = Product code (`sku123`)
|
49
|
+
* `name` = Value of name field in the HTML (`name`)
|
50
|
+
* `value` = Value (or initial value) of the input etc (`Cool Example`)
|
51
|
+
|
52
|
+
See the [FoxyCart docs](https://wiki.foxycart.com/v/2.0/hmac_validation) for more information on `code`, `name` and `value`.
|
53
|
+
|
54
|
+
|
55
|
+
## Contributing
|
56
|
+
|
57
|
+
Under the hood uses the gem [`foxycart_helpers`](https://github.com/rjocoleman/foxycart_helpers) (Foxycart helpers for plain Ruby and Rails)- this is just a thin wrapper for Middleman.
|
58
|
+
|
59
|
+
Bug reports and pull requests are welcome on GitHub on this repo if approparte or at https://github.com/rjocoleman/foxycart_helpers.
|
60
|
+
|
61
|
+
|
62
|
+
## License
|
63
|
+
|
64
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
require 'cucumber/rake/task'
|
5
|
+
|
6
|
+
Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
|
7
|
+
t.cucumber_opts = '--color --tags ~@wip --strict'
|
8
|
+
end
|
9
|
+
|
10
|
+
require 'rake/clean'
|
11
|
+
|
12
|
+
task test: ['cucumber']
|
13
|
+
|
14
|
+
task default: :test
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'middleman-core'
|
2
|
+
|
3
|
+
class Foxycart < ::Middleman::Extension
|
4
|
+
option :api_key, ENV['FOXYCART_API_KEY'], 'FoxyCart API key'
|
5
|
+
option :url, ENV['FOXYCART_URL'], 'FoxyCart domain'
|
6
|
+
option :auto_encode_hrefs, true, 'Automatically encode HREFs with product validation hashes?'
|
7
|
+
|
8
|
+
def initialize(app, options_hash={}, &block)
|
9
|
+
super
|
10
|
+
|
11
|
+
require 'foxycart_helpers'
|
12
|
+
|
13
|
+
FoxycartHelpers.configure do |config|
|
14
|
+
config.api_key = options.api_key
|
15
|
+
config.url = options.url
|
16
|
+
config.auto_encode_hrefs = options.auto_encode_hrefs
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
helpers do
|
21
|
+
def foxycart_encode(code, name, value)
|
22
|
+
FoxycartHelpers::ProductVerification.encode code, name, value
|
23
|
+
end
|
24
|
+
|
25
|
+
def foxycart_encoded_name(code, name, value)
|
26
|
+
FoxycartHelpers::ProductVerification.encoded_name code, name, value
|
27
|
+
end
|
28
|
+
|
29
|
+
def foxycart_url_for(name, price, code=nil, opts={})
|
30
|
+
FoxycartHelpers::Link.href name, price, code, opts
|
31
|
+
end
|
32
|
+
|
33
|
+
def foxycart_loader_js_url
|
34
|
+
FoxycartHelpers::Javascript.url
|
35
|
+
end
|
36
|
+
|
37
|
+
def foxycart_loader_js
|
38
|
+
FoxycartHelpers::Javascript.html_element
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
Foxycart.register(:foxycart)
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'middleman-foxycart'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'middleman-foxycart'
|
6
|
+
s.version = '0.1.0'
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ['Robert Coleman']
|
9
|
+
s.email = ['github@robert.net.nz']
|
10
|
+
s.homepage = 'https://github.com/rjocoleman/middleman-foxycart'
|
11
|
+
s.summary = %q{FoxyCart helpers for Middleman static sites}
|
12
|
+
s.description = %q{FoxyCart helpers for Middleman static sites}
|
13
|
+
s.license = 'MIT'
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
s.require_paths = ['lib']
|
19
|
+
|
20
|
+
s.add_runtime_dependency 'middleman-core', '>= 3.4.0'
|
21
|
+
|
22
|
+
s.add_runtime_dependency 'foxycart_helpers', '~> 1.0'
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: middleman-foxycart
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Robert Coleman
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: middleman-core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.4.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.4.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: foxycart_helpers
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
description: FoxyCart helpers for Middleman static sites
|
42
|
+
email:
|
43
|
+
- github@robert.net.nz
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- features/support/env.rb
|
54
|
+
- lib/middleman-foxycart.rb
|
55
|
+
- lib/middleman_extension.rb
|
56
|
+
- middleman-foxycart.gemspec
|
57
|
+
homepage: https://github.com/rjocoleman/middleman-foxycart
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.4.5.1
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: FoxyCart helpers for Middleman static sites
|
81
|
+
test_files:
|
82
|
+
- features/support/env.rb
|
83
|
+
has_rdoc:
|