silverstripe / externallinks
Adds tracking of broken external links to the SilverStripe CMS
Installs: 206 660
Dependents: 5
Suggesters: 1
Security: 0
Stars: 10
Watchers: 6
Forks: 18
Open Issues: 12
Type:silverstripe-vendormodule
Requires
- php: ^8.1
- silverstripe/cms: ^5
Requires (Dev)
Suggests
- symbiote/silverstripe-queuedjobs: Provides a more efficient method of generating/updating the report
- 4.x-dev
- 3.x-dev
- 3.3.x-dev
- 3.3.0
- 3.3.0-rc1
- 3.3.0-beta1
- 3.2.x-dev
- 3.2.1
- 3.2.0
- 3.2.0-rc1
- 3.2.0-beta1
- 3.1.x-dev
- 3.1.2
- 3.1.1
- 3.1.0
- 3.1.0-rc1
- 3.1.0-beta1
- 3.0.x-dev
- 3.0.2
- 3.0.1
- 3.0.0
- 3.0.0-rc1
- 3.0.0-beta1
- 2.x-dev
- 2.4.x-dev
- 2.4.4
- 2.4.3
- 2.4.2
- 2.4.1
- 2.4.0
- 2.4.0-rc1
- 2.4.0-beta1
- 2.3.x-dev
- 2.3.0
- 2.3.0-rc1
- 2.3.0-beta2
- 2.3.0-beta1
- 2.2.x-dev
- 2.2.1
- 2.2.0
- 2.2.0-rc1
- 2.2.0-beta1
- 2.1.x-dev
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.x-dev
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 2.0.0-beta1
- 1.1.x-dev
- 1.1.1
- 1.1.0
- 1.0.x-dev
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-dependabot/npm_and_yarn/cross-spawn-7.0.6
- dev-pulls/3/update-js-1725215694
- dev-master
This package is auto-updated.
Last update: 2024-11-20 23:08:05 UTC
README
Introduction
The external links module is a task and ModelAdmin to track and to report on broken external links.
Maintainer Contact
- Damian Mooyman (@tractorcow) damian@silverstripe.com
Features
- Add external links to broken links reports
- Add a task to track external broken links
Installation
composer require silverstripe/externallinks
Report
A new report is added called 'External Broken links report'. When viewing this report, a user may press the "Create new report" button which will trigger an ajax request to initiate a report run.
In this initial ajax request this module will do one of two things, depending on which modules are included:
- If the queuedjobs module is installed, a new queued job will be initiated. The queuedjobs module will then manage the progress of the task.
- If the queuedjobs module is absent, then the controller will fallback to running a buildtask in the background. This is less robust, as a failure or error during this process will abort the run.
In either case, the background task will loop over every page in the system, inspecting all external urls and
checking the status code returned by requesting each one. If a URL returns a response code that is considered
"broken" (defined as < 200 or > 302) then the ss-broken
css class will be assigned to that url, and
a line item will be added to the report. If a previously broken link has been corrected or fixed, then
this class is removed.
In the actual report generated the user can click on any broken link item to either view the link in their browser, or edit the containing page in the CMS.
While a report is running the current status of this report will be displayed on the report details page, along with the status. The user may leave this page and return to it later to view the ongoing status of this report.
Any subsequent report may not be generated until a prior report has completed.
Dev task
Run the following task http://path.to.silverstripe/dev/tasks/CheckExternalLinksTask to check your site for external broken links.
Queued job
If you have the queuedjobs module installed you can set the task to be run every so often.
Whitelisting codes
If you want to ignore or whitelist certain HTTP codes this can be setup via ignore_codes
in the config.yml
file in mysite/_config
:
SilverStripe\ExternalLinks\Tasks\CheckExternalLinksTask: ignore_codes: - 401 - 403 - 501
Follow 301 redirects
You may want to follow a redirected URL a example of this would be redirecting from http to https can give you a false poitive as the http code of 301 will be returned which will be classed as a working link.
To allow redirects to be followed setup the following config in your config.yml
# Follow 301 redirects SilverStripe\ExternalLinks\Tasks\CurlLinkChecker: follow_location: 1
Bypass cache
By default the task will attempt to cache any results the cache can be bypassed with the following config in config.yml.
# Bypass SS_Cache SilverStripe\ExternalLinks\Tasks\CurlLinkChecker:: bypass_cache: 1
Headers
You may want to set headers to be sent with the CURL request (eg: user-agent) to avoid website rejecting the request thinking it is a bot. You can set them with the following config in config.yml.
# Headers SilverStripe\ExternalLinks\Tasks\CurlLinkChecker: headers: - 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0' - 'accept-encoding: gzip, deflate, br' - 'referer: https://www.domain.com/' - 'sec-fetch-mode: navigate' ...