spree_pinterest 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ \#*
2
+ *~
3
+ .#*
4
+ .DS_Store
5
+ .idea
6
+ .project
7
+ tmp
8
+ nbproject
9
+ *.swp
10
+ spec/dummy
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source 'http://rubygems.org'
2
+
3
+ group :test do
4
+ gem 'ffaker'
5
+ end
6
+
7
+ if RUBY_VERSION < "1.9"
8
+ gem "ruby-debug"
9
+ else
10
+ gem "ruby-debug19"
11
+ end
12
+
13
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2012 [name of plugin creator]
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Spree nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # Spree Pinterest
2
+
3
+ Simple Spree extension for adding a Pinterest ![Pin it](http://passets-cdn.pinterest.com/images/pinit_preview_horizontal.png) button for your
4
+ product images. It will add the button below each image on the
5
+ `products#index` page and on the `products#show` page.
6
+
7
+ It has some
8
+ default styling that works with the default Spree theme, but you can
9
+ easily override this styling to fit your needs.
10
+
11
+ ## Button parameters
12
+
13
+ There are three parameters that the button uses to create the pin:
14
+ _url_, _media_, and _description_. The values used for each of these are
15
+ as follows:
16
+
17
+ * url - The URL of the page that the pin button is located on
18
+ * media - The URL for the image that is being pinned
19
+ * description - The product name
20
+
21
+ When you click the "Pin it" button, a Pinterest-provided window is
22
+ opened for you to confirm the pin. Here you will have the opportunity
23
+ to choose your pin board, as well as modify the description if you don't
24
+ want to use the default.
25
+
26
+ ## Testing this engine
27
+
28
+ Be sure to bundle your dependencies and then create a dummy test app for the specs to run against.
29
+
30
+ $ bundle
31
+ $ bundle exec rake test app
32
+ $ bundle exec rspec spec
33
+
34
+ Copyright (c) 2012 [Genuity Technology Services](http://genuitytech.com), released under the New BSD License
data/Rakefile ADDED
@@ -0,0 +1,29 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/packagetask'
4
+ require 'rubygems/package_task'
5
+ require 'rspec/core/rake_task'
6
+ require 'spree/core/testing_support/common_rake'
7
+
8
+ RSpec::Core::RakeTask.new
9
+
10
+ task :default => [:spec]
11
+
12
+ spec = eval(File.read('spree_pinterest.gemspec'))
13
+
14
+ Gem::PackageTask.new(spec) do |p|
15
+ p.gem_spec = spec
16
+ end
17
+
18
+ desc "Release to gemcutter"
19
+ task :release => :package do
20
+ require 'rake/gemcutter'
21
+ Rake::Gemcutter::Tasks.new(spec).define
22
+ Rake::Task['gem:push'].invoke
23
+ end
24
+
25
+ desc "Generates a dummy app for testing"
26
+ task :test_app do
27
+ ENV['LIB_NAME'] = 'spree_pinterest'
28
+ Rake::Task['common:test_app'].invoke
29
+ end
data/Versionfile ADDED
@@ -0,0 +1 @@
1
+ "1.0.x" => { :tag => "v0.1.0", :version => "0.1.0" }
@@ -0,0 +1 @@
1
+ //= require admin/spree_core
@@ -0,0 +1,22 @@
1
+ //= require store/spree_core
2
+
3
+ (function() {
4
+ window.PinIt = window.PinIt || { loaded:false };
5
+ if (window.PinIt.loaded) return;
6
+ window.PinIt.loaded = true;
7
+ function async_load(){
8
+ var s = document.createElement("script");
9
+ s.type = "text/javascript";
10
+ s.async = true;
11
+ if (window.location.protocol == "https:")
12
+ s.src = "https://assets.pinterest.com/js/pinit.js";
13
+ else
14
+ s.src = "http://assets.pinterest.com/js/pinit.js";
15
+ var x = document.getElementsByTagName("script")[0];
16
+ x.parentNode.insertBefore(s, x);
17
+ }
18
+ if (window.attachEvent)
19
+ window.attachEvent("onload", async_load);
20
+ else
21
+ window.addEventListener("load", async_load, false);
22
+ })();
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require admin/spree_core
3
+ */
@@ -0,0 +1,9 @@
1
+ iframe[src*='pinit.html']
2
+ margin-top: 4px
3
+
4
+ [data-hook='products_list_item']
5
+ iframe[src*='pinit.html']
6
+ float: left
7
+
8
+ span.price
9
+ float: right
@@ -0,0 +1,4 @@
1
+ /*
2
+ *= require store/spree_core
3
+ *= require_tree .
4
+ */
@@ -0,0 +1,22 @@
1
+ module Spree
2
+ module PinterestHelper
3
+ def pin_it_button(product)
4
+ return if product.images.blank?
5
+
6
+ url = escape request.url
7
+ media = escape product.images.first.attachment.url
8
+ description = escape product.name
9
+
10
+ link_to("Pin It",
11
+ "http://pinterest.com/pin/create/button/?url=#{url}&media=#{media}&description=#{description}",
12
+ :class => "pin-it-button",
13
+ "count-layout" => "horizontal").html_safe
14
+ end
15
+
16
+ private
17
+
18
+ def escape(string)
19
+ URI.escape string, /[^#{URI::PATTERN::UNRESERVED}]/
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,9 @@
1
+ Deface::Override.new(:virtual_path => "spree/shared/_products",
2
+ :insert_bottom => "[data-hook='products_list_item']",
3
+ :text => "<%= pin_it_button(product) %>",
4
+ :name => "index_pin_it")
5
+
6
+ Deface::Override.new(:virtual_path => "spree/products/show",
7
+ :insert_after => "#main-image",
8
+ :text => "<%= pin_it_button(@product) %>",
9
+ :name => "show_pin_it")
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Spree::Core::Engine.routes.draw do
2
+ # Add your extension routes here
3
+ end
@@ -0,0 +1,29 @@
1
+ module SpreePinterest
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+
5
+ def add_javascripts
6
+ append_file "app/assets/javascripts/store/all.js", "//= require store/spree_pinterest\n"
7
+ append_file "app/assets/javascripts/admin/all.js", "//= require admin/spree_pinterest\n"
8
+ end
9
+
10
+ def add_stylesheets
11
+ inject_into_file "app/assets/stylesheets/store/all.css", " *= require store/spree_pinterest\n", :before => /\*\//, :verbose => true
12
+ inject_into_file "app/assets/stylesheets/admin/all.css", " *= require admin/spree_pinterest\n", :before => /\*\//, :verbose => true
13
+ end
14
+
15
+ def add_migrations
16
+ run 'bundle exec rake railties:install:migrations FROM=spree_pinterest'
17
+ end
18
+
19
+ def run_migrations
20
+ res = ask "Would you like to run the migrations now? [Y/n]"
21
+ if res == "" || res.downcase == "y"
22
+ run 'bundle exec rake db:migrate'
23
+ else
24
+ puts "Skiping rake db:migrate, don't forget to run it!"
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,2 @@
1
+ require 'spree_core'
2
+ require 'spree_pinterest/engine'
@@ -0,0 +1,24 @@
1
+ module SpreePinterest
2
+ class Engine < Rails::Engine
3
+ engine_name 'spree_pinterest'
4
+
5
+ config.autoload_paths += %W(#{config.root}/lib)
6
+
7
+ # use rspec for tests
8
+ config.generators do |g|
9
+ g.test_framework :rspec
10
+ end
11
+
12
+ def self.activate
13
+ Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c|
14
+ Rails.configuration.cache_classes ? require(c) : load(c)
15
+ end
16
+
17
+ Dir.glob(File.join(File.dirname(__FILE__), "../../app/overrides/*.rb")) do |c|
18
+ Rails.configuration.cache_classes ? require(c) : load(c)
19
+ end
20
+ end
21
+
22
+ config.to_prepare &method(:activate).to_proc
23
+ end
24
+ end
@@ -0,0 +1,3 @@
1
+ module SpreePinterest
2
+ VERSION = "0.1.0"
3
+ end
data/script/rails ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ ENGINE_PATH = File.expand_path('../..', __FILE__)
5
+ load File.expand_path('../../spec/dummy/script/rails', __FILE__)
@@ -0,0 +1,32 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
+
6
+ require 'rspec/rails'
7
+
8
+ # Requires supporting ruby files with custom matchers and macros, etc,
9
+ # in spec/support/ and its subdirectories.
10
+ Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each {|f| require f }
11
+
12
+ # Requires factories defined in spree_core
13
+ require 'spree/core/testing_support/factories'
14
+
15
+ RSpec.configure do |config|
16
+ # == Mock Framework
17
+ #
18
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
19
+ #
20
+ # config.mock_with :mocha
21
+ # config.mock_with :flexmock
22
+ # config.mock_with :rr
23
+ config.mock_with :rspec
24
+
25
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
26
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
27
+
28
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
29
+ # examples within a transaction, remove the following line or assign false
30
+ # instead of true.
31
+ config.use_transactional_fixtures = true
32
+ end
@@ -0,0 +1,29 @@
1
+ # encoding: UTF-8
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "spree_pinterest/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.platform = Gem::Platform::RUBY
7
+ s.name = 'spree_pinterest'
8
+ s.version = SpreePinterest::VERSION
9
+ s.summary = 'Pinterest button for Spree products'
10
+ s.description = 'This extension provides a Pinterest "Pin it" button for your Spree product images.'
11
+ s.required_ruby_version = '>= 1.8.7'
12
+
13
+ s.author = 'Chad Boyd'
14
+ s.email = 'chad@genuitytech.com'
15
+ s.homepage = 'http://genuitytech.com'
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.require_path = 'lib'
20
+ s.requirements << 'none'
21
+
22
+ s.add_dependency 'spree_core', '~> 1.0.0'
23
+
24
+ s.add_development_dependency 'capybara', '1.0.1'
25
+ s.add_development_dependency 'factory_girl'
26
+ s.add_development_dependency 'ffaker'
27
+ s.add_development_dependency 'rspec-rails', '~> 2.7'
28
+ s.add_development_dependency 'sqlite3'
29
+ end
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spree_pinterest
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Chad Boyd
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-02-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: spree_core
16
+ requirement: &70268505990460 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.0.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70268505990460
25
+ - !ruby/object:Gem::Dependency
26
+ name: capybara
27
+ requirement: &70268505989960 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - =
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.1
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70268505989960
36
+ - !ruby/object:Gem::Dependency
37
+ name: factory_girl
38
+ requirement: &70268505989560 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70268505989560
47
+ - !ruby/object:Gem::Dependency
48
+ name: ffaker
49
+ requirement: &70268505989100 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70268505989100
58
+ - !ruby/object:Gem::Dependency
59
+ name: rspec-rails
60
+ requirement: &70268505988600 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: '2.7'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70268505988600
69
+ - !ruby/object:Gem::Dependency
70
+ name: sqlite3
71
+ requirement: &70268505988180 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70268505988180
80
+ description: This extension provides a Pinterest "Pin it" button for your Spree product
81
+ images.
82
+ email: chad@genuitytech.com
83
+ executables: []
84
+ extensions: []
85
+ extra_rdoc_files: []
86
+ files:
87
+ - .gitignore
88
+ - .rspec
89
+ - Gemfile
90
+ - LICENSE
91
+ - README.md
92
+ - Rakefile
93
+ - Versionfile
94
+ - app/assets/javascripts/admin/spree_pinterest.js
95
+ - app/assets/javascripts/store/spree_pinterest.js
96
+ - app/assets/stylesheets/admin/spree_pinterest.css
97
+ - app/assets/stylesheets/store/pin_it_button.css.sass
98
+ - app/assets/stylesheets/store/spree_pinterest.css
99
+ - app/helpers/spree/pinterest_helper.rb
100
+ - app/overrides/pin_it_button.rb
101
+ - config/locales/en.yml
102
+ - config/routes.rb
103
+ - lib/generators/spree_pinterest/install/install_generator.rb
104
+ - lib/spree_pinterest.rb
105
+ - lib/spree_pinterest/engine.rb
106
+ - lib/spree_pinterest/version.rb
107
+ - script/rails
108
+ - spec/spec_helper.rb
109
+ - spree_pinterest.gemspec
110
+ homepage: http://genuitytech.com
111
+ licenses: []
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
121
+ version: 1.8.7
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ! '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements:
129
+ - none
130
+ rubyforge_project:
131
+ rubygems_version: 1.8.11
132
+ signing_key:
133
+ specification_version: 3
134
+ summary: Pinterest button for Spree products
135
+ test_files:
136
+ - spec/spec_helper.rb