MojoX-ValidateHeadLinks

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

.gitignore
bin/validate.head.links.pl
Build.PL
Changelog.ini
Changes
lib/MojoX/ValidateHeadLinks.pm
LICENSE
Makefile.PL
MANIFEST			This list of files
META.json
META.yml
README

bin/validate.head.links.pl  view on Meta::CPAN

{
	pod2usage(2);
}

__END__

=pod

=head1 NAME

validate.head.links.pl - Ensure CSS and JS links in web pages point to real files

=head1 SYNOPSIS

validate.head.links.pl [options]

	Options:
	-help
	-doc_root aDirName
	-maxlevel logOption1
	-minlevel logOption2
	-url aURL

Exit value: 0 for success, 1+ for failure. Die upon error.

lib/MojoX/ValidateHeadLinks.pm  view on Meta::CPAN

# -----------------------------------------------

1;

=head1 NAME

MojoX::ValidateHeadLinks - Ensure CSS and JS links in web pages point to real files

=head1 Synopsis

	shell> validate.head.links.pl -h
	shell> validate.head.links.pl -d /run/shm/html -u http://127.0.0.1/index.html

This program calls the L</run()> method, which returns the number of errors found. Various logging
options, discussed under L</Constructor and initialization> and in the L</FAQ>, control the amount
of output. Nothing is printed by default.

On my machine, /run/shm/ is the directory used to access the Debian built-in RAM disk, and
/run/shm/html/ is my web server document root directory.

Since this script -validate.head.links.pl - ships in the bin/ directory, it is installed somewhere
along your executable search path when the module is installed.

=head1 Description

C<MojoX::ValidateHeadLinks> is a pure Perl module.

It does no more than this:

=over 4

=item o Downloads and parses a web page using L<Mojo::UserAgent>

Hence the -url parameter to validate.head.links.pl.

=item o Checks whether the CSS and JS links point to real files

Hence the -directory parameter to validate.head.links.pl.

=back

It handles the '@import' option used in some CSS links.

=head1 Distributions

This module is available as a Unix-style distro (*.tgz).

See L<http://savage.net.au/Perl-modules.html> for details.

lib/MojoX/ValidateHeadLinks.pm  view on Meta::CPAN

Returns the number of errors detected, so 0 is good and N > 0 is bad.

=head2 url([$url])

Here, the [] indicate an optional parameter.

Get or set the URL of the web page your wish to check.

=head1 FAQ

=head2 How does bin/validate.head.links.pl differ from linkcheck.pl?

L<linkcheck.pl|http://world.std.com/~swmcd/steven/perl/pm/lc/linkcheck.html> does not check that
links to non-HTML resources (CSS, JS) point to real files.

=head2 How does the -maxlevel parameter affect the output?

In these examples, $DR stands for the /run/shm/html/ directory, the doc root of my web server.

Output from a real run, where my dev web site is the same as my real web site (so -d $DR works):

	shell> validate.head.links.pl -d $DR -url http://savage.net.au/Novels-etc.html -max debug

	URL: http://savage.net.au/Novels-etc.html
	 Import: /run/shm/html/assets/js/DataTables-1.9.4/media/css/demo_page.css
	 Import: /run/shm/html/assets/js/DataTables-1.9.4/media/css/demo_table.css
	   Link: /run/shm/html/assets/css/local/default.css
	 Script: /run/shm/html/assets/js/DataTables-1.9.4/media/js/jquery.js
	 Script: /run/shm/html/assets/js/DataTables-1.9.4/media/js/jquery.dataTables.min.js
	Imports: 2. Errors: 0
	  Links: 1. Errors: 0
	Scripts: 2. Errors: 0

	shell> validate.head.links.pl -d $DR -url http://savage.net.au/Novels-etc.html -max info

	Imports: 2. Errors: 0
	  Links: 1. Errors: 0
	Scripts: 2. Errors: 0

	shell> validate.head.links.pl -d $DR -url http://savage.net.au/Novels-etc.html -max error

	(No output)

	shell> echo $?
	0

=head1 Repository

L<https://github.com/ronsavage/MojoX-ValidateHeadLinks>

t/assets/js/DataTables-1.9.4/media/js/jquery.dataTables.js  view on Meta::CPAN

			/* Recalculate the sanity width - now that we've applied the required width, before it was
			 * a temporary variable. This is required because the column width calculation is done
			 * before this table DOM is created.
			 */
			iSanityWidth = $(o.nTable).outerWidth();
			
			/* We want the hidden header to have zero height, so remove padding and borders. Then
			 * set the width based on the real headers
			 */
			
			// Apply all styles in one pass. Invalidates layout only once because we don't read any 
			// DOM properties.
			_fnApplyToChildren( zeroOut, anHeadSizers );
			 
			// Read all widths in next pass. Forces layout only once because we do not change 
			// any DOM properties.
			_fnApplyToChildren( function(nSizer) {
				aApplied.push( _fnStringToCss( $(nSizer).width() ) );
			}, anHeadSizers );
			 
			// Apply all widths in final pass. Invalidates layout only once because we do not
			// read any DOM properties.
			_fnApplyToChildren( function(nToSize, i) {
				nToSize.style.width = aApplied[i];
			}, anHeadToSize );
		
			$(anHeadSizers).height(0);
			
			/* Same again with the footer if we have one */
			if ( o.nTFoot !== null )
			{

xt/author/run.t  view on Meta::CPAN

use Test::More tests => 1;

# ------------------------

my($url)      = 'http://127.0.0.1/Novels-etc.html';
my(@result)   = `$^X bin/validate.head.links.pl -d /run/shm/html -max debug -u $url`;
my($result)   = join('', @result);
my($expected) = <<EOS;
URL: $url
 Import: /run/shm/html/assets/js/DataTables-1.9.4/media/css/demo_page.css
 Import: /run/shm/html/assets/js/DataTables-1.9.4/media/css/demo_table.css
 Script: /run/shm/html/assets/js/DataTables-1.9.4/media/js/jquery.js
 Script: /run/shm/html/assets/js/DataTables-1.9.4/media/js/jquery.dataTables.min.js
Imports: 2. Errors: 0
  Links: 0. Errors: 0
Scripts: 2. Errors: 0



( run in 0.352 second using v1.01-cache-2.11-cpan-bf8d7bb2d05 )