Browse Source

update with support for Spree 0.70.x release

1-2-stable-sysmocom
Josh Nussbaum 10 years ago
parent
commit
9cf59f5a42
  1. 1
      .gitignore
  2. 25
      Gemfile
  3. 243
      Gemfile.lock
  4. 19
      LICENSE
  5. 42
      README.md
  6. 28
      Rakefile
  7. 2
      lib/generators/templates/config/sitemap.rb
  8. 36
      lib/spree_sitemap_generator.rb
  9. 40
      lib/spree_sitemap_generator/engine.rb
  10. 4
      lib/spree_sitemap_generator/spree_defaults.rb
  11. 3
      lib/spree_sitemap_generator_hooks.rb
  12. BIN
      pkg/spree_sitemap_generator-3.0.2.gem
  13. 13
      spree_sitemap_generator.gemspec

1
.gitignore

@ -5,3 +5,4 @@
tmp
*.swp
spec/test_app
pkg

25
Gemfile

@ -0,0 +1,25 @@
source 'http://rubygems.org'
gem 'sqlite3'
group :test do
gem 'autotest'
gem 'rspec-rails', '= 2.6.1'
gem 'factory_girl'
gem 'faker'
end
group :cucumber do
gem 'cucumber-rails', '1.0.0'
gem 'database_cleaner', '= 0.6.7'
gem 'nokogiri'
gem 'capybara', '1.0.1'
end
if RUBY_VERSION < "1.9"
gem "ruby-debug"
else
gem "ruby-debug19"
end
gemspec

243
Gemfile.lock

