diff --git a/Scripts/Functions/Render/Backends/Docbook/docbook.sh b/Scripts/Functions/Render/Backends/Docbook/docbook.sh new file mode 100755 index 0000000..3fe6649 --- /dev/null +++ b/Scripts/Functions/Render/Backends/Docbook/docbook.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# +# render_docbook.sh -- This function performs base-rendition action +# for DocBook 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 render_docbook { + + # Produce xhtml output from docbook template instance using XSL + # stylesheets as reference. + render_docbook_convertToXhtml + + # Produce plaintext output from html outout. + render_xhtml_convertToText + +} diff --git a/Scripts/Functions/Render/Backends/Docbook/docbook_convertToXhtml.sh b/Scripts/Functions/Render/Backends/Docbook/docbook_convertToXhtml.sh new file mode 100755 index 0000000..657ba90 --- /dev/null +++ b/Scripts/Functions/Render/Backends/Docbook/docbook_convertToXhtml.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# +# render_docbook_convertToXhtml.sh -- This function produces XHTML +# output from docbook template instance using XSL stylesheets as +# reference. +# +# 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 render_docbook_convertToXhtml { + + # Print action message. + if [[ -f ${FILE}.xhtml ]];then + cli_printMessage "${FILE}.xhtml" --as-updating-line + else + cli_printMessage "${FILE}.xhtml" --as-creating-line + fi + + # Define list of XSL stylesheets. + local XSL='/usr/share/sgml/docbook/xsl-stylesheets/xhtml/docbook.xsl' + + # Produce xhtml output from docbook template instance using XSL + # stylesheets as reference. + xsltproc ${XSL} $INSTANCE > ${FILE}.xhtml + +} diff --git a/Scripts/Functions/Render/Backends/Svg/svg.sh b/Scripts/Functions/Render/Backends/Svg/svg.sh new file mode 100644 index 0000000..1ed14b2 --- /dev/null +++ b/Scripts/Functions/Render/Backends/Svg/svg.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# +# render_svg.sh -- This function performs base-rendition action 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 render_svg { + + # Initialize the export id used inside design templates. This + # value defines the design area we want to export. + local EXPORTID='CENTOSARTWORK' + + # Verify the export id. + render_svg_checkModelExportId "$INSTANCE" "$EXPORTID" + + # Check existence of external files. Inside design templates and + # their instances, external files are used to refere the + # background information required by the design template. If such + # background information is not available the image is produced + # without background information. This is something that need to + # be avoided. + render_svg_checkModelAbsref "$INSTANCE" + + # Render template instance using inkscape and save the output. + local INKSCAPE_OUTPUT="$(\ + inkscape $INSTANCE --export-id=$EXPORTID --export-png=${FILE}.png)" + + # Modify output from inkscape to fit the centos-art.sh script + # output visual style. + cli_printMessage "$(echo "$INKSCAPE_OUTPUT" | egrep '^Area' \ + | sed -r "s!^Area!`gettext "Area"`:!")" + cli_printMessage "$(echo "$INKSCAPE_OUTPUT" | egrep '^Background' \ + | sed -r "s!^Background (RRGGBBAA):(.*)!`gettext "Background"`: \1 \2!")" + cli_printMessage "$(echo "$INKSCAPE_OUTPUT" | egrep '^Bitmap saved as' \ + | sed -r "s!^Bitmap saved as:!`gettext "Saved as"`:!")" + +} diff --git a/Scripts/Functions/Render/Backends/Svg/svg_checkColorAmount.sh b/Scripts/Functions/Render/Backends/Svg/svg_checkColorAmount.sh new file mode 100755 index 0000000..f4a0b22 --- /dev/null +++ b/Scripts/Functions/Render/Backends/Svg/svg_checkColorAmount.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# +# render_svg_checkColorAmount.sh -- This function verifies whether the +# list of colors provided in the first argument matches the amount of +# colors specified by the second argument. +# +# 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 render_svg_checkColorAmount { + + # Define list of colors. + local COLORS=$1 + + # Define the amount of colors the list provided must have, in + # order to be considered as valid. + local NUMBER=$2 + + # Verify amount of colors provided in the list. + if [[ $(echo "$COLORS" | wc -l) -ne $NUMBER ]];then + cli_printMessage "`gettext "The palette does not have the correct number of colors."`" --as-error-line + fi + +} diff --git a/Scripts/Functions/Render/Backends/Svg/svg_checkColorFormats.sh b/Scripts/Functions/Render/Backends/Svg/svg_checkColorFormats.sh new file mode 100755 index 0000000..e10d3ab --- /dev/null +++ b/Scripts/Functions/Render/Backends/Svg/svg_checkColorFormats.sh @@ -0,0 +1,88 @@ +#!/bin/bash +# +# render_svg_checkColorFormats.sh -- This function verifies formats of +# colors (i.e., the way color information is specified). +# +# 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 render_svg_checkColorFormats { + + # Define short options. + local ARGSS='' + + # Define long options. + local ARGSL='format:' + + # Initialize ARGUMENTS with an empty value and set it as local + # variable to this function scope. + local ARGUMENTS='' + + # Initialize pattern used for color sanitation. + local PATTERN='^#[0-9a-f]{6}$' + + # Redefine ARGUMENTS variable using current positional parameters. + cli_parseArgumentsReDef "$@" + + # Redefine ARGUMENTS variable using getopt output. + cli_parseArguments + + # Redefine positional parameters using ARGUMENTS variable. + eval set -- "$ARGUMENTS" + + # Look for options passed through positional parameters. + while true;do + + case "$1" in + + --format ) + + case "$2" in + + rrggbb|*) + PATTERN='^#[0-9a-f]{6}$' + ;; + + esac + shift 2 + ;; + + -- ) + shift 1 + break + ;; + esac + done + + # Define the location we want to apply verifications to. + local COLOR='' + local COLORS="$@" + + # Loop through colors and perform format verification as specified + # by pattern. + for COLOR in $COLORS;do + + if [[ ! $COLOR =~ $PATTERN ]];then + cli_printMessage "`eval_gettext "The \\\"\\\$COLOR\\\" string is not a valid color code."`" --as-error-line + fi + + done + +} diff --git a/Scripts/Functions/Render/Backends/Svg/svg_checkModelAbsref.sh b/Scripts/Functions/Render/Backends/Svg/svg_checkModelAbsref.sh new file mode 100755 index 0000000..1841d0c --- /dev/null +++ b/Scripts/Functions/Render/Backends/Svg/svg_checkModelAbsref.sh @@ -0,0 +1,129 @@ +#!/bin/bash +# +# render_svg_checkModelAbsref.sh -- This function retrives absolute files +# and checks their existence. In order for design templates to point +# different artistic motifs, design templates make use of external +# files which point to specific artistic motif background images. If +# such external files don't exist, try to create the background image +# required by cropping a higher background image (e.g., +# 2048x1536-final.png). If this isn't possible neither, then create +# the background image using a plain color and crop from it then. We +# can't go on without the required background information. +# +# 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 render_svg_checkModelAbsref { + + local FILE='' + local BG_DST_FILES='' + local BG_DST_FILE='' + local BG_DST_FILE_WIDTH='' + local BG_DST_FILE_HEIGHT='' + local BG_SRC_FILE='' + local BG_SRC_FILE_COLOR='' + local BG_SRC_FILE_WIDTH='' + local BG_SRC_FILE_HEIGHT='' + + # Define absolute path to the translated instance of design model. + FILE="$1" + + # Verify existence of file we need to retrive absolute paths from. + cli_checkFiles "$FILE" + + # Retrive absolute paths from file. + BG_DST_FILES=$(egrep "(sodipodi:absref|xlink:href)=\"${HOME}.+" $FILE \ + | sed -r "s,.+=\"(${HOME}.+\.png)\".*,\1," | sort | uniq) + + # Verify absolute paths retrived from file. + for BG_DST_FILE in $BG_DST_FILES;do + + # Print action + cli_printMessage "$BG_DST_FILE" --as-checking-line + + if [[ ! -a $BG_DST_FILE ]];then + + # Define the source background file, the image file will + # crop when no specific background informatio be available + # for using. Generally, this is the most reusable + # background file inside the artistic motifs (e.g,. the + # `2048x1536-final.png' file). We can use this image file + # to create almost all artworks inside The CentOS + # Distribution visual manifestation when + # resolution-specific backgrounds don't exist. + BG_SRC_FILE=$(echo $BG_DST_FILE \ + | sed -r "s!(.+)/[[:digit:]]+x[[:digit:]]+(-final\.png)!\1/2048x1536\2!") + + # Verify existence of source background file. If the file + # doesn't exist create it using The CentOS Project default + # background color information, as specified in its + # corporate identity manual. + if [[ ! -f $BG_SRC_FILE ]];then + + # Define plain color that will be used as background. + BG_SRC_FILE_COLOR=$(render_svg_getColors) + + # Verify format of color value. + render_svg_checkColorFormats $BG_SRC_FILE_COLOR --format='rrggbb' + + # Define width for the source background file the + # required background information is cropped from. + BG_SRC_FILE_WIDTH=$(echo $BG_SRC_FILE \ + | sed -r 's!.+/([[:digit:]]+)x[[:digit:]]+-final\.png!\1!') + + # Define height for the source background file the + # required background information is cropped from. + BG_SRC_FILE_HEIGHT=$(echo $BG_SRC_FILE \ + | sed -r 's!.+/[[:digit:]]+x([[:digit:]]+)-final\.png!\1!') + + # Print action message. + cli_printMessage "${BG_SRC_FILE} ($BG_SRC_FILE_COLOR)" --as-creating-line + + # Create the source background file. + ppmmake -quiet ${BG_SRC_FILE_COLOR} \ + ${BG_SRC_FILE_WIDTH} ${BG_SRC_FILE_HEIGHT} \ + | pnmtopng > ${BG_SRC_FILE} + + fi + + # Print action message. + cli_printMessage "$BG_SRC_FILE" --as-cropping-line + + # Define the width of the required background information. + BG_DST_FILE_WIDTH=$(echo $BG_DST_FILE \ + | sed -r 's!.+/([[:digit:]]+)x[[:digit:]]+-final\.png!\1!') + + # Define the height of the required background information. + BG_DST_FILE_HEIGHT=$(echo $BG_DST_FILE \ + | sed -r 's!.+/[[:digit:]]+x([[:digit:]]+)-final\.png!\1!') + + # Create required backgrounnd information. + convert -quiet \ + -crop ${BG_DST_FILE_WIDTH}x${BG_DST_FILE_HEIGHT}+0+0 \ + ${BG_SRC_FILE} ${BG_DST_FILE} + + # Verify required background information. + cli_checkFiles $BG_DST_FILE + + fi + + done + +} diff --git a/Scripts/Functions/Render/Backends/Svg/svg_checkModelExportId.sh b/Scripts/Functions/Render/Backends/Svg/svg_checkModelExportId.sh new file mode 100755 index 0000000..febd14e --- /dev/null +++ b/Scripts/Functions/Render/Backends/Svg/svg_checkModelExportId.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# +# render_svg_checkModelExportId.sh -- This function standardizes the export id +# used inside svg files and the way of verify them. +# +# 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 render_svg_checkModelExportId { + + local INSTANCE="$1" + local EXPORTID="$2" + + # Verify instance. + cli_checkFiles $INSTANCE + + # Verify export id. + if [[ $EXPORTID == '' ]];then + cli_printMessage "`gettext "The export id value cannot be empty."`" --as-error-line + fi + + # Check export id inside design templates. + grep "id=\"$EXPORTID\"" $INSTANCE > /dev/null + if [[ $? -gt 0 ]];then + cli_printMessage "`eval_gettext "There is not export id (\\\$EXPORTID) inside \\\"\\\$TEMPLATE\\\"."`" --as-error-line + fi + +} diff --git a/Scripts/Functions/Render/Backends/Svg/svg_convertGplToHex.sh b/Scripts/Functions/Render/Backends/Svg/svg_convertGplToHex.sh new file mode 100755 index 0000000..e37b944 --- /dev/null +++ b/Scripts/Functions/Render/Backends/Svg/svg_convertGplToHex.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# +# render_svg_convertGplToHex.sh -- This function takes one palette +# produced by Gimp (e.g., syslinux.gpl) as input and outputs the list +# of hexadecimal colors and their respective index position the +# `pnmtolss16' program needs (e.g., #RRGGBB=0 #RRGGBB=1 ... [all +# values in the same line]). +# +# 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 render_svg_convertGplToHex { + + # Define path to GPL palette. This is the .gpl file we use to + # retrive color information from. + local PALETTE_GPL="$1" + + # Define path to HEX palette. This is the palette used to stored + # the color information the `ppmtolss16' program needs. + local PALETTE_HEX="$2" + + # Define the number of colors this function should return. + local NUMBER="$3" + + # Define list of colors from GPL palette. + local COLORS=$(render_svg_getColors $PALETTE_GPL --head=$NUMBER --tail=$NUMBER) + + # Verify number of colors returned in the list. They must match + # exactly the amount specified, no more no less. Sometimes, the + # list of colors may have less colors than it should have, so we + # need to prevent such palettes from being used. + render_svg_checkColorAmount "$COLORS" "$NUMBER" + + # Verify format of colors. + render_svg_checkColorFormats "$COLORS" --format='rrggbb' + + # Create list of colors to be process by pnmtolss16 + echo "$COLORS" | nl | awk '{ printf "%s=%d ", $2, $1 - 1 }' \ + > $PALETTE_HEX + + # Verify HEX palette existence. + cli_checkFiles $PALETTE_HEX + +} diff --git a/Scripts/Functions/Render/Backends/Svg/svg_convertGplToPpm.sh b/Scripts/Functions/Render/Backends/Svg/svg_convertGplToPpm.sh new file mode 100755 index 0000000..ff10c43 --- /dev/null +++ b/Scripts/Functions/Render/Backends/Svg/svg_convertGplToPpm.sh @@ -0,0 +1,72 @@ +#!/bin/bash +# +# render_svg_convertGplToPpm.sh -- This function takes one palette +# produced by Gimp (e.g., syslinux.gpl) as input and outputs one PPM +# file based on it (e.g., syslinux.ppm). +# +# 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 render_svg_convertGplToPpm { + + local FILE='' + local -a FILES + local COUNT=0 + + # Define path to GPL palette. This is the .gpl file we use to + # retrive color information from. + local PALETTE_GPL="$1" + + # Define path to PPM palette. This is the .ppm file we'll save + # color information to. + local PALETTE_PPM="$2" + + # Define the number of colors this function should return. + local NUMBER="$3" + + # Define list of colors from GPL palette. + local COLOR='' + local COLORS=$(render_svg_getColors "$PALETTE_GPL" --head=$NUMBER --tail=$NUMBER --format='rrrggbb') + + # Verify amount of colors in the list of colors. + render_svg_checkColorAmount "$COLORS" "$NUMBER" + + # Verify format of colors. + render_svg_checkColorFormats $COLORS --format='rrggbb' + + # Create temporal images (of 1x1 pixel each) to store each color + # retrived from Gimp's palette. + for COLOR in $COLORS;do + FILES[$COUNT]=$(cli_getTemporalFile ${COUNT}.ppm) + ppmmake $COLOR 1 1 > ${FILES[$COUNT]} + COUNT=$(($COUNT + 1)) + done + + # Concatenate each temporal image from left to right to create the + # PPM file. + pnmcat -lr ${FILES[*]} > $PALETTE_PPM + + # Remove temporal images used to build the ppm palette file. + rm ${FILES[*]} + + # Verify PPM palette existence. + cli_checkFiles "$PALETTE_PPM" + +} diff --git a/Scripts/Functions/Render/Backends/Svg/svg_convertPngTo.sh b/Scripts/Functions/Render/Backends/Svg/svg_convertPngTo.sh new file mode 100644 index 0000000..2217192 --- /dev/null +++ b/Scripts/Functions/Render/Backends/Svg/svg_convertPngTo.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# +# render_svg_convertPngTo.sh -- This function provides post-rendition +# actions to use the `convert' command of ImageMagick tool set. +# +# 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 render_svg_convertPngTo { + + # Get image formats. + local FORMATS=$(render_getConfigOption "$ACTION" '2') + + # Execute ImageMagick convertion. + for FORMAT in $FORMATS;do + cli_printMessage "${FILE}.${FORMAT}" --as-savedas-line + convert -quality 85 ${FILE}.png ${FILE}.${FORMAT} + done + +} diff --git a/Scripts/Functions/Render/Backends/Svg/svg_convertPngToBrands.sh b/Scripts/Functions/Render/Backends/Svg/svg_convertPngToBrands.sh new file mode 100644 index 0000000..d98bf39 --- /dev/null +++ b/Scripts/Functions/Render/Backends/Svg/svg_convertPngToBrands.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# +# render_svg_convertPngToBrands.sh -- This function provides +# last-rendition actions to produce CentOS brands. This function takes +# both The CentOS Symbol and The CentOS Type images and produces +# variation of them in different dimensions and formats using +# ImageMagick tool-set. +# +# 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 render_svg_convertPngToBrands { + + # Define height dimensions you want to produce brands for. + local SIZES="16 20 22 24 32 36 40 48 64 96 128 148 164 196 200 512" + + # Define image formats you want to produce brands for. + local FORMATS="png xpm pdf jpg tif" + + for SIZE in ${SIZES};do + + for FORMAT in ${FORMATS};do + + # Output action information. + cli_printMessage "${FILE}-${SIZE}.${FORMAT}" --as-creating-line + + # Convert and resize to create new file. + convert -support 0.8 -resize x${SIZE} ${FILE}.png ${FILE}-${SIZE}.${FORMAT} + + done + + # Create logo copy in 2 colors. + cli_printMessage "${FILE}-${SIZE}.xbm (`gettext "2 colors grayscale"`)" --as-creating-line + convert -resize x${SIZE} -colorspace gray -colors 2 ${FILE}.png ${FILE}-${SIZE}.xbm + + # Create logo copy in emboss effect. + cli_printMessage "${FILE}-${SIZE}-emboss.png" --as-creating-line + convert -resize x${SIZE} -emboss 1 ${FILE}.png ${FILE}-${SIZE}-emboss.png + + done + +} diff --git a/Scripts/Functions/Render/Backends/Svg/svg_convertPngToDm.sh b/Scripts/Functions/Render/Backends/Svg/svg_convertPngToDm.sh new file mode 100755 index 0000000..265ec4c --- /dev/null +++ b/Scripts/Functions/Render/Backends/Svg/svg_convertPngToDm.sh @@ -0,0 +1,177 @@ +#!/bin/bash +# +# render_svg_convertPngToDm.sh -- This function standardize production +# of display managers (e.g., Gdm and Kdm). This function copies all +# files needed into a temporal directory, realize expansion of +# translation markers and packs all the files into a tar.gz package +# that is used for installation. This function must be used as +# last-rendition action for Gdm and Kdm directory specific +# base-rendition actions. +# +# 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 render_svg_convertPngToDm { + + # Print separator line. + cli_printMessage '-' --as-separator-line + + # Initialize source and destination local variables. + local SRC='' + local DST='' + + # Initialize display manager type. + local DM=$(render_getConfigOption "${ACTION}" '2') + + # Initialize screen resolutions the display manager theme will be + # built for. + local RESOLUTION='' + local RESOLUTIONS=$(render_getConfigOption "${ACTION}" '3') + + # Verify screen resolutions. We cannot produce display manager + # theme if no screen resolution has been specified. + if [[ "$RESOLUTIONS" == '' ]];then + cli_printMessage "`gettext "There is no resolution information to process."`" --as-error-line + fi + + # Initialize theme information we are going to build the display + # manager theme for. + local THEME=$(cli_getPathComponent $ACTIONVAL --motif) + local THEME_NAME=$(cli_getPathComponent $ACTIONVAL --motif-name) + + # Initialize temporal directory where we collect all files needed + # in order to create the tar.gz file. This intermediate step is + # also needed in order to expand translation markers from XML and + # Desktop definitions. + local TMPDIR=$(cli_getTemporalFile 'dm') + + # Initialize source location for brands. This is the place where + # brand information needed to build the display manager theme is + # retrived from. + local BRANDS=$(cli_getRepoTLDir)/Identity/Images/Brands + + # Initialize source location for backgrounds. This is the place + # where background information needed to ubild the display manager + # theme is retrived from. + local BGS=$(cli_getRepoTLDir)/Identity/Images/Themes/${THEME}/Backgrounds/Img/Png + + # Initialize file variables. File variables are used build and + # process the file relation between source and target locations. + local FILE='' + local FILES='' + + # Define file relation between source and target locations, based + # on whether we are producing GDM or KDM. Presently, both GDM and + # KDM are very similar on files with the exception that GDM does + # use icons near actions buttons (e.g., shutdown, reboot, session, + # language) and KDM doesn't. + case ${DM} in + + Gdm ) + FILES="\ + ${BRANDS}/centos-symbol-resized-48.png:centos-symbol.png + ${OUTPUT}/release.png:centos-release.png + ${OUTPUT}/screenshot.png:screenshot.png + $(dirname $TEMPLATE)/GdmGreeterTheme.xml:${THEME_NAME}.xml + $(dirname $TEMPLATE)/GdmGreeterTheme.desktop:GdmGreeterTheme.desktop + $(dirname $TEMPLATE)/icon-language.png:icon-language.png + $(dirname $TEMPLATE)/icon-reboot.png:icon-reboot.png + $(dirname $TEMPLATE)/icon-session.png:icon-session.png + $(dirname $TEMPLATE)/icon-shutdown.png:icon-shutdown.png + " + ;; + + Kdm ) + FILES="\ + ${BRANDS}/centos-symbol-resized-48.png:centos-symbol.png + ${OUTPUT}/release.png:centos-release.png + ${OUTPUT}/screenshot.png:screenshot.png + $(dirname $TEMPLATE)/GdmGreeterTheme.xml:${THEME_NAME}.xml + $(dirname $TEMPLATE)/GdmGreeterTheme.desktop:GdmGreeterTheme.desktop + " + ;; + + * ) + cli_printMessage "`eval_gettext "The \\\"\\\$DM\\\" display manager is not supported yet."`" --as-error-line + ;; + esac + + for FILE in $FILES;do + + # Define source location. + SRC=$(echo $FILE | cut -d: -f1) + + # Define target location. + DST=${TMPDIR}/${THEME_NAME}/$(echo $FILE | cut -d: -f2) + + # Verify source files. + cli_checkFiles $SRC + + # Verify parent directory for target file. + if [[ ! -d $(dirname $DST) ]];then + mkdir -p $(dirname $DST) + fi + + # Copy files from source to target location. + cp ${SRC} ${DST} + + # Expand translation markers. + if [[ ${DST} =~ "\.(xml|desktop)$" ]];then + cli_replaceTMarkers "${DST}" + fi + + done + + # Move into temporal directory. + pushd $TMPDIR > /dev/null + + for RESOLUTION in $RESOLUTIONS;do + + # Verify background information. If it doesn't exist go on + # with the next one in the list. + if [[ ! -f $BGS/${RESOLUTION}-final.png ]];then + continue + fi + + # Print action message. + if [[ -f ${RESOLUTION}.tar.gz ]];then + cli_printMessage "${OUTPUT}/${RESOLUTION}.tar.gz" --as-updating-line + else + cli_printMessage "${OUTPUT}/${RESOLUTION}.tar.gz" --as-creating-line + fi + + # Copy background information. + cp $BGS/${RESOLUTION}-final.png ${THEME_NAME}/background.png + + # Create tar.gz file. + tar -czf ${RESOLUTION}.tar.gz ${THEME_NAME} + + # Move from temporal directory to its final location. + mv ${RESOLUTION}.tar.gz ${OUTPUT} + + done + + # Return to where we were initially. + popd > /dev/null + + # Remove temporal directory. + rm -r ${TMPDIR} + +} diff --git a/Scripts/Functions/Render/Backends/Svg/svg_convertPngToGrub.sh b/Scripts/Functions/Render/Backends/Svg/svg_convertPngToGrub.sh new file mode 100644 index 0000000..383674b --- /dev/null +++ b/Scripts/Functions/Render/Backends/Svg/svg_convertPngToGrub.sh @@ -0,0 +1,110 @@ +#!/bin/bash +# +# render_svg_convertPngToGrub.sh -- This function provides +# post-rendition action used to produce GRUB images. +# +# 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 render_svg_convertPngToGrub { + + # Define number of colors the images will be produced on. + local COLORS='14' + + # Define options using those passed to actions from pre-rendition + # configuration script. These options are applied to pnmremap when + # doing color reduction, so any option available for pnmremap + # command can be passed to renderSyslinux functionality. + local OPTIONS=$(render_getConfigOption "$ACTION" '2-') + + # Check options passed to action. This is required in order to + # aviod using options used already in this script. For example + # -verbose and -mapfile options. + for OPTION in $OPTIONS;do + # Remove anything after equal sign inside option. + OPTION=$(echo -n $OPTION | cut -d'=' -f1) + if [[ "$OPTION" =~ "-(mapfile|verbose)" ]];then + cli_printMessage "`eval_gettext "The \\\"\\\$OPTION\\\" option is already used."`" --as-error-line + fi + done + + # Define file name prefix. + local PREFIX="-${COLORS}c" + + # Redefine file name prefix using options as reference. This is + # useful to differenciate final files produced using + # Floyd-Steinberg dithering and files which are not. + if [[ "$OPTIONS" =~ '-floyd' ]];then + PREFIX="${PREFIX}-floyd" + fi + + # Define absolute path to GPL palette. This palettes should have + # 14 colors only. For more information on this see the GRUB's + # documentation. + local PALETTE_GPL=${MOTIF_DIR}/Palettes/grub.gpl + + # Verify GPL palette existence. If it doesn't exist copy the one + # provided by the design model and expand translation markers in + # it. + if [[ ! -f $PALETTE_GPL ]];then + cp ${MODEL_BASEDIR}/${FLAG_THEME_MODEL}/Palettes/grub.gpl ${PALETTE_GPL} + cli_replaceTMarkers ${PALETTE_GPL} + fi + + # Define absolute path to PPM palette. The PPM palette is built + # from source palette (PALETTE_GPL) and provides the color + # information understood by `ppmremap', the program used to + # produce images in a specific amount of colors. + local PALETTE_PPM=$(cli_getTemporalFile "grub.ppm") + + # Create image in Netpbm superformat (PNM). The PNM image file is + # created from the PNG image rendered previously as centos-art + # base-rendition output. The PNM image is an intermediate format + # used to manipulate images through Netpbm tools. + cli_printMessage "${FILE}.pnm" --as-savedas-line + pngtopnm -verbose \ + < ${FILE}.png 2>${FILE}.log > ${FILE}.pnm + + # Print the path to GPL palette. + cli_printMessage "$PALETTE_GPL" --as-palette-line + + # Create PPM palette using GPL palette. + render_svg_convertGplToPpm "$PALETTE_GPL" "$PALETTE_PPM" "$COLORS" + + # Reduce colors as specified in PPM palette. Here we use the PPM + # palette to enforce the color position in the image index and the + # Floyd-Steinberg dithering in order to improve color reduction. + cli_printMessage "${FILE}${PREFIX}.ppm" --as-savedas-line + pnmremap -verbose -mapfile=$PALETTE_PPM $OPTIONS \ + < ${FILE}.pnm 2>>${FILE}.log > ${FILE}${PREFIX}.ppm + + # Remove PPM palette. It is no longer needed. + if [[ -f ${PALETTE_PPM} ]];then + rm $PALETTE_PPM + fi + + # Create the 14 colors xpm.gz file. + cli_printMessage "${FILE}${PREFIX}.xpm.gz" --as-savedas-line + ppmtoxpm \ + < ${FILE}${PREFIX}.ppm 2>>${FILE}.log > ${FILE}.xpm \ + && gzip --force ${FILE}.xpm \ + && mv ${FILE}.xpm.gz ${FILE}${PREFIX}.xpm.gz + +} diff --git a/Scripts/Functions/Render/Backends/Svg/svg_convertPngToKsplash.sh b/Scripts/Functions/Render/Backends/Svg/svg_convertPngToKsplash.sh new file mode 100755 index 0000000..69ea60e --- /dev/null +++ b/Scripts/Functions/Render/Backends/Svg/svg_convertPngToKsplash.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# +# render_svg_convertPngToKsplash.sh -- This function collects KDE +# splash (KSplash) required files and creates a tar.gz package that +# groups them all together. Use this function as last-rendition action +# for KSplash base-rendition action. +# +# 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 render_svg_convertPngToKsplash { + + local -a SRC + local -a DST + local FONT='' + local COUNT=0 + + # Define font used to print bottom splash message. + FONT=$(cli_getRepoTLDir)/Identity/Fonts/DejaVuLGCSans-Bold.ttf + + # Check existence of font file. + cli_checkFiles "$FONT" + + # Define absolute source location of files. + SRC[0]="${OUTPUT}/splash_top.png" + SRC[1]="${OUTPUT}/splash_active_bar.png" + SRC[2]="${OUTPUT}/splash_inactive_bar.png" + SRC[3]="${OUTPUT}/splash_bottom.png" + SRC[4]="$(dirname $TEMPLATE)/Theme.rc" + + # Check absolute source location of files. + cli_checkFiles "${SRC[@]}" + + # Define relative target location of files. + DST[0]="${OUTPUT}/splash_top.png" + DST[1]="${OUTPUT}/splash_active_bar.png" + DST[2]="${OUTPUT}/splash_inactive_bar.png" + DST[3]="${OUTPUT}/splash_bottom.png" + DST[4]="${OUTPUT}/Theme.rc" + + # Print action message. + cli_printMessage "${OUTPUT}/Preview.png" --as-creating-line + + # Create `Preview.png' image. + convert -append ${SRC[0]} ${SRC[1]} ${SRC[3]} ${OUTPUT}/Preview.png + + # Add bottom text to Preview.png image. The text position was set + # inside an image of 400x300 pixels. If you change the final + # preview image dimension, you probably need to change the text + # position too. + mogrify -draw 'text 6,295 "KDE is up and running."' \ + -fill \#ffffff \ + -font $FONT \ + ${OUTPUT}/Preview.png + + # Copy `Theme.rc' file. + cp ${SRC[4]} ${DST[4]} + + # Apply common translation markers to Theme.rc file. + cli_replaceTMarkers "${DST[4]}" + +} diff --git a/Scripts/Functions/Render/Backends/Svg/svg_convertPngToSyslinux.sh b/Scripts/Functions/Render/Backends/Svg/svg_convertPngToSyslinux.sh new file mode 100755 index 0000000..16b354c --- /dev/null +++ b/Scripts/Functions/Render/Backends/Svg/svg_convertPngToSyslinux.sh @@ -0,0 +1,189 @@ +#!/bin/bash +# +# render_svg_convertPngToSyslinux.sh -- This function provides post-rendition +# action used to produce LSS16 images, the images used by isolinux. +# +# This function uses three different formats to handle the same color +# information. Initially, the color information is defined with GIMP +# (The GNU Image Manipulation Program) as a palette of color. This +# palette of colors contains 16 colors only and is saved in a file +# named `syslinux.gpl. +# +# The `syslinux.gpl' file is used to build two other files: the +# `syslinux.ppm' file and the `syslinux.hex' file. The `syslinux.ppm' +# file is used to reduce a full color PNG image to the amount of +# colors it specifies (i.e., 16 colors). Later, with the 16 color +# image already created, the `syslinux.hex' file is used to build the +# LSS16 image. +# +# In order to produce images in LSS16 format correctly, it is needed +# that both the `syslinux.ppm' and `syslinux.hex' files contain the +# same color information. This is, both `syslinux.ppm' and +# `syslinux.hex' shoud represent the same color values and the same +# color index. +# +# This function save you the work of preparing both `syslinux.ppm' and +# `syslinux.hex'. Instead, you only need to prepare the `syslinux.gpl' +# file with the color information you want to produce images. +# +# In order for this function to work, the `syslinux.gpl' file should +# have a format similar to the following: +# +# GIMP Palette +# Name: TreeFlower-4-Syslinux +# Columns: 16 +# # +# 10 22 40 0a1628 +# 9 28 52 091c34 +# 16 34 63 10223f +# 20 37 67 142543 +# 15 39 74 0f274a +# 12 45 85 0c2d55 +# 20 43 78 142b4e +# 255 255 255 ffffff +# 21 51 95 15335f +# 41 52 70 293446 +# 32 76 141 204c8d +# 77 90 107 4d5a6b +# 143 154 167 8f9aa7 +# 128 179 255 80b3ff +# 194 200 202 c2c8ca +# 231 241 255 e7f1ff +# +# 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 render_svg_convertPngToSyslinux { + + # Define number of colors the images will be produced on. + local COLORS='16' + + # Define options using those passed to actions from pre-rendition + # configuration script. These options are applied to pnmremap when + # doing color reduction, so any option available for pnmremap + # command can be passed to renderSyslinux functionality. + local OPTIONS=$(render_getConfigOption "$ACTION" '2-') + + # Check options passed to action. This is required in order to + # aviod using options already used in this script. For example + # -verbose and -mapfile options. + for OPTION in $OPTIONS;do + # Remove anything after equal sign inside option. + OPTION=$(echo $OPTION | cut -d'=' -f1) + if [[ "$OPTION" =~ "-(mapfile|verbose)" ]];then + cli_printMessage "`eval_gettext "The \\\"\\\$OPTION\\\" option is already used."`" --as-error-line + fi + done + + # Define default file name prefix for 16 colors images. + local PREFIX="-${COLORS}c" + + # Re-define 16 colors images default file name prefix using + # options as reference. This is useful to differenciate final + # files produced using Floyd-Steinberg dithering and final files + # which are not. + if [[ "$OPTIONS" =~ '-floyd' ]];then + PREFIX="${PREFIX}-floyd" + fi + + # Define absolute path to GPL palette. The GPL palette defines the + # color information used to build syslinux images. This palette + # should be set to 16 colors and, as specified in isolinux + # documentation, the background color should be indexed on + # position 0 and the forground in position 7 (see + # /usr/share/doc/syslinux-X.XX/isolinux.doc, for more + # information.) + local PALETTE_GPL=${MOTIF_DIR}/Palettes/syslinux.gpl + + # Verify GPL palette existence. If it doesn't exist copy the one + # provided by the design model and expand translation markers in + # it. + if [[ ! -f $PALETTE_GPL ]];then + cp ${MODEL_BASEDIR}/${FLAG_THEME_MODEL}/Palettes/syslinux.gpl ${PALETTE_GPL} + cli_replaceTMarkers ${PALETTE_GPL} + fi + + # Define absolute path to PPM palette. The PPM palette is built + # from source palette (PALETTE_GPL) and provides the color + # information understood by `ppmremap', the program used to + # produce images in a specific amount of colors. + local PALETTE_PPM=$(cli_getTemporalFile "syslinux.ppm") + + # Define the HEX palette. The HEX palette is built from source + # palette (PALETTE_GPL) and provides the color information in the + # format understood by `ppmtolss16', the program used to produce + # images in LSS16 format. The HEX palette stores just one line + # with the color information as described in isolinux + # documentation (i.e #RRGGBB=0 #RRGGBB=1 ... [all values in the + # same line]) + local PALETTE_HEX=$(cli_getTemporalFile "syslinux.hex") + + # Create image in Netpbm superformat (PNM). The PNM image file is + # created from the PNG image rendered previously as centos-art + # base-rendition output. The PNM image is an intermediate format + # used to manipulate images through Netpbm tools. + cli_printMessage "${FILE}.pnm" --as-savedas-line + pngtopnm -verbose \ + < ${FILE}.png 2>${FILE}.log > ${FILE}.pnm + + # Print the path to GPL palette. + cli_printMessage "$PALETTE_GPL" --as-palette-line + + # Create PPM palette using GPL palette. + render_svg_convertGplToPpm "$PALETTE_GPL" "$PALETTE_PPM" "$COLORS" + + # Create HEX palette using GPL palette. + render_svg_convertGplToHex "$PALETTE_GPL" "$PALETTE_HEX" "$COLORS" + + # Reduce colors as specified in PPM palette. Here we use the PPM + # palette to enforce the color position in the image index and the + # Floyd-Steinberg dithering in order to improve color reduction. + cli_printMessage "${FILE}${PREFIX}.pnm" --as-savedas-line + pnmremap -verbose -mapfile=$PALETTE_PPM $OPTIONS \ + < ${FILE}.pnm 2>> ${FILE}.log > ${FILE}${PREFIX}.pnm + + # Create LSS16 image. + cli_printMessage "${FILE}${PREFIX}.lss" --as-savedas-line + ppmtolss16 $(cat $PALETTE_HEX) \ + < ${FILE}${PREFIX}.pnm 2>>${FILE}.log > ${FILE}${PREFIX}.lss + + # Remove HEX palette. It is no longer needed. + if [[ -f ${PALETTE_HEX} ]];then + rm $PALETTE_HEX + fi + + # Create the PPM image indexed to 16 colors. Also the colormap + # used in the LSS16 image is saved on ${FILE}.log; this is useful to + # verify the correct order of colors in the image index. + cli_printMessage "${FILE}${PREFIX}.ppm" --as-savedas-line + lss16toppm -map \ + < ${FILE}${PREFIX}.lss 2>>${FILE}.log > ${FILE}${PREFIX}.ppm + + # Create the 16 colors PNG image. + cli_printMessage "${FILE}${PREFIX}.png" --as-savedas-line + pnmtopng -verbose -palette=$PALETTE_PPM \ + < ${FILE}${PREFIX}.pnm 2>>${FILE}.log > ${FILE}${PREFIX}.png + + # Remove PPM palette. It is no longer needed. + if [[ -f ${PALETTE_PPM} ]];then + rm $PALETTE_PPM + fi + +} diff --git a/Scripts/Functions/Render/Backends/Svg/svg_convertPngToThumbnail.sh b/Scripts/Functions/Render/Backends/Svg/svg_convertPngToThumbnail.sh new file mode 100755 index 0000000..b69088c --- /dev/null +++ b/Scripts/Functions/Render/Backends/Svg/svg_convertPngToThumbnail.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# +# render_svg_convertPngToThumbnail.sh -- This function provides post-rendition to +# create thumbnails from images produced by centos-art base-rendition. +# Thumbnails are created in PNG and JPG format for you to decide which +# is the more appropriate one. When no size is specified, thumbnails +# are created at 250 pixels width and height is automatically +# calculated to match the image ratio. +# +# 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 render_svg_convertPngToThumbnail { + + # Get image size. + local SIZES=$(render_getConfigOption "$ACTION" '2-') + + # Check image sizes and do convertion. + if [[ "$SIZES" == "" ]];then + SIZES='250' + fi + + # Check base file existence. + cli_checkFiles "${FILE}.png" + + # Create thumbnails. + for SIZE in $SIZES;do + cli_printMessage "${FILE}-thumb-${SIZE}.png" --as-savedas-line + convert -thumbnail ${SIZE} ${FILE}.png ${FILE}-thumb-${SIZE}.png + cli_printMessage "${FILE}-thumb-${SIZE}.jpg" --as-savedas-line + convert -thumbnail ${SIZE} ${FILE}-thumb-${SIZE}.png ${FILE}-thumb-${SIZE}.jpg + cli_printMessage "${FILE}-thumb-${SIZE}.pdf" --as-savedas-line + convert -thumbnail ${SIZE} ${FILE}-thumb-${SIZE}.png ${FILE}-thumb-${SIZE}.pdf + done + +} diff --git a/Scripts/Functions/Render/Backends/Svg/svg_doLastActions.sh b/Scripts/Functions/Render/Backends/Svg/svg_doLastActions.sh new file mode 100644 index 0000000..821628c --- /dev/null +++ b/Scripts/Functions/Render/Backends/Svg/svg_doLastActions.sh @@ -0,0 +1,72 @@ +#!/bin/bash +# +# render_svg_doLastActions.sh -- This function performs +# last-rendition actions 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 render_svg_doLastActions { + + # Verify position of file being produced in the list of files been + # currently processed. + if [[ $THIS_FILE_DIR == $NEXT_FILE_DIR ]];then + return + fi + + local ACTION='' + + # Redefine SVG last-rendition actions as local to avoid undesired + # concatenation when massive rendition is performed. + local -a LASTACTIONS + + # Define SVG directory-specific actions. This is required in order + # to provide a predictable way of producing content inside the + # repository and save you the time of writing long several + # commands each time you need to produce images inside the + # repository. + if [[ $FLAG_DONT_DIRSPECIFIC == 'false' ]];then + if [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Gdm/.+\.svg$" ]];then + LASTACTIONS[((++${#LASTACTIONS[*]}))]='svg_convertPngToDm:Gdm:800x600 1024x768 1280x1024 1360x768 2048x1536 2560x1240' + elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Kdm/.+\.svg$" ]];then + LASTACTIONS[((++${#LASTACTIONS[*]}))]='svg_convertPngToDm:Kdm:800x600 1024x768 1280x1024 1360x768 2048x1536 2560x1240' + elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Ksplash/.+\.svg$" ]];then + LASTACTIONS[((++${#LASTACTIONS[*]}))]='svg_convertPngToKsplash:' + fi + fi + + # Define SVG last-rendition actions. Since last-rendition makes + # use of all files in the output directory structure and + # directory-specific rendition modifies all the files in the + # output directory structure as well, these actions must be + # defined after the directory-specific definition. Otherwise, + # modifications impossed by these actions may interfier the whole + # purpose of having a directory-specific rendition. + [[ $FLAG_LASTRENDITION != '' ]] && LASTACTIONS[((++${#LASTACTIONS[*]}))]="doLastActions:(png|jpg):${FLAG_LASTRENDITION}" + + # At this point centos-art.sh should be producing the last file + # from the same unique directory structure, so, before producing + # images for the next directory structure lets execute the list of + # last-rendition actions for the current directory structure. + for ACTION in "${LASTACTIONS[@]}"; do + ${FUNCNAM}_$(echo "$ACTION" | cut -d: -f1) + done + +} diff --git a/Scripts/Functions/Render/Backends/Svg/svg_doPostActions.sh b/Scripts/Functions/Render/Backends/Svg/svg_doPostActions.sh new file mode 100644 index 0000000..d099fab --- /dev/null +++ b/Scripts/Functions/Render/Backends/Svg/svg_doPostActions.sh @@ -0,0 +1,75 @@ +#!/bin/bash +# +# render_svg_doPostActions.sh -- This function performs +# post-rendition actions 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 render_svg_doPostActions { + + local ACTION='' + + # Redefine SVG post-rendition actions as local to avoid undesired + # concatenation when massive rendition is performed. + local -a POSTACTIONS + + # Define default comment written to base-rendition output. + local COMMENT="`gettext "Created in CentOS Arwork Repository"` ($(cli_printUrl '--projects-artwork'))" + + # Define SVG post-rendition actions. Since these actions are + # applied to base-rendition output and base-rendition output is + # used as reference to perform directory-specific rendition, these + # action must be defined before directory-specific rendition. + # Otherwise it wouldn't be possible to propagate changes impossed + # by these actions to new files produced as result of + # directory-specific rendition. + POSTACTIONS[((++${#POSTACTIONS[*]}))]="doPostActions:png:mogrify -comment '$COMMENT'" + [[ $FLAG_POSTRENDITION != '' ]] && POSTACTIONS[((++${#POSTACTIONS[*]}))]="doPostActions:png:${FLAG_POSTRENDITION}" + + # Define SVG directory-specific rendition. Directory-specfic + # rendition provides a predictable way of producing content inside + # the repository. + if [[ $FLAG_DONT_DIRSPECIFIC == 'false' ]];then + if [[ $TEMPLATE =~ "Backgrounds/.+\.svg$" ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]='svg_convertPngTo:jpg' + POSTACTIONS[((++${#POSTACTIONS[*]}))]='svg_groupBy:png jpg' + elif [[ $TEMPLATE =~ "Concept/.+\.svg$" ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]='svg_convertPngTo:jpg pdf' + POSTACTIONS[((++${#POSTACTIONS[*]}))]='svg_convertPngToThumbnail:250' + elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Syslinux/.+\.svg$" ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]='svg_convertPngToSyslinux:' + POSTACTIONS[((++${#POSTACTIONS[*]}))]='svg_convertPngToSyslinux:-floyd' + elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Grub/.+\.svg$" ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]='svg_convertPngToGrub:' + POSTACTIONS[((++${#POSTACTIONS[*]}))]='svg_convertPngToGrub:-floyd' + elif [[ $TEMPLATE =~ "Posters/.+\.svg$" ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]='svg_convertPngTo:jpg pdf' + elif [[ $TEMPLATE =~ "trunk/Identity/Models/Brands/.+\.svg$" ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]='svg_convertPngToBrands' + fi + fi + + # Execute SVG post-rendition actions. + for ACTION in "${POSTACTIONS[@]}"; do + ${FUNCNAM}_$(echo "$ACTION" | cut -d: -f1) + done + +} diff --git a/Scripts/Functions/Render/Backends/Svg/svg_getColors.sh b/Scripts/Functions/Render/Backends/Svg/svg_getColors.sh new file mode 100755 index 0000000..02340a8 --- /dev/null +++ b/Scripts/Functions/Render/Backends/Svg/svg_getColors.sh @@ -0,0 +1,153 @@ +#!/bin/bash +# +# render_svg_getColors.sh -- This function takes one palette produced +# by Gimp (e.g., syslinux.gpl) as input and outputs a list of colors +# in the specified format. In order for this function to output the +# color in the format specified, it is needed that the fourth column +# in the gpl palette be set in the `rrggbb' format and the appropriate +# conversion be implemented here. +# +# Notice that using both the `--head' and `--tail' options it is +# possible to control how many consecutive items does the list of +# colors is going to have. It is possible to output all colors in the +# list, or a consecutive range of them. +# +# 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 render_svg_getColors { + + # Define short options. + local ARGSS='' + + # Define long options. + local ARGSL='head:,tail:,format:' + + # Initialize ARGUMENTS with an empty value and set it as local + # variable to this function scope. + local ARGUMENTS='' + + # Initialize both head and tail values to return the first line of + # color information from the palette. + local HEAD=1 + local TAIL=1 + + # Initialize format value used as default when no format option be + # provided. + local FORMAT='rrggbb' + + # Initialize list of colors. + local COLORS='' + + # Redefine ARGUMENTS variable using current positional parameters. + cli_parseArgumentsReDef "$@" + + # Redefine ARGUMENTS variable using getopt output. + cli_parseArguments + + # Redefine positional parameters using ARGUMENTS variable. + eval set -- "$ARGUMENTS" + + # Look for options passed through positional parameters. + while true;do + + case "$1" in + + --head ) + HEAD=$2 + shift 2 + ;; + + --tail ) + TAIL=$2 + shift 2 + ;; + + --format ) + FORMAT=$2 + shift 2 + ;; + + -- ) + shift 1 + break + ;; + esac + done + + # Define path to gpl palette. This is the first file we use to + # retrive color information from. Only the first file provided + # will be used. + local PALETTE=$(echo $@ | cut -d' ' -f1) + + if [[ $PALETTE == '' ]];then + + # Define palette path inside the theme's artistic motif. + local MOTIF_PALETTE=$(cli_getRepoTLDir)/Identity/Images/Themes/$(cli_getPathComponent $ACTIONVAL --motif)/Palettes/grub.gpl + + # Define palette path inside the theme's design model. + local MODEL_PALETTE=$(cli_getRepoTLDir)/Identity/Models/Themes/${THEME_MODEL_NAME}/Palettes/grub.gpl + + # Redefine default background color using palettes provided by + # artistic motif first, and design model later. Assuming none + # of them is present, use The CentOS Project default color + # then. + if [[ -f $MOTIF_PALETTE ]];then + COLORS=$(render_svg_getColors $MOTIF_PALETTE --head=1 --tail=1) + elif [[ -f $MODEL_PALETTE ]];then + COLORS=$(render_svg_getColors $MODEL_PALETTE --head=1 --tail=1) + else + COLORS='#204c8d' + fi + + else + + # Retrive the fourth column from GPL palette. The fourth + # column of a GPL palette contains the palette commentary + # field. The palette commentary field can be anything, but for + # the sake of our own convenience we use it to store the color + # value in hexadecimal format (e.g., rrggbb). Notice that you + # can put your comments from the fifth column on using an + # space as field separator. + COLORS=$(sed -r '1,/^#/d' $PALETTE \ + | awk '{ printf "%s\n", $4 }' | head -n $HEAD | tail -n $TAIL) + + fi + + # Implement color formats convertions from rrggbb to other formats + # that you might need to use. + for COLOR in $COLORS;do + + case $FORMAT in + + rrggbb|* ) + if [[ ! $COLOR =~ '^#' ]];then + COLOR="#${COLOR}" + fi + ;; + + esac + + # Output color value. + echo "$COLOR" + + done + +} diff --git a/Scripts/Functions/Render/Backends/Svg/svg_groupBy.sh b/Scripts/Functions/Render/Backends/Svg/svg_groupBy.sh new file mode 100755 index 0000000..f6c43fa --- /dev/null +++ b/Scripts/Functions/Render/Backends/Svg/svg_groupBy.sh @@ -0,0 +1,69 @@ +#!/bin/bash +# +# render_svg_groupBy.sh -- This function provides post-rendition +# action to group files inside directories named as their file +# extensions. For example: if the current file is a .png file, it is +# moved inside a Png/ directory; if the current file is a .jpg file, +# it is stored inside a Jpg/ directory, and so on. +# +# For this function to work correctly, you need to specify which file +# type you want to group. This is done in the post-rendition ACTIONS +# array inside the appropriate `render.conf.sh' pre-configuration +# script. This function cannot be used as last-rendition action. +# +# 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 render_svg_groupBy { + + local SOURCE='' + local TARGET='' + + # Sanitate file types passed from render.conf.sh pre-rendition + # configuration script. + local FORMATS=$(render_getConfigOption "$ACTION" '2-') + + for FORMAT in $FORMATS;do + + # Redifine source file we want to move. + SOURCE=${FILE}.${FORMAT} + + # Define target directory where source file will be moved + # into. + TARGET=$(dirname "$FILE")/$(cli_getRepoName $FORMAT -d) + + # Check existence of source file. + cli_checkFiles $SOURCE + + # Check existence of target directory. + if [[ ! -d $TARGET ]];then + mkdir -p $TARGET + fi + + # Redifine file path to add file and its type. + TARGET=${TARGET}/$(cli_getRepoName $FILE -f).${FORMAT} + + # Move file into its final location. + cli_printMessage "$TARGET" --as-movedto-line + mv ${SOURCE} ${TARGET} + + done + +} diff --git a/Scripts/Functions/Render/Backends/Xhtml/xhtml.sh b/Scripts/Functions/Render/Backends/Xhtml/xhtml.sh new file mode 100755 index 0000000..09b78be --- /dev/null +++ b/Scripts/Functions/Render/Backends/Xhtml/xhtml.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# +# render_xhtml.sh -- This function performs base-rendition action 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 render_xhtml { + + # Print action message. + if [[ -f ${FILE}.xhtml ]];then + cli_printMessage "${FILE}.xhtml" --as-updating-line + else + cli_printMessage "${FILE}.xhtml" --as-creating-line + fi + + # Create xhtml file from instance. + cp $INSTANCE ${FILE}.xhtml + + # Produce plaintext output from html outout. + render_xhtml_convertToText + +} diff --git a/Scripts/Functions/Render/Backends/Xhtml/xhtml_convertToText.sh b/Scripts/Functions/Render/Backends/Xhtml/xhtml_convertToText.sh new file mode 100755 index 0000000..2821bed --- /dev/null +++ b/Scripts/Functions/Render/Backends/Xhtml/xhtml_convertToText.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# +# render_svg_convertHtmlToText.sh -- This function takes one HTML file +# and produces one plain-text file (i.e., without markup inside). +# +# 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 render_xhtml_convertToText { + + # Verify existence of HTML file. + cli_checkFiles ${FILE}.xhtml + + local COMMAND='' + local OPTIONS='' + + # Define the command path to text-based web browser and options + # used to produce plain-text files. Most of these programs have a + # dump option that print formatted plain-text versions of given + # HTML file to stdout. + if [[ -x '/usr/bin/lynx' ]];then + COMMAND='/usr/bin/lynx' + OPTIONS='-force_html -nolist -width 70 -dump' + elif [[ -x '/usr/bin/elinks' ]];then + COMMAND='/usr/bin/elinks' + OPTIONS='-force_html -no-numbering -no-references -width 70 -dump' + elif [[ -x '/usr/bin/w3m' ]];then + COMMAND='/usr/bin/w3m' + OPTIONS='-dump' + fi + + if [[ $COMMAND != '' ]];then + + # Print action message. + if [[ -f ${FILE}.txt ]];then + cli_printMessage "${FILE}.txt" --as-updating-line + else + cli_printMessage "${FILE}.txt" --as-creating-line + fi + + # Convert from HTML to plain-text without markup. + ${COMMAND} ${OPTIONS} ${FILE}.xhtml > ${FILE}.txt + + else + cli_printMessage "`gettext "No way to convert from HTML to plain-text found."`" --as-error-line + fi + +} diff --git a/Scripts/Functions/Render/render_docbook.sh b/Scripts/Functions/Render/render_docbook.sh deleted file mode 100755 index 3fe6649..0000000 --- a/Scripts/Functions/Render/render_docbook.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -# -# render_docbook.sh -- This function performs base-rendition action -# for DocBook 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 render_docbook { - - # Produce xhtml output from docbook template instance using XSL - # stylesheets as reference. - render_docbook_convertToXhtml - - # Produce plaintext output from html outout. - render_xhtml_convertToText - -} diff --git a/Scripts/Functions/Render/render_docbook_convertToXhtml.sh b/Scripts/Functions/Render/render_docbook_convertToXhtml.sh deleted file mode 100755 index 657ba90..0000000 --- a/Scripts/Functions/Render/render_docbook_convertToXhtml.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -# -# render_docbook_convertToXhtml.sh -- This function produces XHTML -# output from docbook template instance using XSL stylesheets as -# reference. -# -# 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 render_docbook_convertToXhtml { - - # Print action message. - if [[ -f ${FILE}.xhtml ]];then - cli_printMessage "${FILE}.xhtml" --as-updating-line - else - cli_printMessage "${FILE}.xhtml" --as-creating-line - fi - - # Define list of XSL stylesheets. - local XSL='/usr/share/sgml/docbook/xsl-stylesheets/xhtml/docbook.xsl' - - # Produce xhtml output from docbook template instance using XSL - # stylesheets as reference. - xsltproc ${XSL} $INSTANCE > ${FILE}.xhtml - -} diff --git a/Scripts/Functions/Render/render_svg.sh b/Scripts/Functions/Render/render_svg.sh deleted file mode 100644 index 1ed14b2..0000000 --- a/Scripts/Functions/Render/render_svg.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -# -# render_svg.sh -- This function performs base-rendition action 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 render_svg { - - # Initialize the export id used inside design templates. This - # value defines the design area we want to export. - local EXPORTID='CENTOSARTWORK' - - # Verify the export id. - render_svg_checkModelExportId "$INSTANCE" "$EXPORTID" - - # Check existence of external files. Inside design templates and - # their instances, external files are used to refere the - # background information required by the design template. If such - # background information is not available the image is produced - # without background information. This is something that need to - # be avoided. - render_svg_checkModelAbsref "$INSTANCE" - - # Render template instance using inkscape and save the output. - local INKSCAPE_OUTPUT="$(\ - inkscape $INSTANCE --export-id=$EXPORTID --export-png=${FILE}.png)" - - # Modify output from inkscape to fit the centos-art.sh script - # output visual style. - cli_printMessage "$(echo "$INKSCAPE_OUTPUT" | egrep '^Area' \ - | sed -r "s!^Area!`gettext "Area"`:!")" - cli_printMessage "$(echo "$INKSCAPE_OUTPUT" | egrep '^Background' \ - | sed -r "s!^Background (RRGGBBAA):(.*)!`gettext "Background"`: \1 \2!")" - cli_printMessage "$(echo "$INKSCAPE_OUTPUT" | egrep '^Bitmap saved as' \ - | sed -r "s!^Bitmap saved as:!`gettext "Saved as"`:!")" - -} diff --git a/Scripts/Functions/Render/render_svg_checkColorAmount.sh b/Scripts/Functions/Render/render_svg_checkColorAmount.sh deleted file mode 100755 index f4a0b22..0000000 --- a/Scripts/Functions/Render/render_svg_checkColorAmount.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -# -# render_svg_checkColorAmount.sh -- This function verifies whether the -# list of colors provided in the first argument matches the amount of -# colors specified by the second argument. -# -# 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 render_svg_checkColorAmount { - - # Define list of colors. - local COLORS=$1 - - # Define the amount of colors the list provided must have, in - # order to be considered as valid. - local NUMBER=$2 - - # Verify amount of colors provided in the list. - if [[ $(echo "$COLORS" | wc -l) -ne $NUMBER ]];then - cli_printMessage "`gettext "The palette does not have the correct number of colors."`" --as-error-line - fi - -} diff --git a/Scripts/Functions/Render/render_svg_checkColorFormats.sh b/Scripts/Functions/Render/render_svg_checkColorFormats.sh deleted file mode 100755 index e10d3ab..0000000 --- a/Scripts/Functions/Render/render_svg_checkColorFormats.sh +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/bash -# -# render_svg_checkColorFormats.sh -- This function verifies formats of -# colors (i.e., the way color information is specified). -# -# 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 render_svg_checkColorFormats { - - # Define short options. - local ARGSS='' - - # Define long options. - local ARGSL='format:' - - # Initialize ARGUMENTS with an empty value and set it as local - # variable to this function scope. - local ARGUMENTS='' - - # Initialize pattern used for color sanitation. - local PATTERN='^#[0-9a-f]{6}$' - - # Redefine ARGUMENTS variable using current positional parameters. - cli_parseArgumentsReDef "$@" - - # Redefine ARGUMENTS variable using getopt output. - cli_parseArguments - - # Redefine positional parameters using ARGUMENTS variable. - eval set -- "$ARGUMENTS" - - # Look for options passed through positional parameters. - while true;do - - case "$1" in - - --format ) - - case "$2" in - - rrggbb|*) - PATTERN='^#[0-9a-f]{6}$' - ;; - - esac - shift 2 - ;; - - -- ) - shift 1 - break - ;; - esac - done - - # Define the location we want to apply verifications to. - local COLOR='' - local COLORS="$@" - - # Loop through colors and perform format verification as specified - # by pattern. - for COLOR in $COLORS;do - - if [[ ! $COLOR =~ $PATTERN ]];then - cli_printMessage "`eval_gettext "The \\\"\\\$COLOR\\\" string is not a valid color code."`" --as-error-line - fi - - done - -} diff --git a/Scripts/Functions/Render/render_svg_checkModelAbsref.sh b/Scripts/Functions/Render/render_svg_checkModelAbsref.sh deleted file mode 100755 index 1841d0c..0000000 --- a/Scripts/Functions/Render/render_svg_checkModelAbsref.sh +++ /dev/null @@ -1,129 +0,0 @@ -#!/bin/bash -# -# render_svg_checkModelAbsref.sh -- This function retrives absolute files -# and checks their existence. In order for design templates to point -# different artistic motifs, design templates make use of external -# files which point to specific artistic motif background images. If -# such external files don't exist, try to create the background image -# required by cropping a higher background image (e.g., -# 2048x1536-final.png). If this isn't possible neither, then create -# the background image using a plain color and crop from it then. We -# can't go on without the required background information. -# -# 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 render_svg_checkModelAbsref { - - local FILE='' - local BG_DST_FILES='' - local BG_DST_FILE='' - local BG_DST_FILE_WIDTH='' - local BG_DST_FILE_HEIGHT='' - local BG_SRC_FILE='' - local BG_SRC_FILE_COLOR='' - local BG_SRC_FILE_WIDTH='' - local BG_SRC_FILE_HEIGHT='' - - # Define absolute path to the translated instance of design model. - FILE="$1" - - # Verify existence of file we need to retrive absolute paths from. - cli_checkFiles "$FILE" - - # Retrive absolute paths from file. - BG_DST_FILES=$(egrep "(sodipodi:absref|xlink:href)=\"${HOME}.+" $FILE \ - | sed -r "s,.+=\"(${HOME}.+\.png)\".*,\1," | sort | uniq) - - # Verify absolute paths retrived from file. - for BG_DST_FILE in $BG_DST_FILES;do - - # Print action - cli_printMessage "$BG_DST_FILE" --as-checking-line - - if [[ ! -a $BG_DST_FILE ]];then - - # Define the source background file, the image file will - # crop when no specific background informatio be available - # for using. Generally, this is the most reusable - # background file inside the artistic motifs (e.g,. the - # `2048x1536-final.png' file). We can use this image file - # to create almost all artworks inside The CentOS - # Distribution visual manifestation when - # resolution-specific backgrounds don't exist. - BG_SRC_FILE=$(echo $BG_DST_FILE \ - | sed -r "s!(.+)/[[:digit:]]+x[[:digit:]]+(-final\.png)!\1/2048x1536\2!") - - # Verify existence of source background file. If the file - # doesn't exist create it using The CentOS Project default - # background color information, as specified in its - # corporate identity manual. - if [[ ! -f $BG_SRC_FILE ]];then - - # Define plain color that will be used as background. - BG_SRC_FILE_COLOR=$(render_svg_getColors) - - # Verify format of color value. - render_svg_checkColorFormats $BG_SRC_FILE_COLOR --format='rrggbb' - - # Define width for the source background file the - # required background information is cropped from. - BG_SRC_FILE_WIDTH=$(echo $BG_SRC_FILE \ - | sed -r 's!.+/([[:digit:]]+)x[[:digit:]]+-final\.png!\1!') - - # Define height for the source background file the - # required background information is cropped from. - BG_SRC_FILE_HEIGHT=$(echo $BG_SRC_FILE \ - | sed -r 's!.+/[[:digit:]]+x([[:digit:]]+)-final\.png!\1!') - - # Print action message. - cli_printMessage "${BG_SRC_FILE} ($BG_SRC_FILE_COLOR)" --as-creating-line - - # Create the source background file. - ppmmake -quiet ${BG_SRC_FILE_COLOR} \ - ${BG_SRC_FILE_WIDTH} ${BG_SRC_FILE_HEIGHT} \ - | pnmtopng > ${BG_SRC_FILE} - - fi - - # Print action message. - cli_printMessage "$BG_SRC_FILE" --as-cropping-line - - # Define the width of the required background information. - BG_DST_FILE_WIDTH=$(echo $BG_DST_FILE \ - | sed -r 's!.+/([[:digit:]]+)x[[:digit:]]+-final\.png!\1!') - - # Define the height of the required background information. - BG_DST_FILE_HEIGHT=$(echo $BG_DST_FILE \ - | sed -r 's!.+/[[:digit:]]+x([[:digit:]]+)-final\.png!\1!') - - # Create required backgrounnd information. - convert -quiet \ - -crop ${BG_DST_FILE_WIDTH}x${BG_DST_FILE_HEIGHT}+0+0 \ - ${BG_SRC_FILE} ${BG_DST_FILE} - - # Verify required background information. - cli_checkFiles $BG_DST_FILE - - fi - - done - -} diff --git a/Scripts/Functions/Render/render_svg_checkModelExportId.sh b/Scripts/Functions/Render/render_svg_checkModelExportId.sh deleted file mode 100755 index febd14e..0000000 --- a/Scripts/Functions/Render/render_svg_checkModelExportId.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash -# -# render_svg_checkModelExportId.sh -- This function standardizes the export id -# used inside svg files and the way of verify them. -# -# 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 render_svg_checkModelExportId { - - local INSTANCE="$1" - local EXPORTID="$2" - - # Verify instance. - cli_checkFiles $INSTANCE - - # Verify export id. - if [[ $EXPORTID == '' ]];then - cli_printMessage "`gettext "The export id value cannot be empty."`" --as-error-line - fi - - # Check export id inside design templates. - grep "id=\"$EXPORTID\"" $INSTANCE > /dev/null - if [[ $? -gt 0 ]];then - cli_printMessage "`eval_gettext "There is not export id (\\\$EXPORTID) inside \\\"\\\$TEMPLATE\\\"."`" --as-error-line - fi - -} diff --git a/Scripts/Functions/Render/render_svg_convertGplToHex.sh b/Scripts/Functions/Render/render_svg_convertGplToHex.sh deleted file mode 100755 index e37b944..0000000 --- a/Scripts/Functions/Render/render_svg_convertGplToHex.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash -# -# render_svg_convertGplToHex.sh -- This function takes one palette -# produced by Gimp (e.g., syslinux.gpl) as input and outputs the list -# of hexadecimal colors and their respective index position the -# `pnmtolss16' program needs (e.g., #RRGGBB=0 #RRGGBB=1 ... [all -# values in the same line]). -# -# 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 render_svg_convertGplToHex { - - # Define path to GPL palette. This is the .gpl file we use to - # retrive color information from. - local PALETTE_GPL="$1" - - # Define path to HEX palette. This is the palette used to stored - # the color information the `ppmtolss16' program needs. - local PALETTE_HEX="$2" - - # Define the number of colors this function should return. - local NUMBER="$3" - - # Define list of colors from GPL palette. - local COLORS=$(render_svg_getColors $PALETTE_GPL --head=$NUMBER --tail=$NUMBER) - - # Verify number of colors returned in the list. They must match - # exactly the amount specified, no more no less. Sometimes, the - # list of colors may have less colors than it should have, so we - # need to prevent such palettes from being used. - render_svg_checkColorAmount "$COLORS" "$NUMBER" - - # Verify format of colors. - render_svg_checkColorFormats "$COLORS" --format='rrggbb' - - # Create list of colors to be process by pnmtolss16 - echo "$COLORS" | nl | awk '{ printf "%s=%d ", $2, $1 - 1 }' \ - > $PALETTE_HEX - - # Verify HEX palette existence. - cli_checkFiles $PALETTE_HEX - -} diff --git a/Scripts/Functions/Render/render_svg_convertGplToPpm.sh b/Scripts/Functions/Render/render_svg_convertGplToPpm.sh deleted file mode 100755 index ff10c43..0000000 --- a/Scripts/Functions/Render/render_svg_convertGplToPpm.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# -# render_svg_convertGplToPpm.sh -- This function takes one palette -# produced by Gimp (e.g., syslinux.gpl) as input and outputs one PPM -# file based on it (e.g., syslinux.ppm). -# -# 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 render_svg_convertGplToPpm { - - local FILE='' - local -a FILES - local COUNT=0 - - # Define path to GPL palette. This is the .gpl file we use to - # retrive color information from. - local PALETTE_GPL="$1" - - # Define path to PPM palette. This is the .ppm file we'll save - # color information to. - local PALETTE_PPM="$2" - - # Define the number of colors this function should return. - local NUMBER="$3" - - # Define list of colors from GPL palette. - local COLOR='' - local COLORS=$(render_svg_getColors "$PALETTE_GPL" --head=$NUMBER --tail=$NUMBER --format='rrrggbb') - - # Verify amount of colors in the list of colors. - render_svg_checkColorAmount "$COLORS" "$NUMBER" - - # Verify format of colors. - render_svg_checkColorFormats $COLORS --format='rrggbb' - - # Create temporal images (of 1x1 pixel each) to store each color - # retrived from Gimp's palette. - for COLOR in $COLORS;do - FILES[$COUNT]=$(cli_getTemporalFile ${COUNT}.ppm) - ppmmake $COLOR 1 1 > ${FILES[$COUNT]} - COUNT=$(($COUNT + 1)) - done - - # Concatenate each temporal image from left to right to create the - # PPM file. - pnmcat -lr ${FILES[*]} > $PALETTE_PPM - - # Remove temporal images used to build the ppm palette file. - rm ${FILES[*]} - - # Verify PPM palette existence. - cli_checkFiles "$PALETTE_PPM" - -} diff --git a/Scripts/Functions/Render/render_svg_convertPngTo.sh b/Scripts/Functions/Render/render_svg_convertPngTo.sh deleted file mode 100644 index 2217192..0000000 --- a/Scripts/Functions/Render/render_svg_convertPngTo.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash -# -# render_svg_convertPngTo.sh -- This function provides post-rendition -# actions to use the `convert' command of ImageMagick tool set. -# -# 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 render_svg_convertPngTo { - - # Get image formats. - local FORMATS=$(render_getConfigOption "$ACTION" '2') - - # Execute ImageMagick convertion. - for FORMAT in $FORMATS;do - cli_printMessage "${FILE}.${FORMAT}" --as-savedas-line - convert -quality 85 ${FILE}.png ${FILE}.${FORMAT} - done - -} diff --git a/Scripts/Functions/Render/render_svg_convertPngToBrands.sh b/Scripts/Functions/Render/render_svg_convertPngToBrands.sh deleted file mode 100644 index d98bf39..0000000 --- a/Scripts/Functions/Render/render_svg_convertPngToBrands.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash -# -# render_svg_convertPngToBrands.sh -- This function provides -# last-rendition actions to produce CentOS brands. This function takes -# both The CentOS Symbol and The CentOS Type images and produces -# variation of them in different dimensions and formats using -# ImageMagick tool-set. -# -# 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 render_svg_convertPngToBrands { - - # Define height dimensions you want to produce brands for. - local SIZES="16 20 22 24 32 36 40 48 64 96 128 148 164 196 200 512" - - # Define image formats you want to produce brands for. - local FORMATS="png xpm pdf jpg tif" - - for SIZE in ${SIZES};do - - for FORMAT in ${FORMATS};do - - # Output action information. - cli_printMessage "${FILE}-${SIZE}.${FORMAT}" --as-creating-line - - # Convert and resize to create new file. - convert -support 0.8 -resize x${SIZE} ${FILE}.png ${FILE}-${SIZE}.${FORMAT} - - done - - # Create logo copy in 2 colors. - cli_printMessage "${FILE}-${SIZE}.xbm (`gettext "2 colors grayscale"`)" --as-creating-line - convert -resize x${SIZE} -colorspace gray -colors 2 ${FILE}.png ${FILE}-${SIZE}.xbm - - # Create logo copy in emboss effect. - cli_printMessage "${FILE}-${SIZE}-emboss.png" --as-creating-line - convert -resize x${SIZE} -emboss 1 ${FILE}.png ${FILE}-${SIZE}-emboss.png - - done - -} diff --git a/Scripts/Functions/Render/render_svg_convertPngToDm.sh b/Scripts/Functions/Render/render_svg_convertPngToDm.sh deleted file mode 100755 index 265ec4c..0000000 --- a/Scripts/Functions/Render/render_svg_convertPngToDm.sh +++ /dev/null @@ -1,177 +0,0 @@ -#!/bin/bash -# -# render_svg_convertPngToDm.sh -- This function standardize production -# of display managers (e.g., Gdm and Kdm). This function copies all -# files needed into a temporal directory, realize expansion of -# translation markers and packs all the files into a tar.gz package -# that is used for installation. This function must be used as -# last-rendition action for Gdm and Kdm directory specific -# base-rendition actions. -# -# 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 render_svg_convertPngToDm { - - # Print separator line. - cli_printMessage '-' --as-separator-line - - # Initialize source and destination local variables. - local SRC='' - local DST='' - - # Initialize display manager type. - local DM=$(render_getConfigOption "${ACTION}" '2') - - # Initialize screen resolutions the display manager theme will be - # built for. - local RESOLUTION='' - local RESOLUTIONS=$(render_getConfigOption "${ACTION}" '3') - - # Verify screen resolutions. We cannot produce display manager - # theme if no screen resolution has been specified. - if [[ "$RESOLUTIONS" == '' ]];then - cli_printMessage "`gettext "There is no resolution information to process."`" --as-error-line - fi - - # Initialize theme information we are going to build the display - # manager theme for. - local THEME=$(cli_getPathComponent $ACTIONVAL --motif) - local THEME_NAME=$(cli_getPathComponent $ACTIONVAL --motif-name) - - # Initialize temporal directory where we collect all files needed - # in order to create the tar.gz file. This intermediate step is - # also needed in order to expand translation markers from XML and - # Desktop definitions. - local TMPDIR=$(cli_getTemporalFile 'dm') - - # Initialize source location for brands. This is the place where - # brand information needed to build the display manager theme is - # retrived from. - local BRANDS=$(cli_getRepoTLDir)/Identity/Images/Brands - - # Initialize source location for backgrounds. This is the place - # where background information needed to ubild the display manager - # theme is retrived from. - local BGS=$(cli_getRepoTLDir)/Identity/Images/Themes/${THEME}/Backgrounds/Img/Png - - # Initialize file variables. File variables are used build and - # process the file relation between source and target locations. - local FILE='' - local FILES='' - - # Define file relation between source and target locations, based - # on whether we are producing GDM or KDM. Presently, both GDM and - # KDM are very similar on files with the exception that GDM does - # use icons near actions buttons (e.g., shutdown, reboot, session, - # language) and KDM doesn't. - case ${DM} in - - Gdm ) - FILES="\ - ${BRANDS}/centos-symbol-resized-48.png:centos-symbol.png - ${OUTPUT}/release.png:centos-release.png - ${OUTPUT}/screenshot.png:screenshot.png - $(dirname $TEMPLATE)/GdmGreeterTheme.xml:${THEME_NAME}.xml - $(dirname $TEMPLATE)/GdmGreeterTheme.desktop:GdmGreeterTheme.desktop - $(dirname $TEMPLATE)/icon-language.png:icon-language.png - $(dirname $TEMPLATE)/icon-reboot.png:icon-reboot.png - $(dirname $TEMPLATE)/icon-session.png:icon-session.png - $(dirname $TEMPLATE)/icon-shutdown.png:icon-shutdown.png - " - ;; - - Kdm ) - FILES="\ - ${BRANDS}/centos-symbol-resized-48.png:centos-symbol.png - ${OUTPUT}/release.png:centos-release.png - ${OUTPUT}/screenshot.png:screenshot.png - $(dirname $TEMPLATE)/GdmGreeterTheme.xml:${THEME_NAME}.xml - $(dirname $TEMPLATE)/GdmGreeterTheme.desktop:GdmGreeterTheme.desktop - " - ;; - - * ) - cli_printMessage "`eval_gettext "The \\\"\\\$DM\\\" display manager is not supported yet."`" --as-error-line - ;; - esac - - for FILE in $FILES;do - - # Define source location. - SRC=$(echo $FILE | cut -d: -f1) - - # Define target location. - DST=${TMPDIR}/${THEME_NAME}/$(echo $FILE | cut -d: -f2) - - # Verify source files. - cli_checkFiles $SRC - - # Verify parent directory for target file. - if [[ ! -d $(dirname $DST) ]];then - mkdir -p $(dirname $DST) - fi - - # Copy files from source to target location. - cp ${SRC} ${DST} - - # Expand translation markers. - if [[ ${DST} =~ "\.(xml|desktop)$" ]];then - cli_replaceTMarkers "${DST}" - fi - - done - - # Move into temporal directory. - pushd $TMPDIR > /dev/null - - for RESOLUTION in $RESOLUTIONS;do - - # Verify background information. If it doesn't exist go on - # with the next one in the list. - if [[ ! -f $BGS/${RESOLUTION}-final.png ]];then - continue - fi - - # Print action message. - if [[ -f ${RESOLUTION}.tar.gz ]];then - cli_printMessage "${OUTPUT}/${RESOLUTION}.tar.gz" --as-updating-line - else - cli_printMessage "${OUTPUT}/${RESOLUTION}.tar.gz" --as-creating-line - fi - - # Copy background information. - cp $BGS/${RESOLUTION}-final.png ${THEME_NAME}/background.png - - # Create tar.gz file. - tar -czf ${RESOLUTION}.tar.gz ${THEME_NAME} - - # Move from temporal directory to its final location. - mv ${RESOLUTION}.tar.gz ${OUTPUT} - - done - - # Return to where we were initially. - popd > /dev/null - - # Remove temporal directory. - rm -r ${TMPDIR} - -} diff --git a/Scripts/Functions/Render/render_svg_convertPngToGrub.sh b/Scripts/Functions/Render/render_svg_convertPngToGrub.sh deleted file mode 100644 index 383674b..0000000 --- a/Scripts/Functions/Render/render_svg_convertPngToGrub.sh +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/bash -# -# render_svg_convertPngToGrub.sh -- This function provides -# post-rendition action used to produce GRUB images. -# -# 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 render_svg_convertPngToGrub { - - # Define number of colors the images will be produced on. - local COLORS='14' - - # Define options using those passed to actions from pre-rendition - # configuration script. These options are applied to pnmremap when - # doing color reduction, so any option available for pnmremap - # command can be passed to renderSyslinux functionality. - local OPTIONS=$(render_getConfigOption "$ACTION" '2-') - - # Check options passed to action. This is required in order to - # aviod using options used already in this script. For example - # -verbose and -mapfile options. - for OPTION in $OPTIONS;do - # Remove anything after equal sign inside option. - OPTION=$(echo -n $OPTION | cut -d'=' -f1) - if [[ "$OPTION" =~ "-(mapfile|verbose)" ]];then - cli_printMessage "`eval_gettext "The \\\"\\\$OPTION\\\" option is already used."`" --as-error-line - fi - done - - # Define file name prefix. - local PREFIX="-${COLORS}c" - - # Redefine file name prefix using options as reference. This is - # useful to differenciate final files produced using - # Floyd-Steinberg dithering and files which are not. - if [[ "$OPTIONS" =~ '-floyd' ]];then - PREFIX="${PREFIX}-floyd" - fi - - # Define absolute path to GPL palette. This palettes should have - # 14 colors only. For more information on this see the GRUB's - # documentation. - local PALETTE_GPL=${MOTIF_DIR}/Palettes/grub.gpl - - # Verify GPL palette existence. If it doesn't exist copy the one - # provided by the design model and expand translation markers in - # it. - if [[ ! -f $PALETTE_GPL ]];then - cp ${MODEL_BASEDIR}/${FLAG_THEME_MODEL}/Palettes/grub.gpl ${PALETTE_GPL} - cli_replaceTMarkers ${PALETTE_GPL} - fi - - # Define absolute path to PPM palette. The PPM palette is built - # from source palette (PALETTE_GPL) and provides the color - # information understood by `ppmremap', the program used to - # produce images in a specific amount of colors. - local PALETTE_PPM=$(cli_getTemporalFile "grub.ppm") - - # Create image in Netpbm superformat (PNM). The PNM image file is - # created from the PNG image rendered previously as centos-art - # base-rendition output. The PNM image is an intermediate format - # used to manipulate images through Netpbm tools. - cli_printMessage "${FILE}.pnm" --as-savedas-line - pngtopnm -verbose \ - < ${FILE}.png 2>${FILE}.log > ${FILE}.pnm - - # Print the path to GPL palette. - cli_printMessage "$PALETTE_GPL" --as-palette-line - - # Create PPM palette using GPL palette. - render_svg_convertGplToPpm "$PALETTE_GPL" "$PALETTE_PPM" "$COLORS" - - # Reduce colors as specified in PPM palette. Here we use the PPM - # palette to enforce the color position in the image index and the - # Floyd-Steinberg dithering in order to improve color reduction. - cli_printMessage "${FILE}${PREFIX}.ppm" --as-savedas-line - pnmremap -verbose -mapfile=$PALETTE_PPM $OPTIONS \ - < ${FILE}.pnm 2>>${FILE}.log > ${FILE}${PREFIX}.ppm - - # Remove PPM palette. It is no longer needed. - if [[ -f ${PALETTE_PPM} ]];then - rm $PALETTE_PPM - fi - - # Create the 14 colors xpm.gz file. - cli_printMessage "${FILE}${PREFIX}.xpm.gz" --as-savedas-line - ppmtoxpm \ - < ${FILE}${PREFIX}.ppm 2>>${FILE}.log > ${FILE}.xpm \ - && gzip --force ${FILE}.xpm \ - && mv ${FILE}.xpm.gz ${FILE}${PREFIX}.xpm.gz - -} diff --git a/Scripts/Functions/Render/render_svg_convertPngToKsplash.sh b/Scripts/Functions/Render/render_svg_convertPngToKsplash.sh deleted file mode 100755 index 69ea60e..0000000 --- a/Scripts/Functions/Render/render_svg_convertPngToKsplash.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/bash -# -# render_svg_convertPngToKsplash.sh -- This function collects KDE -# splash (KSplash) required files and creates a tar.gz package that -# groups them all together. Use this function as last-rendition action -# for KSplash base-rendition action. -# -# 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 render_svg_convertPngToKsplash { - - local -a SRC - local -a DST - local FONT='' - local COUNT=0 - - # Define font used to print bottom splash message. - FONT=$(cli_getRepoTLDir)/Identity/Fonts/DejaVuLGCSans-Bold.ttf - - # Check existence of font file. - cli_checkFiles "$FONT" - - # Define absolute source location of files. - SRC[0]="${OUTPUT}/splash_top.png" - SRC[1]="${OUTPUT}/splash_active_bar.png" - SRC[2]="${OUTPUT}/splash_inactive_bar.png" - SRC[3]="${OUTPUT}/splash_bottom.png" - SRC[4]="$(dirname $TEMPLATE)/Theme.rc" - - # Check absolute source location of files. - cli_checkFiles "${SRC[@]}" - - # Define relative target location of files. - DST[0]="${OUTPUT}/splash_top.png" - DST[1]="${OUTPUT}/splash_active_bar.png" - DST[2]="${OUTPUT}/splash_inactive_bar.png" - DST[3]="${OUTPUT}/splash_bottom.png" - DST[4]="${OUTPUT}/Theme.rc" - - # Print action message. - cli_printMessage "${OUTPUT}/Preview.png" --as-creating-line - - # Create `Preview.png' image. - convert -append ${SRC[0]} ${SRC[1]} ${SRC[3]} ${OUTPUT}/Preview.png - - # Add bottom text to Preview.png image. The text position was set - # inside an image of 400x300 pixels. If you change the final - # preview image dimension, you probably need to change the text - # position too. - mogrify -draw 'text 6,295 "KDE is up and running."' \ - -fill \#ffffff \ - -font $FONT \ - ${OUTPUT}/Preview.png - - # Copy `Theme.rc' file. - cp ${SRC[4]} ${DST[4]} - - # Apply common translation markers to Theme.rc file. - cli_replaceTMarkers "${DST[4]}" - -} diff --git a/Scripts/Functions/Render/render_svg_convertPngToSyslinux.sh b/Scripts/Functions/Render/render_svg_convertPngToSyslinux.sh deleted file mode 100755 index 16b354c..0000000 --- a/Scripts/Functions/Render/render_svg_convertPngToSyslinux.sh +++ /dev/null @@ -1,189 +0,0 @@ -#!/bin/bash -# -# render_svg_convertPngToSyslinux.sh -- This function provides post-rendition -# action used to produce LSS16 images, the images used by isolinux. -# -# This function uses three different formats to handle the same color -# information. Initially, the color information is defined with GIMP -# (The GNU Image Manipulation Program) as a palette of color. This -# palette of colors contains 16 colors only and is saved in a file -# named `syslinux.gpl. -# -# The `syslinux.gpl' file is used to build two other files: the -# `syslinux.ppm' file and the `syslinux.hex' file. The `syslinux.ppm' -# file is used to reduce a full color PNG image to the amount of -# colors it specifies (i.e., 16 colors). Later, with the 16 color -# image already created, the `syslinux.hex' file is used to build the -# LSS16 image. -# -# In order to produce images in LSS16 format correctly, it is needed -# that both the `syslinux.ppm' and `syslinux.hex' files contain the -# same color information. This is, both `syslinux.ppm' and -# `syslinux.hex' shoud represent the same color values and the same -# color index. -# -# This function save you the work of preparing both `syslinux.ppm' and -# `syslinux.hex'. Instead, you only need to prepare the `syslinux.gpl' -# file with the color information you want to produce images. -# -# In order for this function to work, the `syslinux.gpl' file should -# have a format similar to the following: -# -# GIMP Palette -# Name: TreeFlower-4-Syslinux -# Columns: 16 -# # -# 10 22 40 0a1628 -# 9 28 52 091c34 -# 16 34 63 10223f -# 20 37 67 142543 -# 15 39 74 0f274a -# 12 45 85 0c2d55 -# 20 43 78 142b4e -# 255 255 255 ffffff -# 21 51 95 15335f -# 41 52 70 293446 -# 32 76 141 204c8d -# 77 90 107 4d5a6b -# 143 154 167 8f9aa7 -# 128 179 255 80b3ff -# 194 200 202 c2c8ca -# 231 241 255 e7f1ff -# -# 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 render_svg_convertPngToSyslinux { - - # Define number of colors the images will be produced on. - local COLORS='16' - - # Define options using those passed to actions from pre-rendition - # configuration script. These options are applied to pnmremap when - # doing color reduction, so any option available for pnmremap - # command can be passed to renderSyslinux functionality. - local OPTIONS=$(render_getConfigOption "$ACTION" '2-') - - # Check options passed to action. This is required in order to - # aviod using options already used in this script. For example - # -verbose and -mapfile options. - for OPTION in $OPTIONS;do - # Remove anything after equal sign inside option. - OPTION=$(echo $OPTION | cut -d'=' -f1) - if [[ "$OPTION" =~ "-(mapfile|verbose)" ]];then - cli_printMessage "`eval_gettext "The \\\"\\\$OPTION\\\" option is already used."`" --as-error-line - fi - done - - # Define default file name prefix for 16 colors images. - local PREFIX="-${COLORS}c" - - # Re-define 16 colors images default file name prefix using - # options as reference. This is useful to differenciate final - # files produced using Floyd-Steinberg dithering and final files - # which are not. - if [[ "$OPTIONS" =~ '-floyd' ]];then - PREFIX="${PREFIX}-floyd" - fi - - # Define absolute path to GPL palette. The GPL palette defines the - # color information used to build syslinux images. This palette - # should be set to 16 colors and, as specified in isolinux - # documentation, the background color should be indexed on - # position 0 and the forground in position 7 (see - # /usr/share/doc/syslinux-X.XX/isolinux.doc, for more - # information.) - local PALETTE_GPL=${MOTIF_DIR}/Palettes/syslinux.gpl - - # Verify GPL palette existence. If it doesn't exist copy the one - # provided by the design model and expand translation markers in - # it. - if [[ ! -f $PALETTE_GPL ]];then - cp ${MODEL_BASEDIR}/${FLAG_THEME_MODEL}/Palettes/syslinux.gpl ${PALETTE_GPL} - cli_replaceTMarkers ${PALETTE_GPL} - fi - - # Define absolute path to PPM palette. The PPM palette is built - # from source palette (PALETTE_GPL) and provides the color - # information understood by `ppmremap', the program used to - # produce images in a specific amount of colors. - local PALETTE_PPM=$(cli_getTemporalFile "syslinux.ppm") - - # Define the HEX palette. The HEX palette is built from source - # palette (PALETTE_GPL) and provides the color information in the - # format understood by `ppmtolss16', the program used to produce - # images in LSS16 format. The HEX palette stores just one line - # with the color information as described in isolinux - # documentation (i.e #RRGGBB=0 #RRGGBB=1 ... [all values in the - # same line]) - local PALETTE_HEX=$(cli_getTemporalFile "syslinux.hex") - - # Create image in Netpbm superformat (PNM). The PNM image file is - # created from the PNG image rendered previously as centos-art - # base-rendition output. The PNM image is an intermediate format - # used to manipulate images through Netpbm tools. - cli_printMessage "${FILE}.pnm" --as-savedas-line - pngtopnm -verbose \ - < ${FILE}.png 2>${FILE}.log > ${FILE}.pnm - - # Print the path to GPL palette. - cli_printMessage "$PALETTE_GPL" --as-palette-line - - # Create PPM palette using GPL palette. - render_svg_convertGplToPpm "$PALETTE_GPL" "$PALETTE_PPM" "$COLORS" - - # Create HEX palette using GPL palette. - render_svg_convertGplToHex "$PALETTE_GPL" "$PALETTE_HEX" "$COLORS" - - # Reduce colors as specified in PPM palette. Here we use the PPM - # palette to enforce the color position in the image index and the - # Floyd-Steinberg dithering in order to improve color reduction. - cli_printMessage "${FILE}${PREFIX}.pnm" --as-savedas-line - pnmremap -verbose -mapfile=$PALETTE_PPM $OPTIONS \ - < ${FILE}.pnm 2>> ${FILE}.log > ${FILE}${PREFIX}.pnm - - # Create LSS16 image. - cli_printMessage "${FILE}${PREFIX}.lss" --as-savedas-line - ppmtolss16 $(cat $PALETTE_HEX) \ - < ${FILE}${PREFIX}.pnm 2>>${FILE}.log > ${FILE}${PREFIX}.lss - - # Remove HEX palette. It is no longer needed. - if [[ -f ${PALETTE_HEX} ]];then - rm $PALETTE_HEX - fi - - # Create the PPM image indexed to 16 colors. Also the colormap - # used in the LSS16 image is saved on ${FILE}.log; this is useful to - # verify the correct order of colors in the image index. - cli_printMessage "${FILE}${PREFIX}.ppm" --as-savedas-line - lss16toppm -map \ - < ${FILE}${PREFIX}.lss 2>>${FILE}.log > ${FILE}${PREFIX}.ppm - - # Create the 16 colors PNG image. - cli_printMessage "${FILE}${PREFIX}.png" --as-savedas-line - pnmtopng -verbose -palette=$PALETTE_PPM \ - < ${FILE}${PREFIX}.pnm 2>>${FILE}.log > ${FILE}${PREFIX}.png - - # Remove PPM palette. It is no longer needed. - if [[ -f ${PALETTE_PPM} ]];then - rm $PALETTE_PPM - fi - -} diff --git a/Scripts/Functions/Render/render_svg_convertPngToThumbnail.sh b/Scripts/Functions/Render/render_svg_convertPngToThumbnail.sh deleted file mode 100755 index b69088c..0000000 --- a/Scripts/Functions/Render/render_svg_convertPngToThumbnail.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -# -# render_svg_convertPngToThumbnail.sh -- This function provides post-rendition to -# create thumbnails from images produced by centos-art base-rendition. -# Thumbnails are created in PNG and JPG format for you to decide which -# is the more appropriate one. When no size is specified, thumbnails -# are created at 250 pixels width and height is automatically -# calculated to match the image ratio. -# -# 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 render_svg_convertPngToThumbnail { - - # Get image size. - local SIZES=$(render_getConfigOption "$ACTION" '2-') - - # Check image sizes and do convertion. - if [[ "$SIZES" == "" ]];then - SIZES='250' - fi - - # Check base file existence. - cli_checkFiles "${FILE}.png" - - # Create thumbnails. - for SIZE in $SIZES;do - cli_printMessage "${FILE}-thumb-${SIZE}.png" --as-savedas-line - convert -thumbnail ${SIZE} ${FILE}.png ${FILE}-thumb-${SIZE}.png - cli_printMessage "${FILE}-thumb-${SIZE}.jpg" --as-savedas-line - convert -thumbnail ${SIZE} ${FILE}-thumb-${SIZE}.png ${FILE}-thumb-${SIZE}.jpg - cli_printMessage "${FILE}-thumb-${SIZE}.pdf" --as-savedas-line - convert -thumbnail ${SIZE} ${FILE}-thumb-${SIZE}.png ${FILE}-thumb-${SIZE}.pdf - done - -} diff --git a/Scripts/Functions/Render/render_svg_doLastActions.sh b/Scripts/Functions/Render/render_svg_doLastActions.sh deleted file mode 100644 index 821628c..0000000 --- a/Scripts/Functions/Render/render_svg_doLastActions.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# -# render_svg_doLastActions.sh -- This function performs -# last-rendition actions 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 render_svg_doLastActions { - - # Verify position of file being produced in the list of files been - # currently processed. - if [[ $THIS_FILE_DIR == $NEXT_FILE_DIR ]];then - return - fi - - local ACTION='' - - # Redefine SVG last-rendition actions as local to avoid undesired - # concatenation when massive rendition is performed. - local -a LASTACTIONS - - # Define SVG directory-specific actions. This is required in order - # to provide a predictable way of producing content inside the - # repository and save you the time of writing long several - # commands each time you need to produce images inside the - # repository. - if [[ $FLAG_DONT_DIRSPECIFIC == 'false' ]];then - if [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Gdm/.+\.svg$" ]];then - LASTACTIONS[((++${#LASTACTIONS[*]}))]='svg_convertPngToDm:Gdm:800x600 1024x768 1280x1024 1360x768 2048x1536 2560x1240' - elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Kdm/.+\.svg$" ]];then - LASTACTIONS[((++${#LASTACTIONS[*]}))]='svg_convertPngToDm:Kdm:800x600 1024x768 1280x1024 1360x768 2048x1536 2560x1240' - elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Ksplash/.+\.svg$" ]];then - LASTACTIONS[((++${#LASTACTIONS[*]}))]='svg_convertPngToKsplash:' - fi - fi - - # Define SVG last-rendition actions. Since last-rendition makes - # use of all files in the output directory structure and - # directory-specific rendition modifies all the files in the - # output directory structure as well, these actions must be - # defined after the directory-specific definition. Otherwise, - # modifications impossed by these actions may interfier the whole - # purpose of having a directory-specific rendition. - [[ $FLAG_LASTRENDITION != '' ]] && LASTACTIONS[((++${#LASTACTIONS[*]}))]="doLastActions:(png|jpg):${FLAG_LASTRENDITION}" - - # At this point centos-art.sh should be producing the last file - # from the same unique directory structure, so, before producing - # images for the next directory structure lets execute the list of - # last-rendition actions for the current directory structure. - for ACTION in "${LASTACTIONS[@]}"; do - ${FUNCNAM}_$(echo "$ACTION" | cut -d: -f1) - done - -} diff --git a/Scripts/Functions/Render/render_svg_doPostActions.sh b/Scripts/Functions/Render/render_svg_doPostActions.sh deleted file mode 100644 index d099fab..0000000 --- a/Scripts/Functions/Render/render_svg_doPostActions.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/bash -# -# render_svg_doPostActions.sh -- This function performs -# post-rendition actions 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 render_svg_doPostActions { - - local ACTION='' - - # Redefine SVG post-rendition actions as local to avoid undesired - # concatenation when massive rendition is performed. - local -a POSTACTIONS - - # Define default comment written to base-rendition output. - local COMMENT="`gettext "Created in CentOS Arwork Repository"` ($(cli_printUrl '--projects-artwork'))" - - # Define SVG post-rendition actions. Since these actions are - # applied to base-rendition output and base-rendition output is - # used as reference to perform directory-specific rendition, these - # action must be defined before directory-specific rendition. - # Otherwise it wouldn't be possible to propagate changes impossed - # by these actions to new files produced as result of - # directory-specific rendition. - POSTACTIONS[((++${#POSTACTIONS[*]}))]="doPostActions:png:mogrify -comment '$COMMENT'" - [[ $FLAG_POSTRENDITION != '' ]] && POSTACTIONS[((++${#POSTACTIONS[*]}))]="doPostActions:png:${FLAG_POSTRENDITION}" - - # Define SVG directory-specific rendition. Directory-specfic - # rendition provides a predictable way of producing content inside - # the repository. - if [[ $FLAG_DONT_DIRSPECIFIC == 'false' ]];then - if [[ $TEMPLATE =~ "Backgrounds/.+\.svg$" ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]='svg_convertPngTo:jpg' - POSTACTIONS[((++${#POSTACTIONS[*]}))]='svg_groupBy:png jpg' - elif [[ $TEMPLATE =~ "Concept/.+\.svg$" ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]='svg_convertPngTo:jpg pdf' - POSTACTIONS[((++${#POSTACTIONS[*]}))]='svg_convertPngToThumbnail:250' - elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Syslinux/.+\.svg$" ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]='svg_convertPngToSyslinux:' - POSTACTIONS[((++${#POSTACTIONS[*]}))]='svg_convertPngToSyslinux:-floyd' - elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Grub/.+\.svg$" ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]='svg_convertPngToGrub:' - POSTACTIONS[((++${#POSTACTIONS[*]}))]='svg_convertPngToGrub:-floyd' - elif [[ $TEMPLATE =~ "Posters/.+\.svg$" ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]='svg_convertPngTo:jpg pdf' - elif [[ $TEMPLATE =~ "trunk/Identity/Models/Brands/.+\.svg$" ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]='svg_convertPngToBrands' - fi - fi - - # Execute SVG post-rendition actions. - for ACTION in "${POSTACTIONS[@]}"; do - ${FUNCNAM}_$(echo "$ACTION" | cut -d: -f1) - done - -} diff --git a/Scripts/Functions/Render/render_svg_getColors.sh b/Scripts/Functions/Render/render_svg_getColors.sh deleted file mode 100755 index 02340a8..0000000 --- a/Scripts/Functions/Render/render_svg_getColors.sh +++ /dev/null @@ -1,153 +0,0 @@ -#!/bin/bash -# -# render_svg_getColors.sh -- This function takes one palette produced -# by Gimp (e.g., syslinux.gpl) as input and outputs a list of colors -# in the specified format. In order for this function to output the -# color in the format specified, it is needed that the fourth column -# in the gpl palette be set in the `rrggbb' format and the appropriate -# conversion be implemented here. -# -# Notice that using both the `--head' and `--tail' options it is -# possible to control how many consecutive items does the list of -# colors is going to have. It is possible to output all colors in the -# list, or a consecutive range of them. -# -# 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 render_svg_getColors { - - # Define short options. - local ARGSS='' - - # Define long options. - local ARGSL='head:,tail:,format:' - - # Initialize ARGUMENTS with an empty value and set it as local - # variable to this function scope. - local ARGUMENTS='' - - # Initialize both head and tail values to return the first line of - # color information from the palette. - local HEAD=1 - local TAIL=1 - - # Initialize format value used as default when no format option be - # provided. - local FORMAT='rrggbb' - - # Initialize list of colors. - local COLORS='' - - # Redefine ARGUMENTS variable using current positional parameters. - cli_parseArgumentsReDef "$@" - - # Redefine ARGUMENTS variable using getopt output. - cli_parseArguments - - # Redefine positional parameters using ARGUMENTS variable. - eval set -- "$ARGUMENTS" - - # Look for options passed through positional parameters. - while true;do - - case "$1" in - - --head ) - HEAD=$2 - shift 2 - ;; - - --tail ) - TAIL=$2 - shift 2 - ;; - - --format ) - FORMAT=$2 - shift 2 - ;; - - -- ) - shift 1 - break - ;; - esac - done - - # Define path to gpl palette. This is the first file we use to - # retrive color information from. Only the first file provided - # will be used. - local PALETTE=$(echo $@ | cut -d' ' -f1) - - if [[ $PALETTE == '' ]];then - - # Define palette path inside the theme's artistic motif. - local MOTIF_PALETTE=$(cli_getRepoTLDir)/Identity/Images/Themes/$(cli_getPathComponent $ACTIONVAL --motif)/Palettes/grub.gpl - - # Define palette path inside the theme's design model. - local MODEL_PALETTE=$(cli_getRepoTLDir)/Identity/Models/Themes/${THEME_MODEL_NAME}/Palettes/grub.gpl - - # Redefine default background color using palettes provided by - # artistic motif first, and design model later. Assuming none - # of them is present, use The CentOS Project default color - # then. - if [[ -f $MOTIF_PALETTE ]];then - COLORS=$(render_svg_getColors $MOTIF_PALETTE --head=1 --tail=1) - elif [[ -f $MODEL_PALETTE ]];then - COLORS=$(render_svg_getColors $MODEL_PALETTE --head=1 --tail=1) - else - COLORS='#204c8d' - fi - - else - - # Retrive the fourth column from GPL palette. The fourth - # column of a GPL palette contains the palette commentary - # field. The palette commentary field can be anything, but for - # the sake of our own convenience we use it to store the color - # value in hexadecimal format (e.g., rrggbb). Notice that you - # can put your comments from the fifth column on using an - # space as field separator. - COLORS=$(sed -r '1,/^#/d' $PALETTE \ - | awk '{ printf "%s\n", $4 }' | head -n $HEAD | tail -n $TAIL) - - fi - - # Implement color formats convertions from rrggbb to other formats - # that you might need to use. - for COLOR in $COLORS;do - - case $FORMAT in - - rrggbb|* ) - if [[ ! $COLOR =~ '^#' ]];then - COLOR="#${COLOR}" - fi - ;; - - esac - - # Output color value. - echo "$COLOR" - - done - -} diff --git a/Scripts/Functions/Render/render_svg_groupBy.sh b/Scripts/Functions/Render/render_svg_groupBy.sh deleted file mode 100755 index f6c43fa..0000000 --- a/Scripts/Functions/Render/render_svg_groupBy.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/bash -# -# render_svg_groupBy.sh -- This function provides post-rendition -# action to group files inside directories named as their file -# extensions. For example: if the current file is a .png file, it is -# moved inside a Png/ directory; if the current file is a .jpg file, -# it is stored inside a Jpg/ directory, and so on. -# -# For this function to work correctly, you need to specify which file -# type you want to group. This is done in the post-rendition ACTIONS -# array inside the appropriate `render.conf.sh' pre-configuration -# script. This function cannot be used as last-rendition action. -# -# 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 render_svg_groupBy { - - local SOURCE='' - local TARGET='' - - # Sanitate file types passed from render.conf.sh pre-rendition - # configuration script. - local FORMATS=$(render_getConfigOption "$ACTION" '2-') - - for FORMAT in $FORMATS;do - - # Redifine source file we want to move. - SOURCE=${FILE}.${FORMAT} - - # Define target directory where source file will be moved - # into. - TARGET=$(dirname "$FILE")/$(cli_getRepoName $FORMAT -d) - - # Check existence of source file. - cli_checkFiles $SOURCE - - # Check existence of target directory. - if [[ ! -d $TARGET ]];then - mkdir -p $TARGET - fi - - # Redifine file path to add file and its type. - TARGET=${TARGET}/$(cli_getRepoName $FILE -f).${FORMAT} - - # Move file into its final location. - cli_printMessage "$TARGET" --as-movedto-line - mv ${SOURCE} ${TARGET} - - done - -} diff --git a/Scripts/Functions/Render/render_xhtml.sh b/Scripts/Functions/Render/render_xhtml.sh deleted file mode 100755 index 09b78be..0000000 --- a/Scripts/Functions/Render/render_xhtml.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -# -# render_xhtml.sh -- This function performs base-rendition action 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 render_xhtml { - - # Print action message. - if [[ -f ${FILE}.xhtml ]];then - cli_printMessage "${FILE}.xhtml" --as-updating-line - else - cli_printMessage "${FILE}.xhtml" --as-creating-line - fi - - # Create xhtml file from instance. - cp $INSTANCE ${FILE}.xhtml - - # Produce plaintext output from html outout. - render_xhtml_convertToText - -} diff --git a/Scripts/Functions/Render/render_xhtml_convertToText.sh b/Scripts/Functions/Render/render_xhtml_convertToText.sh deleted file mode 100755 index 2821bed..0000000 --- a/Scripts/Functions/Render/render_xhtml_convertToText.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash -# -# render_svg_convertHtmlToText.sh -- This function takes one HTML file -# and produces one plain-text file (i.e., without markup inside). -# -# 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 render_xhtml_convertToText { - - # Verify existence of HTML file. - cli_checkFiles ${FILE}.xhtml - - local COMMAND='' - local OPTIONS='' - - # Define the command path to text-based web browser and options - # used to produce plain-text files. Most of these programs have a - # dump option that print formatted plain-text versions of given - # HTML file to stdout. - if [[ -x '/usr/bin/lynx' ]];then - COMMAND='/usr/bin/lynx' - OPTIONS='-force_html -nolist -width 70 -dump' - elif [[ -x '/usr/bin/elinks' ]];then - COMMAND='/usr/bin/elinks' - OPTIONS='-force_html -no-numbering -no-references -width 70 -dump' - elif [[ -x '/usr/bin/w3m' ]];then - COMMAND='/usr/bin/w3m' - OPTIONS='-dump' - fi - - if [[ $COMMAND != '' ]];then - - # Print action message. - if [[ -f ${FILE}.txt ]];then - cli_printMessage "${FILE}.txt" --as-updating-line - else - cli_printMessage "${FILE}.txt" --as-creating-line - fi - - # Convert from HTML to plain-text without markup. - ${COMMAND} ${OPTIONS} ${FILE}.xhtml > ${FILE}.txt - - else - cli_printMessage "`gettext "No way to convert from HTML to plain-text found."`" --as-error-line - fi - -}