Module which tracks external broken links in SilverStripe CMS pages
Go to file
2024-10-21 11:54:20 +13:00
_config API Make use of the new AdminController (#151) 2024-10-21 11:54:20 +13:00
.github Merge branch '3.2' into 3 2024-08-01 14:15:42 +00:00
.tx ENH Update translations 2023-03-06 18:17:30 +13:00
client API Make use of the new AdminController (#151) 2024-10-21 11:54:20 +13:00
lang TLN Update translations (#139) 2024-08-06 12:41:15 +12:00
src API Make use of the new AdminController (#151) 2024-10-21 11:54:20 +13:00
tests API Update API to reflect changes to CLI interaction (#145) 2024-09-26 17:18:08 +12:00
.editorconfig NEW Add loading animation to Create Report button, fix bug in CurlLinkChecker 2017-11-29 12:14:39 +13:00
.eslintrc.js DEP Upgrade frontend build stack (#90) 2023-01-30 14:04:04 +13:00
.gitattributes Update supporting items for SilverStripe 4 conventions 2017-11-22 14:01:40 +13:00
.gitignore DEP Upgrade frontend build stack (#90) 2023-01-30 14:04:04 +13:00
.nvmrc DEP Upgrade frontend build stack (#90) 2023-01-30 14:04:04 +13:00
.stylelintrc.js MNT Replace sass-lint with stylelint (#123) 2024-05-01 17:01:17 +12:00
babel.config.json DEP Upgrade frontend build stack (#90) 2023-01-30 14:04:04 +13:00
behat.yml MNT Add behat tests 2021-10-01 19:55:27 +13:00
changelog.md Update changelog for 1.0.5 2016-05-18 17:14:35 +12:00
code-of-conduct.md Added standard code of conduct 2015-11-21 20:13:30 +13:00
codecov.yml Update supporting items for SilverStripe 4 conventions 2017-11-22 14:01:40 +13:00
composer.json DEP Use PHPUnit 11 2024-09-18 11:39:29 +12:00
LICENSE MNT Run module-standardiser 2023-08-29 15:10:42 +12:00
package.json Merge branch '3' into 4 2024-09-11 13:46:10 +12:00
phpcs.xml.dist MNT Use shared travis config, use sminnee/phpunit 2020-11-10 12:55:10 +13:00
phpstan.neon.dist MNT Run module-standardiser (#119) 2024-02-02 14:00:14 +13:00
phpunit.xml.dist MNT Standardise modules 2022-08-01 16:21:58 +12:00
README.md API Update API to reflect changes to CLI interaction (#145) 2024-09-26 17:18:08 +12:00
webpack.config.js DEP Upgrade frontend build stack (#90) 2023-01-30 14:04:04 +13:00
yarn.lock Merge branch '3' into 4 2024-09-11 13:46:10 +12:00

External links

CI Silverstripe supported module

Introduction

The external links module is a task and ModelAdmin to track and to report on broken external links.

Maintainer Contact

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 sake 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'
    ...