@ -0,0 +1,243 @@
PATH
remote: .
specs:
spree_logins (0.70.0)
spree_auth (>= 0.70.0)
spree_core (>= 0.70.0)
GEM
remote: http://rubygems.org/
specs:
ZenTest (4.6.2)
actionmailer (3.1.1)
actionpack (= 3.1.1)
mail (~> 2.3.0)
actionpack (3.1.1)
activemodel (= 3.1.1)
activesupport (= 3.1.1)
builder (~> 3.0.0)
erubis (~> 2.7.0)
i18n (~> 0.6)
rack (~> 1.3.2)
rack-cache (~> 1.1)
rack-mount (~> 0.8.2)
rack-test (~> 0.6.1)
sprockets (~> 2.0.2)
activemerchant (1.17.0)
activesupport (>= 2.3.11)
braintree (>= 2.0.0)
builder (>= 2.0.0)
json (>= 1.5.1)
activemodel (3.1.1)
activesupport (= 3.1.1)
builder (~> 3.0.0)
i18n (~> 0.6)
activerecord (3.1.1)
activemodel (= 3.1.1)
activesupport (= 3.1.1)
arel (~> 2.2.1)
tzinfo (~> 0.3.29)
activeresource (3.1.1)
activemodel (= 3.1.1)
activesupport (= 3.1.1)
activesupport (3.1.1)
multi_json (~> 1.0)
acts_as_list (0.1.4)
archive-tar-minitar (0.5.2)
arel (2.2.1)
autotest (4.4.6)
ZenTest (>= 4.4.1)
bcrypt-ruby (3.0.1)
braintree (2.12.0)
builder (>= 2.0.0)
builder (3.0.0)
cancan (1.6.5)
capybara (1.0.1)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 0.1.4)
childprocess (0.2.2)
ffi (~> 1.0.6)
cocaine (0.2.0)
columnize (0.3.4)
cucumber (1.0.6)
builder (>= 2.1.2)
diff-lcs (>= 1.1.2)
gherkin (~> 2.4.18)
json (>= 1.4.6)
term-ansicolor (>= 1.0.6)
cucumber-rails (1.0.0)
capybara (>= 1.0.0)
cucumber (~> 1.0.0)
nokogiri (>= 1.4.4)
rack-test (>= 0.5.7)
database_cleaner (0.6.7)
deface (0.7.0)
nokogiri (~> 1.5.0)
rails (>= 3.0.9)
devise (1.4.7)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.0.3)
warden (~> 1.0.3)
diff-lcs (1.1.3)
erubis (2.7.0)
factory_girl (2.1.2)
activesupport
faker (1.0.0)
i18n (~> 0.4)
ffi (1.0.9)
gherkin (2.4.21)
json (>= 1.4.6)
highline (1.5.1)
hike (1.2.1)
i18n (0.6.0)
jquery-rails (1.0.14)
railties (~> 3.0)
thor (~> 0.14)
json (1.6.1)
json_pure (1.6.1)
kaminari (0.12.4)
rails (>= 3.0.0)
linecache19 (0.5.12)
ruby_core_source (>= 0.1.4)
mail (2.3.0)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
meta_search (1.1.1)
actionpack (~> 3.1.0)
activerecord (~> 3.1.0)
activesupport (~> 3.1.0)
polyamorous (~> 0.5.0)
mime-types (1.16)
multi_json (1.0.3)
nested_set (1.6.8)
activerecord (>= 3.0.0)
railties (>= 3.0.0)
nokogiri (1.5.0)
orm_adapter (0.0.5)
paperclip (2.4.1)
activerecord (>= 2.3.0)
activesupport (>= 2.3.2)
cocaine (>= 0.0.2)
mime-types
polyamorous (0.5.0)
activerecord (~> 3.0)
polyglot (0.3.2)
rack (1.3.4)
rack-cache (1.1)
rack (>= 0.4)
rack-mount (0.8.3)
rack (>= 1.0.0)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.1.1)
actionmailer (= 3.1.1)
actionpack (= 3.1.1)
activerecord (= 3.1.1)
activeresource (= 3.1.1)
activesupport (= 3.1.1)
bundler (~> 1.0)
railties (= 3.1.1)
railties (3.1.1)
actionpack (= 3.1.1)
activesupport (= 3.1.1)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2)
rd_find_by_param (0.1.1)
activerecord (~> 3.0)
activesupport (~> 3.0)
rd_resource_controller (1.0.1)
rdoc (3.10)
json (~> 1.4)
rspec (2.6.0)
rspec-core (~> 2.6.0)
rspec-expectations (~> 2.6.0)
rspec-mocks (~> 2.6.0)
rspec-core (2.6.4)
rspec-expectations (2.6.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.6.0)
rspec-rails (2.6.1)
actionpack (~> 3.0)
activesupport (~> 3.0)
railties (~> 3.0)
rspec (~> 2.6.0)
ruby-debug-base19 (0.11.25)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby_core_source (>= 0.1.4)
ruby-debug19 (0.11.6)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby-debug-base19 (>= 0.11.19)
ruby_core_source (0.1.5)
archive-tar-minitar (>= 0.5.2)
rubyzip (0.9.4)
selenium-webdriver (2.8.0)
childprocess (>= 0.2.1)
ffi (>= 1.0.7)
json_pure
rubyzip
spree_auth (0.70.0)
cancan (= 1.6.5)
devise (= 1.4.7)
spree_core (= 0.70.0)
spree_core (0.70.0)
activemerchant (= 1.17.0)
acts_as_list (= 0.1.4)
deface (>= 0.6.1)
faker (= 1.0.0)
highline (= 1.5.1)
jquery-rails (>= 1.0.14)
kaminari (>= 0.12.4)
meta_search (= 1.1.1)
nested_set (= 1.6.8)
paperclip (= 2.4.1)
rails (= 3.1.1)
rd_find_by_param (= 0.1.1)
rd_resource_controller
state_machine (= 1.0.1)
stringex (= 1.0.3)
sprockets (2.0.2)
hike (~> 1.2)
rack (~> 1.0)
tilt (!= 1.3.0, ~> 1.1)
sqlite3 (1.3.4)
state_machine (1.0.1)
stringex (1.0.3)
term-ansicolor (1.0.6)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.30)
warden (1.0.6)
rack (>= 1.0)
xpath (0.1.4)
nokogiri (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
autotest
capybara (= 1.0.1)
cucumber-rails (= 1.0.0)
database_cleaner (= 0.6.7)
factory_girl
faker
nokogiri
rspec-rails (= 2.6.1)
ruby-debug19
spree_logins!
sqlite3

19
LICENSE

@ -1,14 +1,17 @@
Redistribution and use in source and binary forms, with or without modification,
Copyright (c) 2011 Joshua Nussbaum
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the Rails Dog LLC nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
* Neither the name Spree nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@ -20,4 +23,4 @@ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

42
README.md

@ -1,7 +1,7 @@
Spree Sitemap Generator
=====================
Spree sitemap generator is a sitemap generator based on the sitemap_generator gem [http://github.com/kjvarga/sitemap_generator]. It adheres to the Sitemap 0.9 protocol specification.
Spree sitemap generator is a sitemap generator based on the sitemap_generator gem http://github.com/kjvarga/sitemap_generator. It adheres to the Sitemap 0.9 protocol specification.
Installation
=======
@ -14,23 +14,49 @@ Installation
`bundle install`
3) add sitemap to your `.gitignore`
3) run the installer, it will create a `config/sitemap.rb` file with some sane defaults
`echo "public/sitemap*" >> .gitignore`
`rails generate spree_sitemap_generator:install`
4) BOOM you're done!
4) add sitemap to your `.gitignore`
`echo "public/sitemap*" >> .gitignore`
5) setup a daily job to regenrate your sitemap via the `rake sitemap:refresh` task. If you use the Whenever gem, add this to your `config/schedule.rb`
```
every 1.day, :at => '5:00 am' do
rake "-s sitemap:refresh"
end
```
6) add the following line to your `robots.txt` with your correct domain name
`echo "Sitemap: http://www.example.com/sitemap_index.xml.gz" >> public/robots.txt`
7) BOOM you're done!
More Configuration Options
==========================
Check out the README for the sitemap_generator gem at:
http://github.com/kjvarga/sitemap_generator
Features
=====
- Notifies search engine of new sitemaps (Google, Yahoo, Ask, Bing)
- Supports large huge product catalogs
- Adheres to 0.9 Sitemap protocol specification
- Compresses sitemaps with gzip
- Provides basic sitemap of a Spree site
- Allows you to easily add additional sitemaps for pages you add to your site
- Provides basic sitemap of a Spree site (products, taxons, login page, signup page)
- Easily add additional sitemaps for pages you add to your spree site
- Supports Amazon S3 and other hosting services
- Thin wrapper over battle tested sitemap generator
Special Thanks
=====
- The creators of the rails sitemap gem
- The creators of the sitemap_generator gem
- To all who have provided pull requests, its is much appreciated
Copyright (c) 2011 Joshua Nussbaum, released under the New BSD License

