bridgetown-sitemap 1.2.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f7fdbaa3c96e9fc71d97de9a13f7828a2d3aa6cc45c1a396b8157cc3281b3231
4
- data.tar.gz: ee8c8d4adc46245e9ed35ab05b4450c319c0fc0c0a9d475a0114c5ef02557296
3
+ metadata.gz: b46fc691359d55c28bae04bec5dc2712f995bfeda3b7f9a59d854e9594c61b5d
4
+ data.tar.gz: b5479047c0ccac7ec071a9aaf3428f9d615935548c8dd9d4d9b28f79769bf33a
5
5
  SHA512:
6
- metadata.gz: f3667fc1df4b0e1d8f6e7ddfd404272c56ae996cc7d638a5d2390e9a233849e2a342aae11f7724691b81f3843e9afda18c32c04e5d9ee80c276b1d2529fe2e79
7
- data.tar.gz: f4bf13d4337464aa9455b645971e277d4952c5c4554b8dbf7b9aced457b504842299c79af5ec70d063205192d378ce5f16f3e0ba9f804953f657b1b95eb9c59a
6
+ metadata.gz: 73dd830ca3fc53df0a3850bb2a1fb6b230f2ebe62202281f019ae4d48b3bb414c5f9531a0bafda378b6cd22a94de62ae0f711be0206768ad3f8c2306c4dd2f34
7
+ data.tar.gz: b37f746153cf2c39ce6fe774194fc7e09ac5be31615c555c7f26e438bb32343b1783f517dfa07fdb94acebae756ea48690714411e9f44e61db6efbf117943c19
@@ -14,7 +14,7 @@ jobs:
14
14
  strategy:
15
15
  matrix:
16
16
  ruby_version: [2.7.7, 3.0.5, 3.1.3, 3.2.0]
17
- bridgetown_version: [1.0.0, 1.1.0]
17
+ bridgetown_version: [1.2.0]
18
18
  continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
19
19
  # Has to be top level to cache properly
20
20
  env:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # main
2
2
 
3
+ # 2.0.0 / 25-01-2023
4
+
5
+ * Restrict support to Bridgetown v1.2 and newer.
6
+ * Initialize plugin using the new Ruby DSL in Bridgetown v1.2.
7
+
3
8
  # 1.2.0 / 23-01-2023
4
9
 
5
10
  * Require Bridgetown 1.0 or newer.
data/Gemfile CHANGED
@@ -9,5 +9,5 @@ group :test do
9
9
  gem "minitest"
10
10
  gem "minitest-profile"
11
11
  gem "minitest-reporters"
12
- gem "shoulda"
12
+ gem "minitest-hooks"
13
13
  end
data/README.md CHANGED
@@ -10,26 +10,19 @@ Bridgetown plugin to silently generate a sitemaps.org compliant sitemap for your
10
10
  1. Install the plugin with the following command:
11
11
 
12
12
  ```shell
13
- bundle add bridgetown-sitemap -g bridgetown_plugins
13
+ bundle add bridgetown-sitemap
14
14
  ```
15
15
 
16
- 2. Add the following to your site's `bridgetown.config.yml`:
16
+ 2. Add the following to your site's `config/initializers.rb`:
17
17
 
