blacklight-sitemap 0.0.5 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -4,16 +4,17 @@ Rake task for creating a sitemap from a Blacklight Solr index.
4
4
 
5
5
  == Installation
6
6
 
7
- * In config/environment.rb add:
8
- config.gem 'blacklight-sitemap'
7
+ * This version only works with Rails 3/Blacklight 3. For Blacklight versions 2.x, try v0.0.5
8
+ of this gem.
9
+
10
+ * In Gemfile
11
+ gem 'blacklight-sitemap'
9
12
 
10
13
  * Install the gem:
11
- rake gems:install
12
- or
13
- gem install blacklight-sitemap
14
+ bundle install
14
15
 
15
16
  * Run the generator:
16
- script/generate blacklight_sitemap
17
+ rails g blacklight:sitemap
17
18
 
18
19
  * Open your Rakefile and edit the BlacklightSitemapTask to your liking using the
19
20
  provided documentation.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 1.0.0
@@ -31,6 +31,9 @@ module Rake
31
31
 
32
32
  # Solr sort option
33
33
  attr_accessor :sort
34
+
35
+ # pick a request handler.
36
+ attr_accessor :qt
34
37
 
35
38
  def initialize
36
39
  @url = 'http://localhost:3000/catalog'
@@ -41,6 +44,7 @@ module Rake
41
44
  @lastmod_field = 'timestamp'
42
45
  @priority_field = nil
43
46
  @sort = '_docid_ asc' # http://osdir.com/ml/solr-user.lucene.apache.org/2010-03/msg01371.html
47
+ @qt = 'standard'
44
48
  yield self if block_given?
45
49
  define
46
50
  end
@@ -61,7 +65,7 @@ module Rake
61
65
 
62
66
  puts 'Creating a sitemap...'
63
67
  fl = ['id', @lastmod_field, @priority_field].compact.join(',')
64
- base_solr_parameters = {:qt => 'standard', :q => 'id:[* TO *]', :fl => fl}
68
+ base_solr_parameters = {:qt => @qt, :fq => 'id:[* TO *]', :fl => fl}
65
69
  number_of_resources = Blacklight.solr.find(base_solr_parameters.merge(:rows => 1))['response']['numFound']
66
70
  puts 'Number of resources: ' + number_of_resources.to_s
67
71
  batches = (number_of_resources / @max.to_f).ceil
@@ -0,0 +1,22 @@
1
+ module Blacklight
2
+ module Generators
3
+ class SitemapGenerator < Rails::Generators::Base
4
+ desc 'Creates a configurable new rake task within Rakefile'
5
+
6
+ def self.source_root
7
+ @_blacklight_source_root ||= File.expand_path("../templates", __FILE__)
8
+ end
9
+
10
+
11
+ def create_blacklight_sitemap_task
12
+ rakefile_path = File.join(Rails.root,'Rakefile')
13
+ rakefile = File.read(rakefile_path)
14
+ if rakefile.scan('Rake::BlacklightSitemapTask.new').empty?
15
+ append_to_file(rakefile_path, File.read(File.join(File.dirname(__FILE__),'templates/default_rake_task.rb')))
16
+ end
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+
@@ -1,11 +1,3 @@
1
- class BlacklightSitemapGenerator < Rails::Generator::Base
2
- def initialize(*runtime_args)
3
- super
4
- end
5
-
6
- def manifest
7
- record do |m|
8
- sitemap_task = <<EOF
9
1
  require 'blacklight-sitemap'
10
2
  Rake::BlacklightSitemapTask.new do |sm|
11
3
  # below are configuration options with their default values shown.
@@ -36,21 +28,8 @@ Rake::BlacklightSitemapTask.new do |sm|
36
28
 
37
29
  # Solr query sort parameter
38
30
  # sm.sort = '_docid_ asc'
