From e7e8e850f0ee57b251fc3f9597a5337c2fbde0e2 Mon Sep 17 00:00:00 2001 From: x2000habouzit Date: Wed, 25 Aug 2004 08:59:17 +0000 Subject: [PATCH] some cookie here : automatic html validation --> now a red link appears with the number of errors if appliable --- include/xorg.page.inc.php | 16 ++++++++++++++-- scripts/xhtml/validate.pl | 16 ++++++++++++++++ templates/skin/common.devel.tpl | 4 ++-- 3 files changed, 32 insertions(+), 4 deletions(-) create mode 100755 scripts/xhtml/validate.pl diff --git a/include/xorg.page.inc.php b/include/xorg.page.inc.php index 7e1ea18..e305ef6 100644 --- a/include/xorg.page.inc.php +++ b/include/xorg.page.inc.php @@ -75,11 +75,23 @@ class XorgPage extends DiogenesCorePage { if($site_dev) { $this->assign('db_trace', $globals->db->trace_format($this, 'database-debug.tpl')); $this->assign('validate', urlencode($baseurl.'/valid.html')); - $result = $this->fetch('skin/'.$_SESSION['skin'], $id); + + $result = $this->fetch('skin/'.$_SESSION['skin'], $id); $fd = fopen($this->cache_dir."valid.html","w"); fwrite($fd, $result); fclose($fd); - echo $result; + + exec($globals->spoolroot."/scripts/xhtml/validate.pl ".$this->cache_dir."valid.html", $val); + foreach($val as $h) + if(preg_match("/^X-W3C-Validator-Errors: (\d+)$/", $h, $m)) { + if($m[1]) { + echo str_replace("@NB_ERR@", + "{$m[1]} ERREUR(S) !!!
", $result); + } else { + echo str_replace("@NB_ERR@", "", $result); + } + exit; + } } else parent::display('skin/'.$_SESSION['skin'], $id); } diff --git a/scripts/xhtml/validate.pl b/scripts/xhtml/validate.pl new file mode 100755 index 0000000..cf1ba0a --- /dev/null +++ b/scripts/xhtml/validate.pl @@ -0,0 +1,16 @@ +#!/usr/bin/perl + +use LWP::UserAgent; +use HTTP::Request::Common 'POST'; + +print LWP::UserAgent + ->new + ->request( + POST 'http://amaretto.inria.fr:8080/w3c-markup-validator/check', + Content_Type => 'form-data', + Content => [ + output => 'xml', + uploaded_file => [$ARGV[0]], + ] + )->as_string; + diff --git a/templates/skin/common.devel.tpl b/templates/skin/common.devel.tpl index 8f39576..e393f8e 100644 --- a/templates/skin/common.devel.tpl +++ b/templates/skin/common.devel.tpl @@ -1,10 +1,10 @@ -{* $Id: common.devel.tpl,v 1.2 2004-08-24 20:05:35 x2000habouzit Exp $ *} +{* $Id: common.devel.tpl,v 1.3 2004-08-25 08:59:18 x2000habouzit Exp $ *} {if $validate}
Outils de dev
- VALIDER XHTML 1.1
+ @NB_ERR@ VALIDER CSS
-- 2.1.4