apsoto-sitemap_generator 1.0.1.dev → 1.1.0.dev

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,29 +1,37 @@
1
1
  SitemapGenerator
2
2
  ================
3
3
 
4
- SitemapGenerator is a Rails gem that makes it easy to generate ['enterprise-class'][enterprise_class] Sitemaps readable by all search engines. Generated Sitemaps adhere to the ['Sitemap protocol specification'][sitemap_protocol]. When you generate new Sitemaps, SitemapGenerator can automatically ping the major search engines (including Google, Yahoo and Bing) to notify them. SitemapGenerator includes rake tasks to easily manage your sitemaps.
4
+ SitemapGenerator generates Sitemaps for your Rails application. The Sitemaps adhere to the [Sitemap 0.9 protocol][sitemap_protocol] specification. You specify the contents of your Sitemap using a configuration file, à la Rails Routes. A set of rake tasks is included to help you manage your Sitemaps.
5
5
 
6
6
  Features
7
7
  -------
8
8
 
9
- - v0.2.6: ['Google Image Sitemap'][sitemap_images] support
10
- - v0.2.5: Rails 3 support (beta)
11
-
12
- - Adheres to the ['Sitemap protocol specification'][sitemap_protocol]
9
+ - Supports [Video sitemaps][sitemap_video] and [Image sitemaps][sitemap_images]
10
+ - Rails3 compatible (beta)
11
+ - Adheres to the [Sitemap 0.9 protocol][sitemap_protocol]
13
12
  - Handles millions of links
14
- - Automatic Gzip of Sitemap files
15
- - Automatic ping of search engines to notify them of new sitemaps: Google, Yahoo, Bing, Ask, SitemapWriter
16
- - Leaves your old sitemaps in place if a new one fails to generate
17
- - Allows you to set the hostname for the links in your Sitemap
13
+ - Compresses Sitemaps using GZip
14
+ - Notifies Search Engines (Google, Yahoo, Bing, Ask, SitemapWriter) of new sitemaps
15
+ - Ensures your old Sitemaps stay in place if the new Sitemap fails to generate
16
+ - You set the hostname (and protocol) of the links in your Sitemap
17
+
18
+ Changelog
19
+ -------
20
+
21
+ - v1.1.0: [Video sitemap][sitemap_video] support
22
+ - v0.2.6: [Image Sitemap][sitemap_images] support
23
+ - v0.2.5: Rails 3 support (beta)
18
24
 
19
25
  Foreword
20
26
  -------
21
27
 
22
- Unfortunately, Adam Salter passed away in 2009. Those who knew him know what an amazing guy he was, and what an excellent Rails programmer he was. His passing is a great loss to the Rails community.
28
+ Adam Salter first created SitemapGenerator while we were working together in Sydney, Australia. Unfortunately, he passed away in 2009. Since then I have taken over development of SitemapGenerator.
23
29
 
