Permalink
Browse files

add 1.0.x compatibiity

  • Loading branch information...
1 parent 400f8db commit 6d906eee4669af91238985fa1b86c86ed8b6a42f @kpitn kpitn committed Jan 24, 2012
View
@@ -0,0 +1,5 @@
+.DS_Store
+spec/dummy
+spec/test_app
+Gemfile.lock
+*.swp
View
@@ -0,0 +1,6 @@
+source "http://rubygems.org"
+
+gem 'spree', :git => 'git://github.com/spree/spree.git'
+
+# Specify your dependencies in spree_wishlist.gemspec
+gemspec
View
@@ -7,23 +7,21 @@ This extension is compatible with the [static_content][1] extension and will che
In order to avoid an seo penalty for duplicate content, products are only listed once at /product/_productName_
-for rails 3 and spree >= 0.30.0
+for rails 3 and spree >= 1.0.0rc2
INSTALLATION
------------
1. Install the extension
- gem 'dynamic_sitemaps', :git => 'git://github.com/bzt/spree_dynamic_sitemaps.git'
- bundle install
-
- (rake dynamic_sitemaps:install)
+ gem 'dynamic_sitemaps', :git => 'git://github.com/romul/spree_dynamic_sitemaps.git'
+ bundle install
2. Add link to sitemap to a view
`<%= link_to 'Sitemap', '/sitemap' %>`
-The sitemaps are accessible at public_domain/sitemap.html, public_domain/sitemap.xml, and public_domain/sitemap.txt
+The sitemaps are accessible at www.your_domain.com/sitemap.html, www.your_domain.com/sitemap.xml, and www.your_domain.com/sitemap.txt
Hat tip [stephp][2] for doing all the heavy lifting with her [spree-sitemaps][3] extension.
View
126 Rakefile
@@ -1,120 +1,18 @@
-# I think this is the one that should be moved to the extension Rakefile template
+# encoding: utf-8
-# In rails 1.2, plugins aren't available in the path until they're loaded.
-# Check to see if the rspec plugin is installed first and require
-# it if it is. If not, use the gem version.
+require 'rspec/core/rake_task'
+require 'spree/core/testing_support/common_rake'
-# Determine where the RSpec plugin is by loading the boot
-unless defined? SPREE_ROOT
- ENV["RAILS_ENV"] = "test"
- case
- when ENV["SPREE_ENV_FILE"]
- require File.dirname(ENV["SPREE_ENV_FILE"]) + "/boot"
- when File.dirname(__FILE__) =~ %r{vendor/SPREE/vendor/extensions}
- require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../")}/config/boot"
- else
- require "#{File.expand_path(File.dirname(__FILE__) + "/../../../")}/config/boot"
- end
-end
-
-require 'rake'
-require 'rake/rdoctask'
-require 'rake/testtask'
-
-rspec_base = File.expand_path(SPREE_ROOT + '/vendor/plugins/rspec/lib')
-$LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
-require 'spec/rake/spectask'
-# require 'spec/translator'
-
-# Cleanup the SPREE_ROOT constant so specs will load the environment
-Object.send(:remove_const, :SPREE_ROOT)
-
-extension_root = File.expand_path(File.dirname(__FILE__))
-
-task :default => :spec
-task :stats => "spec:statsetup"
-
-desc "Run all specs in spec directory"
-Spec::Rake::SpecTask.new(:spec) do |t|
- t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
- t.spec_files = FileList["#{extension_root}/spec/**/*_spec.rb"]
-end
-
-namespace :spec do
- desc "Run all specs in spec directory with RCov"
- Spec::Rake::SpecTask.new(:rcov) do |t|
- t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
- t.spec_files = FileList['spec/**/*_spec.rb']
- t.rcov = true
- t.rcov_opts = ['--exclude', 'spec', '--rails']
- end
-
- desc "Print Specdoc for all specs"
- Spec::Rake::SpecTask.new(:doc) do |t|
- t.spec_opts = ["--format", "specdoc", "--dry-run"]
- t.spec_files = FileList['spec/**/*_spec.rb']
- end
+Bundler::GemHelper.install_tasks
+Bundler.setup
- [:models, :controllers, :views, :helpers].each do |sub|
- desc "Run the specs under spec/#{sub}"
- Spec::Rake::SpecTask.new(sub) do |t|
- t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
- t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
- end
- end
-
- # Hopefully no one has written their extensions in pre-0.9 style
- # desc "Translate specs from pre-0.9 to 0.9 style"
- # task :translate do
- # translator = ::Spec::Translator.new
- # dir = RAILS_ROOT + '/spec'
- # translator.translate(dir, dir)
- # end
+RSpec::Core::RakeTask.new
- # Setup specs for stats
- task :statsetup do
- require 'code_statistics'
- ::STATS_DIRECTORIES << %w(Model\ specs spec/models)
- ::STATS_DIRECTORIES << %w(View\ specs spec/views)
- ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers)
- ::STATS_DIRECTORIES << %w(Helper\ specs spec/views)
- ::CodeStatistics::TEST_TYPES << "Model specs"
- ::CodeStatistics::TEST_TYPES << "View specs"
- ::CodeStatistics::TEST_TYPES << "Controller specs"
- ::CodeStatistics::TEST_TYPES << "Helper specs"
- ::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
- end
-
- namespace :db do
- namespace :fixtures do
- desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
- task :load => :environment do
- require 'active_record/fixtures'
- ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
- (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
- Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*'))
- end
- end
- end
- end
-end
+desc "Default Task"
+task :default => [:spec]
-desc 'Generate documentation for the sitemaps extension.'
-Rake::RDocTask.new(:rdoc) do |rdoc|
- rdoc.rdoc_dir = 'rdoc'
- rdoc.title = 'SpreeSitemapsExtension'
- rdoc.options << '--line-numbers' << '--inline-source'
- rdoc.rdoc_files.include('README')
- rdoc.rdoc_files.include('lib/**/*.rb')
+desc "Generates a dummy app for testing"
+task :test_app do
+ ENV['LIB_NAME'] = 'spree/api'
+ Rake::Task['common:test_app'].invoke
end
-
-# For extensions that are in transition
-desc 'Test the sitemaps extension.'
-Rake::TestTask.new(:test) do |t|
- t.libs << 'lib'
- t.pattern = 'test/**/*_test.rb'
- t.verbose = true
-end
-
-# Load any custom rakefiles for extension
-Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
View
@@ -0,0 +1,5 @@
+"1.0.x" => { :branch => "master" }
+"0.50.x" => { :branch => "0.50" }
+"0.30.x" => { :branch => "0.30" }
+"0.11.x" => { :branch => "0.11-stable" }
+
@@ -1,9 +1,9 @@
-class SitemapController < Spree::BaseController
+class Spree::SitemapController < Spree::BaseController
def index
@public_dir = root_url
- @products = Product.active.find(:all)
- @taxonomies = Taxonomy.all
+ @products = Spree::Product.active.find(:all)
+ @taxonomies = Spree::Taxonomy.all
# Get Pages from static_content extension
@pages = _select_static_pages
@@ -25,7 +25,7 @@ def index
private
def _build_xml(nav, public_dir)
- returning '' do |output|
+ ''.tap do |output|
xml = Builder::XmlMarkup.new(:target => output, :indent => 2)
xml.instruct! :xml, :version => "1.0", :encoding => "UTF-8"
xml.urlset( :xmlns => "http://www.sitemaps.org/schemas/sitemap/0.9" ) {
@@ -49,7 +49,7 @@ def _build_xml(nav, public_dir)
def _build_taxon_hash
nav = Hash.new
- Taxon.find(:all).each do |taxon|
+ Spree::Taxon.all.each do |taxon|
tinfo = Hash.new
tinfo['name'] = taxon.name
tinfo['depth'] = taxon.permalink.split('/').size
@@ -61,7 +61,7 @@ def _build_taxon_hash
end
def _add_products_to_tax(nav, multiples_allowed)
- Product.active.find(:all).each do |product|
+ Spree::Product.active.find(:all).each do |product|
pinfo = Hash.new
pinfo['name'] = product.name
pinfo['link'] = 'products/' + product.permalink # primary
@@ -87,7 +87,7 @@ def _select_static_pages
pages = []
begin
slugs_to_reject = ["/on-main-page"]
- Page.visible.each do |page|
+ Spree::Page.visible.each do |page|
pages << page unless slugs_to_reject.include?(page.slug)
end
@@ -1,2 +0,0 @@
-module SitemapHelper
-end
@@ -0,0 +1,2 @@
+module Spree::SitemapHelper
+end
@@ -9,7 +9,7 @@
<% end %>
<% unless @taxonomies.blank? %>
<% @taxonomies.each do |taxonomy| %>
- <% taxons = Taxon.find_all_by_taxonomy_id(taxonomy.id) %>
+ <% taxons = Spree::Taxon.find_all_by_taxonomy_id(taxonomy.id) %>
<h3><%= taxonomy.name %></h3>
<ul>
<% taxons.each do |taxon| %>
View
@@ -1,4 +1,4 @@
-Rails.application.routes.draw do
+Spree::Core::Engine.routes.draw do
resources :sitemap
@@ -2,16 +2,16 @@
module SpreeDynamicSitemaps
class Engine < Rails::Engine
-
- config.autoload_paths += %W(#{config.root}/lib)
-
- def self.activate
+
+ config.autoload_paths += %W(#{config.root}/lib)
+
+ def self.activate
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
-
+
+ config.to_prepare &method(:activate).to_proc
+
end
end
View
@@ -1,26 +0,0 @@
-namespace :dynamic_sitemaps do
- desc "Copies all migrations and assets (NOTE: This will be obsolete with Rails 3.1)"
- task :install do
- Rake::Task['dynamic_sitemaps:install:migrations'].invoke
- Rake::Task['dynamic_sitemaps:install:assets'].invoke
- end
-
- namespace :install do
- desc "Copies all migrations (NOTE: This will be obsolete with Rails 3.1)"
- task :migrations do
- source = File.join(File.dirname(__FILE__), '..', '..', 'db')
- destination = File.join(Rails.root, 'db')
- puts "INFO: Mirroring assets from #{source} to #{destination}"
- Spree::FileUtilz.mirror_files(source, destination)
- end
-
- desc "Copies all assets (NOTE: This will be obsolete with Rails 3.1)"
- task :assets do
- source = File.join(File.dirname(__FILE__), '..', '..', 'public')
- destination = File.join(Rails.root, 'public')
- puts "INFO: Mirroring assets from #{source} to #{destination}"
- Spree::FileUtilz.mirror_files(source, destination)
- end
- end
-
-end
@@ -16,4 +16,8 @@ Gem::Specification.new do |s|
s.require_path = 'lib'
s.requirements << 'none'
+ s.add_development_dependency 'factory_girl'
+ s.add_development_dependency 'rspec-rails', '~> 2.8.0.rc1'
+ s.add_development_dependency 'sqlite3'
+
end

0 comments on commit 6d906ee

Please sign in to comment.