28
Rakefile

@ -1,12 +1,19 @@
require 'rubygems'
require 'rake'
require 'rake/testtask'
require 'rake/packagetask'
require 'rake/gempackagetask'
require 'rubygems/package_task'
require 'rspec/core/rake_task'
require 'cucumber/rake/task'
require 'spree_core/testing_support/common_rake'
RSpec::Core::RakeTask.new
Cucumber::Rake::Task.new
task :default => [:spec, :cucumber ]
spec = eval(File.read('spree_sitemap_generator.gemspec'))
Rake::GemPackageTask.new(spec) do |p|
Gem::PackageTask.new(spec) do |p|
p.gem_spec = spec
end
@ -17,13 +24,8 @@ task :release => :package do
Rake::Task['gem:push'].invoke
end
desc "Default Task"
task :default => [ :spec ]
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new
# require 'cucumber/rake/task'
# Cucumber::Rake::Task.new do |t|
# t.cucumber_opts = %w{--format pretty}
# end
desc "Generates a dummy app for testing"
task :test_app do
ENV['LIB_NAME'] = 'spree_logins'
Rake::Task['common:test_app'].invoke
end

2
lib/generators/templates/config/sitemap.rb

@ -1,3 +1,5 @@
SitemapGenerator::Sitemap.default_host = "http://#{Spree::Config[:site_url]}"
SitemapGenerator::Sitemap.add_links do |sitemap|
# Put links creation logic here.
#

