tImproved the HTML validator. Now check every. single. page - monochromatic - monochromatic blog: http://blog.z3bra.org
HTML git clone git://z3bra.org/monochromatic
DIR Log
DIR Files
DIR Refs
---
DIR commit 9860f60130a4a32ca5474094ab68bd03ccca6b52
DIR parent 0ffecc513f57f6f92d3250aa6966d114589e850e
HTML Author: z3bra <willy@mailoo.org>
Date: Mon, 3 Feb 2014 19:40:12 +0100
Improved the HTML validator. Now check every. single. page
Diffstat:
M tools/check.sh | 57 ++++++++++++++++++++++---------
1 file changed, 41 insertions(+), 16 deletions(-)
---
DIR diff --git a/tools/check.sh b/tools/check.sh
t@@ -5,31 +5,56 @@ charset=utf-8
doctype=Inline
profile=css3
+function w3c_valid () {
+ if (curl -sI "$1" | grep -o 'Invalid' >/dev/null); then
+ echo -e "[\033[1;31mFAIL\033[0m]"
+ echo -e " Errors : $1"
+ exit 1
+ fi
+}
+
+function rss_valid () {
+ if (curl -s "$check" | grep -o 'Sorry' >/dev/null); then
+ echo -e "[\033[1;31mFAIL\033[0m]"
+ echo -e " Errors : $1"
+ exit 1
+ fi
+}
+
+
+# HTML files
http=http://validator.w3.org/check
-check="${http}?uri=${uri}&charset=${charset}&$doctype=${doctype}"
+count=0
+total=`find -name '*.html'|wc -l`
+for file in `find -name '*.html'`; do
+
+ count=$(( $count+1 ))
+ echo -ne "\rChecking HTML file(s) ... $count/$total"
+
+ full_uri=${uri}/${file/.\//}
+ check="${http}?uri=${full_uri}&charset=${charset}&$doctype=${doctype}"
+
+ w3c_valid "$check"
+ echo -ne "\rChecking HTML file(s) ... "
+done
+
+echo -e "[\033[1;32m OK \033[0m]"
-if [[ -n "$(curl -s "$check" | grep -o 'Passed')" ]]; then
- echo -e "\033[1;32mHTML validated!\033[0m"
-else
- echo -e "\033[1;31mHTML not valid!\033[0m\ncheck $check"
-fi
+# CSS files
+echo -n 'Checking CSS file(s) ... '
http=http://jigsaw.w3.org/css-validator/validator
check="${http}?uri=${uri}&profile=${profile}"
-if [[ -n "$(curl -s "$check" | grep -o 'No Error')" ]]; then
- echo -e "\033[1;32mCSS validated!\033[0m"
-else
- echo -e "\033[1;31mCSS not valid!\033[0m\ncheck $check"
-fi
+w3c_valid "$check"
+echo -e "[\033[1;32m OK \033[0m]"
+# RSS feed
+echo -n 'Checking RSS file(s) ... '
http=http://feedvalidator.org/check.cgi
check="${http}?url=${uri}/rss/feed.xml"
-if [[ -n "$(curl -s "$check" | grep -o 'valid RSS feed')" ]]; then
- echo -e "\033[1;32mRSS validated!\033[0m"
-else
- echo -e "\033[1;31mRSS not valid!\033[0m\ncheck $check"
-fi
+rss_valid "$check"
+echo -e "[\033[1;32m OK \033[0m]"