Kia11y is an Elixir client for the AccessLint Service, which is a web service for accesslint-cli, which is a wrapper for the awesome axe-core Accessibility Engine.
In short, Kia11y aims to be the simplest way to integrate A11Y checking in Elixir projects.
This package can be installed from Hex, as:
- Add
kia11y
to your list of dependencies inmix.exs
:
```elixir
def deps do
[{:kia11y, "~> 0.1.0"}]
end
```
- Ensure
kia11y
is started before your application:
```elixir
def application do
[applications: [:kia11y]]
end
```
To check A11Y on a web page, just pass it the URL to check, like this:
{ outcome, response } = Kia11y.check("http://validationhell.com")
If all goes well, outcome
will be :ok
but it could be any of the following:
ok
means the check was performed, you'll get also theviolations
found.error
means theurl
param was invalid.busy
means that there was a timeout due to server overload.crash
means there was an internal server error.
A11Y violations can be accessed through response["violations"]
, for example:
iex> response["violations"]
[ %{
"help" => "Images must have alternate text", "impact" => "critical",
"nodes" => [ "body > .navbar.navbar-fixed-top > .navbar-inner > .container-fluid > .brand > img",
"body > .container-fluid > .row-fluid > .span10 > .hero-unit > div > a:nth-of-type(1) > img" ],
"url" => "http://validationhell.com/"
},
%{
"help" => "Links must have discernible text", "impact" => "critical",
"nodes" => [ "body > .container-fluid > .row-fluid > .span2 > .well.sidebar-nav > .nav.nav-list > a",
"body > .container-fluid > .row-fluid > .span2 > .well.sidebar-nav > a",
"#social > a",
"body > .container-fluid > .row-fluid > .span10 > .hero-unit > div > a:nth-of-type(1)" ],
"url" => "http://validationhell.com/" },
%{
"help" => "<ul> and <ol> must only directly contain <li>, <script> or <template> elements",
"impact" => "serious",
"nodes" => [ "body > .container-fluid > .row-fluid > .span2 > .well.sidebar-nav > .nav.nav-list" ],
"url" => "http://validationhell.com/"
}
]
By default, Kia11y will use the demo server for AccessLint Service at https://accesslint-service-demo.herokuapp.com/ but you're encouraged to install your own instances of the server and use them instead. The demo server is just intended for, you guessed it, demo purposes and might be down or overwhelmed.
AccessLint Service can be installed for free with a click on Heroku.
To use your own servers, pass an array with their URLs and a random one will be picked for each request (poor man's load balancer):
Kia11y.check("http://validationhell.com", checker_urls: ["http://example.com/validator1", "http://example.com/validator2", ])
- Fork it ( https://github.com/jaimeiniesta/kia11y/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request