diff --git a/Scripts/Functions/Html/Config/output_forHeadingsToc.awk b/Scripts/Functions/Html/Config/output_forHeadingsToc.awk
deleted file mode 100644
index bcc0f21..0000000
--- a/Scripts/Functions/Html/Config/output_forHeadingsToc.awk
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/usr/bin/gawk
-#
-# output_forHadingsToc.awk -- This file provides the output format
-# required by html_updateHeadings.sh function, inside centos-art.sh
-# script.
-#
-# Copyright (C) 2009-2010 Alain Reguera Delgado
-#
-# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-# USA.
-#
-# ----------------------------------------------------------------------
-# $Id$
-# ----------------------------------------------------------------------
-
-BEGIN {FS=":"}
-
-{
- if ($1 == 0 && $2 == $3) {
- opentags = "
'
- echo "
`gettext "Table of contents"`
"
- for TOCENTRY in "${TOCENTRIES[@]}";do
- echo $TOCENTRY
- done \
- | awk -f ${CLI_BASEDIR}/Functions/Html/Config/output_forHeadingsToc.awk)
-
- # Update table of contents inside the current file being
- # processed.
- sed -i -r '/
(.*)<\/div>/c'"$(echo -e $TOC)" $FILE
-
- # Reset counters.
- COUNT=0
- PREVCOUNT=0
-
- # Clean up variables to receive the next file.
- unset FINAL
- unset TITLE
- unset MD5SM
- unset OPTNS
- unset LEVEL
- unset PARENT
- unset TOCENTRIES
- unset LINK
-
- done
-
-}
diff --git a/Scripts/Functions/Tuneup/Config/output_forHeadingsToc.awk b/Scripts/Functions/Tuneup/Config/output_forHeadingsToc.awk
new file mode 100644
index 0000000..bcc0f21
--- /dev/null
+++ b/Scripts/Functions/Tuneup/Config/output_forHeadingsToc.awk
@@ -0,0 +1,79 @@
+#!/usr/bin/gawk
+#
+# output_forHadingsToc.awk -- This file provides the output format
+# required by html_updateHeadings.sh function, inside centos-art.sh
+# script.
+#
+# Copyright (C) 2009-2010 Alain Reguera Delgado
+#
+# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA.
+#
+# ----------------------------------------------------------------------
+# $Id$
+# ----------------------------------------------------------------------
+
+BEGIN {FS=":"}
+
+{
+ if ($1 == 0 && $2 == $3) {
+ opentags = "
- "
+ closetags = ""
+ }
+
+ if ($1 > 0 && $2 > $3) {
+ opentags = "
- "
+ closetags = ""
+ }
+
+ if ($1 > 0 && $2 == $3) {
+ opentags = "
- "
+ closetags = ""
+ }
+
+ if ($1 > 0 && $2 < $3) {
+ opentags = ""
+ for (i = 1; i <= ($3 - $2); i++) {
+ opentags = opentags "
"
+ closetags = ""
+ }
+ opentags = opentags " - "
+ }
+
+ printf "%s%s%s\n",opentags,$4,closetags
+
+}
+
+END {
+
+ if ($1 > 0 && $2 >= $3 && $3 > 1) {
+ for (i = 1; i <= $3; i++) {
+ print "
"
+ }
+ }
+
+ if ($1 > 0 && $2 >= $3 && $3 == 1) {
+ print ""
+ print ""
+ }
+
+ if ($1 > 0 && $2 < $3) {
+ for (i = 1; i <= $2; i++) {
+ print ""
+ }
+ }
+
+ print "
"
+}
diff --git a/Scripts/Functions/Tuneup/tuneup.sh b/Scripts/Functions/Tuneup/tuneup.sh
new file mode 100755
index 0000000..5625bc3
--- /dev/null
+++ b/Scripts/Functions/Tuneup/tuneup.sh
@@ -0,0 +1,77 @@
+#!/bin/bash
+#
+# tuneup.sh -- This function groups maintainance tasks which are
+# applied to files based on their extension.
+#
+# Copyright (C) 2009-2011 Alain Reguera Delgado
+#
+# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA.
+#
+# ----------------------------------------------------------------------
+# $Id$
+# ----------------------------------------------------------------------
+
+function tuneup {
+
+ local ACTIONNAM=''
+ local ACTIONVAL=''
+
+ # Interpret arguments and options passed through command-line.
+ tuneup_getArguments
+
+ # Redefine positional parameters using ARGUMENTS. At this point,
+ # option arguments have been removed from ARGUMENTS variable and
+ # only non-option arguments remain in it.
+ eval set -- "$ARGUMENTS"
+
+ # Define action name. No matter what option be passed to
+ # centos-art, there is only one action to perform (i.e., build the
+ # list of files and interpretation of file extensions for further
+ # processing).
+ ACTIONNAM="${FUNCNAME}_doBaseActions"
+
+ # Define action value. We use non-option arguments to define the
+ # action value (ACTIONVAL) variable.
+ for ACTIONVAL in "$@";do
+
+ # Check action value. Be sure the action value matches the
+ # convenctions defined for source locations inside the working
+ # copy.
+ cli_checkRepoDirSource
+
+ # Syncronize changes between repository and working copy. At
+ # this point, changes in the repository are merged in the
+ # working copy and changes in the working copy committed up to
+ # repository.
+ cli_syncroRepoChanges
+
+ # Execute action name.
+ if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then
+ eval $ACTIONNAM
+ else
+ cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine'
+ cli_printMessage "${FUNCDIRNAM}" 'AsToKnowMoreLine'
+ fi
+
+ # Commit changes from working copy to central repository only.
+ # At this point, changes in the repository are not merged in
+ # the working copy, but chages in the working copy do are
+ # committed up to repository.
+ cli_commitRepoChanges
+
+ done
+
+}
diff --git a/Scripts/Functions/Tuneup/tuneup_doBaseActions.sh b/Scripts/Functions/Tuneup/tuneup_doBaseActions.sh
new file mode 100755
index 0000000..87b3244
--- /dev/null
+++ b/Scripts/Functions/Tuneup/tuneup_doBaseActions.sh
@@ -0,0 +1,58 @@
+#!/bin/bash
+#
+# tuneup_doBaseActions.sh -- This function builds the list of files to
+# process, determines the their extensions and performs maintainance
+# tasks file by file them accordingly.
+#
+# Copyright (C) 2009-2011 Alain Reguera Delgado
+#
+# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA.
+#
+# ----------------------------------------------------------------------
+# $Id$
+# ----------------------------------------------------------------------
+
+function tuneup_doBaseActions {
+
+ local FILE=''
+ local FILES=''
+ local EXTENSION=''
+
+ # Define file extensions we'll look files for. This is, the
+ # extension of files we want to perform maintainance tasks for.
+ EXTENSION='(svg|xhtml|sh)'
+
+ # Build list of files to process using action value as reference.
+ FILES=$(cli_getFilesList "${ACTIONVAL}" ".*\.${EXTENSION}")
+
+ # Verify list of files.
+ cli_printActionPreamble "$FILES" '' ''
+
+ # Process list of files and perform maintainance tasks
+ # accordingly.
+ for FILE in $FILES;do
+
+ if [[ $FILE =~ '\.svg$' ]];then
+ ${FUNCNAM}_doSvg
+ elif [[ $FILE =~ '\.xhtml$' ]];then
+ ${FUNCNAM}_doXhtml
+ elif [[ $FILE =~ '\.sh$' ]];then
+ ${FUNCNAM}_doShell
+ fi
+
+ done
+
+}
diff --git a/Scripts/Functions/Tuneup/tuneup_doXhtml.sh b/Scripts/Functions/Tuneup/tuneup_doXhtml.sh
new file mode 100644
index 0000000..babca6d
--- /dev/null
+++ b/Scripts/Functions/Tuneup/tuneup_doXhtml.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+#
+# tuneup_doXhtml.sh -- This function performs maintainance tasks for
+# XHTML files.
+#
+# Copyright (C) 2009-2011 Alain Reguera Delgado
+#
+# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA.
+#
+# ----------------------------------------------------------------------
+# $Id$
+# ----------------------------------------------------------------------
+
+function tuneup_doXhtml {
+
+ # Transforms html headings to make them accessible (e.g., through
+ # a table of contents).
+ tuneup_doXhtmlHeadings
+
+}
diff --git a/Scripts/Functions/Tuneup/tuneup_doXhtmlHeadings.sh b/Scripts/Functions/Tuneup/tuneup_doXhtmlHeadings.sh
new file mode 100644
index 0000000..b66e363
--- /dev/null
+++ b/Scripts/Functions/Tuneup/tuneup_doXhtmlHeadings.sh
@@ -0,0 +1,169 @@
+#!/bin/bash
+#
+# html_updateHeadings.sh -- This function transforms html headings to
+# to make them accessible (e.g., through a table of contents).
+#
+# - In order for this function to work, you need to put headings in
+# just one line and they must have the following formats:
+#
+#
+#
+#
+#
+# In the above examples, h1 alternates from h1 to h6. Closing tag
+# must be present and match the one opentaging. The value of
and options are the md5sum of page
+# location, plus the 'head-' string, plus the heading string. If
+# heading title or page location changes, the values of and options will change too.
+#
+# Copyright (C) 2009-2011 Alain Reguera Delgado
+#
+# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA.
+#
+# ----------------------------------------------------------------------
+# $Id$
+# ----------------------------------------------------------------------
+
+function html_updateHeadings {
+
+ # Define variables as local to avoid conflicts outside.
+ local COUNT=0
+ local FILE=''
+ local FILES=''
+ local PREVCOUNT=0
+ local PATTERN=''
+ local -a FINAL
+ local -a TITLE
+ local -a MD5SM
+ local -a OPTNS
+ local -a LEVEL
+ local -a PARENT
+ local -a TOCENTRIES
+ local -a LINK
+
+ # Define html heading regular expression pattern. Use parenthisis
+ # to save html action name, action value, and heading title.
+ PATTERN="(]>)(.*[^<])"
+
+ # Define list of files to process.
+ FILES=$(cli_getFilesList "$ACTIONVAL" "${FLAG_FILTER}.*\.(xhtml|html|htm)")
+
+ # Set action preamble.
+ cli_printActionPreamble "${FILES}" '' ''
+
+ # Process list of files.
+ for FILE in $FILES;do
+
+ # Verify list of html files. Are files really html files? If
+ # they don't, continue with the next one in the list.
+ if [[ ! $(file --brief $FILE) =~ '^(XHTML|HTML|XML)' ]];then
+ continue
+ fi
+
+ # Output action message.
+ cli_printMessage $FILE 'AsUpdatingLine'
+
+ # Define list of headings to process. When building the
+ # heading, it is required to change spaces characters from its
+ # current decimal output to something different (e.g., its
+ # \040 octal alternative). This is required because the space
+ # character is used as egrep default field separator and
+ # spaces can be present inside heading strings we don't want
+ # to separate.
+ for HEADING in $(egrep "$PATTERN" $FILE \
+ | sed -r -e 's!^[[:space:]]+!!' -e "s! !\\\040!g");do
+
+ # Define previous counter value using current counter
+ # value as reference.
+ if [[ $COUNT -ne 0 ]];then
+ PREVCOUNT=$(($COUNT-1))
+ fi
+
+ # Define initial heading information.
+ FIRST[$COUNT]=$(echo $HEADING | sed -r "s!\\\040! !g")
+ TITLE[$COUNT]=$(echo ${FIRST[$COUNT]} | sed -r "s!$PATTERN!\3!")
+ MD5SM[$COUNT]=$(echo "${FILE}${FIRST[$COUNT]}" | md5sum | sed -r 's![[:space:]]+-$!!')
+ OPTNS[$COUNT]=$(echo ${FIRST[$COUNT]} | sed -r "s!$PATTERN!\2!")
+ LEVEL[$COUNT]=$(echo ${FIRST[$COUNT]} | sed -r "s!$PATTERN!\1!")
+ PARENT[$COUNT]=${LEVEL[$PREVCOUNT]}
+
+ # Transform heading information using initial heading
+ # information as reference.
+ if [[ ${OPTNS[$COUNT]} =~ '^
$' ]];then
+ OPTNS[$COUNT]=''
+ elif [[ ${OPTNS[$COUNT]} =~ '^$' ]];then
+ OPTNS[$COUNT]=''
+ elif [[ ${OPTNS[$COUNT]} =~ '^$' ]];then
+ OPTNS[$COUNT]=''
+ fi
+
+ # Build final html heading structure.
+ FINAL[$COUNT]=''${OPTNS[$COUNT]}${TITLE[$COUNT]}''
+
+ # Build html heading link structure. These links are used
+ # by the table of contents later.
+ LINK[$COUNT]='
'${TITLE[$COUNT]}''
+
+ # Build table of contents entry with numerical
+ # identifications. The numerical identification is what we
+ # use to determine the correct position of each heading
+ # link on the table of content.
+ TOCENTRIES[$COUNT]="$COUNT:${LEVEL[$COUNT]}:${PARENT[$COUNT]}:${LINK[$COUNT]}"
+
+ # Update heading information inside the current file being
+ # processed. Use the first and final heading information.
+ sed -i -r "s!${FIRST[$COUNT]}!${FINAL[$COUNT]}!" $FILE
+
+ # Increase heading counter.
+ COUNT=$(($COUNT + 1))
+
+ done
+
+ # Build the table of contents using heading numerical
+ # identifications as reference. The numerical identification
+ # describes the order of headings in one html file. This
+ # information is processed by awk to make the appropriate
+ # replacements. Finnally, the result is stored in the TOC
+ # variable.
+ TOC=$(echo '
'
+ echo "
`gettext "Table of contents"`
"
+ for TOCENTRY in "${TOCENTRIES[@]}";do
+ echo $TOCENTRY
+ done \
+ | awk -f ${CLI_BASEDIR}/Functions/Html/Config/output_forHeadingsToc.awk)
+
+ # Update table of contents inside the current file being
+ # processed.
+ sed -i -r '/
(.*)<\/div>/c'"$(echo -e $TOC)" $FILE
+
+ # Reset counters.
+ COUNT=0
+ PREVCOUNT=0
+
+ # Clean up variables to receive the next file.
+ unset FINAL
+ unset TITLE
+ unset MD5SM
+ unset OPTNS
+ unset LEVEL
+ unset PARENT
+ unset TOCENTRIES
+ unset LINK
+
+ done
+
+}
diff --git a/Scripts/Functions/Tuneup/tuneup_getArguments.sh b/Scripts/Functions/Tuneup/tuneup_getArguments.sh
new file mode 100755
index 0000000..5c7d29d
--- /dev/null
+++ b/Scripts/Functions/Tuneup/tuneup_getArguments.sh
@@ -0,0 +1,86 @@
+#!/bin/bash
+#
+# tuneup_getArguments.sh -- This function interprets arguments passed to
+# tuneup functionality and calls actions accordingly.
+#
+# Copyright (C) 2009-2011 Alain Reguera Delgado
+#
+# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA.
+#
+# ----------------------------------------------------------------------
+# $Id$
+# ----------------------------------------------------------------------
+
+function tuneup_getArguments {
+
+ # Define short options we want to support.
+ local ARGSS=""
+
+ # Define long options we want to support.
+ local ARGSL="filter:,quiet,answer:,dont-commit-changes"
+
+ # Redefine ARGUMENTS variable using getopt output.
+ cli_doParseArguments
+
+ # Redefine positional parameters using ARGUMENTS variable.
+ eval set -- "$ARGUMENTS"
+
+ # Look for options passed through command-line.
+ while true; do
+
+ case "$1" in
+
+ --filter )
+ FLAG_FILTER="$2"
+ shift 2
+ ;;
+
+ --quiet )
+ FLAG_QUIET="true"
+ FLAG_DONT_COMMIT_CHANGES="true"
+ shift 1
+ ;;
+
+ --answer )
+ FLAG_ANSWER="$2"
+ shift 2
+ ;;
+
+ --dont-commit-changes )
+ FLAG_DONT_COMMIT_CHANGES="true"
+ shift 1
+ ;;
+
+ -- )
+ # Remove the `--' argument from the list of arguments
+ # in order for processing non-option arguments
+ # correctly. At this point all option arguments have
+ # been processed already but the `--' argument still
+ # remains to mark ending of option arguments and
+ # begining of non-option arguments. The `--' argument
+ # needs to be removed here in order to avoid
+ # centos-art.sh script to process it as a path inside
+ # the repository, which obviously is not.
+ shift 1
+ break
+ ;;
+ esac
+ done
+
+ # Redefine ARGUMENTS variable using current positional parameters.
+ cli_doParseArgumentsReDef "$@"
+
+}