solidus_dynamic_sitemaps 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/MIT-LICENSE +23 -0
- data/README.md +115 -0
- data/Rakefile +23 -0
- data/app/controllers/spree/sitemap_controller.rb +103 -0
- data/app/helpers/spree/sitemap_helper.rb +2 -0
- data/app/models/product_decorator.rb +3 -0
- data/app/views/spree/sitemap/index.html.erb +34 -0
- data/app/views/spree/sitemap/index.text.erb +4 -0
- data/app/views/spree/sitemap/index.xml.builder +0 -0
- data/config/locales/en.yml +3 -0
- data/config/locales/es-MX.yml +3 -0
- data/config/routes.rb +3 -0
- data/lib/generators/solidus_dynamic_sitemaps/install/install_generator.rb +12 -0
- data/lib/generators/templates/config/sitemap.rb +52 -0
- data/lib/solidus_dynamic_sitemaps.rb +7 -0
- data/lib/solidus_dynamic_sitemaps/engine.rb +22 -0
- data/lib/solidus_dynamic_sitemaps/factories.rb +6 -0
- data/lib/solidus_dynamic_sitemaps/solidus_defaults.rb +107 -0
- data/lib/solidus_dynamic_sitemaps/version.rb +3 -0
- metadata +221 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a7ed2599639e802b3ca670636782aa680d6d5a8e57787f8c07ad6034b6f1532c
|
4
|
+
data.tar.gz: 5eeaebd00c0119c43b4456c8b0c4528d3b0c9b25c71897d9cdf32e0bdde33bf7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dadcb1b504a3bcdb78c41dede9a6c6fe76ee2a98a2dd9709614b6e932986a7d641004721c46ae7a81d78ee6e0697f3e06ae7a6ae2f00c8566d19f5134e3a3fd3
|
7
|
+
data.tar.gz: f365705587ebb5839170ed4f7d1a10b96f749fd12814a1197cf048d927534c5dfff8a486c7dc49bbecbf8bdf9885bbaebba5b00e73ba34a3e7479859c4fc4de9
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Redistribution and use in source and binary forms, with or without modification,
|
2
|
+
are permitted provided that the following conditions are met:
|
3
|
+
|
4
|
+
* Redistributions of source code must retain the above copyright notice,
|
5
|
+
this list of conditions and the following disclaimer.
|
6
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
7
|
+
this list of conditions and the following disclaimer in the documentation
|
8
|
+
and/or other materials provided with the distribution.
|
9
|
+
* Neither the name of the Rails Dog LLC nor the names of its
|
10
|
+
contributors may be used to endorse or promote products derived from this
|
11
|
+
software without specific prior written permission.
|
12
|
+
|
13
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
14
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
15
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
16
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
17
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
18
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
19
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
20
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
21
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
22
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
23
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
# Solidus Dynamic Sitemaps
|
2
|
+
|
3
|
+
Solidus Dynamic Sitemaps is a sitemap generator based on the [sitemap_generator][1] gem.
|
4
|
+
It adheres to the Sitemap 0.9 protocol specification. This is a continuation of
|
5
|
+
the [original Spree version](https://github.com/spree-contrib/spree_sitemap),
|
6
|
+
updated to work with the [Solidus](https://solidus.io) eCommerce platform.
|
7
|
+
|
8
|
+
### Features
|
9
|
+
|
10
|
+
- Notifies search engine of new sitemaps (Google, Yahoo, Ask, Bing)
|
11
|
+
- Supports large huge product catalogs
|
12
|
+
- Adheres to 0.9 Sitemap protocol specification
|
13
|
+
- Compresses sitemaps with gzip
|
14
|
+
- Provides basic sitemap of a Solidus site (products, taxons, login page, signup page)
|
15
|
+
- Easily add additional sitemaps for pages you add to your solidus site
|
16
|
+
- Supports Amazon S3 and other hosting services
|
17
|
+
- Thin wrapper over battle tested sitemap generator
|
18
|
+
- Add /sitemap route to display the sitemap
|
19
|
+
|
20
|
+
### Configuration Options
|
21
|
+
|
22
|
+
Check out the [README][1] for the [sitemap_generator][1].
|
23
|
+
|
24
|
+
---
|
25
|
+
|
26
|
+
## Installation
|
27
|
+
|
28
|
+
1. Add the gem to your Solidus store's `Gemfile`:
|
29
|
+
```ruby
|
30
|
+
gem 'solidus_dynamic_sitemaps', github: 'jtapia/solidus_dynamic_sitemaps'
|
31
|
+
```
|
32
|
+
|
33
|
+
2. Update your bundle:
|
34
|
+
|
35
|
+
```
|
36
|
+
$ bundle install
|
37
|
+
```
|
38
|
+
|
39
|
+
3. Run the installer, it will create a `config/sitemap.rb` file with some sane
|
40
|
+
defaults
|
41
|
+
|
42
|
+
```
|
43
|
+
$ rails g solidus_dynamic_sitemaps:install
|
44
|
+
```
|
45
|
+
|
46
|
+
4. Add the sitemap to your `.gitignore`, since it will be regenerated
|
47
|
+
server-side.
|
48
|
+
|
49
|
+
```
|
50
|
+
$ echo "public/sitemap*" >> .gitignore
|
51
|
+
```
|
52
|
+
|
53
|
+
5. Set up a cron job to regenrate your sitemap via the `rake sitemap:refresh`
|
54
|
+
task. If you use the [Whenever gem](https://github.com/javan/whenever), add
|
55
|
+
this to your `config/schedule.rb`:
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
every 1.day, at: '5:00 am' do
|
59
|
+
rake '-s sitemap:refresh'
|
60
|
+
end
|
61
|
+
```
|
62
|
+
|
63
|
+
6. Ensure crawlers can find the sitemap, by adding the following line to your
|
64
|
+
`public/robots.txt` with your correct domain name
|
65
|
+
|
66
|
+
```
|
67
|
+
$ echo "Sitemap: http://www.example.com/sitemap.xml.gz" >> public/robots.txt
|
68
|
+
```
|
69
|
+
|
70
|
+
7. Add link to sitemap to a view[Optional]
|
71
|
+
`<%= link_to 'Sitemap', '/sitemap' %>`
|
72
|
+
|
73
|
+
---
|
74
|
+
|
75
|
+
## Acknowledgements
|
76
|
+
|
77
|
+
- [The original Spree version of this gem](https://github.com/spree-contrib/spree_sitemap)
|
78
|
+
- [The creators & contributors of sitemap_generator](http://github.com/kjvarga/sitemap_generator/contributors)
|
79
|
+
- [Joshua Nussbaum's original implementation of spree-sitemap-generator](https://github.com/joshnuss/spree-sitemap-generator)
|
80
|
+
|
81
|
+
---
|
82
|
+
|
83
|
+
## Upgrading
|
84
|
+
|
85
|
+
If you upgrade from early versions of `solidus_dynamic_sitemaps` you need to change your sitemaps from:
|
86
|
+
```ruby
|
87
|
+
SitemapGenerator::Sitemap.add_links do
|
88
|
+
# ...
|
89
|
+
end
|
90
|
+
```
|
91
|
+
|
92
|
+
to this:
|
93
|
+
```ruby
|
94
|
+
SitemapGenerator::Sitemap.create do
|
95
|
+
# ...
|
96
|
+
end
|
97
|
+
```
|
98
|
+
|
99
|
+
---
|
100
|
+
|
101
|
+
## Contributing
|
102
|
+
|
103
|
+
See corresponding [guidelines][2]
|
104
|
+
|
105
|
+
---
|
106
|
+
|
107
|
+
Copyright (c) 2016 [Stembolt](https://stembolt.com/)
|
108
|
+
|
109
|
+
Copyright (c) 2011-2015 [Jeff Dutil][5] and other [contributors][6], released under the [New BSD License][4].
|
110
|
+
|
111
|
+
[1]: http://github.com/kjvarga/sitemap_generator
|
112
|
+
[2]: https://github.com/spree-contrib/spree_i18n/blob/master/CONTRIBUTING.md
|
113
|
+
[4]: https://github.com/spree-contrib/spree_sitemap/blob/master/LICENSE.md
|
114
|
+
[5]: https://github.com/jdutil
|
115
|
+
[6]: https://github.com/solidusio-contrib/solidus_sitemap/graphs/contributors
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'bundler'
|
4
|
+
Bundler::GemHelper.install_tasks
|
5
|
+
|
6
|
+
require 'rspec/core/rake_task'
|
7
|
+
require 'spree/testing_support/extension_rake'
|
8
|
+
|
9
|
+
RSpec::Core::RakeTask.new
|
10
|
+
|
11
|
+
task :default do
|
12
|
+
if Dir["spec/dummy"].empty?
|
13
|
+
Rake::Task[:test_app].invoke
|
14
|
+
Dir.chdir("../../")
|
15
|
+
end
|
16
|
+
Rake::Task[:spec].invoke
|
17
|
+
end
|
18
|
+
|
19
|
+
desc 'Generates a dummy app for testing'
|
20
|
+
task :test_app do
|
21
|
+
ENV['LIB_NAME'] = 'solidus_dynamic_sitemaps'
|
22
|
+
Rake::Task['extension:test_app'].invoke
|
23
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
class Spree::SitemapController < Spree::BaseController
|
2
|
+
def index
|
3
|
+
@public_dir = root_url
|
4
|
+
@products = Spree::Product.available
|
5
|
+
@taxonomies = Spree::Taxonomy.all
|
6
|
+
@pages = _select_static_pages
|
7
|
+
|
8
|
+
respond_to do |format|
|
9
|
+
format.html { }
|
10
|
+
format.xml do
|
11
|
+
nav = _build_taxon_hash
|
12
|
+
nav = _build_pages_hash nav
|
13
|
+
nav = _add_products_to_tax nav, false
|
14
|
+
render layout: false, xml: _build_xml(nav)
|
15
|
+
end
|
16
|
+
|
17
|
+
format.text do
|
18
|
+
@nav = _add_products_to_tax(_build_taxon_hash, false)
|
19
|
+
render layout: false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def _build_xml(nav)
|
27
|
+
''.tap do |output|
|
28
|
+
xml = Builder::XmlMarkup.new(:target => output, :indent => 2)
|
29
|
+
xml.instruct! :xml, :version => "1.0", :encoding => "UTF-8"
|
30
|
+
xml.urlset( :xmlns => "http://www.sitemaps.org/schemas/sitemap/0.9" ) {
|
31
|
+
xml.url {
|
32
|
+
xml.loc @public_dir
|
33
|
+
xml.lastmod Date.today
|
34
|
+
xml.changefreq 'daily'
|
35
|
+
xml.priority '1.0'
|
36
|
+
}
|
37
|
+
nav.each do |k, v|
|
38
|
+
xml.url {
|
39
|
+
xml.loc @public_dir + v['link']
|
40
|
+
xml.lastmod v['updated'].xmlschema #change timestamp of last modified
|
41
|
+
xml.changefreq 'weekly'
|
42
|
+
xml.priority '0.8'
|
43
|
+
}
|
44
|
+
end
|
45
|
+
}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def _build_taxon_hash
|
50
|
+
nav = Hash.new
|
51
|
+
|
52
|
+
Spree::Taxon.all.each do |taxon|
|
53
|
+
tinfo = Hash.new
|
54
|
+
tinfo['name'] = taxon.name
|
55
|
+
tinfo['depth'] = taxon.permalink.split('/').size
|
56
|
+
tinfo['link'] = 't/' + taxon.permalink
|
57
|
+
tinfo['updated'] = taxon.updated_at
|
58
|
+
nav[taxon.permalink] = tinfo
|
59
|
+
end
|
60
|
+
|
61
|
+
nav
|
62
|
+
end
|
63
|
+
|
64
|
+
def _add_products_to_tax(nav, multiples_allowed)
|
65
|
+
Spree::Product.available.each do |product|
|
66
|
+
pinfo = Hash.new
|
67
|
+
pinfo['name'] = product.name
|
68
|
+
pinfo['link'] = 'products/' + product.permalink # primary
|
69
|
+
pinfo['updated'] = product.updated_at
|
70
|
+
nav[pinfo['link']] = pinfo # store primary
|
71
|
+
end
|
72
|
+
|
73
|
+
nav
|
74
|
+
end
|
75
|
+
|
76
|
+
def _build_pages_hash(nav)
|
77
|
+
return nav if @pages.empty?
|
78
|
+
|
79
|
+
@pages.each do |page|
|
80
|
+
nav[page.slug] = {'name' => page.title,
|
81
|
+
'link' => page.slug.gsub(/^\//, ''),
|
82
|
+
'updated' => page.updated_at}
|
83
|
+
end
|
84
|
+
|
85
|
+
nav
|
86
|
+
end
|
87
|
+
|
88
|
+
def _select_static_pages
|
89
|
+
pages = []
|
90
|
+
|
91
|
+
begin
|
92
|
+
slugs_to_reject = ["/on-main-page"]
|
93
|
+
|
94
|
+
Spree::Page.visible.each do |page|
|
95
|
+
pages << page unless slugs_to_reject.include?(page.slug)
|
96
|
+
end
|
97
|
+
|
98
|
+
pages
|
99
|
+
rescue NameError
|
100
|
+
pages = []
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<h1><%= Spree.t(:sitemap) %></h1>
|
2
|
+
<%= link_to Spree::Store.default.name, @public_dir %><br />
|
3
|
+
|
4
|
+
<% unless @pages %>
|
5
|
+
<ul>
|
6
|
+
<% @pages.each do |page| %>
|
7
|
+
<li><%= link_to page.title, @public_dir + page.slug %></li>
|
8
|
+
<% end %>
|
9
|
+
</ul>
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
<% unless @taxonomies.blank? %>
|
13
|
+
<% @taxonomies.each do |taxonomy| %>
|
14
|
+
<% taxons = Spree::Taxon.where(taxonomy_id: taxonomy.id) %>
|
15
|
+
|
16
|
+
<h3><%= taxonomy.name %></h3>
|
17
|
+
|
18
|
+
<ul>
|
19
|
+
<% taxons.each do |taxon| %>
|
20
|
+
<% unless taxon.name == taxonomy.name %><li><%= link_to taxon.name, @public_dir + taxon.permalink %></li><% end %>
|
21
|
+
<% end %>
|
22
|
+
</ul>
|
23
|
+
<% end %>
|
24
|
+
<% end %>
|
25
|
+
|
26
|
+
<% unless @products %>
|
27
|
+
<h3>Products</h3>
|
28
|
+
|
29
|
+
<ul>
|
30
|
+
<% @products.each do |product| %>
|
31
|
+
<li><%= link_to product.name, @public_dir + "products/" + product.slug %></li>
|
32
|
+
<% end %>
|
33
|
+
</ul>
|
34
|
+
<% end %>
|
File without changes
|
data/config/routes.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
module SolidusDynamicSitemaps
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path('../../../templates', __FILE__)
|
5
|
+
|
6
|
+
desc 'Configures your Rails application for use with solidus_sitemap'
|
7
|
+
def copy_config
|
8
|
+
directory 'config'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
SitemapGenerator::Sitemap.default_host = "http://#{Spree::Store.default.url}"
|
2
|
+
|
3
|
+
##
|
4
|
+
## If using Heroku or similar service where you want sitemaps to live in S3 you'll need to setup these settings.
|
5
|
+
##
|
6
|
+
|
7
|
+
## Pick a place safe to write the files
|
8
|
+
# SitemapGenerator::Sitemap.public_path = 'tmp/'
|
9
|
+
|
10
|
+
## Store on S3 using Fog - Note must add fog to your Gemfile.
|
11
|
+
# SitemapGenerator::Sitemap.adapter = SitemapGenerator::S3Adapter.new(aws_access_key_id: Spree::Config[:s3_access_key],
|
12
|
+
# aws_secret_access_key: Spree::Config[:s3_secret],
|
13
|
+
# fog_provider: 'AWS',
|
14
|
+
# fog_directory: Spree::Config[:s3_bucket])
|
15
|
+
|
16
|
+
## Inform the map cross-linking where to find the other maps.
|
17
|
+
# SitemapGenerator::Sitemap.sitemaps_host = "http://#{Spree::Config[:s3_bucket]}.s3.amazonaws.com/"
|
18
|
+
|
19
|
+
## Pick a namespace within your bucket to organize your maps. Note you'll need to set this directory to be public.
|
20
|
+
# SitemapGenerator::Sitemap.sitemaps_path = 'sitemaps/'
|
21
|
+
|
22
|
+
SitemapGenerator::Sitemap.create do
|
23
|
+
# Put links creation logic here.
|
24
|
+
#
|
25
|
+
# The root path '/' and sitemap index file are added automatically.
|
26
|
+
# Links are added to the Sitemap in the order they are specified.
|
27
|
+
#
|
28
|
+
# Usage: add(path, options = {})
|
29
|
+
# (default options are used if you don't specify)
|
30
|
+
#
|
31
|
+
# Defaults: priority: 0.5, changefreq: 'weekly',
|
32
|
+
# lastmod: Time.now, host: default_host
|
33
|
+
#
|
34
|
+
#
|
35
|
+
# Examples:
|
36
|
+
#
|
37
|
+
# Add '/articles'
|
38
|
+
#
|
39
|
+
# add articles_path, priority: 0.7, changefreq: 'daily'
|
40
|
+
#
|
41
|
+
# Add individual articles:
|
42
|
+
#
|
43
|
+
# Article.find_each do |article|
|
44
|
+
# add article_path(article), lastmod: article.updated_at
|
45
|
+
# end
|
46
|
+
add_login
|
47
|
+
add_signup
|
48
|
+
add_account
|
49
|
+
add_password_reset
|
50
|
+
add_taxons
|
51
|
+
add_products
|
52
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module SolidusDynamicSitemaps
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
require 'spree'
|
4
|
+
|
5
|
+
engine_name 'solidus_dynamic_sitemaps'
|
6
|
+
|
7
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
8
|
+
|
9
|
+
# use rspec for tests
|
10
|
+
config.generators do |g|
|
11
|
+
g.test_framework :rspec
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.activate
|
15
|
+
Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c|
|
16
|
+
Rails.env.production? ? require(c) : load(c)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
config.to_prepare &method(:activate).to_proc
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
# Define your Spree extensions Factories within this file to enable applications, and other extensions to use and override them.
|
3
|
+
#
|
4
|
+
# Example adding this to your spec_helper will load these Factories for use:
|
5
|
+
# require 'solidus_dynamic_sitemaps/factories'
|
6
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
module SolidusDynamicSitemaps::SolidusDefaults
|
2
|
+
include Spree::Core::Engine.routes.url_helpers
|
3
|
+
include Spree::BaseHelper # for meta_data
|
4
|
+
|
5
|
+
def default_url_options
|
6
|
+
{ host: SitemapGenerator::Sitemap.default_host }
|
7
|
+
end
|
8
|
+
|
9
|
+
def add_login(options = {})
|
10
|
+
add(login_path, options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def add_signup(options = {})
|
14
|
+
add(signup_path, options)
|
15
|
+
end
|
16
|
+
|
17
|
+
def add_account(options = {})
|
18
|
+
add(account_path, options)
|
19
|
+
end
|
20
|
+
|
21
|
+
def add_password_reset(options = {})
|
22
|
+
add(new_spree_user_password_path, options)
|
23
|
+
end
|
24
|
+
|
25
|
+
def add_products(options = {})
|
26
|
+
available_products = Spree::Product.available.distinct
|
27
|
+
|
28
|
+
add(products_path, options.merge(lastmod: available_products.last_updated))
|
29
|
+
available_products.each do |product|
|
30
|
+
add_product(product, options)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def add_product(product, options = {})
|
35
|
+
opts = options.merge(lastmod: product.updated_at)
|
36
|
+
|
37
|
+
if gem_available?('spree_videos') && product.videos.present?
|
38
|
+
# TODO: add exclusion list configuration option
|
39
|
+
# https://sites.google.com/site/webmasterhelpforum/en/faq-video-sitemaps#multiple-pages
|
40
|
+
|
41
|
+
# don't include all the videos on the page to avoid duplicate title warnings
|
42
|
+
primary_video = product.videos.first
|
43
|
+
opts.merge!(video: [video_options(primary_video.youtube_ref, product)])
|
44
|
+
end
|
45
|
+
|
46
|
+
add(product_path(product), opts)
|
47
|
+
end
|
48
|
+
|
49
|
+
def add_pages(options = {})
|
50
|
+
# TODO: this should be refactored to add_pages & add_page
|
51
|
+
|
52
|
+
Spree::Page.active.each do |page|
|
53
|
+
add(page.path, options.merge(lastmod: page.updated_at))
|
54
|
+
end if gem_available? 'spree_essential_cms'
|
55
|
+
|
56
|
+
Spree::Page.visible.each do |page|
|
57
|
+
add(page.slug, options.merge(lastmod: page.updated_at))
|
58
|
+
end if gem_available? 'spree_static_content'
|
59
|
+
end
|
60
|
+
|
61
|
+
def add_taxons(options = {})
|
62
|
+
Spree::Taxon.roots.each { |taxon| add_taxon(taxon, options) }
|
63
|
+
end
|
64
|
+
|
65
|
+
def add_taxon(taxon, options = {})
|
66
|
+
add(nested_taxons_path(taxon.permalink), options.merge(lastmod: taxon.products.last_updated)) if taxon.permalink.present?
|
67
|
+
taxon.children.each { |child| add_taxon(child, options) }
|
68
|
+
end
|
69
|
+
|
70
|
+
def gem_available?(name)
|
71
|
+
Gem::Specification.find_by_name(name)
|
72
|
+
rescue Gem::LoadError
|
73
|
+
false
|
74
|
+
rescue
|
75
|
+
Gem.available?(name)
|
76
|
+
end
|
77
|
+
|
78
|
+
def main_app
|
79
|
+
Rails.application.routes.url_helpers
|
80
|
+
end
|
81
|
+
|
82
|
+
private
|
83
|
+
|
84
|
+
##
|
85
|
+
# Multiple videos of the same ID can exist, but all videos linked in the sitemap should be inique
|
86
|
+
#
|
87
|
+
# Required video fields:
|
88
|
+
# http://www.seomoz.org/blog/video-sitemap-guide-for-vimeo-and-youtube
|
89
|
+
#
|
90
|
+
# YouTube thumbnail images:
|
91
|
+
# http://www.reelseo.com/youtube-thumbnail-image/
|
92
|
+
#
|
93
|
+
# NOTE title should match the page title, however the title generation isn't self-contained
|
94
|
+
# although not a future proof solution, the best (+ easiest) solution is to mimic the title for product pages
|
95
|
+
# https://github.com/solidusio/solidus/blob/1-3-stable/core/lib/spree/core/controller_helpers/common.rb#L39
|
96
|
+
# https://github.com/solidusio/solidus/blob/1-3-stable/core/app/controllers/spree/products_controller.rb#L41
|
97
|
+
#
|
98
|
+
def video_options(youtube_id, object = false)
|
99
|
+
({ description: meta_data(object)[:description] } rescue {}).merge(
|
100
|
+
({ title: [Spree::Config[:site_name], object.name].join(' - ') } rescue {})
|
101
|
+
).merge(
|
102
|
+
thumbnail_loc: "http://img.youtube.com/vi/#{youtube_id}/0.jpg",
|
103
|
+
player_loc: "http://www.youtube.com/v/#{youtube_id}",
|
104
|
+
autoplay: 'ap=1'
|
105
|
+
)
|
106
|
+
end
|
107
|
+
end
|
metadata
ADDED
@@ -0,0 +1,221 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: solidus_dynamic_sitemaps
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.0'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jonathan Tapia
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-12-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: solidus_core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.2.0
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '3'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.2.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: solidus_support
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 0.1.3
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.1.3
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: sitemap_generator
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 5.1.0
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 5.1.0
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: byebug
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: database_cleaner
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 1.4.0
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 1.4.0
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: factory_bot
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '4.5'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '4.5'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: ffaker
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.25.0
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 1.25.0
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: pry-rails
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: 0.3.0
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: 0.3.0
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: rubocop
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: 0.24.1
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: 0.24.1
|
145
|
+
- !ruby/object:Gem::Dependency
|
146
|
+
name: rspec-rails
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - "~>"
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '3.5'
|
152
|
+
type: :development
|
153
|
+
prerelease: false
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - "~>"
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '3.5'
|
159
|
+
- !ruby/object:Gem::Dependency
|
160
|
+
name: simplecov
|
161
|
+
requirement: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - "~>"
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0.9'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - "~>"
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0.9'
|
173
|
+
description: Soldius Engine for sitemaps
|
174
|
+
email: jonathan.tapia@magmalabs.io
|
175
|
+
executables: []
|
176
|
+
extensions: []
|
177
|
+
extra_rdoc_files: []
|
178
|
+
files:
|
179
|
+
- MIT-LICENSE
|
180
|
+
- README.md
|
181
|
+
- Rakefile
|
182
|
+
- app/controllers/spree/sitemap_controller.rb
|
183
|
+
- app/helpers/spree/sitemap_helper.rb
|
184
|
+
- app/models/product_decorator.rb
|
185
|
+
- app/views/spree/sitemap/index.html.erb
|
186
|
+
- app/views/spree/sitemap/index.text.erb
|
187
|
+
- app/views/spree/sitemap/index.xml.builder
|
188
|
+
- config/locales/en.yml
|
189
|
+
- config/locales/es-MX.yml
|
190
|
+
- config/routes.rb
|
191
|
+
- lib/generators/solidus_dynamic_sitemaps/install/install_generator.rb
|
192
|
+
- lib/generators/templates/config/sitemap.rb
|
193
|
+
- lib/solidus_dynamic_sitemaps.rb
|
194
|
+
- lib/solidus_dynamic_sitemaps/engine.rb
|
195
|
+
- lib/solidus_dynamic_sitemaps/factories.rb
|
196
|
+
- lib/solidus_dynamic_sitemaps/solidus_defaults.rb
|
197
|
+
- lib/solidus_dynamic_sitemaps/version.rb
|
198
|
+
homepage: http://github.com/jtapia/solidus_dynamic_sitemaps
|
199
|
+
licenses: []
|
200
|
+
metadata: {}
|
201
|
+
post_install_message:
|
202
|
+
rdoc_options: []
|
203
|
+
require_paths:
|
204
|
+
- lib
|
205
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
206
|
+
requirements:
|
207
|
+
- - ">="
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
version: '0'
|
210
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
211
|
+
requirements:
|
212
|
+
- - ">="
|
213
|
+
- !ruby/object:Gem::Version
|
214
|
+
version: '0'
|
215
|
+
requirements: []
|
216
|
+
rubyforge_project:
|
217
|
+
rubygems_version: 2.7.3
|
218
|
+
signing_key:
|
219
|
+
specification_version: 4
|
220
|
+
summary: Soldius Engine for sitemaps
|
221
|
+
test_files: []
|