36
lib/spree_sitemap_generator.rb

@ -1,37 +1,3 @@
require 'spree_core'
require 'spree_sitemap_generator_hooks'
require 'sitemap_generator'
module SpreeSitemapGenerator
class Engine < Rails::Engine
config.autoload_paths += %W(#{config.root}/lib)
def self.activate
ActiveRecord::Relation.class_eval do
def last_updated
last_update = order('updated_at DESC').first
last_update.try(:updated_at)
end
end
ActiveRecord::Base.class_eval do
def self.last_updated
scoped.last_updated
end
end
SitemapGenerator::Sitemap.default_host = "http://#{Spree::Config[:site_url]}"
require 'spree_sitemap_generator/spree_defaults'
SitemapGenerator::Interpreter.send :include, SpreeSitemapGenerator::SpreeDefaults
Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
Rails.env.production? ? require(c) : load(c)
end
end
config.to_prepare &method(:activate).to_proc
end
end
require 'spree_sitemap_generator/engine'

40
lib/spree_sitemap_generator/engine.rb

@ -0,0 +1,40 @@
module SpreeSitemapGenerator
class Engine < Rails::Engine
engine_name 'spree_sitemap_generator'
config.autoload_paths += %W(#{config.root}/lib)
# use rspec for tests
config.generators do |g|
g.test_framework :rspec
end
def self.activate
ActiveRecord::Relation.class_eval do
def last_updated
last_update = order('updated_at DESC').first
last_update.try(:updated_at)
end
end
ActiveRecord::Base.class_eval do
def self.last_updated
scoped.last_updated
end
end
require 'spree_sitemap_generator/spree_defaults'
SitemapGenerator::Interpreter.send :include, SpreeSitemapGenerator::SpreeDefaults
Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c|
Rails.application.config.cache_classes ? require(c) : load(c)
end
Dir.glob(File.join(File.dirname(__FILE__), "../../app/overrides/*.rb")) do |c|
Rails.application.config.cache_classes ? require(c) : load(c)
end
end
config.to_prepare &method(:activate).to_proc
end
end

4
lib/spree_sitemap_generator/spree_defaults.rb

@ -1,6 +1,6 @@
module SpreeSitemapGenerator::SpreeDefaults
def default_url_options
{:host => "http://" + Spree::Config[:site_url]}
{:host => SitemapGenerator::Sitemap.default_host}
end
include ::Rails.application.routes.url_helpers
@ -17,7 +17,7 @@ module SpreeSitemapGenerator::SpreeDefaults
end
def add_password_reset(options={})
add(new_password_reset_path, options)
add(new_user_password_path, options)
end
def add_products(options={})

3
lib/spree_sitemap_generator_hooks.rb

@ -1,3 +0,0 @@
class SpreeSitemapGeneratorHooks < Spree::ThemeSupport::HookListener
# custom hooks go here
end

BIN
pkg/spree_sitemap_generator-3.0.2.gem

Binary file not shown.

13
spree_sitemap_generator.gemspec

@ -1,13 +1,13 @@
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'spree_sitemap_generator'
s.version = '3.0.2'
s.summary = 'Add gem summary here'
s.version = '3.0.3'
s.summary = 'Provides a sitemap file for Spree'
#s.description = 'Add (optional) gem description here'
s.required_ruby_version = '>= 1.8.7'
# s.author = 'David Heinemeier Hansson'
# s.email = 'david@loudthinking.com'
s.author = 'Joshua Nussbaum'
s.email = 'joshnuss@gmail.com'
# s.homepage = 'http://www.rubyonrails.org'
# s.rubyforge_project = 'actionmailer'
@ -15,7 +15,6 @@ Gem::Specification.new do |s|
s.require_path = 'lib'
s.requirements << 'none'
s.add_dependency('spree_core', '>= 0.30.1')
s.add_dependency('sitemap_generator', '= 2.0.1')
s.add_dependency('spree_core', '>= 0.70.0')
s.add_dependency('sitemap_generator', '>= 2.0.1')
end

Loading…
Cancel
Save