indexmap 0.11.0 → 0.12.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: 8ccc3c85e74b227729c23c98343802e7b7ab2be886aeb329315176309f17dc41
4
- data.tar.gz: 667474b22b41298892ab0916df1d40f8afc3aa0ab42fe53144e593f8686be5cf
3
+ metadata.gz: 728551661fb89384448bb4316fe0495e070768b81bded6d2ed11a834b4bc0d0e
4
+ data.tar.gz: 05e54058c0bab3f0806f3450214c88ab986d1452c9b64f158b2972c0436cf460
5
5
  SHA512:
6
- metadata.gz: a8c855e46ebd9904d47d67297c19198256bbc5151d7b0f2705b6c942f87fdf834f6625b2906c31cb721cbe174b0a36f1a5cf397c45ee4d65a9384efa8329348a
7
- data.tar.gz: ef366333d205bdda0c8d64f26d97824f8ef186d27e101f70a3b57cf620f74a52e142903be5b96009b4f90bd6e4d95def9bb9f207a08a89e890d6f32b8a0e3f22
6
+ metadata.gz: 1bc48a077acd51e3d00e8fb4475d84d80b3ca7767597bc4e102db040ed7c12aea128b8e17820fde793a22c7363a0df650e4f638ca7172e4d231453e67403c26d
7
+ data.tar.gz: 6187621f4965c9ea84975e5fae2f15776e55bfb2e0594dd2e0ac4c9405838ffcdfd5216a1f9d667a4a8c68ce3a9ba617aa31558fc6e1f996841113b92853342e
data/CHANGELOG.md CHANGED
@@ -5,6 +5,28 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.12.0] - 2026-11-08
9
+
10
+
11
+ ### Added
12
+
13
+ - accept explicit changed entries
14
+
15
+ - accept explicit changed entries ([#37](https://github.com/ethos-link/indexmap/pull/37))
16
+
17
+
18
+
19
+
20
+ ### Changed
21
+
22
+ - use BASE_URL in generated initializers
23
+
24
+ - use BASE_URL in generated initializers ([#36](https://github.com/ethos-link/indexmap/pull/36))
25
+
26
+ - merge main and preserve both upgrade instructions
27
+
28
+
29
+
8
30
  ## [0.11.0] - 2026-11-06
9
31
 
10
32
 
data/README.md CHANGED
@@ -104,7 +104,7 @@ Customize the generated initializer:
104
104
  ```ruby
105
105
  ActiveSupport.on_load(:indexmap) do
106
106
  Indexmap.configure do |config|
107
- config.base_url = -> { ENV.fetch("INDEXMAP_BASE_URL", "https://example.com") }
107
+ config.base_url = -> { ENV.fetch("BASE_URL", "https://example.com") }
108
108
  config.storage = -> do
109
109
  Indexmap::Storage::Filesystem.new(
110
110
  path: Rails.public_path, public_url: config.base_url
@@ -529,6 +529,8 @@ The built-in validator checks for:
529
529
  ## Search Engine Ping
530
530
 
531
531
  `indexmap` can ping Google Search Console and IndexNow after sitemap generation.
532
+ For known page updates or removals, pass `entries:` directly to
533
+ `Indexmap::Pinger::IndexNow#ping`; see [direct change submission](docs/search-engine-ping.md#submit-known-changes-directly).
532
534
  See [Search engine ping](docs/search-engine-ping.md) for Google credential
533
535
  setup, Search Console property configuration, and IndexNow key provisioning.
534
536
 
data/UPGRADE.md CHANGED
@@ -8,6 +8,29 @@ GitHub Actions runs commitlint and release packaging/publication only.
8
8
 
9
9
  ## Next
10
10
 
11
+ ### Explicit IndexNow entries
12
+
13
+ `Indexmap::Pinger::IndexNow#ping` and `.ping` now accept `entries:` containing
14
+ `Indexmap::Entry` objects. Existing calls without this keyword retain sitemap
15
+ selection. An explicit list submits only those URLs, including removed URLs,
16
+ without reading sitemap files or applying date filters. Empty lists skip
17
+ submission. Replace app-owned IndexNow HTTP clients with this API and use its
18
+ per-attempt receipts to update app-owned delivery state. See
19
+ [direct change submission](docs/search-engine-ping.md#submit-known-changes-directly).
20
+
21
+ ### Sitemap origin override
22
+
23
+ The generated initializer and task examples now use `BASE_URL`. In existing
24
+ initializers, replace `ENV.fetch("INDEXMAP_BASE_URL", ...)` with
25
+ `ENV.fetch("BASE_URL", ...)`, and update CI commands, scripts and environment
26
+ settings that supply the old name. Keep the app's default origin and lazy
27
+ configuration. The installer preserves authored initializers; it does not rename
28
+ the variable in an existing app.
29
+
30
+ For example, run `BASE_URL=https://example.com bin/rails indexmap:sitemap:create`.
31
+ The initializer owns this convention; the gem does not read either variable
32
+ outside that configuration.
33
+
11
34
  ### Rails configuration without a host loader
12
35
 
13
36
  The installer now generates `ActiveSupport.on_load(:indexmap)` around the existing
data/docs/deployment.md CHANGED
@@ -22,13 +22,13 @@ block inside `ActiveSupport.on_load(:indexmap)`. Keep storage construction lazy
22
22
  when it uses the configured origin:
23
23
 
24
24
  ```ruby
25
- config.base_url = -> { ENV.fetch("INDEXMAP_BASE_URL", "http://localhost:3000") }
25
+ config.base_url = -> { ENV.fetch("BASE_URL", "http://localhost:3000") }
26
26
  config.storage = -> do
27
27
  Indexmap::Storage::Filesystem.new(path: Rails.public_path, public_url: config.base_url)
28
28
  end
29
29
  ```
30
30
 
31
- Always set `INDEXMAP_BASE_URL` to the actual public origin in deployment. For
31
+ Always set `BASE_URL` to the actual public origin in deployment. For
32
32
  private filesystem storage change `path` to `Rails.root.join("storage/sitemaps")`
33
33
  and explicitly serve it through the Rails controller or web server. That directory
34
34
  does not become publicly reachable merely because it has a `public_url` setting.
@@ -75,8 +75,8 @@ advertising it.
75
75
  ## Development verification
76
76
 
77
77
  ```sh
78
- INDEXMAP_BASE_URL=http://localhost:3000 bin/rails indexmap:sitemap:create
79
- INDEXMAP_BASE_URL=http://localhost:3000 bin/rails indexmap:sitemap:validate
78
+ BASE_URL=http://localhost:3000 bin/rails indexmap:sitemap:create
79
+ BASE_URL=http://localhost:3000 bin/rails indexmap:sitemap:validate
80
80
  bin/rails server
81
81
  ```
82
82
 
@@ -100,9 +100,9 @@ release step, then include every generated root and child in the deployed
100
100
  artifacts:
101
101
 
102
102
  ```sh
103
- RAILS_ENV=production INDEXMAP_BASE_URL=https://example.com \
103
+ RAILS_ENV=production BASE_URL=https://example.com \
104
104
  bin/rails indexmap:sitemap:create
105
- RAILS_ENV=production INDEXMAP_BASE_URL=https://example.com \
105
+ RAILS_ENV=production BASE_URL=https://example.com \
106
106
  bin/rails indexmap:sitemap:validate
107
107
  ```
108
108
 
@@ -23,6 +23,44 @@ Google submits that sitemap URL once. IndexNow recursively reads its referenced
23
23
  child sitemaps and submits their page URLs. Other sitemap-shaped files left in
24
24
  storage are ignored unless the authoritative sitemap references them.
25
25
 
26
+ ## Submit known changes directly
27
+
28
+ When an application already knows which pages changed, pass those entries to
29
+ IndexNow without generating or reading a sitemap:
30
+
31
+ ```ruby
32
+ entries = [
33
+ Indexmap::Entry.new(loc: "https://example.com/articles/updated"),
34
+ Indexmap::Entry.new(loc: "https://example.com/jobs/removed")
35
+ ]
36
+
37
+ result = Indexmap::Pinger::IndexNow.new.ping(entries: entries) do |event|
38
+ if event[:event] == :attempt_finished
39
+ record_receipt(event.fetch(:urls), event)
40
+ end
41
+ end
42
+ ```
43
+
44
+ Use this for publication events, imports, edits, and removals. IndexNow receives
45
+ the same URL notification for each kind of change; removed pages do not need to
46
+ remain in the sitemap. Entries must use absolute HTTP(S) URLs matching the
47
+ configured base URL's scheme, host and port, without queries, fragments or
48
+ userinfo. All explicit entries are validated before the first submission, and
49
+ repeated URLs are submitted once.
50
+
51
+ An explicit list bypasses `SINCE` and `INDEXNOW_RECENT_HOURS`, regardless of
52
+ `lastmod`. An empty list returns `status: :skipped, reason: :no_urls`; it does not
53
+ fall back to the sitemap. Omitting `entries` retains sitemap selection.
54
+
55
+ Explicit entries reuse configured keys, key locations, endpoints, batch limits,
56
+ dry runs, bounded retries and result/event reporting. The class-level
57
+ `Indexmap::Pinger::IndexNow.ping(entries: entries)` form is also supported.
58
+ For durable delivery, keep notification state and scheduling in the application.
59
+ Each `attempt_finished` event identifies its URLs and result; later attempts for
60
+ the same URLs supersede earlier receipts. Retain successful batches when another
61
+ batch fails. A dry run or missing key produces no delivery receipts, so leave
62
+ those notifications pending.
63
+
26
64
  ## Google Search Console
27
65
 
28
66
  Google submission uses the Search Console Sitemaps API. It submits sitemap URLs
@@ -2,7 +2,7 @@
2
2
 
3
3
  ActiveSupport.on_load(:indexmap) do
4
4
  Indexmap.configure do |config|
5
- config.base_url = -> { ENV.fetch("INDEXMAP_BASE_URL", "http://localhost:3000") }
5
+ config.base_url = -> { ENV.fetch("BASE_URL", "http://localhost:3000") }
6
6
  config.storage = -> do
7
7
  Indexmap::Storage::Filesystem.new(
8
8
  path: Rails.public_path,
@@ -10,12 +10,16 @@ module Indexmap
10
10
  class IndexNow < Base
11
11
  KEY_FORMAT = /\A[a-f0-9]{32}\z/
12
12
 
13
+ def self.ping(entries: nil, **options, &block)
14
+ new(**options).ping(entries: entries, &block)
15
+ end
16
+
13
17
  def initialize(configuration: Indexmap.configuration, storage: nil, connection: nil)
14
18
  super(configuration: configuration, storage: storage)
15
19
  @connection = connection
16
20
  end
17
21
 
18
- def ping
22
+ def ping(entries: nil)
19
23
  api_key = read_api_key
20
24
  unless api_key
21
25
  logger.debug("IndexNow API key is not configured.")
@@ -23,7 +27,7 @@ module Indexmap
23
27
  end
24
28
 
25
29
  batch_size = max_urls_per_request
26
- entries = entries_to_ping
30
+ entries = entries.nil? ? entries_to_ping : explicit_entries(entries)
27
31
  results = entries.each_slice(batch_size).map.with_index(1) do |batch, number|
28
32
  urls = batch.map(&:loc)
29
33
 
@@ -111,6 +115,12 @@ module Indexmap
111
115
  configuration.index_now
112
116
  end
113
117
 
118
+ def explicit_entries(entries)
119
+ entries = entries.to_a
120
+ Validator.new(configuration: configuration).validate_locations!(entries)
121
+ entries.uniq(&:loc)
122
+ end
123
+
114
124
  def entries_to_ping
115
125
  enum_for(:each_selection, cutoff: since_cutoff).lazy.filter_map do |entry, _reason, selected|
116
126
  entry if selected
@@ -30,10 +30,7 @@ module Indexmap
30
30
  Dir.mktmpdir("indexmap-validation") do |directory|
31
31
  duplicates = Duplicates.new(directory: directory)
32
32
  validate_sitemap_files!(sitemap_filename) do |entry|
33
- validate_parameterized_urls!([entry])
34
- validate_fragment_urls!([entry])
35
- validate_absolute_http_urls!([entry])
36
- validate_same_host_urls!([entry])
33
+ validate_locations!([entry])
37
34
  validate_lastmods!([entry])
38
35
  yield entry if block_given?
39
36
  duplicates.add(entry.loc)
@@ -47,6 +44,18 @@ module Indexmap
47
44
  true
48
45
  end
49
46
 
47
+ def validate_locations!(entries)
48
+ if entries.any? { |entry| entry.loc.to_s.length >= 2048 }
49
+ raise ValidationError, "Sitemap loc must be shorter than 2,048 characters"
50
+ end
51
+
52
+ validate_parameterized_urls!(entries)
53
+ validate_fragment_urls!(entries)
54
+ validate_absolute_http_urls!(entries)
55
+ validate_same_host_urls!(entries)
56
+ true
57
+ end
58
+
50
59
  def each_entry
51
60
  return enum_for(:each_entry) unless block_given?
52
61
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Indexmap
4
- VERSION = "0.11.0"
4
+ VERSION = "0.12.0"
5
5
  end
@@ -14,7 +14,7 @@ class IndexmapInstallGeneratorTest < Minitest::Test
14
14
  RUBY
15
15
  Indexmap::Generators::InstallGenerator.start([], destination_root: destination)
16
16
  initializer = File.join(destination, "config/initializers/indexmap.rb")
17
- source = File.read(initializer).sub('ENV.fetch("INDEXMAP_BASE_URL", "http://localhost:3000")', "Rails.origin")
17
+ source = File.read(initializer).sub('ENV.fetch("BASE_URL", "http://localhost:3000")', "Rails.origin")
18
18
  source = source.sub("# config.sections = -> { Sitemap.sections }", <<~RUBY.strip)
19
19
  config.format = :single_file
20
20
  config.entries = -> { [Indexmap::Entry.new(loc: Rails.origin + "/page")] }
@@ -375,6 +375,99 @@ class IndexmapPingerIndexNowTest < Minitest::Test
375
375
  assert_equal 1, calls
376
376
  end
377
377
 
378
+ def test_pings_explicit_entries_without_a_sitemap_or_date_filter
379
+ configuration = configuration_with
380
+ configuration.index_now.key = VALID_KEY
381
+ entries = [
382
+ Indexmap::Entry.new(loc: "https://www.example.com/updated", lastmod: "2020-01-01"),
383
+ Indexmap::Entry.new(loc: "https://www.example.com/deleted")
384
+ ]
385
+ request = stub_request(:post, "https://api.indexnow.org/indexnow").with do |request|
386
+ JSON.parse(request.body).fetch("urlList") == entries.map(&:loc)
387
+ end.to_return(status: 202)
388
+ events = []
389
+
390
+ with_env("SINCE" => "invalid", "INDEXNOW_RECENT_HOURS" => "24") do
391
+ result = Indexmap::Pinger::IndexNow.new(configuration: configuration).ping(entries: entries) { |event| events << event }
392
+
393
+ assert_equal :submitted, result.fetch(:status)
394
+ assert_equal 2, result.fetch(:url_count)
395
+ end
396
+
397
+ assert_requested request, times: 1
398
+ assert_equal entries.map(&:loc), events.last.fetch(:urls)
399
+ assert_equal :validation_pending, events.last.fetch(:receipt)
400
+ end
401
+
402
+ def test_explicit_empty_entries_do_not_fall_back_to_the_sitemap
403
+ configuration = configuration_with(storage: sitemap_storage)
404
+ configuration.index_now.key = VALID_KEY
405
+
406
+ result = Indexmap::Pinger::IndexNow.new(configuration: configuration).ping(entries: [])
407
+
408
+ assert_equal({status: :skipped, reason: :no_urls}, result)
409
+ assert_not_requested(:post, "https://api.indexnow.org/indexnow")
410
+ end
411
+
412
+ def test_validates_all_explicit_entries_before_sending_any_batch
413
+ configuration = configuration_with
414
+ configuration.index_now.key = VALID_KEY
415
+ configuration.index_now.max_urls_per_request = 1
416
+ entries = [Indexmap::Entry.new(loc: "https://www.example.com/updated"),
417
+ Indexmap::Entry.new(loc: "https://another.example.com/deleted")]
418
+
419
+ assert_raises(Indexmap::ValidationError) do
420
+ Indexmap::Pinger::IndexNow.new(configuration: configuration).ping(entries: entries)
421
+ end
422
+
423
+ assert_not_requested(:post, "https://api.indexnow.org/indexnow")
424
+ end
425
+
426
+ def test_batches_explicit_entries_and_reports_partial_delivery
427
+ configuration = configuration_with
428
+ configuration.index_now.key = VALID_KEY
429
+ configuration.index_now.max_urls_per_request = 1
430
+ entries = [Indexmap::Entry.new(loc: "https://www.example.com/updated"),
431
+ Indexmap::Entry.new(loc: "https://www.example.com/deleted")]
432
+ stub_request(:post, "https://api.indexnow.org/indexnow").to_return(status: 200).then.to_return(status: 429)
433
+ events = []
434
+
435
+ result = Indexmap::Pinger::IndexNow.ping(configuration: configuration, entries: entries) { |event| events << event }
436
+
437
+ assert_equal :partial, result.fetch(:status)
438
+ assert_equal 1, result.fetch(:url_count)
439
+ assert_equal 429, result.fetch(:failures).first.fetch(:status_code)
440
+ assert_equal [entries.last.loc], events.last.fetch(:urls)
441
+ end
442
+
443
+ def test_explicit_entries_reuse_dry_run_and_deduplicate_urls
444
+ configuration = configuration_with
445
+ configuration.index_now.key = VALID_KEY
446
+ configuration.index_now.dry_run = true
447
+ entry = Indexmap::Entry.new(loc: "https://www.example.com/updated")
448
+
449
+ result = Indexmap::Pinger::IndexNow.new(configuration: configuration).ping(entries: [entry, entry])
450
+
451
+ assert_equal :dry_run, result.fetch(:status)
452
+ assert_equal 1, result.fetch(:url_count)
453
+ assert_not_requested(:post, "https://api.indexnow.org/indexnow")
454
+ end
455
+
456
+ def test_rejects_invalid_explicit_locations_before_submission
457
+ configuration = configuration_with
458
+ configuration.index_now.key = VALID_KEY
459
+ [nil, "", "/relative", "ftp://www.example.com/file", "https://user@www.example.com/private",
460
+ "https://www.example.com/page?query=value", "https://www.example.com/page#fragment",
461
+ "http://www.example.com/page", "https://www.example.com:8443/page",
462
+ "https://www.example.com/#{"x" * 2048}"].each do |location|
463
+ assert_raises(Indexmap::ValidationError) do
464
+ Indexmap::Pinger::IndexNow.new(configuration: configuration).ping(entries: [Indexmap::Entry.new(loc: location)])
465
+ end
466
+ end
467
+
468
+ assert_not_requested(:post, "https://api.indexnow.org/indexnow")
469
+ end
470
+
378
471
  private
379
472
 
380
473
  def with_env(overrides)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: indexmap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paulo Fidalgo
@@ -201,8 +201,8 @@ metadata:
201
201
  homepage_uri: https://www.ethos-link.com/opensource/indexmap
202
202
  source_code_uri: https://github.com/ethos-link/indexmap
203
203
  bug_tracker_uri: https://github.com/ethos-link/indexmap/issues
204
- changelog_uri: https://github.com/ethos-link/indexmap/blob/v0.11.0/CHANGELOG.md
205
- documentation_uri: https://github.com/ethos-link/indexmap/blob/v0.11.0/README.md
204
+ changelog_uri: https://github.com/ethos-link/indexmap/blob/v0.12.0/CHANGELOG.md
205
+ documentation_uri: https://github.com/ethos-link/indexmap/blob/v0.12.0/README.md
206
206
  funding_uri: https://www.reviato.com/
207
207
  github_repo: ssh://github.com/ethos-link/indexmap
208
208
  allowed_push_host: https://rubygems.org