Module: SitemapGenerator::LinkSet::LocationHelpers
- Included in:
- SitemapGenerator::LinkSet
- Defined in:
- lib/sitemap_generator/link_set.rb
Instance Method Summary (collapse)
-
- (Object) create_index=(value, force = false)
Set the value of create_index on the SitemapIndexLocation object of the SitemapIndexFile.
-
- (Object) default_host=(value)
Set the host name, including protocol, that will be used by default on each of your sitemap links.
-
- (Object) filename=(value)
Set the filename base to use when generating sitemaps (and the sitemap index).
-
- (Object) namer
Return the namer object.
-
- (Object) namer=(value)
Set the namer to use to generate the sitemap (and index) file names.
-
- (Object) public_path
Return a Pathname with the full path to the public directory.
-
- (Object) public_path=(value)
Set the public_path.
-
- (Object) search_engines
Return the hash of search engines.
-
- (Object) search_engines=(value)
Set the search engines hash to a new hash of search engine names mapped to ping URLs (see ping_search_engines).
-
- (Object) sitemap_index_location
Return a new SitemapIndexLocation instance with the current options included.
-
- (Object) sitemap_location
Return a new SitemapLocation instance with the current options included.
-
- (Object) sitemaps_host=(value)
Set the host name, including protocol, that will be used on all links to your sitemap files.
-
- (Object) sitemaps_path=(value)
Set the sitemaps_path.
Instance Method Details
- (Object) create_index=(value, force = false)
Set the value of create_index on the SitemapIndexLocation object of the SitemapIndexFile.
585 586 587 588 589 590 591 |
# File 'lib/sitemap_generator/link_set.rb', line 585 def create_index=(value, force=false) @create_index = value # Allow overriding the protected status of the index when we are creating a group. # Because sometimes we need to force an index in that case. But generally we don't # want to allow people to mess with this value if the index is protected. @sitemap_index.location[:create_index] = value if @sitemap_index && ((!@sitemap_index.finalized? && !@protect_index) || force) end |
- (Object) default_host=(value)
Set the host name, including protocol, that will be used by default on each of your sitemap links. You can pass a different host in your options to `add` if you need to change it on a per-link basis.
489 490 491 492 |
# File 'lib/sitemap_generator/link_set.rb', line 489 def default_host=(value) @default_host = value update_location_info(:host, value) end |
- (Object) filename=(value)
Set the filename base to use when generating sitemaps (and the sitemap index).
Example
filename = :sitemap
Generates
sitemap.xml.gz, sitemap1.xml.gz, sitemap2.xml.gz, ...
539 540 541 542 |
# File 'lib/sitemap_generator/link_set.rb', line 539 def filename=(value) @filename = value self.namer = SitemapGenerator::SimpleNamer.new(@filename) end |
- (Object) namer
Return the namer object. If it is not set, looks for it on the current sitemap and if there is no sitemap, creates a new one using the current filename.
604 605 606 |
# File 'lib/sitemap_generator/link_set.rb', line 604 def namer @namer ||= @sitemap && @sitemap.location.namer || SitemapGenerator::SimpleNamer.new(@filename) end |
- (Object) namer=(value)
Set the namer to use to generate the sitemap (and index) file names. This should be an instance of SitemapGenerator::SimpleNamer
595 596 597 598 599 |
# File 'lib/sitemap_generator/link_set.rb', line 595 def namer=(value) @namer = value @sitemap.location[:namer] = value if @sitemap && !@sitemap.finalized? @sitemap_index.location[:namer] = value if @sitemap_index && !@sitemap_index.finalized? && !@protect_index end |
- (Object) public_path
Return a Pathname with the full path to the public directory
509 510 511 |
# File 'lib/sitemap_generator/link_set.rb', line 509 def public_path @public_path ||= self.send(:public_path=, 'public/') end |
- (Object) public_path=(value)
Set the public_path. This path gives the location of your public directory. The default is the public/ directory in your Rails root. Or if Rails is not found, it defaults to public/ in the current directory (of the process).
Example: 'tmp/' if you don't want to generate in public for some reason.
Set to nil to use the current directory.
501 502 503 504 505 506 |
# File 'lib/sitemap_generator/link_set.rb', line 501 def public_path=(value) @public_path = Pathname.new(value.to_s) @public_path = SitemapGenerator.app.root + @public_path if @public_path.relative? update_location_info(:public_path, @public_path) @public_path end |
- (Object) search_engines
Return the hash of search engines.
554 555 556 |
# File 'lib/sitemap_generator/link_set.rb', line 554 def search_engines @search_engines || {} end |
- (Object) search_engines=(value)
Set the search engines hash to a new hash of search engine names mapped to ping URLs (see ping_search_engines). If the value is nil it is converted to an empty hash.
Example
search_engines = { :google => "http://www.google.com/webmasters/sitemaps/ping?sitemap=%s" }
549 550 551 |
# File 'lib/sitemap_generator/link_set.rb', line 549 def search_engines=(value) @search_engines = value || {} end |
- (Object) sitemap_index_location
Return a new SitemapIndexLocation instance with the current options included
571 572 573 574 575 576 577 578 579 580 581 |
# File 'lib/sitemap_generator/link_set.rb', line 571 def sitemap_index_location SitemapGenerator::SitemapLocation.new( :host => sitemaps_host, :namer => sitemap_index_namer || namer, # sitemap_index_namer is deprecated :public_path => public_path, :sitemaps_path => @sitemaps_path, :adapter => @adapter, :verbose => verbose, :create_index => @create_index ) end |
- (Object) sitemap_location
Return a new SitemapLocation instance with the current options included
559 560 561 562 563 564 565 566 567 568 |
# File 'lib/sitemap_generator/link_set.rb', line 559 def sitemap_location SitemapGenerator::SitemapLocation.new( :host => sitemaps_host, :namer => sitemaps_namer || namer, # sitemaps_namer is deprecated :public_path => public_path, :sitemaps_path => @sitemaps_path, :adapter => @adapter, :verbose => verbose ) end |
- (Object) sitemaps_host=(value)
Set the host name, including protocol, that will be used on all links to your sitemap files. Useful when the server that hosts the sitemaps is not on the same host as the links in the sitemap.
Note that `include_index` will be turned off to avoid adding a link to a sitemap with a different host than the other links.
527 528 529 530 |
# File 'lib/sitemap_generator/link_set.rb', line 527 def sitemaps_host=(value) @sitemaps_host = value update_location_info(:host, value) end |
- (Object) sitemaps_path=(value)
Set the sitemaps_path. This path gives the location to write sitemaps to relative to your public_path. Example: 'sitemaps/' to generate your sitemaps in 'public/sitemaps/'.
516 517 518 519 |
# File 'lib/sitemap_generator/link_set.rb', line 516 def sitemaps_path=(value) @sitemaps_path = value update_location_info(:sitemaps_path, value) end |