24
- [Karl Varga](http://github.com/kjvarga) has taken over development of SitemapGenerator. The canonical repository is [http://github.com/kjvarga/sitemap_generator][canonical_repo]
30
+ Those who knew him know what an amazing guy he was, and what an excellent Rails programmer he was. His passing is a great loss to the Rails community.
25
31
 
26
- Installation
32
+ The canonical repository is now: [http://github.com/kjvarga/sitemap_generator][canonical_repo]
33
+
34
+ Install
27
35
  =======
28
36
 
29
37
  **Rails 3:**
@@ -56,31 +64,55 @@ Installation
56
64
 
57
65
  1. <code>$ ./script/plugin install git://github.com/kjvarga/sitemap_generator.git</code>
58
66
 
59
- ----
67
+ Usage
68
+ ======
69
+
70
+ <code>rake sitemap:install</code> creates a <tt>config/sitemap.rb</tt> file which will contain your logic for generating the Sitemap files.
71
+
72
+ Once you have configured your sitemap in <tt>config/sitemap.rb</tt> run <code>rake sitemap:refresh</code> as needed to create/rebuild your Sitemap files. Sitemaps are generated into the <tt>public/</tt> folder and are named <tt>sitemap_index.xml.gz</tt>, <tt>sitemap1.xml.gz</tt>, <tt>sitemap2.xml.gz</tt>, etc.
73
+
74
+ Using <code>rake sitemap:refresh</code> will notify major search engines to let them know that a new Sitemap is available (Google, Yahoo, Bing, Ask, SitemapWriter). To generate new Sitemaps without notifying search engines (for example when running in a local environment) use <code>rake sitemap:refresh:no_ping</code>.
75
+
76
+ To ping Yahoo you will need to set your Yahoo AppID in <tt>config/sitemap.rb</tt>. For example: <code>SitemapGenerator::Sitemap.yahoo_app_id = "my_app_id"</code>
60
77
 
61
- Installation creates a <tt>config/sitemap.rb</tt> file which will contain your logic for generating the Sitemap files. If you want to create this file manually run <code>rake sitemap:install</code>.
78
+ To disable all non-essential output (only errors will be displayed) run the rake tasks with the <code>-s</code> option. For example <code>rake -s sitemap:refresh</code>.
62
79
 
63
- You can run <code>rake sitemap:refresh</code> as needed to create Sitemap files. This will also ping these ['major search engines'][sitemap_engines]: Google, Yahoo, Bing, Ask, SitemapWriter. If you want to disable all non-essential output run the rake task with <code>rake -s sitemap:refresh</code>.
80
+ Cron
81
+ -----
64
82
 
65
- To keep your Sitemaps up-to-date, setup a cron job. Pass the <tt>-s</tt> option to the rake task to silence all but the most important output. If you're using Whenever, then your schedule would look something like:
83
+ To keep your Sitemaps up-to-date, setup a cron job. Make sure to pass the <code>-s</code> option to silence rake. That way you will only get email when the sitemap build fails.
84
+
85
+ If you're using Whenever, your schedule would look something like the following:
66
86
 
67
87
  # config/schedule.rb
68
88
  every 1.day, :at => '5:00 am' do
69
89
  rake "-s sitemap:refresh"
70
90
  end
71
91
 
72
- Optionally, you can add the following to your <code>public/robots.txt</code> file, so that robots can find the sitemap file:
92
+ Robots.txt
93
+ ----------
94
+
95
+ You should add the Sitemap index file to <code>public/robots.txt</code> to help search engines find your Sitemaps. The URL should be the complete URL to the Sitemap index file. For example:
96
+
97
+ Sitemap: http://www.example.org/sitemap_index.xml.gz
73
98
 
74
- Sitemap: <hostname>/sitemap_index.xml.gz
99
+ Image and Video Sitemaps
100
+ -----------
75
101
 
76
- The Sitemap URL in the robots file should be the complete URL to the Sitemap Index, such as <tt>http://www.example.org/sitemap_index.xml.gz</tt>
102
+ Images can be added to a sitemap URL by passing an <tt>:images</tt> array to <tt>add()</tt>. Each item in the array must be a Hash containing tags defined by the [Image Sitemap][image_tags] specification. For example:
77
103
 
104
+ sitemap.add('/index.html', :images => [{ :loc => 'http://www.example.com/image.png', :title => 'Image' }])
78
105
 
79
- Example 'config/sitemap.rb'
80
- ==========
106
+ A video can be added to a sitemap URL by passing a <tt>:video</tt> Hash to <tt>add()</tt>. The Hash can contain tags defined by the [Video Sitemap specification][video_tags]. To associate more than one <tt>tag</tt> with a video, pass the tags as an array with the key <tt>:tags</tt>.
107
+
108
+ sitemap.add('/index.html', :video => { :thumbnail_loc => 'http://www.example.com/video1_thumbnail.png', :title => 'Title', :description => 'Description', :content_loc => 'http://www.example.com/cool_video.mpg', :tags => %w[one two three], :category => 'Category' })
109
+
110
+ Example <code>config/sitemap.rb</code>
111
+ ---------
81
112
 
82
113
  # Set the host name for URL creation
83
114
  SitemapGenerator::Sitemap.default_host = "http://www.example.com"
115
+ SitemapGenerator::Sitemap.yahoo_app_id = nil # Set to your Yahoo AppID to ping Yahoo
84
116
 
85
117
  SitemapGenerator::Sitemap.add_links do |sitemap|
86
118
  # Put links creation logic here.
@@ -94,25 +126,21 @@ Example 'config/sitemap.rb'
94
126
  # Defaults: :priority => 0.5, :changefreq => 'weekly',
95
127
  # :lastmod => Time.now, :host => default_host
96
128
 
97
-
98
- # Examples:
99
-
100
129
  # add '/articles'
101
130
  sitemap.add articles_path, :priority => 0.7, :changefreq => 'daily'
102
131
 
103
- # add all individual articles
104
- Article.find(:all).each do |a|
132
+ # add all articles
133
+ Article.all.each do |a|
105
134
  sitemap.add article_path(a), :lastmod => a.updated_at
106
135
  end
107
136
 
108
- # add merchant path
109
- sitemap.add '/purchase', :priority => 0.7, :host => "https://www.example.com"
110
-
111
- # add all individual news with images
112
- News.all.each do |n|
113
- sitemap.add news_path(n), :lastmod => n.updated_at, :images=>n.images.collect{ |r| :loc=>r.image.url, :title=>r.image.name }
137
+ # add news page with images
138
+ News.all.each do |news|
139
+ images = news.images.collect do |image|
140
+ { :loc => image.url, :title => image.name }
141
+ end
142
+ sitemap.add news_path(news), :images => images
114
143
  end
115
-
116
144
  end
117
145
 
118
146
  # Including Sitemaps from Rails Engines.
@@ -159,9 +187,9 @@ Compatibility
159
187
 
160
188
  Tested and working on:
161
189
 
162
- - **Rails** 3.0.0, sitemap_generator version >= 0.2.5
163
- - **Rails** 1.x - 2.3.5
164
- - **Ruby** 1.8.6, 1.8.7, 1.9.1
190
+ - **Rails** 3.0.0
191
+ - **Rails** 1.x - 2.3.8
192
+ - **Ruby** 1.8.6, 1.8.7, 1.8.7 Enterprise Edition, 1.9.1
165
193
 
166
194
  Notes
167
195
  =======
@@ -185,8 +213,6 @@ Notes
185
213
  end
186
214
  end
187
215
 
188
- 3) If generation of your sitemap fails for some reason, the old sitemap will remain in public/. This ensures that robots will always find a valid sitemap. Running silently (`rake -s sitemap:refresh`) and with email forwarding setup you'll only get an email if your sitemap fails to build, and no notification when everything is fine - which will be most of the time.
189
-
190
216
  Known Bugs
191
217
  ========
192
218
 
@@ -196,15 +222,16 @@ Known Bugs
196
222
  Wishlist & Coming Soon
197
223
  ========
198
224
 
199
- - Support for generating sitemaps for sites with multiple domains. Sitemaps are generated into subdirectories and we use a Rack middleware to rewrite requests for sitemaps to the correct subdirectory based on the request host.
200
- - I want to refactor the code because it has grown a lot. Part of this refactoring will include implementing some more checks to make sure we adhere to standards as well as making sure that the sitemaps are being generated as efficiently as possible.
201
-
202
- I'd like to simplify adding links to a sitemap. Right now it's all or nothing. I'd like to break it up so you can add batches.
225
+ - Ultimately I'd like to make this gem framework agnostic. It is better suited to being run as a command-line tool as opposed to Ruby-specific Rake tasks.
226
+ - Add rake tasks/options to validate the generated sitemaps.
227
+ - Support News, Mobile, Geo and other types of sitemaps
228
+ - Support for generating sitemaps for sites with multiple domains. Sitemaps can be generated into subdirectories and we can use Rack middleware to rewrite requests for sitemaps to the correct subdirectory based on the request host.
203
229
  - Auto coverage testing. Generate a report of broken URLs by checking the status codes of each page in the sitemap.
204
230
 
205
231
  Thanks (in no particular order)
206
232
  ========
207
233
 
234
+ - [Alex Soto](http://github.com/apsoto) for video sitemaps
208
235
  - [Alexadre Bini](http://github.com/alexandrebini) for image sitemaps
209
236
  - [Dan Pickett](http://github.com/dpickett)
210
237
  - [Rob Biedenharn](http://github.com/rab)
@@ -217,11 +244,11 @@ Copyright (c) 2009 Karl Varga released under the MIT license
217
244
 
218
245
  [canonical_repo]:http://github.com/kjvarga/sitemap_generator
219
246
  [enterprise_class]:https://twitter.com/dhh/status/1631034662 "I use enterprise in the same sense the Phusion guys do - i.e. Enterprise Ruby. Please don't look down on my use of the word 'enterprise' to represent being a cut above. It doesn't mean you ever have to work for a company the size of IBM. Or constantly fight inertia, writing crappy software, adhering to change management practices and spending hours in meetings... Not that there's anything wrong with that - Wait, what?"
220
- [sitemap_engines]:http://en.wikipedia.org/wiki/Sitemap_index "http://en.wikipedia.org/wiki/Sitemap_index"
221
247
  [sitemaps_org]:http://www.sitemaps.org/protocol.php "http://www.sitemaps.org/protocol.php"
222
248
  [sitemaps_xml]:http://www.sitemaps.org/protocol.php#xmlTagDefinitions "XML Tag Definitions"
223
249
  [sitemap_generator_usage]:http://wiki.github.com/adamsalter/sitemap_generator/sitemapgenerator-usage "http://wiki.github.com/adamsalter/sitemap_generator/sitemapgenerator-usage"
224
- [boost_juice]:http://www.boostjuice.com.au/ "Mmmm, sweet, sweet Boost Juice."
225
- [cb]:http://codebright.net "http://codebright.net"
226
250
  [sitemap_images]:http://www.google.com/support/webmasters/bin/answer.py?answer=178636
227
- [sitemap_protocol]:http://sitemaps.org/protocol.php
251
+ [sitemap_video]:http://www.google.com/support/webmasters/bin/topic.py?topic=10079
252
+ [sitemap_protocol]:http://sitemaps.org/protocol.php
253
+ [video_tags]:http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=80472#4
254
+ [image_tags]:http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=178636
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1.dev
1
+ 1.1.0.dev
@@ -4,6 +4,14 @@ require 'zlib'
4
4
 
5
5
  module SitemapGenerator
6
6
  module Builder
7
+ #
8
+ # General Usage:
9
+ #
10
+ # sitemap = SitemapFile.new('public/', 'sitemap.xml', 'http://example.com')
11
+ # <- creates a new sitemap file in directory public/
12
+ # sitemap.add_link({ ... }) <- add a link to the sitemap
13
+ # sitemap.finalize! <- write and close the sitemap file
14
+ #
7
15
  class SitemapFile
8
16
  include SitemapGenerator::Builder::Helper
9
17
 
@@ -104,14 +112,13 @@ module SitemapGenerator
104
112
  video = link[:video]
105
113
  builder.video :video do
106
114
  # required elements
107
- builder.video :thumbnail_loc, video[:thumbnail_loc]
108
- builder.video :title, video[:title]
109
- builder.video :description, video[:description]
110
-
111
115
  builder.video :content_loc, video[:content_loc] if video[:content_loc]
112
116
  if video[:player_loc]
113
117
  builder.video :player_loc, video[:player_loc], :allow_embed => (video[:allow_embed] ? 'yes' : 'no'), :autoplay => video[:autoplay]
114
118
  end
119
+ builder.video :thumbnail_loc, video[:thumbnail_loc]
120
+ builder.video :title, video[:title]
121
+ builder.video :description, video[:description]
115
122
 
116
123
  builder.video :rating, video[:rating] if video[:rating]
117
124
  builder.video :view_count, video[:view_count] if video[:view_count]
@@ -121,7 +128,9 @@ module SitemapGenerator
121
128
  builder.video :family_friendly, (video[:family_friendly] ? 'yes' : 'no') if video[:family_friendly]
122
129
  builder.video :duration, video[:duration] if video[:duration]
123
130
  video[:tags].each {|tag| builder.video :tag, tag } if video[:tags]
124
- video[:categories].each {|category| builder.video :category, category} if video[:categories]
131
+ builder.video :tag, video[:tag] if video[:tag]
132
+ builder.video :category, video[:category] if video[:category]
133
+ builder.video :gallery_loc, video[:gallery_loc] if video[:gallery_loc]
125
134
  end
126
135
  end
127
136
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apsoto-sitemap_generator
3
3
  version: !ruby/object:Gem::Version
4
- hash: 858800296
4
+ hash: 858800292
5
5
  prerelease: true
6
6
  segments:
7
7
  - 1
8
- - 0
9
8
  - 1
9
+ - 0
10
10
  - dev
11
- version: 1.0.1.dev
11
+ version: 1.1.0.dev
12
12
  platform: ruby
13
13
  authors:
14
14
  - Alex Soto
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2010-09-13 00:00:00 -07:00
21
+ date: 2010-09-20 00:00:00 -07:00
22
22
  default_executable:
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency