crawlscope 0.9.2 → 0.10.1
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 +4 -4
- data/CHANGELOG.md +27 -0
- data/README.md +52 -261
- data/UPGRADE.md +17 -2
- data/docs/rails.md +121 -0
- data/docs/rules.md +95 -0
- data/docs/server-timing.md +59 -0
- data/lib/crawlscope/rules/links.rb +37 -33
- data/lib/crawlscope/url.rb +2 -1
- data/lib/crawlscope/version.rb +1 -1
- data/test/crawlscope/crawl_test.rb +18 -0
- data/test/crawlscope/links_rule_test.rb +48 -0
- data/test/crawlscope/url_test.rb +4 -0
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1ff240a395648f3047e4fd24fe2728ad5c7ad3c22406029f7dbb0316f43bee73
|
|
4
|
+
data.tar.gz: 93e012e28037929afadba5df00f8ad441665ddda8cbc55775278fcc427d5af00
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d7f51921917c37fd1cb6576d1c1c56957cdc6be141906b5958153c548296248a76316832efd7dcd562835a08b6393a3009e577ed59f676b72786ec3dc99cd81b
|
|
7
|
+
data.tar.gz: 7db8cd080f1256e42e17cf09cbd3a34f2a62bcbd0e48238e58f420359519fd4e737516c21ad48212c17bc34e093914e641d2a8fbbd60ec94f68600466ae098bf
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,33 @@ 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.10.1] - 2026-11-08
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Documentation
|
|
12
|
+
|
|
13
|
+
- make Ethos Link the canonical documentation home
|
|
14
|
+
|
|
15
|
+
- keep audited technical guidance alongside the code
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## [0.10.0] - 2026-11-06
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- keep checks local and adopt Gemkit 0.3.1
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
|
|
31
|
+
- distinguish filtered URLs in crawl results
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
8
35
|
## [0.9.2] - 2026-11-05
|
|
9
36
|
|
|
10
37
|
|
data/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# Crawlscope
|
|
2
2
|
|
|
3
3
|
[](https://badge.fury.io/rb/crawlscope)
|
|
4
|
-
[](https://github.com/ethos-link/crawlscope/actions/workflows/commitlint.yml)
|
|
5
5
|
|
|
6
|
-
`crawlscope`
|
|
6
|
+
`crawlscope` audits sitemap URLs for indexability, metadata, structured data and internal links.
|
|
7
7
|
|
|
8
8
|
It is built by [Ethos Link](https://www.ethos-link.com) and used in production by [Reviato](https://www.reviato.com).
|
|
9
9
|
|
|
10
10
|
It is designed for Rails apps and plain Ruby scripts that want:
|
|
11
11
|
|
|
12
|
-
-
|
|
12
|
+
- sitemap-driven crawling
|
|
13
13
|
- structured validation issues instead of free-form strings
|
|
14
14
|
- app-configurable rule and schema registries
|
|
15
15
|
- first-party rake tasks instead of a large DSL
|
|
@@ -30,6 +30,16 @@ The default rule set includes:
|
|
|
30
30
|
- content-quality checks
|
|
31
31
|
- internal-link checks
|
|
32
32
|
|
|
33
|
+
## Documentation
|
|
34
|
+
|
|
35
|
+
This README and the linked repository guides describe the checked-out code.
|
|
36
|
+
The [Ethos Link project page](https://www.ethos-link.com/opensource/crawlscope)
|
|
37
|
+
provides the canonical public project guide, overview and resources.
|
|
38
|
+
|
|
39
|
+
- [Rails integration and tasks](docs/rails.md)
|
|
40
|
+
- [Rule catalogue and schema registries](docs/rules.md)
|
|
41
|
+
- [Server timing and diagnostic headers](docs/server-timing.md)
|
|
42
|
+
|
|
33
43
|
## Installation
|
|
34
44
|
|
|
35
45
|
Crawlscope requires Ruby 4.0 or newer. Rails is optional; the CLI and Ruby
|
|
@@ -63,7 +73,7 @@ If you want browser rendering, also add:
|
|
|
63
73
|
gem "ferrum"
|
|
64
74
|
```
|
|
65
75
|
|
|
66
|
-
`crawlscope` only loads Ferrum when you run in browser mode.
|
|
76
|
+
`crawlscope` only loads Ferrum when you run in browser mode. Install a compatible Chrome or Chromium executable as well.
|
|
67
77
|
|
|
68
78
|
## CLI Usage
|
|
69
79
|
|
|
@@ -163,277 +173,46 @@ puts result.issues.to_a.map(&:message)
|
|
|
163
173
|
`result.ok?` returns `false` when an error is present. Warnings and notices
|
|
164
174
|
remain available through `result.issues` without making the result fail.
|
|
165
175
|
|
|
166
|
-
##
|
|
167
|
-
|
|
168
|
-
Crawlscope parses the
|
|
169
|
-
[`Server-Timing`](https://www.w3.org/TR/server-timing/) response header for both
|
|
170
|
-
HTTP and browser-rendered crawls. Each page exposes its parsed header through
|
|
171
|
-
`page.server_timing`:
|
|
172
|
-
|
|
173
|
-
```ruby
|
|
174
|
-
page.server_timing.each do |metric|
|
|
175
|
-
puts [metric.name, metric.duration, metric.description].compact.join(": ")
|
|
176
|
-
end
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
The validation report adds a `Server Timing` section only when at least one page
|
|
180
|
-
publishes the header. It includes:
|
|
181
|
-
|
|
182
|
-
- header coverage and the number of pages publishing durations
|
|
183
|
-
- sample and page counts with average, p50, p95, and maximum per metric
|
|
184
|
-
- non-duration signals, including cache status and routing descriptions
|
|
185
|
-
- the ten pages with the largest individual metric
|
|
186
|
-
- the number of malformed entries ignored during parsing
|
|
187
|
-
|
|
188
|
-
`dur` values are reported as milliseconds, as recommended by the specification.
|
|
189
|
-
Crawlscope does not add durations together because metrics such as `total`,
|
|
190
|
-
`app`, and `db` may overlap. A page's worst-offender entry is its largest
|
|
191
|
-
individual metric instead.
|
|
192
|
-
|
|
193
|
-
The current HTTP and browser transports expose response headers, not response
|
|
194
|
-
trailers. Metrics published only in a `Server-Timing` trailer are therefore not
|
|
195
|
-
available to Crawlscope.
|
|
176
|
+
## Rails integration
|
|
196
177
|
|
|
197
|
-
|
|
178
|
+
Add `gem "crawlscope", require: false` to the host application's Gemfile, run
|
|
179
|
+
`bundle install`, then install the task/configuration integration:
|
|
198
180
|
|
|
199
|
-
```
|
|
200
|
-
config.server_timing = true
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
Applications that expose timing only to authenticated diagnostics can set
|
|
204
|
-
`config.profile_token`. When this value is present, Crawlscope sends it as
|
|
205
|
-
`X-Profile-Token` on same-origin sitemap, HTTP, and browser document requests.
|
|
206
|
-
The header survives same-origin redirects but is removed before a cross-origin
|
|
207
|
-
redirect, and browser subresources never receive it. Keep the token in the host
|
|
208
|
-
application's secret store rather than a URL, command argument, report, or
|
|
209
|
-
checked-in configuration.
|
|
210
|
-
|
|
211
|
-
`CRAWLSCOPE_PROFILE_TOKEN` is the portable default for Rails, the standalone
|
|
212
|
-
CLI, Rake tasks, and plain Ruby callers. Rails applications may instead assign
|
|
213
|
-
`config.profile_token` from encrypted credentials when that is their established
|
|
214
|
-
secret-management boundary; explicit configuration takes precedence over the
|
|
215
|
-
environment.
|
|
216
|
-
|
|
217
|
-
New Rails applications enable it in development by default; production remains
|
|
218
|
-
opt-in. Rails publishes the Active Support notification names observed during
|
|
219
|
-
each request and sums repeated events with the same name. The exact metrics
|
|
220
|
-
therefore depend on the application and request, but commonly include controller,
|
|
221
|
-
view, database, and cache instrumentation. Crawlscope accepts Rails' dotted
|
|
222
|
-
metric names and reports each metric independently.
|
|
223
|
-
|
|
224
|
-
## Rails Usage
|
|
225
|
-
|
|
226
|
-
Install Rails 8 in the host application; Crawlscope does not install Railties.
|
|
227
|
-
For a process that loads Crawlscope before Rails, require `crawlscope/rails`
|
|
228
|
-
after Rails is available. The Ruby and CLI entry points remain independent of Rails.
|
|
229
|
-
|
|
230
|
-
Run the install generator after adding the gem:
|
|
231
|
-
|
|
232
|
-
```bash
|
|
181
|
+
```sh
|
|
233
182
|
bin/rails generate crawlscope:install
|
|
183
|
+
bin/rails crawlscope:validate
|
|
234
184
|
```
|
|
235
185
|
|
|
236
|
-
|
|
237
|
-
`
|
|
238
|
-
|
|
239
|
-
the
|
|
240
|
-
|
|
241
|
-
Customize the `Crawlscope.configure` block inside the generated initializer:
|
|
242
|
-
|
|
243
|
-
```ruby
|
|
244
|
-
Crawlscope.configure do |config|
|
|
245
|
-
config.base_url = -> { ENV.fetch("CRAWLSCOPE_BASE_URL", "http://localhost:3000") }
|
|
246
|
-
config.sitemap_path = lambda {
|
|
247
|
-
ENV.fetch("SITEMAP", "#{config.base_url.to_s.chomp("/")}/sitemap.xml")
|
|
248
|
-
}
|
|
249
|
-
config.site_name = ENV.fetch("CRAWLSCOPE_SITE_NAME", "Application")
|
|
250
|
-
end
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
Runtime callers must apply the generated configuration before using
|
|
254
|
-
Crawlscope:
|
|
186
|
+
Edit the generated `Crawlscope.configure` block to set `base_url`,
|
|
187
|
+
`sitemap_path` and any custom rule/schema registries. Tasks load and apply it
|
|
188
|
+
automatically. From runtime application code, apply the generated loader and
|
|
189
|
+
execute the crawl explicitly:
|
|
255
190
|
|
|
256
191
|
```ruby
|
|
257
192
|
CrawlscopeConfiguration.apply
|
|
258
|
-
Crawlscope.configuration.audit
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
Rake tasks apply it automatically because `crawlscope/tasks` loads the gem
|
|
262
|
-
before Rails evaluates the initializer. Each Rake entry point passes the shared
|
|
263
|
-
`Crawlscope.configuration` object to the CLI, so configured base URLs, sitemap
|
|
264
|
-
paths, registries, and runtime settings are preserved unless a task argument or
|
|
265
|
-
environment override replaces them.
|
|
266
|
-
|
|
267
|
-
Then run:
|
|
268
|
-
|
|
269
|
-
```bash
|
|
270
|
-
bin/rails crawlscope:validate
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
Available environment overrides:
|
|
274
|
-
|
|
275
|
-
- `URL`
|
|
276
|
-
- `SITEMAP`
|
|
277
|
-
- `CRAWLSCOPE_PROFILE_TOKEN`
|
|
278
|
-
- `RULES=metadata,links`
|
|
279
|
-
- `JS=1` or `RENDERER=browser`
|
|
280
|
-
- `TIMEOUT=30`
|
|
281
|
-
- `NETWORK_IDLE_TIMEOUT=10`
|
|
282
|
-
- `CONCURRENCY=5`
|
|
283
|
-
- `FETCH_EXECUTOR=threaded` or `FETCH_EXECUTOR=async`
|
|
284
|
-
|
|
285
|
-
Available tasks:
|
|
286
|
-
|
|
287
|
-
```bash
|
|
288
|
-
bin/rails crawlscope:validate
|
|
289
|
-
bin/rails crawlscope:validate:indexability
|
|
290
|
-
bin/rails crawlscope:validate:metadata
|
|
291
|
-
bin/rails crawlscope:validate:structured_data
|
|
292
|
-
bin/rails crawlscope:validate:uniqueness
|
|
293
|
-
bin/rails crawlscope:validate:content_quality
|
|
294
|
-
bin/rails crawlscope:validate:links
|
|
295
|
-
bin/rails crawlscope:validate:ldjson
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
The same validation surface is also available in the gem repository itself through plain `rake`:
|
|
299
|
-
|
|
300
|
-
```bash
|
|
301
|
-
bundle exec rake crawlscope:validate URL=https://example.com
|
|
302
|
-
bundle exec rake 'crawlscope:validate[https://example.com]'
|
|
303
|
-
bundle exec rake crawlscope:validate:metadata URL=https://example.com
|
|
304
|
-
bundle exec rake 'crawlscope:validate:metadata[https://example.com]'
|
|
305
|
-
bundle exec rake crawlscope:validate:ldjson URL=https://example.com/article
|
|
306
|
-
bundle exec rake 'crawlscope:validate:ldjson[https://example.com/article]'
|
|
307
|
-
```
|
|
308
|
-
|
|
309
|
-
`crawlscope:validate` runs all default sitemap rules: indexability, metadata,
|
|
310
|
-
structured data, uniqueness, content quality, and links. `URL` is the site
|
|
311
|
-
base. Without `SITEMAP`, Crawlscope uses the configured sitemap URL, then fetches
|
|
312
|
-
`/sitemap.xml` from `URL` over HTTP. With `SITEMAP`, Crawlscope uses `URL` as
|
|
313
|
-
the site base and validates URLs from that sitemap. `SITEMAP` may be a full URL
|
|
314
|
-
or an explicitly selected local file path.
|
|
315
|
-
|
|
316
|
-
Plain `rake` does not pass `--url` style flags to tasks. Use `URL=...` or the
|
|
317
|
-
task-argument form above instead.
|
|
318
|
-
|
|
319
|
-
`FETCH_EXECUTOR=async` is the default for HTTP crawling. It uses Ruby's fiber
|
|
320
|
-
scheduler and Async::HTTP through Faraday, preserving the same `CONCURRENCY`
|
|
321
|
-
bound. Use `FETCH_EXECUTOR=threaded` or `--fetch-executor threaded` for the
|
|
322
|
-
thread-pool executor. Browser rendering uses the threaded executor by default
|
|
323
|
-
because async fetch execution is only supported with HTTP rendering.
|
|
324
|
-
|
|
325
|
-
`crawlscope:validate:ldjson` is separate because it directly checks the URL or semicolon-separated URLs in `URL`; it does not crawl the sitemap. Without `URL`, it checks the configured base URL, falling back to `http://localhost:3000`.
|
|
326
|
-
|
|
327
|
-
### Structured Data URL Audit
|
|
328
|
-
|
|
329
|
-
For one-off structured-data checks:
|
|
330
|
-
|
|
331
|
-
```bash
|
|
332
|
-
bin/rails crawlscope:validate:ldjson URL=https://example.com/article
|
|
333
|
-
bin/rails crawlscope:validate:ldjson URL='https://example.com/a;https://example.com/b' SUMMARY=1
|
|
334
|
-
bin/rails crawlscope:validate:ldjson URL=https://example.com/article REPORT_PATH=tmp/structured-data.json
|
|
193
|
+
result = Crawlscope.configuration.audit.call
|
|
335
194
|
```
|
|
336
195
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
- `DEBUG=1`: print detected items
|
|
340
|
-
- `SUMMARY=1`: print grouped failures
|
|
341
|
-
- `REPORT_PATH=...`: write a JSON report. Treat this as trusted operator input; Crawlscope writes to the path the task process can access.
|
|
342
|
-
- `JS=1` or `RENDERER=browser`: render with Ferrum
|
|
343
|
-
|
|
344
|
-
## Rules
|
|
345
|
-
|
|
346
|
-
Built-in rules:
|
|
347
|
-
|
|
348
|
-
- `indexability`
|
|
349
|
-
- `metadata`
|
|
350
|
-
- `structured_data`
|
|
351
|
-
- `uniqueness`
|
|
352
|
-
- `content_quality`
|
|
353
|
-
- `links`
|
|
354
|
-
|
|
355
|
-
### Indexability
|
|
356
|
-
|
|
357
|
-
Checks:
|
|
358
|
-
|
|
359
|
-
- page-level meta robots `noindex`
|
|
360
|
-
- `X-Robots-Tag: noindex`
|
|
361
|
-
|
|
362
|
-
### Metadata
|
|
363
|
-
|
|
364
|
-
Checks:
|
|
365
|
-
|
|
366
|
-
- missing `<h1>`
|
|
367
|
-
- missing `<title>`
|
|
368
|
-
- title length
|
|
369
|
-
- repeated site name in the title
|
|
370
|
-
- missing meta description
|
|
371
|
-
- meta description length
|
|
372
|
-
- missing canonical link
|
|
373
|
-
- canonical mismatch
|
|
374
|
-
|
|
375
|
-
### Structured Data
|
|
196
|
+
See [Rails integration](docs/rails.md) for lazy loading, all tasks,
|
|
197
|
+
environment overrides and structured-data URL audits.
|
|
376
198
|
|
|
377
|
-
|
|
199
|
+
## Configuration and limits
|
|
378
200
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
201
|
+
The shared configuration defaults to HTTP rendering, the async fetch executor,
|
|
202
|
+
10 concurrent requests and a 20-second request timeout. Browser rendering uses
|
|
203
|
+
the threaded executor with at most four concurrent browser fetches. Configure
|
|
204
|
+
`concurrency`, `timeout_seconds`, `renderer`, `fetch_executor`, `rule_registry`
|
|
205
|
+
and `schema_registry` through `Crawlscope.configure` when using that shared
|
|
206
|
+
configuration; direct `Crawlscope::Crawl.new` callers pass their own options.
|
|
383
207
|
|
|
384
|
-
|
|
208
|
+
Use [rule and schema registries](docs/rules.md) to select or extend checks.
|
|
209
|
+
Near-duplicate scanning is limited to 250 HTML pages by default; exact duplicate
|
|
210
|
+
checks still run for larger crawls. Validation describes observed responses and
|
|
211
|
+
configured rules; it does not establish Google rich-result eligibility or
|
|
212
|
+
search ranking.
|
|
385
213
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
- duplicate titles
|
|
389
|
-
- duplicate meta descriptions
|
|
390
|
-
- duplicate content fingerprints
|
|
391
|
-
- near-duplicate visible content for up to 250 HTML pages
|
|
392
|
-
|
|
393
|
-
For larger crawls, exact duplicate checks still run and Crawlscope reports
|
|
394
|
-
`near_duplicate_scan_skipped`. Configure `Rules::Uniqueness` with
|
|
395
|
-
`max_near_duplicate_pages:` in a custom rule registry to change the limit.
|
|
396
|
-
|
|
397
|
-
### Content Quality
|
|
398
|
-
|
|
399
|
-
Checks:
|
|
400
|
-
|
|
401
|
-
- thin visible text
|
|
402
|
-
- low visible-text-to-HTML ratio
|
|
403
|
-
- low unique-token ratio
|
|
404
|
-
|
|
405
|
-
### Links
|
|
406
|
-
|
|
407
|
-
Checks:
|
|
408
|
-
|
|
409
|
-
- broken internal links
|
|
410
|
-
- unresolved internal links
|
|
411
|
-
- low inbound anchor-link counts
|
|
412
|
-
|
|
413
|
-
## Schema Registry
|
|
414
|
-
|
|
415
|
-
`crawlscope` ships with a default schema registry for common types such as:
|
|
416
|
-
|
|
417
|
-
- `Article`
|
|
418
|
-
- `FAQPage`
|
|
419
|
-
- `Organization`
|
|
420
|
-
- `Product`
|
|
421
|
-
- `Review`
|
|
422
|
-
- `SoftwareApplication`
|
|
423
|
-
- `WebApplication`
|
|
424
|
-
- `WebSite`
|
|
425
|
-
|
|
426
|
-
The default schema definitions live in `Crawlscope::Schemas`; `Crawlscope::SchemaRegistry` owns registration and validation.
|
|
427
|
-
|
|
428
|
-
Host apps can replace or extend the registry:
|
|
429
|
-
|
|
430
|
-
```ruby
|
|
431
|
-
Crawlscope.configure do |config|
|
|
432
|
-
config.schema_registry = -> { MyApp::StructuredData::SchemaRegistry.new }
|
|
433
|
-
end
|
|
434
|
-
```
|
|
435
|
-
|
|
436
|
-
That makes `crawlscope` useful as the audit engine while the app remains the owner of stricter product-specific schema rules.
|
|
214
|
+
[Server timing](docs/server-timing.md) covers response timings, diagnostic
|
|
215
|
+
profile tokens and the limits of those measurements.
|
|
437
216
|
|
|
438
217
|
## Contributing
|
|
439
218
|
|
|
@@ -463,3 +242,15 @@ bundle exec rake verify
|
|
|
463
242
|
Tests use controlled local fixtures and need no service account.
|
|
464
243
|
Release preparation, publication, registry setup and recovery are documented
|
|
465
244
|
in the [Gemkit release guide](https://github.com/ethos-link/ethos-gemkit#releasing-a-gem).
|
|
245
|
+
|
|
246
|
+
## About Ethos Link
|
|
247
|
+
|
|
248
|
+
[Ethos Link](https://www.ethos-link.com) is a software company founded by
|
|
249
|
+
[Paulo Fidalgo](https://www.fidalgo.pt). This gem is part of the open-source
|
|
250
|
+
tooling we publish alongside our business products:
|
|
251
|
+
|
|
252
|
+
- [Reviato](https://www.reviato.com): collect private customer feedback and analyse public reviews.
|
|
253
|
+
- [Nuntio](https://www.nuntiohq.com): prepare, review and schedule social posts.
|
|
254
|
+
- [EthosPlaces](https://www.ethos.place): find places, opening hours and contact details.
|
|
255
|
+
|
|
256
|
+
Explore our [open-source projects](https://www.ethos-link.com/opensource).
|
data/UPGRADE.md
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
# Upgrade Guide
|
|
2
2
|
|
|
3
|
+
Run `bundle exec rake verify` locally before pushing or preparing a release.
|
|
4
|
+
GitHub Actions runs commitlint and release packaging/publication only.
|
|
5
|
+
|
|
3
6
|
## 0.9.1
|
|
4
7
|
|
|
5
|
-
Development and release tooling uses Gemkit 0.3.
|
|
8
|
+
Development and release tooling uses Gemkit 0.3.1. Update the gem and workflow
|
|
6
9
|
pins together; see the [Gemkit upgrade guide](https://github.com/ethos-link/ethos-gemkit/blob/main/UPGRADE.md).
|
|
7
10
|
Runtime APIs are unchanged.
|
|
8
11
|
|
|
@@ -34,6 +37,18 @@ in the README; the shared workflow does not inherit another gem's permission.
|
|
|
34
37
|
|
|
35
38
|
## Next Release
|
|
36
39
|
|
|
40
|
+
### Query links retain their own URL identity
|
|
41
|
+
|
|
42
|
+
URL normalization now preserves query strings and still removes fragments.
|
|
43
|
+
Resolvers, caches and issue consumers must keep the query string when identifying
|
|
44
|
+
a URL. A filtered page no longer shares a resolution or inbound-link count with
|
|
45
|
+
its unfiltered page.
|
|
46
|
+
|
|
47
|
+
Nofollow warnings exclude self-links and destinations that explicitly declare
|
|
48
|
+
`noindex` in their response headers or HTML. Other indexable destinations,
|
|
49
|
+
including query URLs, still produce nofollow warnings. Broken and redirected
|
|
50
|
+
links remain checked. No host configuration changes are required.
|
|
51
|
+
|
|
37
52
|
### Structured-data length errors include the measured size
|
|
38
53
|
|
|
39
54
|
String-length schema errors now include an optional `length` field with the
|
|
@@ -141,4 +156,4 @@ Recommended migration:
|
|
|
141
156
|
4. Set `FETCH_EXECUTOR=threaded` or pass `--fetch-executor threaded` for a
|
|
142
157
|
conservative rollout or for explicit thread-pool execution.
|
|
143
158
|
5. Browser rendering continues to use threaded execution by default because
|
|
144
|
-
async fetch execution is only supported with HTTP rendering.
|
|
159
|
+
async fetch execution is only supported with HTTP rendering.
|
data/docs/rails.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Rails integration
|
|
2
|
+
|
|
3
|
+
[README](../README.md) · [Project guide](https://www.ethos-link.com/opensource/crawlscope)
|
|
4
|
+
|
|
5
|
+
Install Rails 8 in the host application; Crawlscope does not install Railties.
|
|
6
|
+
For a process that loads Crawlscope before Rails, require `crawlscope/rails`
|
|
7
|
+
after Rails is available. The Ruby and CLI entry points remain independent of Rails.
|
|
8
|
+
|
|
9
|
+
Run the install generator after adding the gem:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
bin/rails generate crawlscope:install
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The generator creates `config/initializers/crawlscope.rb` with an idempotent
|
|
16
|
+
`CrawlscopeConfiguration.apply` loader and adds conditional `crawlscope/tasks`
|
|
17
|
+
loading to the application's `Rakefile`. This preserves `bin/rails --tasks` and
|
|
18
|
+
the `crawlscope:*` tasks without loading Crawlscope during normal Rails boot.
|
|
19
|
+
|
|
20
|
+
Customize the `Crawlscope.configure` block inside the generated initializer:
|
|
21
|
+
|
|
22
|
+
```ruby
|
|
23
|
+
Crawlscope.configure do |config|
|
|
24
|
+
config.base_url = -> { ENV.fetch("CRAWLSCOPE_BASE_URL", "http://localhost:3000") }
|
|
25
|
+
config.sitemap_path = lambda {
|
|
26
|
+
ENV.fetch("SITEMAP", "#{config.base_url.to_s.chomp("/")}/sitemap.xml")
|
|
27
|
+
}
|
|
28
|
+
config.site_name = ENV.fetch("CRAWLSCOPE_SITE_NAME", "Application")
|
|
29
|
+
end
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Runtime callers must apply the generated configuration before using
|
|
33
|
+
Crawlscope:
|
|
34
|
+
|
|
35
|
+
```ruby
|
|
36
|
+
CrawlscopeConfiguration.apply
|
|
37
|
+
Crawlscope.configuration.audit.call
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Rake tasks apply it automatically because `crawlscope/tasks` loads the gem
|
|
41
|
+
before Rails evaluates the initializer. Each Rake entry point passes the shared
|
|
42
|
+
`Crawlscope.configuration` object to the CLI, so configured base URLs, sitemap
|
|
43
|
+
paths, registries, and runtime settings are preserved unless a task argument or
|
|
44
|
+
environment override replaces them.
|
|
45
|
+
|
|
46
|
+
Then run:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
bin/rails crawlscope:validate
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Available environment overrides:
|
|
53
|
+
|
|
54
|
+
- `URL`
|
|
55
|
+
- `SITEMAP`
|
|
56
|
+
- `CRAWLSCOPE_PROFILE_TOKEN`
|
|
57
|
+
- `RULES=metadata,links`
|
|
58
|
+
- `JS=1` or `RENDERER=browser`
|
|
59
|
+
- `TIMEOUT=30`
|
|
60
|
+
- `NETWORK_IDLE_TIMEOUT=10`
|
|
61
|
+
- `CONCURRENCY=5`
|
|
62
|
+
- `FETCH_EXECUTOR=threaded` or `FETCH_EXECUTOR=async`
|
|
63
|
+
|
|
64
|
+
Available tasks:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
bin/rails crawlscope:validate
|
|
68
|
+
bin/rails crawlscope:validate:indexability
|
|
69
|
+
bin/rails crawlscope:validate:metadata
|
|
70
|
+
bin/rails crawlscope:validate:structured_data
|
|
71
|
+
bin/rails crawlscope:validate:uniqueness
|
|
72
|
+
bin/rails crawlscope:validate:content_quality
|
|
73
|
+
bin/rails crawlscope:validate:links
|
|
74
|
+
bin/rails crawlscope:validate:ldjson
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The same validation surface is also available in the gem repository itself through plain `rake`:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
bundle exec rake crawlscope:validate URL=https://example.com
|
|
81
|
+
bundle exec rake 'crawlscope:validate[https://example.com]'
|
|
82
|
+
bundle exec rake crawlscope:validate:metadata URL=https://example.com
|
|
83
|
+
bundle exec rake 'crawlscope:validate:metadata[https://example.com]'
|
|
84
|
+
bundle exec rake crawlscope:validate:ldjson URL=https://example.com/article
|
|
85
|
+
bundle exec rake 'crawlscope:validate:ldjson[https://example.com/article]'
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
`crawlscope:validate` runs all default sitemap rules: indexability, metadata,
|
|
89
|
+
structured data, uniqueness, content quality, and links. `URL` is the site
|
|
90
|
+
base. Without `SITEMAP`, Crawlscope uses the configured sitemap URL, then fetches
|
|
91
|
+
`/sitemap.xml` from `URL` over HTTP. With `SITEMAP`, Crawlscope uses `URL` as
|
|
92
|
+
the site base and validates URLs from that sitemap. `SITEMAP` may be a full URL
|
|
93
|
+
or an explicitly selected local file path.
|
|
94
|
+
|
|
95
|
+
Plain `rake` does not pass `--url` style flags to tasks. Use `URL=...` or the
|
|
96
|
+
task-argument form above instead.
|
|
97
|
+
|
|
98
|
+
`FETCH_EXECUTOR=async` is the default for HTTP crawling. It uses Ruby's fiber
|
|
99
|
+
scheduler and Async::HTTP through Faraday, preserving the same `CONCURRENCY`
|
|
100
|
+
bound. Use `FETCH_EXECUTOR=threaded` or `--fetch-executor threaded` for the
|
|
101
|
+
thread-pool executor. Browser rendering uses the threaded executor by default
|
|
102
|
+
because async fetch execution is only supported with HTTP rendering.
|
|
103
|
+
|
|
104
|
+
`crawlscope:validate:ldjson` is separate because it directly checks the URL or semicolon-separated URLs in `URL`; it does not crawl the sitemap. Without `URL`, it checks the configured base URL, falling back to `http://localhost:3000`.
|
|
105
|
+
|
|
106
|
+
## Structured Data URL Audit
|
|
107
|
+
|
|
108
|
+
For one-off structured-data checks:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
bin/rails crawlscope:validate:ldjson URL=https://example.com/article
|
|
112
|
+
bin/rails crawlscope:validate:ldjson URL='https://example.com/a;https://example.com/b' SUMMARY=1
|
|
113
|
+
bin/rails crawlscope:validate:ldjson URL=https://example.com/article REPORT_PATH=tmp/structured-data.json
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Optional flags:
|
|
117
|
+
|
|
118
|
+
- `DEBUG=1`: print detected items
|
|
119
|
+
- `SUMMARY=1`: print grouped failures
|
|
120
|
+
- `REPORT_PATH=...`: write a JSON report. Treat this as trusted operator input; Crawlscope writes to the path the task process can access.
|
|
121
|
+
- `JS=1` or `RENDERER=browser`: render with Ferrum
|
data/docs/rules.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Rules and schemas
|
|
2
|
+
|
|
3
|
+
[README](../README.md) · [Project guide](https://www.ethos-link.com/opensource/crawlscope)
|
|
4
|
+
|
|
5
|
+
Built-in rules:
|
|
6
|
+
|
|
7
|
+
- `indexability`
|
|
8
|
+
- `metadata`
|
|
9
|
+
- `structured_data`
|
|
10
|
+
- `uniqueness`
|
|
11
|
+
- `content_quality`
|
|
12
|
+
- `links`
|
|
13
|
+
|
|
14
|
+
## Indexability
|
|
15
|
+
|
|
16
|
+
Checks:
|
|
17
|
+
|
|
18
|
+
- page-level meta robots `noindex`
|
|
19
|
+
- `X-Robots-Tag: noindex`
|
|
20
|
+
|
|
21
|
+
## Metadata
|
|
22
|
+
|
|
23
|
+
Checks:
|
|
24
|
+
|
|
25
|
+
- missing `<h1>`
|
|
26
|
+
- missing `<title>`
|
|
27
|
+
- title length
|
|
28
|
+
- repeated site name in the title
|
|
29
|
+
- missing meta description
|
|
30
|
+
- meta description length
|
|
31
|
+
- missing canonical link
|
|
32
|
+
- canonical mismatch
|
|
33
|
+
|
|
34
|
+
## Structured Data
|
|
35
|
+
|
|
36
|
+
Checks:
|
|
37
|
+
|
|
38
|
+
- malformed JSON-LD
|
|
39
|
+
- missing required fields for supported schema types
|
|
40
|
+
- schema validation failures from the configured registry
|
|
41
|
+
- direct URL structured-data audits through `crawlscope:validate:ldjson`
|
|
42
|
+
|
|
43
|
+
## Uniqueness
|
|
44
|
+
|
|
45
|
+
Checks:
|
|
46
|
+
|
|
47
|
+
- duplicate titles
|
|
48
|
+
- duplicate meta descriptions
|
|
49
|
+
- duplicate content fingerprints
|
|
50
|
+
- near-duplicate visible content for up to 250 HTML pages
|
|
51
|
+
|
|
52
|
+
For larger crawls, exact duplicate checks still run and Crawlscope reports
|
|
53
|
+
`near_duplicate_scan_skipped`. Configure `Rules::Uniqueness` with
|
|
54
|
+
`max_near_duplicate_pages:` in a custom rule registry to change the limit.
|
|
55
|
+
|
|
56
|
+
## Content Quality
|
|
57
|
+
|
|
58
|
+
Checks:
|
|
59
|
+
|
|
60
|
+
- thin visible text
|
|
61
|
+
- low visible-text-to-HTML ratio
|
|
62
|
+
- low unique-token ratio
|
|
63
|
+
|
|
64
|
+
## Links
|
|
65
|
+
|
|
66
|
+
Checks:
|
|
67
|
+
|
|
68
|
+
- broken internal links
|
|
69
|
+
- unresolved internal links
|
|
70
|
+
- low inbound anchor-link counts
|
|
71
|
+
|
|
72
|
+
## Schema Registry
|
|
73
|
+
|
|
74
|
+
`crawlscope` ships with a default schema registry for common types such as:
|
|
75
|
+
|
|
76
|
+
- `Article`
|
|
77
|
+
- `FAQPage`
|
|
78
|
+
- `Organization`
|
|
79
|
+
- `Product`
|
|
80
|
+
- `Review`
|
|
81
|
+
- `SoftwareApplication`
|
|
82
|
+
- `WebApplication`
|
|
83
|
+
- `WebSite`
|
|
84
|
+
|
|
85
|
+
The default schema definitions live in `Crawlscope::Schemas`; `Crawlscope::SchemaRegistry` owns registration and validation.
|
|
86
|
+
|
|
87
|
+
Host apps can replace or extend the registry:
|
|
88
|
+
|
|
89
|
+
```ruby
|
|
90
|
+
Crawlscope.configure do |config|
|
|
91
|
+
config.schema_registry = -> { MyApp::StructuredData::SchemaRegistry.new }
|
|
92
|
+
end
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
That makes `crawlscope` useful as the audit engine while the app remains the owner of stricter product-specific schema rules.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Server timing
|
|
2
|
+
|
|
3
|
+
[README](../README.md) · [Project guide](https://www.ethos-link.com/opensource/crawlscope)
|
|
4
|
+
|
|
5
|
+
Crawlscope parses the
|
|
6
|
+
[`Server-Timing`](https://www.w3.org/TR/server-timing/) response header for both
|
|
7
|
+
HTTP and browser-rendered crawls. Each page exposes its parsed header through
|
|
8
|
+
`page.server_timing`:
|
|
9
|
+
|
|
10
|
+
```ruby
|
|
11
|
+
page.server_timing.each do |metric|
|
|
12
|
+
puts [metric.name, metric.duration, metric.description].compact.join(": ")
|
|
13
|
+
end
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The validation report adds a `Server Timing` section only when at least one page
|
|
17
|
+
publishes the header. It includes:
|
|
18
|
+
|
|
19
|
+
- header coverage and the number of pages publishing durations
|
|
20
|
+
- sample and page counts with average, p50, p95, and maximum per metric
|
|
21
|
+
- non-duration signals, including cache status and routing descriptions
|
|
22
|
+
- the ten pages with the largest individual metric
|
|
23
|
+
- the number of malformed entries ignored during parsing
|
|
24
|
+
|
|
25
|
+
`dur` values are reported as milliseconds, as recommended by the specification.
|
|
26
|
+
Crawlscope does not add durations together because metrics such as `total`,
|
|
27
|
+
`app`, and `db` may overlap. A page's worst-offender entry is its largest
|
|
28
|
+
individual metric instead.
|
|
29
|
+
|
|
30
|
+
The current HTTP and browser transports expose response headers, not response
|
|
31
|
+
trailers. Metrics published only in a `Server-Timing` trailer are therefore not
|
|
32
|
+
available to Crawlscope.
|
|
33
|
+
|
|
34
|
+
Rails 8 applications can enable `ActionDispatch::ServerTiming` with:
|
|
35
|
+
|
|
36
|
+
```ruby
|
|
37
|
+
config.server_timing = true
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Applications that expose timing only to authenticated diagnostics can set
|
|
41
|
+
`config.profile_token`. When this value is present, Crawlscope sends it as
|
|
42
|
+
`X-Profile-Token` on same-origin sitemap, HTTP, and browser document requests.
|
|
43
|
+
The header survives same-origin redirects but is removed before a cross-origin
|
|
44
|
+
redirect, and browser subresources never receive it. Keep the token in the host
|
|
45
|
+
application's secret store rather than a URL, command argument, report, or
|
|
46
|
+
checked-in configuration.
|
|
47
|
+
|
|
48
|
+
`CRAWLSCOPE_PROFILE_TOKEN` is the portable default for Rails, the standalone
|
|
49
|
+
CLI, Rake tasks, and plain Ruby callers. Rails applications may instead assign
|
|
50
|
+
`config.profile_token` from encrypted credentials when that is their established
|
|
51
|
+
secret-management boundary; explicit configuration takes precedence over the
|
|
52
|
+
environment.
|
|
53
|
+
|
|
54
|
+
New Rails applications enable Server-Timing in development by default;
|
|
55
|
+
production remains opt-in. Rails publishes the Active Support notification names observed during
|
|
56
|
+
each request and sums repeated events with the same name. The exact metrics
|
|
57
|
+
therefore depend on the application and request, but commonly include controller,
|
|
58
|
+
view, database, and cache instrumentation. Crawlscope accepts Rails' dotted
|
|
59
|
+
metric names and reports each metric independently.
|
|
@@ -31,7 +31,7 @@ module Crawlscope
|
|
|
31
31
|
links = extract_links(pages)
|
|
32
32
|
validate_url_hygiene(urls, links, issues)
|
|
33
33
|
resolved_links = resolve_links(links, issues)
|
|
34
|
-
validate_nofollow_outgoing_links(
|
|
34
|
+
validate_nofollow_outgoing_links(resolved_links, issues)
|
|
35
35
|
validate_http_internal_links(links, issues)
|
|
36
36
|
validate_pages_with_no_outgoing_links(urls, pages, links, issues)
|
|
37
37
|
validate_indexable_pages_missing_from_sitemap(urls, resolved_links, issues)
|
|
@@ -139,7 +139,9 @@ module Crawlscope
|
|
|
139
139
|
end
|
|
140
140
|
|
|
141
141
|
def validate_nofollow_outgoing_links(links, issues)
|
|
142
|
-
links.select
|
|
142
|
+
links.select do |link|
|
|
143
|
+
link[:nofollow] && link[:source_url] != link[:final_url] && !target_for(link[:target_url]).noindex?
|
|
144
|
+
end.group_by { |link| link[:source_url] }.each do |source_url, grouped_links|
|
|
143
145
|
target_urls = grouped_links.map { |link| link[:target_url] }.uniq
|
|
144
146
|
|
|
145
147
|
issues.add(
|
|
@@ -301,17 +303,17 @@ module Crawlscope
|
|
|
301
303
|
end
|
|
302
304
|
|
|
303
305
|
def validate_inbound_counts(urls, pages, resolved_links, issues)
|
|
304
|
-
|
|
306
|
+
sitemap_urls = urls.filter_map do |url|
|
|
305
307
|
normalized_url = Url.normalize(url, base_url: @base_url)
|
|
306
308
|
path = Url.path(normalized_url)
|
|
307
309
|
next if path.nil?
|
|
308
310
|
next if skip_internal_path?(path)
|
|
309
311
|
|
|
310
|
-
|
|
311
|
-
end
|
|
312
|
-
return if
|
|
312
|
+
normalized_url
|
|
313
|
+
end.to_set
|
|
314
|
+
return if sitemap_urls.size < 2
|
|
313
315
|
|
|
314
|
-
|
|
316
|
+
html_urls = pages.each_with_object(Set.new) do |page, result|
|
|
315
317
|
next unless page.html?
|
|
316
318
|
|
|
317
319
|
[page.normalized_url, page.normalized_final_url].compact.each do |url|
|
|
@@ -319,7 +321,7 @@ module Crawlscope
|
|
|
319
321
|
next if path.nil?
|
|
320
322
|
next if skip_internal_path?(path)
|
|
321
323
|
|
|
322
|
-
result <<
|
|
324
|
+
result << url
|
|
323
325
|
end
|
|
324
326
|
end
|
|
325
327
|
|
|
@@ -331,36 +333,37 @@ module Crawlscope
|
|
|
331
333
|
nofollow_sources_by_target = Hash.new { |hash, key| hash[key] = [] }
|
|
332
334
|
|
|
333
335
|
resolved_links.each do |link|
|
|
334
|
-
|
|
335
|
-
next unless
|
|
336
|
-
next if link[:
|
|
336
|
+
target_url = link[:final_url]
|
|
337
|
+
next unless sitemap_urls.include?(target_url)
|
|
338
|
+
next if target_for(link[:target_url]).noindex?
|
|
339
|
+
next if link[:source_url] == target_url
|
|
337
340
|
|
|
338
|
-
inbound_anchor_counts[
|
|
339
|
-
source_samples = sample_sources_by_target[
|
|
341
|
+
inbound_anchor_counts[target_url] += 1
|
|
342
|
+
source_samples = sample_sources_by_target[target_url]
|
|
340
343
|
source_samples << link[:source_url] unless source_samples.include?(link[:source_url])
|
|
341
344
|
|
|
342
345
|
if link[:nofollow]
|
|
343
|
-
nofollow_inbound_counts[
|
|
344
|
-
nofollow_sources = nofollow_sources_by_target[
|
|
346
|
+
nofollow_inbound_counts[target_url] += 1
|
|
347
|
+
nofollow_sources = nofollow_sources_by_target[target_url]
|
|
345
348
|
nofollow_sources << link[:source_url] unless nofollow_sources.include?(link[:source_url])
|
|
346
349
|
else
|
|
347
|
-
dofollow_inbound_counts[
|
|
348
|
-
dofollow_sources = dofollow_sources_by_target[
|
|
350
|
+
dofollow_inbound_counts[target_url] += 1
|
|
351
|
+
dofollow_sources = dofollow_sources_by_target[target_url]
|
|
349
352
|
dofollow_sources << link[:source_url] unless dofollow_sources.include?(link[:source_url])
|
|
350
353
|
end
|
|
351
354
|
end
|
|
352
355
|
|
|
353
|
-
|
|
354
|
-
next unless
|
|
356
|
+
sitemap_urls.each do |target_url|
|
|
357
|
+
next unless html_urls.include?(target_url)
|
|
355
358
|
|
|
356
|
-
inbound_count = inbound_anchor_counts[
|
|
357
|
-
dofollow_count = dofollow_inbound_counts[
|
|
358
|
-
nofollow_count = nofollow_inbound_counts[
|
|
359
|
+
inbound_count = inbound_anchor_counts[target_url]
|
|
360
|
+
dofollow_count = dofollow_inbound_counts[target_url]
|
|
361
|
+
nofollow_count = nofollow_inbound_counts[target_url]
|
|
359
362
|
|
|
360
363
|
report_orphan_page(target_url, issues) if inbound_count.zero?
|
|
361
364
|
|
|
362
365
|
if inbound_count.positive? && inbound_count < MIN_INBOUND_ANCHOR_LINKS
|
|
363
|
-
source_samples = sample_sources_by_target[
|
|
366
|
+
source_samples = sample_sources_by_target[target_url]
|
|
364
367
|
|
|
365
368
|
issues.add(
|
|
366
369
|
code: :low_inbound_anchor_links,
|
|
@@ -372,9 +375,9 @@ module Crawlscope
|
|
|
372
375
|
)
|
|
373
376
|
end
|
|
374
377
|
|
|
375
|
-
report_low_dofollow_inlinks(target_url,
|
|
376
|
-
report_only_nofollow_internal_inlinks(target_url, nofollow_count, dofollow_count, nofollow_sources_by_target[
|
|
377
|
-
report_mixed_follow_internal_inlinks(target_url, nofollow_count, dofollow_count, nofollow_sources_by_target[
|
|
378
|
+
report_low_dofollow_inlinks(target_url, dofollow_count, dofollow_sources_by_target, issues)
|
|
379
|
+
report_only_nofollow_internal_inlinks(target_url, nofollow_count, dofollow_count, nofollow_sources_by_target[target_url], issues)
|
|
380
|
+
report_mixed_follow_internal_inlinks(target_url, nofollow_count, dofollow_count, nofollow_sources_by_target[target_url], dofollow_sources_by_target[target_url], issues)
|
|
378
381
|
end
|
|
379
382
|
end
|
|
380
383
|
|
|
@@ -475,11 +478,11 @@ module Crawlscope
|
|
|
475
478
|
)
|
|
476
479
|
end
|
|
477
480
|
|
|
478
|
-
def report_low_dofollow_inlinks(target_url,
|
|
481
|
+
def report_low_dofollow_inlinks(target_url, dofollow_count, sources_by_target, issues)
|
|
479
482
|
return if dofollow_count.zero?
|
|
480
483
|
return if dofollow_count >= MIN_DOFOLLOW_INBOUND_LINKS
|
|
481
484
|
|
|
482
|
-
source_samples = sources_by_target[
|
|
485
|
+
source_samples = sources_by_target[target_url]
|
|
483
486
|
|
|
484
487
|
issues.add(
|
|
485
488
|
code: :low_dofollow_inlinks,
|
|
@@ -529,7 +532,7 @@ module Crawlscope
|
|
|
529
532
|
end
|
|
530
533
|
return if sitemap_pages.size < 2
|
|
531
534
|
|
|
532
|
-
|
|
535
|
+
dofollow_counts_by_url = dofollow_counts_by_final_url(resolved_links)
|
|
533
536
|
canonical_entries = canonical_entries_for(sitemap_pages)
|
|
534
537
|
@resolved_targets_by_url.merge!(resolve_targets(canonical_entries.map { |entry| entry.fetch(:canonical_url) }))
|
|
535
538
|
|
|
@@ -537,7 +540,7 @@ module Crawlscope
|
|
|
537
540
|
page = entry.fetch(:page)
|
|
538
541
|
canonical_url = entry.fetch(:canonical_url)
|
|
539
542
|
canonical_path = entry.fetch(:canonical_path)
|
|
540
|
-
if canonical_path && !root_path?(canonical_path) &&
|
|
543
|
+
if canonical_path && !root_path?(canonical_path) && dofollow_counts_by_url[canonical_url].zero?
|
|
541
544
|
issues.add(
|
|
542
545
|
code: :canonical_no_internal_inlinks,
|
|
543
546
|
severity: :warning,
|
|
@@ -570,12 +573,13 @@ module Crawlscope
|
|
|
570
573
|
end
|
|
571
574
|
end
|
|
572
575
|
|
|
573
|
-
def
|
|
576
|
+
def dofollow_counts_by_final_url(resolved_links)
|
|
574
577
|
resolved_links.each_with_object(Hash.new(0)) do |link, counts|
|
|
575
578
|
next if link[:nofollow]
|
|
576
|
-
next if link[:
|
|
579
|
+
next if link[:source_url] == link[:final_url]
|
|
580
|
+
next if target_for(link[:target_url]).noindex?
|
|
577
581
|
|
|
578
|
-
counts[link[:
|
|
582
|
+
counts[link[:final_url]] += 1
|
|
579
583
|
end
|
|
580
584
|
end
|
|
581
585
|
|
data/lib/crawlscope/url.rb
CHANGED
|
@@ -18,7 +18,8 @@ module Crawlscope
|
|
|
18
18
|
host = uri.host.to_s
|
|
19
19
|
host = "#{host}:#{uri.port}" if uri.port && uri.port != uri.default_port
|
|
20
20
|
|
|
21
|
-
"
|
|
21
|
+
query = uri.query ? "?#{uri.query}" : ""
|
|
22
|
+
"#{uri.scheme}://#{host}#{normalized_path}#{query}"
|
|
22
23
|
rescue URI::InvalidURIError
|
|
23
24
|
url.to_s
|
|
24
25
|
end
|
data/lib/crawlscope/version.rb
CHANGED
|
@@ -42,6 +42,24 @@ class CrawlscopeCrawlTest < Minitest::Test
|
|
|
42
42
|
FileUtils.rm_rf(@tmp_dir)
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
+
def test_fetches_nofollow_query_targets_separately_from_cached_sitemap_pages
|
|
46
|
+
File.write(@sitemap_path, '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><url><loc>https://example.com/pricing</loc></url></urlset>')
|
|
47
|
+
stub_request(:get, "https://example.com/pricing").to_return(
|
|
48
|
+
headers: {"Content-Type" => "text/html"}, body: '<a href="/pricing?sample=cafe#demo" rel="nofollow">Demo</a>'
|
|
49
|
+
)
|
|
50
|
+
filtered = stub_request(:get, "https://example.com/pricing?sample=cafe").to_return(
|
|
51
|
+
headers: {"Content-Type" => "text/html", "X-Robots-Tag" => "noindex, follow"}, body: "Demo"
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
result = Crawlscope::Crawl.new(
|
|
55
|
+
base_url: "https://example.com", sitemap_path: @sitemap_path,
|
|
56
|
+
rules: [Crawlscope::Rules::Links.new], schema_registry: Crawlscope::SchemaRegistry.default
|
|
57
|
+
).call
|
|
58
|
+
|
|
59
|
+
assert_requested filtered
|
|
60
|
+
assert_empty result.issues.to_a
|
|
61
|
+
end
|
|
62
|
+
|
|
45
63
|
def test_http_renderer_defaults_to_async_executor
|
|
46
64
|
crawl = Crawlscope::Crawl.new(
|
|
47
65
|
base_url: "https://example.com",
|
|
@@ -3,6 +3,54 @@
|
|
|
3
3
|
require "test_helper"
|
|
4
4
|
|
|
5
5
|
class CrawlscopeLinksRuleTest < Minitest::Test
|
|
6
|
+
def test_nofollow_controls_do_not_count_as_links_to_the_indexable_page
|
|
7
|
+
issues = Crawlscope::IssueCollection.new
|
|
8
|
+
requested = []
|
|
9
|
+
resolver = lambda do |url|
|
|
10
|
+
requested << url
|
|
11
|
+
{crawled: false, error: nil, final_url: url, status: 200, html: true,
|
|
12
|
+
doc: Nokogiri::HTML('<meta name="robots" content="noindex,follow">')}
|
|
13
|
+
end
|
|
14
|
+
pages = [
|
|
15
|
+
page(url: "https://example.com/guide", body: '<a href="/pricing">Pricing</a><a href="/pricing?sample=cafe#demo" rel="nofollow">Demo</a><a href="/guide" rel="nofollow">Reset</a>'),
|
|
16
|
+
page(url: "https://example.com/about", body: '<a href="/pricing">Pricing</a>'),
|
|
17
|
+
page(url: "https://example.com/pricing", body: '<a href="/guide">Guide</a><a href="/about">About</a>')
|
|
18
|
+
]
|
|
19
|
+
Crawlscope::Rules::Links.new.call(urls: pages.map(&:url), pages: pages, issues: issues, context: context(resolver: resolver))
|
|
20
|
+
|
|
21
|
+
assert_includes requested, "https://example.com/pricing?sample=cafe"
|
|
22
|
+
refute_includes issues.map(&:code), :nofollow_internal_outlinks
|
|
23
|
+
refute_includes issues.map(&:code), :mixed_follow_internal_inlinks
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_still_reports_nofollow_query_links_to_indexable_pages
|
|
27
|
+
issues = Crawlscope::IssueCollection.new
|
|
28
|
+
url = "https://example.com/catalog?page=2"
|
|
29
|
+
Crawlscope::Rules::Links.new.call(
|
|
30
|
+
urls: [], pages: [page(url: "https://example.com/guide", body: '<a href="/catalog?page=2" rel="nofollow">Next</a>')],
|
|
31
|
+
issues: issues, context: context(resolver: ->(target) { {crawled: false, final_url: target, status: 200, html: true} })
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
issue = issues.find { |item| item.code == :nofollow_internal_outlinks }
|
|
35
|
+
assert_equal [url], issue.details[:target_urls]
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_query_variants_have_separate_inbound_link_counts
|
|
39
|
+
issues = Crawlscope::IssueCollection.new
|
|
40
|
+
pages = [
|
|
41
|
+
page(url: "https://example.com/guide", body: '<a href="/catalog?page=2">Next</a><a href="/catalog">Catalog</a>'),
|
|
42
|
+
page(url: "https://example.com/catalog", body: '<a href="/guide">Guide</a>'),
|
|
43
|
+
page(url: "https://example.com/catalog?page=2", body: '<a href="/guide">Guide</a>')
|
|
44
|
+
]
|
|
45
|
+
Crawlscope::Rules::Links.new.call(
|
|
46
|
+
urls: pages.map(&:url), pages: pages, issues: issues,
|
|
47
|
+
context: context(resolver: ->(target) { {crawled: true, final_url: target, status: 200, html: true} })
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
counts = issues.select { |item| item.code == :low_dofollow_inlinks }.to_h { |item| [item.url, item.details[:dofollow_inbound_count]] }
|
|
51
|
+
assert_equal({"https://example.com/catalog" => 1, "https://example.com/catalog?page=2" => 1}, counts)
|
|
52
|
+
end
|
|
53
|
+
|
|
6
54
|
def test_reports_broken_internal_links
|
|
7
55
|
issues = Crawlscope::IssueCollection.new
|
|
8
56
|
rule = Crawlscope::Rules::Links.new
|
data/test/crawlscope/url_test.rb
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
require "test_helper"
|
|
4
4
|
|
|
5
5
|
class CrawlscopeUrlTest < Minitest::Test
|
|
6
|
+
def test_normalize_preserves_query_strings_and_removes_fragments
|
|
7
|
+
assert_equal "https://example.com/reviews?rating=1", Crawlscope::Url.normalize("/reviews/?rating=1#results", base_url: "https://example.com")
|
|
8
|
+
end
|
|
9
|
+
|
|
6
10
|
def test_normalize_resolves_relative_urls_and_removes_trailing_slash
|
|
7
11
|
assert_equal "https://example.com/pricing", Crawlscope::Url.normalize("/pricing/", base_url: "https://example.com")
|
|
8
12
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: crawlscope
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.10.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Paulo Fidalgo
|
|
@@ -178,6 +178,9 @@ files:
|
|
|
178
178
|
- LICENSE.txt
|
|
179
179
|
- README.md
|
|
180
180
|
- UPGRADE.md
|
|
181
|
+
- docs/rails.md
|
|
182
|
+
- docs/rules.md
|
|
183
|
+
- docs/server-timing.md
|
|
181
184
|
- exe/crawlscope
|
|
182
185
|
- lib/crawlscope.rb
|
|
183
186
|
- lib/crawlscope/browser.rb
|
|
@@ -270,7 +273,7 @@ metadata:
|
|
|
270
273
|
source_code_uri: https://github.com/ethos-link/crawlscope
|
|
271
274
|
bug_tracker_uri: https://github.com/ethos-link/crawlscope/issues
|
|
272
275
|
changelog_uri: https://github.com/ethos-link/crawlscope/blob/main/CHANGELOG.md
|
|
273
|
-
documentation_uri: https://
|
|
276
|
+
documentation_uri: https://www.ethos-link.com/opensource/crawlscope
|
|
274
277
|
funding_uri: https://www.reviato.com/
|
|
275
278
|
github_repo: ssh://github.com/ethos-link/crawlscope
|
|
276
279
|
allowed_push_host: https://rubygems.org
|