Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
154 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
------ | ||
W3C HTML Java Validator (Local) | ||
------ | ||
Antonio Acevedo | ||
------ | ||
2014-09-03 | ||
------ | ||
|
||
~~ | ||
~~ Copyright (c) 2014, jcabi.com | ||
~~ All rights reserved. | ||
~~ | ||
~~ Redistribution and use in source and binary forms, with or without | ||
~~ modification, are permitted provided that the following conditions | ||
~~ are met: 1) Redistributions of source code must retain the above | ||
~~ copyright notice, this list of conditions and the following | ||
~~ disclaimer. 2) Redistributions in binary form must reproduce the above | ||
~~ copyright notice, this list of conditions and the following | ||
~~ disclaimer in the documentation and/or other materials provided | ||
~~ with the distribution. 3) Neither the name of the jcabi.com nor | ||
~~ the names of its contributors may be used to endorse or promote | ||
~~ products derived from this software without specific prior written | ||
~~ permission. | ||
~~ | ||
~~ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
~~ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT | ||
~~ NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
~~ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | ||
~~ THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | ||
~~ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
~~ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
~~ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
~~ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
~~ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
~~ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
~~ OF THE POSSIBILITY OF SUCH DAMAGE. | ||
~~ | ||
|
||
W3C HTML Java Validator (Local) | ||
|
||
Validate your HTML against a local instance of | ||
{{{http://validator.w3.org/}W3C Markup Validation Service}} | ||
installed in your server as describes the following | ||
{{{https://raymii.org/s/tutorials/Local_W3C_HTML5_Validator_Server.html}tutorial}}. | ||
|
||
|
||
Install required packages. | ||
|
||
+-- | ||
apt-get install w3c-markup-validator mercurial subversion python default-jdk | ||
+-- | ||
|
||
Compile/install the HTML5 validator (not included in W3 validator). | ||
|
||
+-- | ||
mkdir /usr/share/html5-validator | ||
cd /usr/share/html5-validator | ||
+-- | ||
|
||
Set the <<<JAVA_HOME>>> path. | ||
|
||
+-- | ||
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk | ||
+-- | ||
|
||
Clone the latest validator source. | ||
|
||
+-- | ||
hg clone https://bitbucket.org/validator/build build | ||
+-- | ||
|
||
Start the build (If you encounter a Java exception, run the build script again). | ||
|
||
+-- | ||
python build/build.py all | ||
+-- | ||
|
||
Configuring the w3c-validator to allow private networks in <<</etc/w3c/validator.conf>>>. | ||
|
||
+-- | ||
Allow Private IPs = yes | ||
+-- | ||
|
||
Enable the HTML5 validator by uncommenting the following. | ||
|
||
+-- | ||
<![CDATA[ | ||
<External> | ||
HTML5 = http://localhost:8888/html5/ | ||
</External> | ||
]]> | ||
+-- | ||
|
||
Create the upstart script to start the HTML5 validator at boot. | ||
|
||
+-- | ||
vim /etc/init/html5-validator.conf | ||
+-- | ||
|
||
Contents. | ||
|
||
+-- | ||
description "Validator.nu HTML5 Validator" | ||
|
||
start on (local-filesystems and net-device-up) | ||
stop on runlevel [016] | ||
|
||
chdir /usr/share/html5-validator | ||
exec python build/build.py --control-port=8889 run | ||
respawn | ||
+-- | ||
|
||
Save and start it. | ||
|
||
+-- | ||
start html5-validator | ||
+-- | ||
|
||
Afterwards you can access your validator via <<<http://server/w3c-validator>>> and set the URI in your code. | ||
|
||
+-- | ||
public class My { | ||
public void main() { | ||
String xhtml = "<html><body><p>Hello, world!</p></body></html>"; | ||
URI instanceURL = new URI("http://server/w3c-validator/check") | ||
ValidationResponse response = | ||
new ValidatorBuilder().html(instanceURL).validate(xhtml); | ||
assert response.valid(); | ||
} | ||
} | ||
+-- | ||
|
||
Similar mechanism is available for | ||
{{{./html-validator.html}HTML remote validation}} | ||
and | ||
{{{./css-validator.html}CSS validation}}. | ||
|
||
All events are logged through {{{http://www.slf4j.org/}slf4j}}, | ||
using <<<"com.jcabi.w3c">>> logger. | ||
If you want to see them, just add proper binding to classpath, | ||
as explained in {{{http://www.slf4j.org/manual.html}SLF4J manual}}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters