Skip to content

Commit

Permalink
Merge remote branch 'fork/1'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Sep 3, 2014
2 parents f8987be + d34fc8d commit 7a25f18
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/site/apt/css-validator.apt.vm
Expand Up @@ -54,7 +54,9 @@ public class My {
+--

Similar mechanism is available for
{{{./html-validator.html}HTML validation}}.
{{{./html-validator-local-instance.html}HTML local validation}}
and
{{{./html-validator.html}HTML remote validation}}.

All events are logged through {{{http://www.slf4j.org/}slf4j}},
using <<<"com.jcabi.w3c">>> logger.
Expand Down
141 changes: 141 additions & 0 deletions src/site/apt/html-validator-local-instance.apt.vm
@@ -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}}.
4 changes: 3 additions & 1 deletion src/site/apt/html-validator.apt.vm
Expand Up @@ -40,7 +40,7 @@ W3C HTML Java Validator

Validate your HTML against
{{{http://validator.w3.org/}W3C Markup Validation Service}}
with this code:
with this code.

+--
public class My {
Expand All @@ -54,6 +54,8 @@ public class My {
+--

Similar mechanism is available for
{{{./html-validator-local-instance.html}HTML local validation}}
and
{{{./css-validator.html}CSS validation}}.

All events are logged through {{{http://www.slf4j.org/}slf4j}},
Expand Down
7 changes: 6 additions & 1 deletion src/site/apt/index.apt.vm
Expand Up @@ -42,7 +42,12 @@ W3C Java Validators

* {{{./html-validator.html}<<<HtmlValidator>>>}} -
validates HTML against
{{{http://validator.w3.org/}W3C Markup Validation Service}};
{{{http://validator.w3.org/}W3C Markup Validation Service}}.

* {{{./html-validator-local-instance.html}<<<HtmlValidator (local)>>>}} -
validates HTML against a local instance of
{{{http://validator.w3.org/}W3C Markup Validation Service}}
installed in your server.

* {{{./css-validator.html}<<<CssValidator>>>}} -
validates CSS against
Expand Down
1 change: 1 addition & 0 deletions src/site/site.xml
Expand Up @@ -58,6 +58,7 @@
</menu>
<menu name="Examples">
<item name="HTML Validator" href="./html-validator.html"/>
<item name="HTML Validator (local)" href="./html-validator-local-instance.html"/>
<item name="CSS Validator" href="./css-validator.html"/>
</menu>
<menu ref="reports"/>
Expand Down

0 comments on commit 7a25f18

Please sign in to comment.