link-error-test is plugin for Collection
The plugin is for the compilation & render milestones
Compiles a list of the links produced by Content files. The plugin cannot handle links in Collection files because the compilation stage occurs after the compilation plugins are run. This plugin generates a web page which is to be included in the output, so it has to be rendered during the compilation stage.
The report stage has access to all links, but Collection
stores report output in the report directory. This
plugin stores output in the output (html) folder.
One testing approach is to check all links using Javascript within the error page. However, Cross over restrictions make the retrieval of just headers from popular sources, such as Wikipedia, a pain inside a browser.
Consequently, the links are tested in three ways:
external links (viz., to http(s):// schemas) are tested using LibCurl and checking the response code.
local links, which are links to targets in documents within the Collection, are tested by verifying whether the file exists at the local specified.
internal links, which are links within a document (viz. a
#target
schema), and internal links to local files (viz., a/path/to/file#internal_target
schema) are tested by looking at thetargets
datastructure thatProcessedPod
collects. All targets are registered to ensure that they are unique.
Configuration
Testing remote files is slow, so it can be turned off by setting no-remote
to True in the plugin config file.
Reporting
Links are considered to have an error if:
for remote sites, and error is when the site generates a 4xx || 5xx response. The response code is provided.
for local links specified as only the file, there is an error if the file does not exist.
for local links specified with an internal target, there is an error if the target is not registered for that file
for internal links, there is an error if the target is not registered.
Errors are reported in that order.
Custom blocks
Using the following will list the link errors.
LinkErrorTest
Templates
linkerrortest is used to render the information generated by the plugin.