39
- end
40
- EOF
41
- rakefile = File.read('Rakefile')
42
- if rakefile.scan('Rake::BlacklightSitemapTask.new').empty?
43
- rakefile << "\n" << sitemap_task
44
- File.open('Rakefile', 'w'){|f| f.puts rakefile}
45
- end
46
- end
47
- end
48
-
49
- protected
50
-
51
- def banner
52
- %{Usage: #{$0} #{spec.name}\nCopies OpenURL.js public/javascripts/}
53
- end
54
-
55
- end
56
-
31
+
32
+ # Solr request handler. This can be useful when your Solr configuration already has
33
+ # a filter query appended.
34
+ # sm.qt = 'standard'
35
+ end
@@ -94,6 +94,13 @@ describe "BlacklightSitemap" do
94
94
  end
95
95
  task.sort.should eq('timestamp asc')
96
96
  end
97
+
98
+ it 'should be able to set a new value for qt' do
99
+ task = Rake::BlacklightSitemapTask.new do |sm|
100
+ sm.qt = 'bozart'
101
+ end
102
+ task.qt.should eq('bozart')
103
+ end
97
104
 
98
105
  it 'should create the sitemap clobber task' do
99
106
  Rake::BlacklightSitemapTask.new
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: 21
5
- prerelease: false
4
+ hash: 23
5
+ prerelease:
6
6
  segments:
7
+ - 1
7
8
  - 0
8
9
  - 0
9
- - 5
10
- version: 0.0.5
10
+ version: 1.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jason Ronallo
@@ -15,11 +15,12 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-05 00:00:00 -05:00
18
+ date: 2011-06-01 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ type: :runtime
23
+ requirement: &id001 !ruby/object:Gem::Requirement
23
24
  none: false
24
25
  requirements:
25
26
  - - ">="
@@ -28,12 +29,12 @@ dependencies:
28
29
  segments:
29
30
  - 0
30
31
  version: "0"
31
- requirement: *id001
32
- prerelease: false
33
- type: :runtime
34
32
  name: nokogiri
33
+ version_requirements: *id001
34
+ prerelease: false
35
35
  - !ruby/object:Gem::Dependency
36
- version_requirements: &id002 !ruby/object:Gem::Requirement
36
+ type: :development
37
+ requirement: &id002 !ruby/object:Gem::Requirement
37
38
  none: false
38
39
  requirements:
39
40
  - - ~>
@@ -44,12 +45,12 @@ dependencies:
44
45
  - 1
45
46
  - 0
46
47
  version: 2.1.0
47
- requirement: *id002
48
- prerelease: false
49
- type: :development
50
48
  name: rspec
49
+ version_requirements: *id002
50
+ prerelease: false
51
51
  - !ruby/object:Gem::Dependency
52
- version_requirements: &id003 !ruby/object:Gem::Requirement
52
+ type: :development
53
+ requirement: &id003 !ruby/object:Gem::Requirement
53
54
  none: false
54
55
  requirements:
55
56
  - - ~>
@@ -60,12 +61,12 @@ dependencies:
60
61
  - 0
61
62
  - 0
62
63
  version: 1.0.0
63
- requirement: *id003
64
- prerelease: false
65
- type: :development
66
64
  name: bundler
65
+ version_requirements: *id003
66
+ prerelease: false
67
67
  - !ruby/object:Gem::Dependency
68
- version_requirements: &id004 !ruby/object:Gem::Requirement
68
+ type: :development
69
+ requirement: &id004 !ruby/object:Gem::Requirement
69
70
  none: false
70
71
  requirements:
71
72
  - - ~>
@@ -76,12 +77,12 @@ dependencies:
76
77
  - 5
77
78
  - 1
78
79
  version: 1.5.1
79
- requirement: *id004
80
- prerelease: false
81
- type: :development
82
80
  name: jeweler
81
+ version_requirements: *id004
82
+ prerelease: false
83
83
  - !ruby/object:Gem::Dependency
84
- version_requirements: &id005 !ruby/object:Gem::Requirement
84
+ type: :development
85
+ requirement: &id005 !ruby/object:Gem::Requirement
85
86
  none: false
86
87
  requirements:
87
88
  - - ">="
@@ -90,10 +91,9 @@ dependencies:
90
91
  segments:
91
92
  - 0
92
93
  version: "0"
93
- requirement: *id005
94
- prerelease: false
95
- type: :development
96
94
  name: rcov
95
+ version_requirements: *id005
96
+ prerelease: false
97
97
  description: Blacklight sitemap rake task.
98
98
  email: jronallo@gmail.com
99
99
  executables: []
@@ -110,8 +110,9 @@ files:
110
110
  - README.rdoc
111
111
  - Rakefile
112
112
  - VERSION
113
- - generators/blacklight_sitemap/blacklight_sitemap_generator.rb
114
113
  - lib/blacklight-sitemap.rb
114
+ - lib/rails/generators/blacklight/sitemap/sitemap_generator.rb
115
+ - lib/rails/generators/blacklight/sitemap/templates/default_rake_task.rb
115
116
  - spec/blacklight-sitemap_spec.rb
116
117
  - spec/spec_helper.rb
117
118
  has_rdoc: true
@@ -144,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
145
  requirements: []
145
146
 
146
147
  rubyforge_project:
147
- rubygems_version: 1.3.7
148
+ rubygems_version: 1.6.2
148
149
  signing_key:
149
150
  specification_version: 3
150
151
  summary: Blacklight sitemap rake task.