Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Remove geo and cleanup builder #24

Merged
merged 2 commits into from over 2 years ago

2 participants

Tobias Bielohlawek Alex Rabarts
Tobias Bielohlawek
Collaborator

Another small change: get rid of geobuilder (it never worked right & was tested anyway), make header config consistent using class constants.

Alex Rabarts alexrabarts merged commit 69f13b9 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.

Showing 2 changed files with 8 additions and 19 deletions. Show diff stats Hide diff stats

  1. +0 3  lib/big_sitemap.rb
  2. +8 16 lib/big_sitemap/builder.rb
3  lib/big_sitemap.rb
@@ -378,9 +378,6 @@ def with_sitemap(options={})
378 378
379 379 sitemap = if options[:type] == 'index'
380 380 IndexBuilder.new(options)
381   - elsif options[:geo]
382   - options[:filename] << '_kml'
383   - GeoBuilder.new(options)
384 381 else
385 382 Builder.new(options)
386 383 end
24 lib/big_sitemap/builder.rb
@@ -4,10 +4,11 @@
4 4 class BigSitemap
5 5 class Builder
6 6 MAX_URLS = 50000
  7 + HEADER_NAME = 'urlset'
7 8 HEADER_ATTRIBUTES = {
8 9 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9',
9 10 'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",
10   - 'xsi:schemaLocation' => "http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
  11 + 'xsi:schemaLocation' => "http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
11 12 }
12 13
13 14 def initialize(options)
@@ -75,11 +76,11 @@ def _open_writer(filename)
75 76 @gzip ? ::Zlib::GzipWriter.new(file) : file
76 77 end
77 78
78   - def _init_document(name='urlset', attrs=HEADER_ATTRIBUTES)
  79 + def _init_document
79 80 @urls = 0
80 81 target!.print '<?xml version="1.0" encoding="UTF-8"?>'
81 82 _newline
82   - _open_tag name, attrs
  83 + _open_tag self.class::HEADER_NAME, self.class::HEADER_ATTRIBUTES
83 84 end
84 85
85 86 def _rotate(part_nr=nil)
@@ -141,10 +142,10 @@ def _newline
141 142 end
142 143
143 144 class IndexBuilder < Builder
144   - def _init_document(name = 'sitemapindex', attrs = {'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9'})
145   - attrs.merge('xmlns:geo' => "http://www.google.com/geo/schemas/sitemap/1.0")
146   - super(name, attrs)
147   - end
  145 + HEADER_NAME = 'sitemapindex'
  146 + HEADER_ATTRIBUTES = {
  147 + 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9'
  148 + }
148 149
149 150 def add_url!(location, options={})
150 151 _open_tag 'sitemap'
@@ -156,14 +157,5 @@ def add_url!(location, options={})
156 157 end
157 158 end
158 159
159   - class GeoBuilder < Builder
160   - #_build_geo if @geo
161   -
162   - # def _build_geo
163   - # geo :geo do
164   - # geo :format, 'kml'
165   - # end
166   - # end
167   - end
168 160
169 161 end

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.