diff --git a/Documentation/Manpages/Locales/en_US/tuneup.asciidoc.po b/Documentation/Manpages/Locales/en_US/tuneup.asciidoc.po new file mode 100644 index 0000000..b164488 --- /dev/null +++ b/Documentation/Manpages/Locales/en_US/tuneup.asciidoc.po @@ -0,0 +1,392 @@ +msgid "" +msgstr "" +"Project-Id-Version: tuneup.asciidoc 0.6\n" +"POT-Creation-Date: 2013-11-07 15:18-0500\n" +"PO-Revision-Date: 2013-11-07 15:18-0500\n" +"Last-Translator: Localization SIG \n" +"Language-Team: English\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgid "tuneup" +msgstr "tuneup" + +msgid "1" +msgstr "1" + +msgid "" +"Standardizes source code maintenance tasks inside the repository." +msgstr "" +"Standardizes source code maintenance tasks inside the repository." + +msgid "centos-art.sh tuneup [FILE …|DIRECTORY …] [--filter=\"REGEX\"]" +msgstr "" +"centos-art.sh tuneup [FILE …|DIRECTORY …] [--filter=\"REGEX\"]" + +msgid "Execute source code maintenance tasks." +msgstr "Execute source code maintenance tasks." + +msgid "Description" +msgstr "Description" + +msgid "" +"When you run the tuneup module " +"it may enter into either file or directory processing, based on " +"whether you provide a file or directory as argument for processing " +"in the command-line. When you provide a file as argument to " +"tuneup module, it uses the " +"file's extension as reference for applying maintenance tasks on " +"that file as described in . When you provide a directory as argument, tuneup looks for all files with supported " +"extensions inside that directory and then process them, one by one." +msgstr "" +"When you run the tuneup module " +"it may enter into either file or directory processing, based on " +"whether you provide a file or directory as argument for processing " +"in the command-line. When you provide a file as argument to " +"tuneup module, it uses the " +"file's extension as reference for applying maintenance tasks on " +"that file as described in . When you provide a directory as argument, tuneup looks for all files with supported " +"extensions inside that directory and then process them, one by one." + +msgid "" +"The tuneup module exists to " +"automate frequent tasks related to code maintenance, inside the " +"repository (see ). It is advisable to " +"run tuneup module over your " +"files from time to time so they all have a common look and feel." +msgstr "" +"The tuneup module exists to " +"automate frequent tasks related to code maintenance, inside the " +"repository (see ). It is advisable to " +"run tuneup module over your " +"files from time to time so they all have a common look and feel." + +msgid "Supported File Extensions" +msgstr "Supported File Extensions" + +msgid "" +"The tuneup module supports " +"maintenance tasks for the following file extensions:" +msgstr "" +"The tuneup module supports " +"maintenance tasks for the following file extensions:" + +msgid ".svgz, .svg" +msgstr ".svgz, .svg" + +msgid "Provides maintenance tasks for Scalable Vector Graphics (SVG)." +msgstr "" +"Provides maintenance tasks for Scalable Vector Graphics (SVG)." + +msgid "" +"When processing svg files, tuneup uses the inkscape's --vaccumm option to cleanup source " +"code and applies few sed commands to modify inkscape's metadata " +"using dynamic information like document title, date, copyright " +"information, urls, and locale information retrieved from from " +"centos-art.sh script and the file location inside the repository." +msgstr "" +"When processing svg files, tuneup uses the inkscape's --vaccumm option to cleanup source " +"code and applies few sed commands to modify inkscape's metadata " +"using dynamic information like document title, date, copyright " +"information, urls, and locale information retrieved from from " +"centos-art.sh script and the file location inside the repository." + +msgid "" +"Each time you create a new svg file or change one, it is advisable " +"to run tuneup module over it." +msgstr "" +"Each time you create a new svg file or change one, it is advisable " +"to run tuneup module over it." + +msgid ".xhtml, .html, .htm" +msgstr ".xhtml, .html, .htm" + +msgid "" +"Provides maintenance tasks for HyperText Markup Language (HTML)." +msgstr "" +"Provides maintenance tasks for HyperText Markup Language (HTML)." + +msgid "" +"When processing html-like files, tuneup changes each file to create a table of contents for each " +"heading constructions (see below) first and then transforms the " +"(probably malformed) HTML markup into valid XHTML documents using " +"xmllint(1) program." +msgstr "" +"When processing html-like files, tuneup changes each file to create a table of contents for each " +"heading constructions (see below) first and then transforms the " +"(probably malformed) HTML markup into valid XHTML documents using " +"xmllint(1) program." + +msgid "" +"In order for tuneup to create " +"the table of contents correctly, the heading construction inside " +"the HTML document must comply the following restrictions:" +msgstr "" +"In order for tuneup to create " +"the table of contents correctly, the heading construction inside " +"the HTML document must comply the following restrictions:" + +msgid "Headings must have one of the following forms:" +msgstr "Headings must have one of the following forms:" + +#, no-wrap +msgid "" +"<h1><a name=\"\">Title</a></h1>\n" +"<h1><a href=\"\">Title</a></h1>\n" +"<h1><a name=\"\" href=\"\">Title</a></h1>" +msgstr "" +"<h1><a name=\"\">Title</a></h1>\n" +"<h1><a href=\"\">Title</a></h1>\n" +"<h1><a name=\"\" href=\"\">Title</a></h1>" + +msgid "" +"In these constructions, the heading level may vary from h1 to h6 " +"but the heading content (e.g., “Title”) must not be empty." +msgstr "" +"In these constructions, the heading level may vary from h1 to h6 " +"but the heading content (e.g., “Title”) must not be empty." + +msgid "" +"When producing table of contents through tuneup module, both `name' and `href' attributes in " +"the anchor element of each heading will be reset dynamically using " +"a md5 string. The md5 string used in these cases is based on the " +"heading content (i.e., the text shown as heading when the page is " +"rendered in a browser) and won't change until you change the " +"heading content and run tuneup " +"module over it again." +msgstr "" +"When producing table of contents through tuneup module, both `name' and `href' attributes in " +"the anchor element of each heading will be reset dynamically using " +"a md5 string. The md5 string used in these cases is based on the " +"heading content (i.e., the text shown as heading when the page is " +"rendered in a browser) and won't change until you change the " +"heading content and run tuneup " +"module over it again." + +msgid "" +"The final table of contents will be expanded wherever you set the " +"<div class=\"toc\"></div> HTML " +"construction as a line of its own inside the file being processed." +msgstr "" +"The final table of contents will be expanded wherever you set the " +"<div class=\"toc\"></div> HTML " +"construction as a line of its own inside the file being processed." + +msgid ".sh" +msgstr ".sh" + +msgid "Provides maintenance tasks for Bash scripts." +msgstr "Provides maintenance tasks for Bash scripts." + +msgid "" +"When processing sh files, tuneup changes the file to update the written by section, " +"copyright year and license information inside shell scripts' top " +"comment. Later, it corrects variable name's references to be all " +"written in upper-case between brackets (e.g.," +msgstr "" +"When processing sh files, tuneup changes the file to update the written by section, " +"copyright year and license information inside shell scripts' top " +"comment. Later, it corrects variable name's references to be all " +"written in upper-case between brackets (e.g.," + +msgid "" +"In order for tuneup module to " +"update the top comment of your shell scripts correctly, it is " +"necessary that your top comments have one written by line followed by a line of 70 number-sign (#) characters, " +"as illustrated in This is the basic " +"construction. Everything between the written by " +"line and the last line of 70 number-sign characters will be " +"replaced by tuneup module top-" +"comment template which includes people names, copyright and license " +"information. Everything else does remain untouched." +msgstr "" +"In order for tuneup module to " +"update the top comment of your shell scripts correctly, it is " +"necessary that your top comments have one written by line followed by a line of 70 number-sign (#) characters, " +"as illustrated in This is the basic " +"construction. Everything between the written by " +"line and the last line of 70 number-sign characters will be " +"replaced by tuneup module top-" +"comment template which includes people names, copyright and license " +"information. Everything else does remain untouched." + +msgid "Top-comment convention used by tuneup module." +msgstr "Top-comment convention used by tuneup module." + +#, no-wrap +msgid "" +"#!/bin/bash\n" +"######################################################################\n" +"#\n" +"# ${FILE}.sh -- ${DESCRIPTION}\n" +"#\n" +"# Written by:\n" +"#\n" +"######################################################################" +msgstr "" +"#!/bin/bash\n" +"######################################################################\n" +"#\n" +"# ${FILE}.sh -- ${DESCRIPTION}\n" +"#\n" +"# Written by:\n" +"#\n" +"######################################################################" + +msgid "Options" +msgstr "Options" + +msgid "--help" +msgstr "--help" + +msgid "Print module's documentation." +msgstr "Print module's documentation." + +msgid "--version" +msgstr "--version" + +msgid "Print module's version." +msgstr "Print module's version." + +msgid "--filter=\"REGEX\"" +msgstr "--filter=\"REGEX\"" + +msgid "" +"This option let you reduce the number of files you want to process " +"by applying a (POSIX-egrep) regular expression to the list of file " +"paths returned for processing. This option is specially useful when " +"you need to process files inside a directory structure based on a " +"specific name patterns." +msgstr "" +"This option let you reduce the number of files you want to process " +"by applying a (POSIX-egrep) regular expression to the list of file " +"paths returned for processing. This option is specially useful when " +"you need to process files inside a directory structure based on a " +"specific name patterns." + +msgid "Examples" +msgstr "Examples" + +msgid "centos-art.sh tuneup Automation/Scripts" +msgstr "centos-art.sh tuneup Automation/Scripts" + +msgid "" +"This command updates the top comment and variable name references " +"of all files inside the Automation/Scripts directory, recursively." +msgstr "" +"This command updates the top comment and variable name references " +"of all files inside the Automation/Scripts directory, recursively." + +msgid "centos-art.sh tuneup Automation/Scripts/tcar_printVersion.sh" +msgstr "centos-art.sh tuneup Automation/Scripts/tcar_printVersion.sh" + +msgid "" +"This commands updates the top comment and variable name references " +"inside the tcar_printVersion.sh file only." +msgstr "" +"This commands updates the top comment and variable name references " +"inside the tcar_printVersion.sh file only." + +msgid "" +"centos-art.sh tuneup Automation/Scripts --filter=\"tcar_print.+\\.sh" +"$\"" +msgstr "" +"centos-art.sh tuneup Automation/Scripts --filter=\"tcar_print.+\\.sh" +"$\"" + +msgid "" +"This command updates the top comment and variable name refrences " +"inside files which name only begins with “tcar_print” followed by " +"any character and ends with “.sh”. All other files won't be touched." +msgstr "" +"This command updates the top comment and variable name refrences " +"inside files which name only begins with “tcar_print” followed by " +"any character and ends with “.sh”. All other files won't be touched." + +msgid "Author" +msgstr "Author" + +msgid "" +"The tuneup module has received " +"contributions from the following people:" +msgstr "" +"The tuneup module has received " +"contributions from the following people:" + +msgid "" +"Alain Reguera Delgado, =COPYRIGHT_YEAR_FIRST=-=COPYRIGHT_YEAR_LAST=" +msgstr "" +"Alain Reguera Delgado, =COPYRIGHT_YEAR_FIRST=-=COPYRIGHT_YEAR_LAST=" + +msgid "Copyright" +msgstr "Copyright" + +msgid "" +"Copyright © =COPYRIGHT_YEAR_FIRST=-=COPYRIGHT_YEAR_LAST= " +"=COPYRIGHT_HOLDER=" +msgstr "" +"Copyright © =COPYRIGHT_YEAR_FIRST=-=COPYRIGHT_YEAR_LAST= " +"=COPYRIGHT_HOLDER=" + +msgid "" +"The tuneup module 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." +msgstr "" +"The tuneup module 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." + +msgid "" +"Tue tuneup module 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." +msgstr "" +"Tue tuneup module 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." + +msgid "" +"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." +msgstr "" +"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." + +msgid "See Also" +msgstr "See Also" + +msgid "centos-art.sh(1), xmllint(1)" +msgstr "centos-art.sh(1), xmllint(1)" + +#. Put one translator per line, in the form of NAME , YEAR1, YEAR2. +msgid "translator-credits" +msgstr "translator-credits" diff --git a/Documentation/Manpages/render.conf b/Documentation/Manpages/render.conf index 13a0f90..b2d3532 100644 --- a/Documentation/Manpages/render.conf +++ b/Documentation/Manpages/render.conf @@ -90,3 +90,10 @@ render-from = "render.asciidoc" locale-from = "Locales/${TCAR_SCRIPT_LANG_LC}/render.asciidoc.po" formats = "xhtml manpage" mansect = "1" +[tuneup] +render-type = "asciidoc" +render-flow = "manpage" +render-from = "tuneup.asciidoc" +locale-from = "Locales/${TCAR_SCRIPT_LANG_LC}/tuneup.asciidoc.po" +formats = "xhtml manpage" +mansect = "1" diff --git a/Documentation/Manpages/tuneup.asciidoc b/Documentation/Manpages/tuneup.asciidoc new file mode 100644 index 0000000..bfe5edd --- /dev/null +++ b/Documentation/Manpages/tuneup.asciidoc @@ -0,0 +1,198 @@ +tuneup(1) +========= + +Name +---- + +tuneup - Standardizes source code maintenance tasks inside the +repository. + +Synopsis +-------- + +*centos-art.sh tuneup [FILE ...|DIRECTORY ...] [--filter="REGEX"]*:: + Execute source code maintenance tasks. + +Description +----------- + +When you run the *tuneup* module it may enter into either file or +directory processing, based on whether you provide a file or directory +as argument for processing in the command-line. When you provide a +file as argument to *tuneup* module, it uses the file's extension as +reference for applying maintenance tasks on that file as described in +<>. When you provide a directory as +argument, *tuneup* looks for all files with supported extensions +inside that directory and then process them, one by one. + +The *tuneup* module exists to automate frequent tasks related to code +maintenance, inside the repository (see <>). It is advisable +to run *tuneup* module over your files from time to time so they all +have a common look and feel. + +[[supported-file-extensions]] +Supported File Extensions +------------------------- + +The *tuneup* module supports maintenance tasks for the following file +extensions: + +.svgz, .svg +~~~~~~~~~~~ + +Provides maintenance tasks for Scalable Vector Graphics (SVG). + +When processing svg files, *tuneup* uses the inkscape's --vaccumm +option to cleanup source code and applies few sed commands to modify +inkscape's metadata using dynamic information like document title, +date, copyright information, urls, and locale information retrieved +from from centos-art.sh script and the file location inside the +repository. + +Each time you create a new svg file or change one, it is advisable to +run *tuneup* module over it. + +.xhtml, .html, .htm +~~~~~~~~~~~~~~~~~~~ + +Provides maintenance tasks for HyperText Markup Language (HTML). + +When processing html-like files, *tuneup* changes each file to create +a table of contents for each heading constructions (see below) first +and then transforms the (probably malformed) HTML markup into valid +XHTML documents using xmllint(1) program. + +In order for *tuneup* to create the table of contents correctly, the +heading construction inside the HTML document must comply the +following restrictions: + +1. Headings must have one of the following forms: ++ +---------------------------------------------------------------------- +

Title

+

Title

+

Title

+---------------------------------------------------------------------- ++ +In these constructions, the heading level may vary from h1 to h6 but +the heading content (e.g., ``Title'') must not be empty. + +When producing table of contents through *tuneup* module, both `name' +and `href' attributes in the anchor element of each heading will be +reset dynamically using a md5 string. The md5 string used in these +cases is based on the heading content (i.e., the text shown as heading +when the page is rendered in a browser) and won't change until you +change the heading content and run *tuneup* module over it again. + +The final table of contents will be expanded wherever you set the ++
+ HTML construction as a line of its own +inside the file being processed. + +.sh +~~~ + +Provides maintenance tasks for Bash scripts. + +When processing sh files, *tuneup* changes the file to update the +written by section, copyright year and license information inside +shell scripts' top comment. Later, it corrects variable name's +references to be all written in upper-case between brackets (e.g., +``${VARNAME}''). + +In order for *tuneup* module to update the top comment of your shell +scripts correctly, it is necessary that your top comments have one ++written by+ line followed by a line of 70 number-sign (\#) +characters, as illustrated in <> This is the basic +construction. Everything between the +written by+ line and the last +line of 70 number-sign characters will be replaced by *tuneup* module +top-comment template which includes people names, copyright and +license information. Everything else does remain untouched. + +[[top-comment]] +.Top-comment convention used by tuneup module. +====================================================================== +---------------------------------------------------------------------- +#!/bin/bash +###################################################################### +# +# ${FILE}.sh -- ${DESCRIPTION} +# +# Written by: +# +###################################################################### +---------------------------------------------------------------------- +====================================================================== + +[[options]] +Options +------- + +*--help*:: + Print module's documentation. +*--version*:: + Print module's version. +*--filter="REGEX"*:: + This option let you reduce the number of files you want to process + by applying a (POSIX-egrep) regular expression to the list of file + paths returned for processing. This option is specially useful + when you need to process files inside a directory structure based + on a specific name patterns. + +[[examples]] + +Examples +-------- + +*centos-art.sh tuneup Automation/Scripts*:: + This command updates the top comment and variable name references + of all files inside the Automation/Scripts directory, recursively. + +*centos-art.sh tuneup Automation/Scripts/tcar_printVersion.sh*:: + This commands updates the top comment and variable name references + inside the tcar_printVersion.sh file only. + +*centos-art.sh tuneup Automation/Scripts --filter="tcar_print.+\.sh$"*:: + This command updates the top comment and variable name refrences + inside files which name only begins with ``tcar_print'' followed + by any character and ends with ``.sh''. All other files won't be + touched. + +[[author]] + +Author +------ + +The *tuneup* module has received contributions from the following +people: + + * mailto:al@centos.org.cu[Alain Reguera Delgado], =COPYRIGHT_YEAR_FIRST=-=COPYRIGHT_YEAR_LAST= + +[[copyright]] + +Copyright +--------- + +Copyright (C) =COPYRIGHT_YEAR_FIRST=-=COPYRIGHT_YEAR_LAST= =COPYRIGHT_HOLDER= + +The *tuneup* module 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. + +Tue *tuneup* module 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. + +[[see-also]] + +See Also +-------- + +centos-art.sh(1), xmllint(1) + +// vim: set syntax=asciidoc: diff --git a/Scripts/Modules/Tuneup/Locales/es_ES/tuneup.sh.po b/Scripts/Modules/Tuneup/Locales/es_ES/tuneup.sh.po new file mode 100644 index 0000000..72d358b --- /dev/null +++ b/Scripts/Modules/Tuneup/Locales/es_ES/tuneup.sh.po @@ -0,0 +1,16 @@ +msgid "" +msgstr "" +"Project-Id-Version: tuneup.sh 0.6\n" +"Report-Msgid-Bugs-To: centos-l10n-es@centos.org.cu\n" +"POT-Creation-Date: 2013-10-07 15:20-0400\n" +"PO-Revision-Date: 2013-10-07 15:20-0400\n" +"Last-Translator: Localization SIG \n" +"Language-Team: Spanish\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: Automation/Modules/Tuneup/tuneup.sh:50 +msgid "The argument provided isn't valid." +msgstr "El argumento suministado no es válido." diff --git a/Scripts/Modules/Tuneup/Modules/Sh/Configs/topcomment.sed b/Scripts/Modules/Tuneup/Modules/Sh/Configs/topcomment.sed new file mode 100755 index 0000000..a5fef74 --- /dev/null +++ b/Scripts/Modules/Tuneup/Modules/Sh/Configs/topcomment.sed @@ -0,0 +1,57 @@ +#!/bin/sed +###################################################################### +# +# topcomment.sed -- This file standardizes the top comment inside +# centos-art.sh scripts. +# +# Written by: +# * Alain Reguera Delgado +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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. +# +###################################################################### +/^#[[:space:]]*Written by:[[:space:]]*$/a\ +# Written by:\ +# * Alain Reguera Delgado , =COPYRIGHT_YEAR_FIRST=-=COPYRIGHT_YEAR_LAST=\ +#\ +# Copyright (C) =COPYRIGHT_YEAR_FIRST=-=COPYRIGHT_YEAR_LAST= =COPYRIGHT_HOLDER=\ +#\ +# 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 previous copyright notice, just to be sure the one above be +# used always. +/^#[[:space:]]*Written by:[[:space:]]*$/,/^#{70}$/{ +d +} + +# Define script first line. +1c\ +#!/bin/bash diff --git a/Scripts/Modules/Tuneup/Modules/Sh/sh.sh b/Scripts/Modules/Tuneup/Modules/Sh/sh.sh new file mode 100755 index 0000000..27ef589 --- /dev/null +++ b/Scripts/Modules/Tuneup/Modules/Sh/sh.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# +# sh.sh -- This module standardizes file Bash scripts maintenance +# tasks inside the repository. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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. +# +###################################################################### + +function sh { + + sh_setTopComment + sh_setVariableNames + +} diff --git a/Scripts/Modules/Tuneup/Modules/Sh/sh_setTopComment.sh b/Scripts/Modules/Tuneup/Modules/Sh/sh_setTopComment.sh new file mode 100755 index 0000000..87c1314 --- /dev/null +++ b/Scripts/Modules/Tuneup/Modules/Sh/sh_setTopComment.sh @@ -0,0 +1,44 @@ +#!/bin/bash +###################################################################### +# +# sh_setTopComment.sh -- This function standardizes presentation for +# top comment section of shell scripts (*.sh) using a predefined +# template. +# +# Copyright (C) 2009-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. +# +###################################################################### + +function sh_setTopComment { + + local COMMENT_TEMPLATE="${TCAR_MODULE_DIR_CONFIGS}/topcomment.sed" + + tcar_checkFiles -ef ${COMMENT_TEMPLATE} + + local COMMENT_INSTANCE=$(tcar_getTemporalFile ${COMMENT_TEMPLATE}) + + cp ${COMMENT_TEMPLATE} ${COMMENT_INSTANCE} + + tcar_setTranslationMarkers ${COMMENT_INSTANCE} + + sed -r -i -f ${COMMENT_INSTANCE} ${FILE} + + if [[ -f ${COMMENT_INSTANCE} ]];then + rm ${COMMENT_INSTANCE} + fi + +} diff --git a/Scripts/Modules/Tuneup/Modules/Sh/sh_setVariableNames.sh b/Scripts/Modules/Tuneup/Modules/Sh/sh_setVariableNames.sh new file mode 100755 index 0000000..588f325 --- /dev/null +++ b/Scripts/Modules/Tuneup/Modules/Sh/sh_setVariableNames.sh @@ -0,0 +1,37 @@ +#!/bin/bash +###################################################################### +# +# sh_setVariableNames.sh -- This function standardizes presentation +# of variable's names inside shell scripts. +# +# Copyright (C) 2009-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. +# +###################################################################### + +function sh_setVariableNames { + + local -a COMMANDS + + # Write non-array variable names all in upper case and between + # brackets. For example: ${VARIABLE} -> ${VARIABLE} + COMMANDS[++((${#COMMANDS[*]}))]='s/\$(\w+\b|@)/${\U\1}/g' + + for COMMAND in ${COMMANDS[*]};do + sed -r -i ${COMMAND} ${FILE} + done + +} diff --git a/Scripts/Modules/Tuneup/Modules/Svg/Configs/metadata.sed b/Scripts/Modules/Tuneup/Modules/Svg/Configs/metadata.sed new file mode 100755 index 0000000..199c44d --- /dev/null +++ b/Scripts/Modules/Tuneup/Modules/Svg/Configs/metadata.sed @@ -0,0 +1,64 @@ +# This file is the metadata information used by CentOS Artwork SIG on +# its scalable vector graphics (SVG) files. This files is used with +# the regular expression '.*\.svg$' only. +# --------------------------------------------------- +# $Id$ +# --------------------------------------------------- +/\ + \ + \ + image/svg+xml\ + \ + \ + =TITLE=\ + =DATE=\ + \ + \ + =COPYRIGHT_HOLDER=\ + \ + \ + \ + \ + =COPYRIGHT_HOLDER=\ + \ + \ + \ + \ + =COPYRIGHT_HOLDER=\ + \ + \ + =URL=\ + =URL=\ + =URL=\ + =LOCALE=\ + \ + \ +=KEYWORDS=\ + \ + \ + =COPYRIGHT_HOLDER=\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + diff --git a/Scripts/Modules/Tuneup/Modules/Svg/svg.sh b/Scripts/Modules/Tuneup/Modules/Svg/svg.sh new file mode 100755 index 0000000..b124cb0 --- /dev/null +++ b/Scripts/Modules/Tuneup/Modules/Svg/svg.sh @@ -0,0 +1,34 @@ +#!/bin/bash +###################################################################### +# +# svg.sh -- This module standardizes source code maintainance of SVG +# files inside the repository. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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. +# +###################################################################### + +function svg { + + svg_doMetadata + + svg_doVacuumDefs + +} diff --git a/Scripts/Modules/Tuneup/Modules/Svg/svg_setMetadata.sh b/Scripts/Modules/Tuneup/Modules/Svg/svg_setMetadata.sh new file mode 100755 index 0000000..ec897bd --- /dev/null +++ b/Scripts/Modules/Tuneup/Modules/Svg/svg_setMetadata.sh @@ -0,0 +1,92 @@ +#!/bin/bash +###################################################################### +# +# svg_setMetadata.sh -- This function updates metadata values inside +# scalable vector graphic (SVG) files using default values from The +# CentOS Project. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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. +# +###################################################################### + +function svg_setMetadata { + + # Define template file name. + local TEMPLATE="${TCAR_MODULE_DIR_CONFIGS}/metadata.sed" + + # Check template file existence. + tcar_checkFiles -ef ${TEMPLATE} + + # Build title from file path. + local TITLE=$(basename "${FILE}") + + # Build url from file path. + local URL=$(echo ${FILE} \ + | sed 's!/home/centos!https://projects.centos.org/svn!') + + # Build keywords from file path. Do not include filename, it is + # already on title. + local KEY='' + local KEYS=$(dirname "${FILE}" | cut -d/ -f6- | tr '/' '\n') + + # Build keywords using SVG standard format. Note that this + # information is inserted inside template file. The template file + # is a replacement set of sed commands so we need to escape the + # new line of each line using one backslash (\). As we are doing + # this inside bash, it is required to escape the backslash with + # another backslash so one of them passes literally to template + # file. + KEYS=$(\ + for KEY in ${KEYS};do + echo " ${KEY}\\" + done) + + # Redefine template instance file name. + local INSTANCE=$(tcar_getTemporalFile ${TEMPLATE}) + + # Create instance. + cp ${TEMPLATE} ${INSTANCE} + + # Check template instance. We cannot continue if the template + # instance couldn't be created. + tcar_checkFiles -e ${INSTANCE} + + # Expand translation markers inside template instance. + sed -r -i \ + -e "s!=TITLE=!${TITLE}!" \ + -e "s!=URL=!${URL}!" \ + -e "s!=DATE=!$(date "+%Y-%m-%d")!" ${INSTANCE} + sed -i -r "/=KEYWORDS=/c\\${KEYS}" ${INSTANCE} + sed -i -r 's/>$/>\\/g' ${INSTANCE} + + tcar_setTranslationMarkers ${INSTANCE} + + # Update scalable vector graphic using template instance. + sed -i -f ${INSTANCE} ${FILE} + + # Remove template instance. + if [[ -f ${INSTANCE} ]];then + rm ${INSTANCE} + fi + + # Sanitate scalable vector graphic. + sed -i -r '/^[[:space:]]*$/d' ${FILE} + +} diff --git a/Scripts/Modules/Tuneup/Modules/Svg/svg_setVacuumDefs.sh b/Scripts/Modules/Tuneup/Modules/Svg/svg_setVacuumDefs.sh new file mode 100755 index 0000000..dae1648 --- /dev/null +++ b/Scripts/Modules/Tuneup/Modules/Svg/svg_setVacuumDefs.sh @@ -0,0 +1,32 @@ +#!/bin/bash +###################################################################### +# +# svg_setVacuumDefs.sh -- This function removes all unused items from +# the defs section of the SVG file. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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. +# +###################################################################### + +function svg_setVacuumDefs { + + inkscape --vacuum-defs ${FILE} 2&> /dev/null + +} diff --git a/Scripts/Modules/Tuneup/Modules/Xhtml/Configs/toc.awk b/Scripts/Modules/Tuneup/Modules/Xhtml/Configs/toc.awk new file mode 100755 index 0000000..ad47670 --- /dev/null +++ b/Scripts/Modules/Tuneup/Modules/Xhtml/Configs/toc.awk @@ -0,0 +1,80 @@ +#!/usr/bin/gawk +# +# toc.awk -- This file provides the output format required by +# `xhtml_setToc' function, inside centos-art.sh script, to produce +# the table of contents correctly. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Pubdtc License as pubdtshed 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 usefdl, but +# WITHOUT ANY WARRANTY; without even the impdted warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Pubdtc License for more details. +# +# You shodld have received a copy of the GNU General Pubdtc License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +###################################################################### + +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/Modules/Tuneup/Modules/Xhtml/xhtml.sh b/Scripts/Modules/Tuneup/Modules/Xhtml/xhtml.sh new file mode 100755 index 0000000..bb0207f --- /dev/null +++ b/Scripts/Modules/Tuneup/Modules/Xhtml/xhtml.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# +# xhtml.sh -- This function standardizes maintainance tasks for +# HTML-like files. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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. +# +###################################################################### + +function xhtml { + + xhtml_setToc + xhtml_setCleanUp + +} diff --git a/Scripts/Modules/Tuneup/Modules/Xhtml/xhtml_setCleanUp.sh b/Scripts/Modules/Tuneup/Modules/Xhtml/xhtml_setCleanUp.sh new file mode 100755 index 0000000..95de440 --- /dev/null +++ b/Scripts/Modules/Tuneup/Modules/Xhtml/xhtml_setCleanUp.sh @@ -0,0 +1,42 @@ +#!/bin/bash +###################################################################### +# +# xhtml_setCleanUp.sh -- This function creates valid XHTML files +# from (probably malformed) HTML files. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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. +# +###################################################################### + +function xhtml_setCleanUp { + + grep ' /dev/null \ + || egrep '\-//W3C//DTD XHTML 1.0 (Strict|Transitional)//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 + +} diff --git a/Scripts/Modules/Tuneup/Modules/Xhtml/xhtml_setToc.sh b/Scripts/Modules/Tuneup/Modules/Xhtml/xhtml_setToc.sh new file mode 100755 index 0000000..e75a2b3 --- /dev/null +++ b/Scripts/Modules/Tuneup/Modules/Xhtml/xhtml_setToc.sh @@ -0,0 +1,162 @@ +#!/bin/bash +###################################################################### +# +# xhtml_setToc.sh -- This functionality transforms web page headings +# to make them accessible through a table of contents. The table of +# contents is expanded in place, wherever the
piece of code be in the page. Once the
piece of code has be expanded, there is no need +# to put anything else in the page. +# +# In order for the tuneup functionality to transform headings, you +# need to put headings in just one line using one of the following +# forms: +# +#

Title

+#

Title

+#

Title

+# +# In the example above, h1 can vary from h1 to h6. Closing tag must +# be present and also match the openning tag. The value of `name' +# and `href' options from the anchor element are set dynamically +# using the md5sum output of combining the page location, the head- +# string and the heading string. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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. +# +###################################################################### + +function xhtml_setToc { + + # Define variables as local to avoid conflicts outside. + local COUNT=0 + local PREVCOUNT=0 + local -a FINAL + local -a TITLE + local -a MD5SM + local -a OPTNS + local -a CLASS + local -a LEVEL + local -a PARENT + local -a TOCENTRIES + local -a LINK + + # Define table of content configuration file, the file used to + # produce the table of content XHTML output code. + local TOC_CONFIG=${TCAR_MODULE_DIR_CONFIGS}/toc.awk + + # Verify table of content configuration file. + tcar_checkFiles -ef ${TOC_CONFIG} + + # Define html heading regular expression pattern. Use parenthisis + # to save html action name, action value, and heading title. + local PATTERN='(]>)(.*[^<])' + + # 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 + + # 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}!\4!") + MD5SM[${COUNT}]=$(echo "${TITLE[${COUNT}]}" | md5sum | sed -r 's![[:space:]]+-$!!') + OPTNS[${COUNT}]=$(echo "${FIRST[${COUNT}]}" | sed -r "s!${PATTERN}!\3!") + CLASS[${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 xhtml 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 ${TOC_CONFIG}) + + # Update table of contents inside the current file being + # processed. + sed -i -r '/
[^<\/div].*<\/div>/c'"$(echo -e ${TOC})" ${FILE} + + # Clean up variables to receive the next file. + unset FINAL + unset TITLE + unset MD5SM + unset OPTNS + unset CLASS + unset LEVEL + unset PARENT + unset TOCENTRIES + unset LINK + +} diff --git a/Scripts/Modules/Tuneup/tuneup.sh b/Scripts/Modules/Tuneup/tuneup.sh new file mode 100755 index 0000000..c1c55f7 --- /dev/null +++ b/Scripts/Modules/Tuneup/tuneup.sh @@ -0,0 +1,75 @@ +#!/bin/bash +###################################################################### +# +# tuneup.sh -- This module standardizes source code file +# maintainance inside the repository. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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. +# +###################################################################### + +function tuneup { + + # Define file extensions tuneup module will look for processing. + local FILE_EXTENSION_REGEX='\.(svgz|svg|shtml|xhtml|html|sh)$' + + tuneup_getOptions + + for ARGUMENT in ${TCAR_MODULE_ARGUMENT};do + + # Sanitate non-option arguments to be sure they match the + # directory conventions established by centos-art.sh script + # against source directory locations in the working copy. + local ARGUMENT=$(tcar_checkRepoDirSource ${ARGUMENT}) + + # Build list of files to process. + if [[ -f ${ARGUMENT} ]];then + local FILES=${ARGUMENT} + elif [[ -d ${ARGUMENT} ]];then + local FILES=$(tcar_getFilesList ${ARGUMENT} \ + --pattern=".+${FILE_EXTENSION_REGEX}" \ + --type='f' | egrep ${TCAR_FLAG_FILTER}) + else + tcar_printMessage "`gettext "The argument provided isn't valid."`" --as-error-line + fi + + # Process list of files. + for FILE in ${FILES};do + + # Print action message. + tcar_printMessage "${FILE}" --as-tuningup-line + + # Retrieve module name to apply based on file extension . + local FILE_EXTENSION=$(echo ${FILE} \ + | sed -r "s/.+${FILE_EXTENSION_REGEX}/\1/") + + # Set module aliases. + if [[ ${FILE_EXTENSION} =~ '(shtml|html|htm)' ]];then + FILE_EXTENSION='xhtml' + fi + + # Initiate module's environment for processing file. + tcar_setModuleEnvironment -m "${FILE_EXTENSION}" -t "child" "${FILE}" + + done + + done + +} diff --git a/Scripts/Modules/Tuneup/tuneup_getOptions.sh b/Scripts/Modules/Tuneup/tuneup_getOptions.sh new file mode 100755 index 0000000..47bd426 --- /dev/null +++ b/Scripts/Modules/Tuneup/tuneup_getOptions.sh @@ -0,0 +1,71 @@ +#!/bin/bash +###################################################################### +# +# tuneup_getOptions.sh -- This file initialize the command-line +# options used by tuneup module. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# 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. +# +###################################################################### + +function tuneup_getOptions { + + # Define short options we want to support. + local ARGSS="h::,v,f:" + + # Define long options we want to support. + local ARGSL="help::,version,filter::" + + # Redefine arguments using getopt(1) command parser. + tcar_setModuleArguments + + # Reset positional parameters on this function, using output + # produced from (getopt) arguments parser. + eval set -- "${TCAR_MODULE_ARGUMENT}" + + # Look for options passed through command-line. + while true; do + case "${1}" in + + -h | --help ) + tcar_printHelp "${2}" + ;; + + -v | --version ) + tcar_printVersion "${TCAR_MODULE_NAME}" + ;; + + -f | --filter ) + TCAR_FLAG_FILTER="${2:-${TCAR_FLAG_FILTER}}" + shift 2 + ;; + + -- ) + shift 1 + break + ;; + esac + done + + # Redefine arguments using current positional parameters. Only + # paths should remain as arguments, at this point. + TCAR_MODULE_ARGUMENT="${@}" + +}