18
- ```yml
19
- url: "https://example.com" # the base hostname & protocol for your site
20
- ```
21
-
22
- <br>
23
-
24
- **This plugin only supports Bridgetown sites that use the [resource content engine](https://www.bridgetownrb.com/docs/resources).**
25
-
26
- This can be configured by adding the following line to your site's `bridgetown.config.yml`:
18
+ ```ruby
19
+ Bridgetown.configure do |config|
20
+ config.url = "https://example.com" # the base hostname & protocol for your site
27
21
 
28
- ```yml
29
- content_engine: "resource"
22
+ init :"bridgetown-sitemap"
23
+ end
30
24
  ```
31
25
 
32
-
33
26
  ## `<lastmod>` tag
34
27
  The `<lastmod>` tag in the `sitemap.xml` will reflect by priority:
35
28
 
@@ -46,15 +39,17 @@ sitemap flag to `false` in the front matter for the page.
46
39
  sitemap: false
47
40
  ```
48
41
 
49
- To exclude multiple files, add a glob config to your `bridgetown.config.yml` file.
42
+ To exclude multiple files, add a glob config to your `config/initializers.rb` file.
50
43
 
51
- ```yml
52
- defaults:
53
- -
54
- scope:
55
- path: "assets/**/*.pdf"
56
- values:
57
- sitemap: false
44
+ ```ruby
45
+ Bridgetown.configure do |config|
46
+ # ...
47
+
48
+ config.defaults << {
49
+ "scope" => { "path" => "assets/**/*.pdf" },
50
+ "values" => { "sitemap" => false }
51
+ }
52
+ end
58
53
  ```
59
54
 
60
55
  ## Testing
@@ -75,4 +70,4 @@ defaults:
75
70
 
76
71
  Bridgetown Sitemap is released under the [MIT License](https://opensource.org/licenses/MIT).
77
72
 
78
- Copyright © 2021 [Ayush Newatia](https://twitter.com/ayushn21)
73
+ Copyright © 2023 [Ayush Newatia](https://twitter.com/ayushn21)
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
 
19
19
  spec.required_ruby_version = ">= 2.7.0"
20
20
 
21
- spec.add_dependency "bridgetown", ">= 1.0", "< 2.0"
21
+ spec.add_dependency "bridgetown", ">= 1.2.0", "< 2.0"
22
22
 
23
23
  spec.add_development_dependency "bundler"
24
24
  spec.add_development_dependency "rake"
@@ -3,17 +3,9 @@
3
3
  require "fileutils"
4
4
 
5
5
  module BridgetownSitemap
6
- class UnsupportedContentEngine < StandardError; end
7
-
8
6
  class Builder < Bridgetown::Builder
9
7
  def build
10
8
  hook :site, :pre_render, priority: :low do |site|
11
- unless site.uses_resource?
12
- Bridgetown.logger.error "\n\nbridgetown-sitemap only supports the resource content engine"
13
- Bridgetown.logger.info "Add `content_engine: 'resource'` to your bridgetown.config.yml\n\n"
14
- raise UnsupportedContentEngine
15
- end
16
-
17
9
  @site = site
18
10
 
19
11
  @site.generated_pages << sitemap unless file_exists?("sitemap.xml")
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BridgetownSitemap
4
- VERSION = "1.2.0"
4
+ VERSION = "2.0.0"
5
5
  end
@@ -4,4 +4,6 @@ require "bridgetown"
4
4
  require "bridgetown/resource/base"
5
5
  require "bridgetown-sitemap/builder"
6
6
 
7
- BridgetownSitemap::Builder.register
7
+ Bridgetown.initializer :"bridgetown-sitemap" do |config|
8
+ config.builder BridgetownSitemap::Builder
9
+ end
data/lib/sitemap.erb CHANGED
@@ -18,12 +18,12 @@
18
18
  <% end %>
19
19
 
20
20
  <% site.generated_pages.each do |generated_page| %>
21
- <% next if ["sitemap.erb", "robots.liquid"].include? generated_page.name %>
22
- <% next if generated_page.data.sitemap == false %>
23
- <url>
24
- <loc><%= xml_escape absolute_url(generated_page.url) %></loc>
25
- <lastmod><%= (generated_page.data.last_modified_at || site.time).localtime.xmlschema %></lastmod>
26
- </url>
21
+ <% next if ["sitemap.erb", "robots.liquid"].include? generated_page.name %>
22
+ <% next if generated_page.data.sitemap == false %>
23
+ <url>
24
+ <loc><%= xml_escape absolute_url(generated_page.url) %></loc>
25
+ <lastmod><%= (generated_page.data.last_modified_at || site.time).localtime.xmlschema %></lastmod>
26
+ </url>
27
27
  <% end %>
28
28
 
29
29
  <% page.data.static_files.each do |file| %>
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ Bridgetown.configure do |config|
4
+ timezone "UTC"
5
+
6
+ config.defaults << {
7
+ "scope" => { "path" => "excluded_files/**/*" },
8
+ "values" => { "sitemap" => false }
9
+ }
10
+
11
+ init :"bridgetown-sitemap"
12
+ end
data/test/helper.rb CHANGED
@@ -2,9 +2,12 @@
2
2
 
3
3
  require "minitest/autorun"
4
4
  require "minitest/reporters"
5
- require "minitest/profile"
6
- require "shoulda"
7
- require_relative "../lib/bridgetown-sitemap"
5
+ require 'minitest/hooks/default'
6
+ require "bridgetown"
7
+
8
+ Bridgetown.begin!
9
+
10
+ require File.expand_path("../lib/bridgetown-sitemap", __dir__)
8
11
 
9
12
  # Report with color.
10
13
  Minitest::Reporters.use! [
@@ -14,15 +17,13 @@ Minitest::Reporters.use! [
14
17
  ]
15
18
 
16
19
  class BridgetownSitemap::Test < Minitest::Test
20
+ extend Minitest::Spec::DSL
21
+ include Minitest::Hooks
22
+
17
23
  ROOT_DIR = File.expand_path("fixtures", __dir__)
18
24
  SOURCE_DIR = File.join(ROOT_DIR, "src")
19
25
  DEST_DIR = File.expand_path("dest", __dir__)
20
26
 
21
- def build_site
22
- @site = Bridgetown::Site.new(config)
23
- process_site
24
- end
25
-
26
27
  def root_dir(*files)
27
28
  File.join(ROOT_DIR, *files)
28
29
  end
@@ -38,42 +39,4 @@ class BridgetownSitemap::Test < Minitest::Test
38
39
  def make_context(registers = {})
39
40
  Liquid::Context.new({}, {}, { :site => site }.merge(registers))
40
41
  end
41
-
42
- def config_overrides
43
- {}
44
- end
45
-
46
- def metadata_overrides
47
- {}
48
- end
49
-
50
- private
51
-
52
- def process_site
53
- @metadata = {
54
- "name" => "My Awesome Site",
55
- "author" => {
56
- "name" => "Ada Lovejoy",
57
- }
58
- }
59
-
60
- metadata = @metadata.merge(metadata_overrides).to_yaml.sub("---\n", "")
61
- File.write(source_dir("_data/site_metadata.yml"), metadata)
62
- @site.process
63
- FileUtils.rm(source_dir("_data/site_metadata.yml"))
64
- end
65
-
66
- def config
67
- @config ||= Bridgetown.configuration(Bridgetown::Utils.deep_merge_hashes({
68
- "full_rebuild" => true,
69
- "root_dir" => root_dir,
70
- "source" => source_dir,
71
- "destination" => dest_dir,
72
- "content_engine" => "resource",
73
- "url" => "https://example.com",
74
- "quiet" => true
75
- },
76
- config_overrides
77
- ))
78
- end
79
42
  end
data/test/test_sitemap.rb CHANGED
@@ -3,216 +3,216 @@
3
3
  require "helper"
4
4
 
5
5
  class TestSitemap < BridgetownSitemap::Test
6
+ def prepare_site
7
+ Bridgetown.reset_configuration!
8
+ @config = Bridgetown.configuration(
9
+ "full_rebuild" => true,
10
+ "root_dir" => root_dir,
11
+ "source" => source_dir,
12
+ "destination" => dest_dir,
13
+ "url" => "https://example.com",
14
+ "quiet" => true
15
+ )
16
+
17
+ @config.run_initializers! context: :static
18
+ @site = Bridgetown::Site.new(@config)
19
+ end
20
+
21
+ def process_site
22
+ @site.process
23
+ end
6
24
 
7
- context "rendering the site with defaults" do
8
- setup { build_site }
25
+ describe "rendering the site with defaults" do
26
+ before(:all) do
27
+ prepare_site
28
+ process_site
9
29
 
10
- should "create the sitemap" do
30
+ @sitemap = File.read(dest_dir("sitemap.xml"))
31
+ @robots = File.read(dest_dir("robots.txt"))
32
+ end
33
+
34
+ it "creates the sitemap without a layout" do
11
35
  assert File.exist?(dest_dir("sitemap.xml"))
36
+ refute_match %r!THIS IS MY LAYOUT!, @sitemap
12
37
  end
13
38
 
14
- should "create robots.txt" do
39
+ it "creates robots.txt without a layout" do
15
40
  assert File.exist?(dest_dir("robots.txt"))
41
+ refute_match %r!\ATHIS IS MY LAYOUT!, @robots
16
42
  end
17
43
 
18
- context "the sitemap" do
19
- setup { @sitemap = File.read(dest_dir("sitemap.xml")) }
20
-
21
- should "have no layout" do
22
- refute_match %r!THIS IS MY LAYOUT!, @sitemap
23
- end
24
-
25
- should "put all the pages in the sitemap" do
26
- assert_match %r!<loc>https://example\.com/</loc>!, @sitemap
27
- assert_match %r!<loc>https://example\.com/some-subfolder/this-is-a-subpage/</loc>!, @sitemap
28
- end
29
-
30
- should "not put files with output: false into the sitemap" do
31
- refute_match %r!/other_things/test2\.html</loc>!, @sitemap
32
- end
33
-
34
- should "performs URI encoding of site paths" do
35
- assert_match %r!<loc>https://example\.com/this%20url%20has%20an%20%C3%BCmlaut</loc>!, @sitemap
36
- end
37
-
38
- should "put all the posts in the sitemap" do
39
- assert_match %r!<loc>https://example.com/2021/05/06/may-the-sixth/</loc>!, @sitemap
40
- assert_match %r!<loc>https://example.com/2021/03/04/march-the-fourth/</loc>!, @sitemap
41
- assert_match %r!<loc>https://example.com/2021/03/02/march-the-second/</loc>!, @sitemap
42
- assert_match %r!<loc>https://example.com/2019/07/14/last-modified-at/</loc>!, @sitemap
43
- end
44
+ it "puts all the pages in the sitemap" do
45
+ assert_match %r!<loc>https://example\.com/</loc>!, @sitemap
46
+ assert_match %r!<loc>https://example\.com/some-subfolder/this-is-a-subpage/</loc>!, @sitemap
47
+ end
44
48
 
45
- should "generate the correct date for each of the posts" do
46
- assert_match %r!<lastmod>2021-05-06T00:00:00(-|\+)\d+:\d+</lastmod>!, @sitemap
47
- assert_match %r!<lastmod>2021-03-04T00:00:00(-|\+)\d+:\d+</lastmod>!, @sitemap
48
- assert_match %r!<lastmod>2021-03-02T00:00:00(-|\+)\d+:\d+</lastmod>!, @sitemap
49
+ it "does not put files with output: false into the sitemap" do
50
+ refute_match %r!/other_things/test2\.html</loc>!, @sitemap
51
+ end
49
52
 
50
- # This doesn't work on CI because it runs a git command which isn't allowed I guess
51
- unless ENV["GITHUB_ACTIONS"]
52
- assert_match %r!<lastmod>2019-07-14T18:22:00\+00:00</lastmod>!, @sitemap
53
- end
54
- end
53
+ it "performs URI encoding of site paths" do
54
+ assert_match %r!<loc>https://example\.com/this%20url%20has%20an%20%C3%BCmlaut</loc>!, @sitemap
55
+ end
55
56
 
56
- should "puts all the static HTML files in the sitemap.xml file" do
57
- assert_match %r!<loc>https://example\.com/some-subfolder/this-is-a-subfile\.html</loc>!, @sitemap
58
- end
57
+ it "puts all the posts in the sitemap" do
58
+ assert_match %r!<loc>https://example.com/2021/05/06/may-the-sixth/</loc>!, @sitemap
59
+ assert_match %r!<loc>https://example.com/2021/03/04/march-the-fourth/</loc>!, @sitemap
60
+ assert_match %r!<loc>https://example.com/2021/03/02/march-the-second/</loc>!, @sitemap
61
+ assert_match %r!<loc>https://example.com/2019/07/14/last-modified-at/</loc>!, @sitemap
62
+ end
59
63
 
60
- should "does not include assets or any static files that aren't .html" do
61
- refute_match %r!/assets/sample_image\.jpg</loc>!, @sitemap
62
- refute_match %r!/feeds/atom\.xml</loc>!, @sitemap
63
- end
64
+ it "generates the correct date for each of the posts" do
65
+ assert_match %r!<lastmod>2021-05-06T00:00:00(-|\+)\d+:\d+</lastmod>!, @sitemap
66
+ assert_match %r!<lastmod>2021-03-04T00:00:00(-|\+)\d+:\d+</lastmod>!, @sitemap
67
+ assert_match %r!<lastmod>2021-03-02T00:00:00(-|\+)\d+:\d+</lastmod>!, @sitemap
64
68
 
65
- should "include assets or any static files with .xhtml and .htm extensions" do
66
- assert_match %r!<loc>https://example\.com/some-subfolder/xhtml\.xhtml</loc>!, @sitemap
67
- assert_match %r!<loc>https://example\.com/some-subfolder/htm\.htm</loc>!, @sitemap
69
+ # This doesn't work on CI because it runs a git command which isn't allowed I guess
70
+ unless ENV["GITHUB_ACTIONS"]
71
+ assert_match %r!<lastmod>2019-07-14T18:22:00\+00:00</lastmod>!, @sitemap
68
72
  end
73
+ end
69
74
 
70
- should "include assets or any static files with .pdf extension" do
71
- assert_match %r!<loc>https://example\.com/assets/sample_pdf\.pdf</loc>!, @sitemap
72
- end
75
+ it "puts all the static HTML files in the sitemap.xml file" do
76
+ assert_match %r!<loc>https://example\.com/some-subfolder/this-is-a-subfile\.html</loc>!, @sitemap
77
+ end
73
78
 
74
- should "not include any files named 404.html" do
75
- refute_match %r!404.html!, @sitemap
76
- end
79
+ it "does not include assets or any static files that aren't .html" do
80
+ refute_match %r!/assets/sample_image\.jpg</loc>!, @sitemap
81
+ refute_match %r!/feeds/atom\.xml</loc>!, @sitemap
82
+ end
77
83
 
78
- should "not include any static files that have set 'sitemap: false'" do
79
- refute_match %r!/excluded_files/excluded\.pdf!, @sitemap
80
- end
84
+ it "includes assets or any static files with .xhtml and .htm extensions" do
85
+ assert_match %r!<loc>https://example\.com/some-subfolder/xhtml\.xhtml</loc>!, @sitemap
86
+ assert_match %r!<loc>https://example\.com/some-subfolder/htm\.htm</loc>!, @sitemap
87
+ end
81
88
 
82
- should "not include any static html files that have set 'sitemap: false'" do
83
- refute_match %r!/excluded_files/html_file\.html!, @sitemap
84
- end
89
+ it "includes assets or any static files with .pdf extension" do
90
+ assert_match %r!<loc>https://example\.com/assets/sample_pdf\.pdf</loc>!, @sitemap
91
+ end
85
92
 
86
- should "not include posts that have set 'sitemap: false'" do
87
- refute_match %r!exclude-this-post!, @sitemap
88
- end
93
+ it "does not include any files named 404.html" do
94
+ refute_match %r!404.html!, @sitemap
95
+ end
89
96
 
90
- should "not include pages that have set 'sitemap: false'" do
91
- refute_match %r!exclude-this-page!, @sitemap
92
- refute_match %r!about!, @sitemap
93
- end
97
+ it "does not include any static files that have set 'sitemap: false'" do
98
+ refute_match %r!/excluded_files/excluded\.pdf!, @sitemap
99
+ end
94
100
 
95
- should "correctly format timestamps of static files" do
96
- assert_match %r!/this-is-a-subfile\.html</loc>\s+<lastmod>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(-|\+)\d{2}:\d{2}</lastmod>!, @sitemap
97
- end
101
+ it "does not include any static html files that have set 'sitemap: false'" do
102
+ refute_match %r!/excluded_files/html_file\.html!, @sitemap
103
+ end
98
104
 
99
- should "include the correct number of items" do
100
- assert_equal 18, @sitemap.scan(%r!(?=<url>)!).count
101
- end
105
+ it "does not include posts that have set 'sitemap: false'" do
106
+ refute_match %r!exclude-this-post!, @sitemap
107
+ end
102
108
 
103
- should "include generated pages" do
104
- assert_match %r!<loc>https://example.com/generated_page/</loc>!, @sitemap
105
- end
109
+ it "does not include pages that have set 'sitemap: false'" do
110
+ refute_match %r!exclude-this-page!, @sitemap
111
+ refute_match %r!about!, @sitemap
106
112
  end
107
113
 
108
- context "the robots.txt" do
109
- setup { @robots = File.read(dest_dir("robots.txt")) }
114
+ it "correctly formats timestamps of static files" do
115
+ assert_match %r!/this-is-a-subfile\.html</loc>\s+<lastmod>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(-|\+)\d{2}:\d{2}</lastmod>!, @sitemap
116
+ end
110
117
 
111
- should "have no layout" do
112
- refute_match %r!\ATHIS IS MY LAYOUT!, @robots
113
- end
118
+ it "includes the correct number of items for the sitemap" do
119
+ assert_equal 18, @sitemap.scan(%r!(?=<url>)!).count
120
+ end
114
121
 
115
- should "renders liquid" do
116
- assert_match "Sitemap: https://example.com/sitemap.xml", @robots
117
- end
122
+ it "includes generated pages in the sitemap" do
123
+ assert_match %r!<loc>https://example.com/generated_page/</loc>!, @sitemap
118
124
  end
119
- end
120
125
 
121
- context "rendering the site with a baseurl" do
122
- setup do
123
- config.base_path = "/baseurl"
124
- build_site
126
+ it "renders liquid in the robots.txt" do
127
+ assert_match "Sitemap: https://example.com/sitemap.xml", @robots
125
128
  end
129
+ end
126
130
 
127
- context "the sitemap" do
128
- setup { @sitemap = File.read(dest_dir("sitemap.xml")) }
131
+ describe "rendering the site with a base URL" do
132
+ before(:all) do
133
+ prepare_site
134
+ @config.base_path = "/baseurl"
135
+ process_site
129
136
 
130
- should "add the baseurl to the static files" do
131
- assert_match %r!<loc>https://example\.com/baseurl/some-subfolder/this-is-a-subfile\.html</loc>!, @sitemap
132
- end
137
+ @sitemap = File.read(dest_dir("sitemap.xml"))
138
+ @robots = File.read(dest_dir("robots.txt"))
139
+ end
133
140
 
134
- should "add the baseurl to the pages" do
135
- assert_match %r!<loc>https://example\.com/baseurl/</loc>!, @sitemap
136
- assert_match %r!<loc>https://example\.com/baseurl/some-subfolder/this-is-a-subpage/</loc>!, @sitemap
137
- end
141
+ it "adds the baseurl to the static files in the sitemap" do
142
+ assert_match %r!<loc>https://example\.com/baseurl/some-subfolder/this-is-a-subfile\.html</loc>!, @sitemap
143
+ end
138
144
 
139
- should "add the baseurl to the posts" do
140
- assert_match %r!<loc>https://example.com/baseurl/2021/05/06/may-the-sixth/</loc>!, @sitemap
141
- assert_match %r!<loc>https://example.com/baseurl/2021/03/04/march-the-fourth/</loc>!, @sitemap
142
- assert_match %r!<loc>https://example.com/baseurl/2021/03/02/march-the-second/</loc>!, @sitemap
143
- assert_match %r!<loc>https://example.com/baseurl/2019/07/14/last-modified-at/</loc>!, @sitemap
144
- end
145
+ it "adds the baseurl to the pages in the sitemap" do
146
+ assert_match %r!<loc>https://example\.com/baseurl/</loc>!, @sitemap
147
+ assert_match %r!<loc>https://example\.com/baseurl/some-subfolder/this-is-a-subpage/</loc>!, @sitemap
145
148
  end
146
149
 
147
- context "the robots.txt" do
148
- setup { @robots = File.read(dest_dir("robots.txt")) }
150
+ it "adds the baseurl to the posts in the sitemap" do
151
+ assert_match %r!<loc>https://example.com/baseurl/2021/05/06/may-the-sixth/</loc>!, @sitemap
152
+ assert_match %r!<loc>https://example.com/baseurl/2021/03/04/march-the-fourth/</loc>!, @sitemap
153
+ assert_match %r!<loc>https://example.com/baseurl/2021/03/02/march-the-second/</loc>!, @sitemap
154
+ assert_match %r!<loc>https://example.com/baseurl/2019/07/14/last-modified-at/</loc>!, @sitemap
155
+ end
149
156
 
150
- should "add contain the baseurl" do
151
- assert_match "Sitemap: https://example.com/baseurl/sitemap.xml", @robots
152
- end
157
+ it "adds the baseurl in the robots.txt" do
158
+ assert_match "Sitemap: https://example.com/baseurl/sitemap.xml", @robots
153
159
  end
154
160
  end
155
161
 
156
- context "rendering the site with a url that needs URI encoding" do
157
- setup do
158
- config.url = "http://ümlaut.example.org"
159
- build_site
160
- end
162
+ describe "rendering the site with a url that needs URI encoding" do
163
+ before(:all) do
164
+ prepare_site
165
+ @config.url = "http://ümlaut.example.org"
166
+ process_site
161
167
 
162
- context "the sitemap" do
163
- setup { @sitemap = File.read(dest_dir("sitemap.xml")) }
168
+ @sitemap = File.read(dest_dir("sitemap.xml"))
169
+ end
164
170
 
165
- should "performs URI encoding of site url" do
166
- assert_match %r!<loc>http://xn--mlaut-jva.example.org/</loc>!, @sitemap
167
- assert_match %r!<loc>http://xn--mlaut-jva.example.org/some-subfolder/this-is-a-subpage/</loc>!, @sitemap
168
- assert_match %r!<loc>http://xn--mlaut-jva.example.org/2021/03/04/march-the-fourth/</loc>!, @sitemap
169
- assert_match %r!<loc>http://xn--mlaut-jva.example.org/2020/04/03/%E9%94%99%E8%AF%AF</loc>!, @sitemap
170
- assert_match %r!<loc>http://xn--mlaut-jva.example.org/2020/04/02/%E9%94%99%E8%AF%AF</loc>!, @sitemap
171
- assert_match %r!<loc>http://xn--mlaut-jva.example.org/2019/04/01/%E9%94%99%E8%AF%AF/</loc>!, @sitemap
172
- end
171
+ it "performs URI encoding of site url" do
172
+ assert_match %r!<loc>http://xn--mlaut-jva.example.org/</loc>!, @sitemap
173
+ assert_match %r!<loc>http://xn--mlaut-jva.example.org/some-subfolder/this-is-a-subpage/</loc>!, @sitemap
174
+ assert_match %r!<loc>http://xn--mlaut-jva.example.org/2021/03/04/march-the-fourth/</loc>!, @sitemap
175
+ assert_match %r!<loc>http://xn--mlaut-jva.example.org/2020/04/03/%E9%94%99%E8%AF%AF</loc>!, @sitemap
176
+ assert_match %r!<loc>http://xn--mlaut-jva.example.org/2020/04/02/%E9%94%99%E8%AF%AF</loc>!, @sitemap
177
+ assert_match %r!<loc>http://xn--mlaut-jva.example.org/2019/04/01/%E9%94%99%E8%AF%AF/</loc>!, @sitemap
173
178
  end
174
179
  end
175
180
 
176
- context "rendering the site with a user defined robots.txt" do
177
- setup do
181
+ describe "rendering the site with a user defined robots.txt" do
182
+ before(:all) do
183
+ prepare_site
178
184
  File.write(source_dir("robots.txt"), "ROBOT")
179
- build_site
185
+ process_site
186
+
180
187
  @robots = File.read(dest_dir("robots.txt"))
181
188
  end
182
189
 
183
- teardown do
190
+ after(:all) do
184
191
  File.delete(source_dir("robots.txt"))
185
192
  end
186
193
 
187
- should "not overwrite the robots.txt" do
194
+ it "does not overwrite the robots.txt" do
188
195
  assert_match %r!ROBOT!, @robots
189
196
  refute_match %r!Sitemap!, @robots
190
197
  end
191
198
  end
192
199
 
193
- context "rendering the site with an uncommitted file" do
194
- setup do
200
+ describe "rendering the site with an uncommitted file" do
201
+ before(:all) do
202
+ prepare_site
195
203
  File.write(source_dir("new.html"), "---\n---")
196
- build_site
204
+ process_site
205
+
197
206
  @sitemap = File.read(dest_dir("sitemap.xml"))
198
207
  end
199
208
 
200
- teardown do
209
+ after(:all) do
201
210
  File.delete(source_dir("new.html"))
202
211
  end
203
212
 
204
- should "include the uncommitted file in the sitemap" do
213
+ it "includes the uncommitted file in the sitemap" do
205
214
  assert_match %r!<loc>https://example.com/new/</loc>!, @sitemap
206
215
  end
207
216
  end
208
-
209
- context "rendering the site without the resource content engine" do
210
- setup { config.delete "content_engine" }
211
-
212
- should "throw an error" do
213
- capture_io do
214
- assert_raises(BridgetownSitemap::UnsupportedContentEngine) { build_site }
215
- end
216
- end
217
- end
218
217
  end
218
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bridgetown-sitemap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ayush Newatia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-23 00:00:00.000000000 Z
11
+ date: 2023-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bridgetown
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: 1.2.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '2.0'
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '1.0'
29
+ version: 1.2.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '2.0'
@@ -97,7 +97,7 @@ files:
97
97
  - script/fmt
98
98
  - script/release
99
99
  - script/test
100
- - test/fixtures/bridgetown.config.yml
100
+ - test/fixtures/config/initializers.rb
101
101
  - test/fixtures/plugins/builders/generated_pages.rb
102
102
  - test/fixtures/plugins/site_builder.rb
103
103
  - test/fixtures/src/_data/.keep
@@ -153,7 +153,7 @@ signing_key:
153
153
  specification_version: 4
154
154
  summary: Automatically generate a sitemap.xml for your Bridgetown site.
155
155
  test_files:
156
- - test/fixtures/bridgetown.config.yml
156
+ - test/fixtures/config/initializers.rb
157
157
  - test/fixtures/plugins/builders/generated_pages.rb
158
158
  - test/fixtures/plugins/site_builder.rb
159
159
  - test/fixtures/src/_data/.keep
@@ -1,8 +0,0 @@
1
- timezone: UTC
2
-
3
- defaults:
4
- -
5
- scope:
6
- path: "excluded_files/**/*"
7
- values:
8
- sitemap: false