diff --git a/Scripts/Functions/Tuneup/Backends/Shell/shell.sh b/Scripts/Functions/Tuneup/Backends/Shell/shell.sh new file mode 100755 index 0000000..4436635 --- /dev/null +++ b/Scripts/Functions/Tuneup/Backends/Shell/shell.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# +# tuneup_shell.sh -- This function performs maintainance tasks for +# Shell script files. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function tuneup_shell { + + # Rebuild top comment inside shell scripts, mainly to update + # copyright information. + tuneup_shell_doTopComment + +} diff --git a/Scripts/Functions/Tuneup/Backends/Shell/shell_doTopComment.sh b/Scripts/Functions/Tuneup/Backends/Shell/shell_doTopComment.sh new file mode 100755 index 0000000..974d80d --- /dev/null +++ b/Scripts/Functions/Tuneup/Backends/Shell/shell_doTopComment.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# +# tuneup_shell_doTopComment.sh -- This function tunnes up the top +# comment section inside shell scripts (*.sh) using a predefined +# template. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function tuneup_shell_doTopComment { + + # Define absolute path to template file. + local TEMPLATE="${FUNCCONFIG}/shell_topcomment.sed" + + # Check template file existence. + cli_checkFiles $TEMPLATE + + # Define file name to template instance. + local INSTANCE=$(cli_getTemporalFile $TEMPLATE) + + # Create template instance. + cp $TEMPLATE $INSTANCE + + # Check template instance. We cannot continue if template instance + # couldn't be created. + cli_checkFiles $INSTANCE + + # Expand translation markers in template instance. + cli_replaceTMarkers $INSTANCE + + # Apply template instance to file. + sed -r -i -f $INSTANCE $FILE + + # Remove template instance. + if [[ -f ${INSTANCE} ]];then + rm ${INSTANCE} + fi + +} diff --git a/Scripts/Functions/Tuneup/Backends/Svg/Config/svg_metadata.sed b/Scripts/Functions/Tuneup/Backends/Svg/Config/svg_metadata.sed new file mode 100644 index 0000000..199c44d --- /dev/null +++ b/Scripts/Functions/Tuneup/Backends/Svg/Config/svg_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/Functions/Tuneup/Backends/Svg/svg.sh b/Scripts/Functions/Tuneup/Backends/Svg/svg.sh new file mode 100755 index 0000000..ed1caa9 --- /dev/null +++ b/Scripts/Functions/Tuneup/Backends/Svg/svg.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# +# tuneup_svg.sh -- This function performs maintainance tasks for +# SVG files. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function tuneup_svg { + + # Update metadata information. + tuneup_svg_doMetadata + + # Remove all unused items. + tuneup_svg_doUnusedItems + +} diff --git a/Scripts/Functions/Tuneup/Backends/Svg/svg_doMetadata.sh b/Scripts/Functions/Tuneup/Backends/Svg/svg_doMetadata.sh new file mode 100755 index 0000000..c48aee2 --- /dev/null +++ b/Scripts/Functions/Tuneup/Backends/Svg/svg_doMetadata.sh @@ -0,0 +1,93 @@ +#!/bin/bash +# +# tuneup_doSvgMetadata.sh -- This function updates metadata values +# inside scalable vector graphic (SVG) files using The CentOS Project +# default values. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function tuneup_doSvgMetadata { + + local NAM='' + local URL='' + local KEYS='' + local INSTANCE='' + local TEMPLATES='' + + # Define template file name. + TEMPLATE="${FUNCCONFIG}/svg_metadata.sed" + + # Check template file existence. + cli_checkFiles $TEMPLATE + + # Build title from file path. + NAM=$(basename "$FILE") + + # Build url from file path. + 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. + 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. + INSTANCE=$(cli_getTemporalFile $TEMPLATE) + + # Create template instance. + cp $TEMPLATE $INSTANCE + + # Check template instance. We cannot continue if the template + # instance couldn't be created. + cli_checkFiles $INSTANCE + + # Expand translation markers inside template instance. + sed -r -i \ + -e "s!=TITLE=!$NAM!" \ + -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 + cli_replaceTMarkers $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/Functions/Tuneup/Backends/Svg/svg_doUnusedItems.sh b/Scripts/Functions/Tuneup/Backends/Svg/svg_doUnusedItems.sh new file mode 100755 index 0000000..8b1aa52 --- /dev/null +++ b/Scripts/Functions/Tuneup/Backends/Svg/svg_doUnusedItems.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# +# tuneup_svg_doUnusedItems.sh -- This function removes all unused items +# from the defs section of the SVG file. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function tuneup_svg_doUnusedItems { + + # Vacuum unused svg definition using inkscape. + inkscape --vacuum-defs $FILE &> /dev/null + +} diff --git a/Scripts/Functions/Tuneup/Backends/Svg/svg_metadata.sed b/Scripts/Functions/Tuneup/Backends/Svg/svg_metadata.sed deleted file mode 100644 index 199c44d..0000000 --- a/Scripts/Functions/Tuneup/Backends/Svg/svg_metadata.sed +++ /dev/null @@ -1,64 +0,0 @@ -# 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/Functions/Tuneup/Backends/Xhtml/xhtml.sh b/Scripts/Functions/Tuneup/Backends/Xhtml/xhtml.sh new file mode 100644 index 0000000..f293355 --- /dev/null +++ b/Scripts/Functions/Tuneup/Backends/Xhtml/xhtml.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# +# tuneup_xhtml.sh -- This function performs maintainance tasks for +# XHTML files. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function tuneup_xhtml { + + # Transforms html headings to make them accessible (e.g., through + # a table of contents). + tuneup_xhtml_doHeadings + +} diff --git a/Scripts/Functions/Tuneup/Backends/Xhtml/xhtml_doToc.sh b/Scripts/Functions/Tuneup/Backends/Xhtml/xhtml_doToc.sh new file mode 100644 index 0000000..38b4676 --- /dev/null +++ b/Scripts/Functions/Tuneup/Backends/Xhtml/xhtml_doToc.sh @@ -0,0 +1,155 @@ +#!/bin/bash +# +# tuneup_xhtml_doHeadings.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. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function tuneup_xhtml_doHeadings { + + # Define variables as local to avoid conflicts outside. + local COUNT=0 + 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="(]>)(.*[^<])" + + # 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!\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 ${FUNCCONFIG}/output_forHeadingsToc.awk) + + # Update table of contents inside the current file being + # processed. + sed -i -r '/
[^<\/div].*<\/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 + +} diff --git a/Scripts/Functions/Tuneup/tuneup_shell.sh b/Scripts/Functions/Tuneup/tuneup_shell.sh deleted file mode 100755 index 4436635..0000000 --- a/Scripts/Functions/Tuneup/tuneup_shell.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# -# tuneup_shell.sh -- This function performs maintainance tasks for -# Shell script files. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function tuneup_shell { - - # Rebuild top comment inside shell scripts, mainly to update - # copyright information. - tuneup_shell_doTopComment - -} diff --git a/Scripts/Functions/Tuneup/tuneup_shell_doTopComment.sh b/Scripts/Functions/Tuneup/tuneup_shell_doTopComment.sh deleted file mode 100755 index 974d80d..0000000 --- a/Scripts/Functions/Tuneup/tuneup_shell_doTopComment.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -# -# tuneup_shell_doTopComment.sh -- This function tunnes up the top -# comment section inside shell scripts (*.sh) using a predefined -# template. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function tuneup_shell_doTopComment { - - # Define absolute path to template file. - local TEMPLATE="${FUNCCONFIG}/shell_topcomment.sed" - - # Check template file existence. - cli_checkFiles $TEMPLATE - - # Define file name to template instance. - local INSTANCE=$(cli_getTemporalFile $TEMPLATE) - - # Create template instance. - cp $TEMPLATE $INSTANCE - - # Check template instance. We cannot continue if template instance - # couldn't be created. - cli_checkFiles $INSTANCE - - # Expand translation markers in template instance. - cli_replaceTMarkers $INSTANCE - - # Apply template instance to file. - sed -r -i -f $INSTANCE $FILE - - # Remove template instance. - if [[ -f ${INSTANCE} ]];then - rm ${INSTANCE} - fi - -} diff --git a/Scripts/Functions/Tuneup/tuneup_svg.sh b/Scripts/Functions/Tuneup/tuneup_svg.sh deleted file mode 100755 index ed1caa9..0000000 --- a/Scripts/Functions/Tuneup/tuneup_svg.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -# -# tuneup_svg.sh -- This function performs maintainance tasks for -# SVG files. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function tuneup_svg { - - # Update metadata information. - tuneup_svg_doMetadata - - # Remove all unused items. - tuneup_svg_doUnusedItems - -} diff --git a/Scripts/Functions/Tuneup/tuneup_svg_doMetadata.sh b/Scripts/Functions/Tuneup/tuneup_svg_doMetadata.sh deleted file mode 100755 index c48aee2..0000000 --- a/Scripts/Functions/Tuneup/tuneup_svg_doMetadata.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/bash -# -# tuneup_doSvgMetadata.sh -- This function updates metadata values -# inside scalable vector graphic (SVG) files using The CentOS Project -# default values. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function tuneup_doSvgMetadata { - - local NAM='' - local URL='' - local KEYS='' - local INSTANCE='' - local TEMPLATES='' - - # Define template file name. - TEMPLATE="${FUNCCONFIG}/svg_metadata.sed" - - # Check template file existence. - cli_checkFiles $TEMPLATE - - # Build title from file path. - NAM=$(basename "$FILE") - - # Build url from file path. - 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. - 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. - INSTANCE=$(cli_getTemporalFile $TEMPLATE) - - # Create template instance. - cp $TEMPLATE $INSTANCE - - # Check template instance. We cannot continue if the template - # instance couldn't be created. - cli_checkFiles $INSTANCE - - # Expand translation markers inside template instance. - sed -r -i \ - -e "s!=TITLE=!$NAM!" \ - -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 - cli_replaceTMarkers $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/Functions/Tuneup/tuneup_svg_doUnusedItems.sh b/Scripts/Functions/Tuneup/tuneup_svg_doUnusedItems.sh deleted file mode 100755 index 8b1aa52..0000000 --- a/Scripts/Functions/Tuneup/tuneup_svg_doUnusedItems.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -# -# tuneup_svg_doUnusedItems.sh -- This function removes all unused items -# from the defs section of the SVG file. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function tuneup_svg_doUnusedItems { - - # Vacuum unused svg definition using inkscape. - inkscape --vacuum-defs $FILE &> /dev/null - -} diff --git a/Scripts/Functions/Tuneup/tuneup_xhtml.sh b/Scripts/Functions/Tuneup/tuneup_xhtml.sh deleted file mode 100644 index f293355..0000000 --- a/Scripts/Functions/Tuneup/tuneup_xhtml.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# -# tuneup_xhtml.sh -- This function performs maintainance tasks for -# XHTML files. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function tuneup_xhtml { - - # Transforms html headings to make them accessible (e.g., through - # a table of contents). - tuneup_xhtml_doHeadings - -} diff --git a/Scripts/Functions/Tuneup/tuneup_xhtml_doHeadings.sh b/Scripts/Functions/Tuneup/tuneup_xhtml_doHeadings.sh deleted file mode 100644 index 38b4676..0000000 --- a/Scripts/Functions/Tuneup/tuneup_xhtml_doHeadings.sh +++ /dev/null @@ -1,155 +0,0 @@ -#!/bin/bash -# -# tuneup_xhtml_doHeadings.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. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function tuneup_xhtml_doHeadings { - - # Define variables as local to avoid conflicts outside. - local COUNT=0 - 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="(]>)(.*[^<])" - - # 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!\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 ${FUNCCONFIG}/output_forHeadingsToc.awk) - - # Update table of contents inside the current file being - # processed. - sed -i -r '/
[^<\/div].*<\/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 - -}