module DynamicSitemaps
Contains the result of a sitemap generation
Constants
- DEFAULT_ALWAYS_GENERATE_INDEX
- DEFAULT_FOLDER
- DEFAULT_INDEX_FILE_NAME
- DEFAULT_PER_PAGE
- DEFAULT_PING_ENVIRONMENTS
- SEARCH_ENGINE_PING_URLS
- VERSION
Attributes
always_generate_index[W]
index_file_name[W]
per_page[W]
ping_environments[W]
search_engine_ping_urls[W]
Public Class Methods
always_generate_index()
click to toggle source
# File lib/dynamic_sitemaps.rb, line 74 def always_generate_index return @always_generate_index if instance_variable_defined?(:@always_generate_index) @always_generate_index = DEFAULT_ALWAYS_GENERATE_INDEX end
config_path()
click to toggle source
# File lib/dynamic_sitemaps.rb, line 79 def config_path @config_path ||= Rails.root.join("config", "sitemap.rb").to_s end
config_path=(new_path)
click to toggle source
# File lib/dynamic_sitemaps.rb, line 83 def config_path=(new_path) raise ArgumentError, "DynamicSitemaps.config_path can't be blank." if new_path.blank? @config_path = new_path.to_s end
configure() { |self| ... }
click to toggle source
Configure DynamicSitemaps
. Defaults:
DynamicSitemaps.configure do |config| config.path = Rails.root.join("public") config.folder = "sitemaps" config.index_file_name = "sitemap.xml" config.always_generate_index = false config.config_path = Rails.root.join("config", "sitemap.rb") config.per_page = 50_000 end
To ping search engines after generating the sitemap:
DynamicSitemaps.configure do |config| config.search_engine_ping_urls << "http://customsearchengine.com/ping?url=%s" # Default is Google and Bing config.ping_environments << "staging" # Default is production end
# File lib/dynamic_sitemaps.rb, line 48 def configure yield self end
folder()
click to toggle source
# File lib/dynamic_sitemaps.rb, line 52 def folder @folder ||= DEFAULT_FOLDER end
folder=(new_folder)
click to toggle source
# File lib/dynamic_sitemaps.rb, line 56 def folder=(new_folder) raise ArgumentError, "DynamicSitemaps.folder can't be blank." if new_folder.blank? @folder = new_folder end
generate_sitemap(&block)
click to toggle source
Generates the sitemap(s) and index based on the configuration file specified in DynamicSitemaps.config_path
. If you supply a block, that block is evaluated instead of the configuration file.
# File lib/dynamic_sitemaps.rb, line 26 def generate_sitemap(&block) DynamicSitemaps::Generator.new.generate(&block) end
index_file_name()
click to toggle source
# File lib/dynamic_sitemaps.rb, line 70 def index_file_name @index_file_name ||= DEFAULT_INDEX_FILE_NAME end
path()
click to toggle source
# File lib/dynamic_sitemaps.rb, line 61 def path @path ||= Rails.root.join("public").to_s end
path=(new_path)
click to toggle source
# File lib/dynamic_sitemaps.rb, line 65 def path=(new_path) raise ArgumentError, "DynamicSitemaps.path can't be blank." if new_path.blank? @path = new_path.to_s end
per_page()
click to toggle source
# File lib/dynamic_sitemaps.rb, line 88 def per_page @per_page ||= DEFAULT_PER_PAGE end
ping_environments()
click to toggle source
# File lib/dynamic_sitemaps.rb, line 96 def ping_environments @ping_environments ||= DEFAULT_PING_ENVIRONMENTS.dup end
reset!()
click to toggle source
Resets all instance variables. Used for testing.
# File lib/dynamic_sitemaps.rb, line 110 def reset! instance_variables.each { |var| remove_instance_variable var } end
search_engine_ping_urls()
click to toggle source
# File lib/dynamic_sitemaps.rb, line 92 def search_engine_ping_urls @search_engine_ping_urls ||= SEARCH_ENGINE_PING_URLS.dup end
sitemap_ping_urls=(array_or_proc)
click to toggle source
Removed in version 2.0.0.beta2
# File lib/dynamic_sitemaps.rb, line 101 def sitemap_ping_urls=(array_or_proc) raise "sitemap_ping_urls has been removed. Please use `ping \"http://example.com/sitemap.xml\"` in config/sitemap.rb instead." end
temp_path()
click to toggle source
# File lib/dynamic_sitemaps.rb, line 105 def temp_path @temp_path ||= Rails.root.join("tmp", "dynamic_sitemaps").to_s end