MT-W3CValidator: A Movable Type Plugin

Current version is 1.5.0.0 released on 2007-04-17

Contents

What This Plugin Does

This plugin will validate your web pages on the fly when published from Movable Type. The validation is done live against the W3C's Markup Validation Service by sending your newly published page. A compliant page will then include a badge from the W3C. A non-compliant page will not display a badge.

This plugin was built to address the issue of many web pages claiming to be compliant but are not. They probably were at one time, but as you post things to your blog, you may post non-compliant code now and then and become uncompliant. This plugin makes sure your pages are compliant, before you claim it! Now, if you notice the badge missing from your page, you know something is wrong.

This plugin is not intended to be a tool for debugging and diagnosing why you are not compliant. That is what the W3C's Markup Validation Service is for. Go there and enter your page name if that is your goal. The goal of this plugin is to just quickly check if you are compliant or not and show the badge when you are compliant.

Requirements

  • This plugin works with Movable Type version 3.3 and higher.
  • Perl version 5.8.5 or higher. This is what I use. It may work on lower versions. Let me know if it does and I will lower this.
  • This plugin will only work in static (not dynamic) templates.

Installation Instructions

  1. Download the latest version of the plugin.
  2. Unzip the contents of the file.
  3. Copy the file W3CValidator.pl to your Movable Type "plugins" directory. (If you don't have a plugins directory, create a plugins directory in the same directory where your mt.cgi file is located. Then upload W3CValidator.pl into the newly created plugins directory.)
  4. Give me some credit. You have many choices. Do one or all! 1) Add a trackback link to this page on your page. 2) Donate so that I continue to enhance this plugin.

How To Use The Tags

This plugin will only work in static (not dynamic) templates.

  • MTW3CValidate
    A container tag that should surround the entire contents of your page. Ideally, this should be the first and last tag in your template file. All output between these tags is used in the validator.

  • MTW3CValidBadge
    This tag returns the standard image HTML as recommended by the W3C for valid pages. Place this tag within the MTW3CValidate tags where you want the image to appear. If the page is not valid, this tag returns nothing. This tag must be placed within the container MTW3CValidate.

  • MTW3CValidBadgeCustom
    A container tag that allows you to specify your own HTML for the valid badge instead of using the default HTML recommended by the W3C. Some people like to use other smaller images or save the image to their own server. Place these tags within the MTW3CValidate tags where you want the image to appear. If the page is not valid, these tags returns nothing. This tag must be placed within the container MTW3CValidate.

  • MTW3CInvalidBadgeCustom
    A container tag that allows you to specify your own HTML for the invalid badge. If the page is valid, these tags returns nothing. This tag must be placed within the container MTW3CValidate.

  • MTW3CValidatorOutput
    A tag that prints out the HTML returned from the validator. If your page is not validating, this should give you information on why its not working. This tag should only be used to debug your installation if you are having problems. This tag is not meant to be an every day debugging tool for invalid pages. You will want to just use the validator for this. A word of caution, this tag will blindly insert the contents of the validator response into your web page -- that combination is guaranteed to be invalid because its a page within a page. Again, this is only a debugging technique. This tag must be placed within the container MTW3CValidate.

Frequently Asked Questions

  • Q: Are there any other plugins that can help me format my entries to be XHTML-compliant?
    A: Yes, I use and recommend SafeHref to help encode URLs that I put on my pages. URLs are normally the number one thing that breaks compliance. Its a great help. You can also use Amputator to fix those pesky ampersands.

  • Q: This plugin (and others) don't seem to be working on my server. Why?
    A: Internally, Movable Type requires some Perl modules to be installed for plugins to work. Some servers do not have these modules installed by default. Please run mt-check.cgi on your server to find out what you are missing.

Examples

1. In this simple example, we create a page that is validated and has the badge displayed.

<MTW3CValidate>
<!DOCTYPE html PUBLIC 
      "-//W3C//DTD XHTML 1.0 Transitional//EN" 
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
   <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
         <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
         <title>Virtual Library</title>
      </head>
      <body>
         <p>Moved to <a href="http://example.org/">example.org</a>.</p>
         <MTW3CValidBadge>
      </body>
   </html>
</MTW3CValidate>

2. In this simple example, we create a page that is validated and has a custom badge displayed.

<MTW3CValidate>
<!DOCTYPE html PUBLIC 
      "-//W3C//DTD XHTML 1.0 Transitional//EN" 
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
   <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
         <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
         <title>Virtual Library</title>
      </head>
      <body>
         <p>Moved to <a href="http://example.org/">example.org</a>.</p>
         <MTW3CValidBadgeCustom>
         [My page is XHTML-valid, dude!]
         </MTW3CValidBadgeCustom>
         <MTW3CInvalidBadgeCustom>
         [My page is NOT XHTML-valid, dude!]
         </MTW3CInvalidBadgeCustom>
      </body>
   </html>
</MTW3CValidate>

Donate

If you enjoy using this plugin and/or would like to see it enhanced, please donate a buck or two...or fifty. I will use the money to buy my wife dinner so she lets me keep working on this stuff for free and does not complain.

License

This software is licensed under the CC-GNU LGPL.

CC-GNU LGPL

Download

Download the current version from the link below. Past versions are not archived.

Version History

1.5.0.0 -- 2007-04-17
  • Updated to use W3C header parsing instead of page for results.
1.0.1.0 -- 2005-09-04
  • Updated plugin info to take advantage of MT 3.2 enhancements.
1.0.0.2 -- 2004-12-10
  • Fixed bug where plugin reported error in MT-Medic.
1.0.0.1 -- 2004-11-11
  • Fixed defect where errors generated by other tags within MTW3CValidate tag did not show errors correctly.
1.0.0.0 -- 2004-01-02
  • Made compatible with Movable Type 3.0.
0.37 -- 2004-01-02
  • Change URL link for plugin.
0.36 -- 2003-11-20
  • Added an "Unable to connect" message in the place of all the tags when your server cannot connect to the validator service.
0.35 -- 2003-11-19
  • Added the MTW3CValidatorOutput tag to help people debug their site.
0.31 -- 2003-11-03
  • Removed the border attribute from the built-in validation badge because its not valid XHTML-Strict. I use XHTML-Transitional on my pages so I didn't notice.
  • Added copyright notice for tracking usage.
0.30 -- 2003-10-19
  • Added ability to specify custom HTML for invalid badge.
0.20 - 2003-10-14
  • Added ability to specify custom HTML for valid badge.
0.10 -- 2003-09-24
  • Works for me.

Contact

For questions, suggestions, bug reports, and anything else related to this plugin, please e-mail brandon@fuller.name or leave a comment.

Updated: 2010-11-05 at 07:44 MST in Hacks
Tags: movabletype
Related Posts with Thumbnails