blacklight-sitemap 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/blacklight-sitemap.rb +19 -4
  3. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -40,7 +40,7 @@ module Rake
40
40
  @max = 50000 #default value for max number of locs per sitemap file
41
41
  @lastmod_field = 'timestamp'
42
42
  @priority_field = nil
43
- @sort = '_docid_ asc'
43
+ @sort = '_docid_ asc' # http://osdir.com/ml/solr-user.lucene.apache.org/2010-03/msg01371.html
44
44
  yield self if block_given?
45
45
  define
46
46
  end
@@ -64,6 +64,12 @@ module Rake
64
64
  puts 'Total sitemap to create: ' + batches.to_s
65
65
  master_sitemap = ''
66
66
  base_solr_parameters.merge!(:sort => @sort) if @sort
67
+
68
+ # create a hash of batches with lastmod dates so that the most recent
69
+ # lastmod date shows up associated with that batch. This will feed
70
+ # into the lastmod for each sitemap in the index sitemap.
71
+ batch_lastmods = {}
72
+
67
73
  batches.times do |batch_number|
68
74
  current_page = batch_number + 1
69
75
  start = batch_number * @max
@@ -75,7 +81,12 @@ module Rake
75
81
  xml.url do
76
82
  # FIXME through config
77
83
  xml.loc File.join(@url.to_s, doc['id'])
78
- xml.lastmod doc[@lastmod_field].to_s if @lastmod_field and doc[@lastmod_field]
84
+ if @lastmod_field and doc[@lastmod_field]
85
+ xml.lastmod doc[@lastmod_field].to_s
86
+ if batch_lastmods[batch_number].blank? or batch_lastmods[batch_number] < doc[@lastmod_field]
87
+ batch_lastmods[batch_number] = doc[@lastmod_field]
88
+ end
89
+ end
79
90
  xml.priority doc[@priority_field] if @priority_field and doc[@priority_field]
80
91
  xml.changefreq @changefreq if @changefreq
81
92
  end
@@ -91,7 +102,7 @@ module Rake
91
102
  end
92
103
  end
93
104
  puts 'Creating sitemap index...'
94
- lastmod = DateTime.now.utc.strftime("%Y-%m-%dT%H:%M:%S+00:00")
105
+ rake_run_lastmod = DateTime.now.utc.strftime("%Y-%m-%dT%H:%M:%S+00:00")
95
106
  sitemap_index_builder = Nokogiri::XML::Builder.new do |xml|
96
107
  xml.sitemapindex 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9' do
97
108
  batches.times do |batch|
@@ -99,7 +110,11 @@ module Rake
99
110
  sitemap_filename << '.gz' if @gzip
100
111
  xml.sitemap{
101
112
  xml.loc sitemap_filename
102
- xml.lastmod lastmod
113
+ if batch_lastmods[batch]
114
+ xml.lastmod batch_lastmods[batch]
115
+ else
116
+ xml.lastmod rake_run_lastmod
117
+ end
103
118
  }
104
119
  end
105
120
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacklight-sitemap
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jason Ronallo