# Django output validator

This app validates all the HTML (or potentially other data) that is generated by your Django project. This is meant to be used only in development.

## Installation

• Run setup.py to install the package into your python path, or use easy_install django-output-validator (or pip).

• Insert the middleware "output_validator.middleware.ValidatorMiddleware" near the beginning of the middleware list (which means it will get the the response object after everything else). It must be after every middleware that does post-processing, but mustn't be after GZip, since it can't handle gzipped HTML. ( I just disable the GZip middleware for development)

• Alter your URL conf to include the URLs for the validator. You need this line inserted somewhere:

(r'^validator/', include('output_validator.urls'))

• Add a setting to tell the app where to find the 'validate' executable used for validation. This is a dictionary of mimetypes and corresponding validators, allowing this app to be extended to any other generated content:

OUTPUT_VALIDATOR_VALIDATORS = {
'text/html': '/usr/bin/validate',
'application/xml+xhtml': '/usr/bin/validate',
}


I usually use a small wrapper for this executable that pops up a message when it fails - the following works for GNOME (if you have the notify-send program installed):

#!/bin/sh
validate "\$1" || {
notify-send "Validation failed";
}

• Finally, run the django admin script to set up the database tables:

./manage.py --settings="yourproject.settings" syncdb


OR, if you are using South:

./manage.py --settings="yourproject.settings" migrate output_validator

• Optionally, set the following settings:

• OUTPUT_VALIDATOR_IGNORE_PATHS - this is a list of path prefixes that will be ignored. For example, if you have the admin at /admin/ you can ignore any errors in the admin with this:

OUTPUT_VALIDATOR_IGNORE_PATHS = [
]


## Usage

When browsing any of your pages in development, all HTML will be validated. If it fails, it will be logged. You can see all failures at 'http://localhost:8000/validator/' (assuming local development and the URL conf suggested above). Use the app to delete old failures once they have been fixed.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.