From 8268f461259b8dddd9c57b7771112db9d0af86cc Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Sep 12 2013 03:21:25 +0000 Subject: Update centos-art.sh script's tuneup module. - Previously, when cleaning up HTML files, tuneup module used the cleanup-before.sed and cleanup-after.sed files for applying sed commands to the file being processed. The commands set in those sed files remain from mailman's template customization and aren't really needed in most generic HTML files the tuneup module exist for. This commit removes both cleanup-before.sed and cleanup-after.sed files from tuneup module and the line that executed them from xhtml_setCleanUp function. - Previously, when cleaning up XHTML files, tuneup module generated wrong HTML preambles by creating a line. This was because xmllint was processing the file as HTML not XML. This commit permits you to cleanup both HTML and XHTML files without such problem. To do this, a grep line was added to verify whether the -//W3C//DTD XHTML 1.0 Strict//EN definition exists or not in the file being processed. Based on it, when XHTML definition doesn't exist, xmllint treats the file as XML and, when it doesn't exist, xmllint treats the file as HTML. --- diff --git a/Automation/Modules/Tuneup/Modules/Xhtml/Configs/cleanup-after.sed b/Automation/Modules/Tuneup/Modules/Xhtml/Configs/cleanup-after.sed deleted file mode 100644 index a7f82b7..0000000 --- a/Automation/Modules/Tuneup/Modules/Xhtml/Configs/cleanup-after.sed +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sed -###################################################################### -# -# cleanup-after.sed -- This file is read by xhtml_setCleanUp -# function to convert special tags into HTML comments after cleanup -# process. -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# -# Copyright (C) 2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -###################################################################### - -# Convert Mailman-specific tags back into their original form (see: -# cleanup-before.sed). -s//<\1>/g -s/%3C!--%20((mm|MM)-[[:alnum:]_-]+)%20--%3E/<\1>/g -s/<!-- ((mm|MM)[[:alnum:]_-]+) -->/<\1>/g - -s//\1/g -s/%3C!--%20(%\([[:alnum:]_-]+\)[[:alpha:]])%20--%3E/\1/g -s/<!-- (%\([[:alnum:]_-]+\)[[:alpha:]]) -->/\1/g diff --git a/Automation/Modules/Tuneup/Modules/Xhtml/Configs/cleanup-before.sed b/Automation/Modules/Tuneup/Modules/Xhtml/Configs/cleanup-before.sed deleted file mode 100644 index 80eb2b5..0000000 --- a/Automation/Modules/Tuneup/Modules/Xhtml/Configs/cleanup-before.sed +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sed -###################################################################### -# -# cleanup-before.sed -- This file is read by xhtml_setCleanUp -# function to convert special tags into HTML comments before cleanup -# process. Once the file has been cleaned up, the special tags are -# converted back to their original form (see: cleanup-after.sed). -# -# Written by: -# * Alain Reguera Delgado , 2009-2013 -# -# Copyright (C) 2013 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -###################################################################### - -# Remove HTML preable, if any. It will be added later by xmllint, -# based on its own interpretation of the document. -/{1}/d - -# Convert Mailman-specific tags into comments. These tags are found in -# Mailman's templates and should not be touched in any way because -# they are used to display dynamic content at Mailman's run time. -s/<((mm|MM)-[[:alnum:]_-]+)>//g -s/(%\([[:alnum:]_-]+\)[[:alpha:]])//g diff --git a/Automation/Modules/Tuneup/Modules/Xhtml/xhtml_setCleanUp.sh b/Automation/Modules/Tuneup/Modules/Xhtml/xhtml_setCleanUp.sh index 4ff454a..d3b48b1 100755 --- a/Automation/Modules/Tuneup/Modules/Xhtml/xhtml_setCleanUp.sh +++ b/Automation/Modules/Tuneup/Modules/Xhtml/xhtml_setCleanUp.sh @@ -27,12 +27,15 @@ function xhtml_setCleanUp { - sed -i -r -f "${MODULE_DIR_CONFIGS}/cleanup-before.sed" "${FILE}" - - /usr/bin/xmllint --html --xmlout --format --noblanks \ - --nonet --nowarning \ - --output ${FILE} ${FILE} 2&> /dev/null - - sed -i -r -f "${MODULE_DIR_CONFIGS}/cleanup-after.sed" "${FILE}" + grep '\-//W3C//DTD XHTML 1.0 Strict//EN' ${FILE} > /dev/null + if [[ $? -eq 0 ]];then + /usr/bin/xmllint --xmlout --format --noblanks \ + --nonet --nowarning \ + --output ${FILE} ${FILE} 2&> /dev/null + else + /usr/bin/xmllint --html --xmlout --format --noblanks \ + --nonet --nowarning \ + --output ${FILE} ${FILE} 2&> /dev/null + fi }