From 9b64fcb5c596916854d33cc8f29be8cce2612c38 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Jun 20 2011 03:46:00 +0000 Subject: Update `render' functionality: - Move backend-specific functionalities out of Backends directory. There is no need to have an extra level of organization, here. --- diff --git a/Scripts/Functions/Render/Backends/Docbook/Styles/docbook2fo.xsl b/Scripts/Functions/Render/Backends/Docbook/Styles/docbook2fo.xsl deleted file mode 100755 index 6eac1da..0000000 --- a/Scripts/Functions/Render/Backends/Docbook/Styles/docbook2fo.xsl +++ /dev/null @@ -1,6 +0,0 @@ - - - - diff --git a/Scripts/Functions/Render/Backends/Docbook/Styles/docbook2pdf.dsl b/Scripts/Functions/Render/Backends/Docbook/Styles/docbook2pdf.dsl deleted file mode 100644 index 407a604..0000000 --- a/Scripts/Functions/Render/Backends/Docbook/Styles/docbook2pdf.dsl +++ /dev/null @@ -1,464 +0,0 @@ - - -]]> -]> - - - - - - -;;====================================== -;;General Options -;;====================================== - -;;Do you want to print on both sides of the paper? -(define %two-side% - #t) - -;;Do you want enumerated sections? (E.g, 1.1, 1.1.1, 1.2, etc.) -(define %section-autolabel% - #t) - -;;Show URL links? If the text of the link and the URL are identical, -;;the parenthetical URL is suppressed. -(define %show-ulinks% - #t) - -;Make Ulinks footnotes to stop bleeding in the edges - this increases -;'jade --> print' time tremendously keep this in mind before -;complaining! -(define %footnote-ulinks% - #t) - -;;Tex Backend on -(define tex-backend - #t) - -;;Define Line Spacing -(define %line-spacing-factor% 1.3) - -;;Define the Paragraph Style -(define para-style - (style - font-size: %bf-size% - font-weight: 'medium - font-posture: 'upright - font-family-name: %body-font-family% - line-spacing: (* %bf-size% %line-spacing-factor%))) - -(define ($object-titles-after$) - (list (normalize "figure"))) - -;;====================================== -;;Book Options -;;====================================== - - -;;Do you want a title page for a Book? -(define %generate-book-titlepage% - #t) - -;;Do you want a separate page for the title? -(define %generate-book-titlepage-on-separate-page% - #t) - -;;Generate Book TOC? -(define %generate-book-toc% - #t) - -;;What depth should the TOC generate? -;;!Only top level of appendixes! -(define (toc-depth nd) - (if (string=? (gi nd) (normalize "book")) - 3 - (if (string=? (gi nd) (normalize "appendix")) - 0 - 1))) - -;;Do you want a TOC for the element part? -(define %generate-part-toc% - #t) - -;;Do you want the part toc on the part titlepage or separate? -(define %generate-part-toc-on-titlepage% - #t) - -;;Generate Part Title Page? -(define %generate-part-titlepage% - #t) - -;;Do you want the Part intro on the part title page? -(define %generate-partintro-on-titlepage% - #t) - -;;What elements should have a LOT? -(define ($generate-book-lot-list$) - (list (normalize "equation"))) - -;;Do you want chapters enumerated? -(define %chapter-autolabel% - #t) - -;;Do you want Chapter's and Appendix's -;;to have automatic labels? -(define %chap-app-running-head-autolabel% - #t) - -;;====================================== -;;Article Options -;;====================================== - -;;Do you want a title page for an Article? -(define %generate-article-titlepage% - #t) - -;;Generate Article TOC? -(define %generate-article-toc% - #t) - -;;Do you want a separate page for the title? -(define %generate-article-titlepage-on-separate-page% - #t) - -;;Do you want the article toc on the titlepage or separate? -(define %generate-article-toc-on-titlepage% - #t) - -;;Do you want to start new page numbers with each article? -(define %article-page-number-restart% - #f) - -;;Titlepage Separate? -(define (chunk-skip-first-element-list) - '()) - -;;Titlepage Not Separate -;(define (chunk-skip-first-element-list) -; (list (normalize "sect1") -; (normalize "section"))) - -;;====================================== -;;Columns -;;====================================== - -;;How many columns do you want? -(define %page-n-columns% - 1) - -;;How much space between columns? -(define %page-column-sep% - 0.2in) - -;;How many Columns on the titlepage? -(define %titlepage-n-columns% - 1) - -;;Balance columns? -(define %page-balance-colums% - #t) - -;;====================================== -;;Fonts -;;====================================== - -;;Defines the general size of the text in the document. normal(10), -;;presbyopic(12), and large-type(24). -(define %visual-acuity% - "presbyopic") - -;;What font would you like for titles? -(define %title-font-family% - "Helvetica") - -;;What font would you like for the body? -(define %body-font-family% - "Palatino") - -;;What font would you like for mono-seq? -(define %mono-font-family% - "Courier New") - -;;If the base fontsize is 10pt, and '%hsize-bump-factor%' is -;; 1.2, hsize 1 is 12pt, hsize 2 is 14.4pt, hsize 3 is 17.28pt, etc -(define %hsize-bump-factor% - 1.1) - -;;What size do you want the body fonts? -(define %bf-size% - (case %visual-acuity% - (("tiny") 8pt) - (("normal") 10pt) - (("presbyopic") 12pt) - (("large-type") 24pt))) - -(define-unit em %bf-size%) - -;;====================================== -;;Margins -;;====================================== - -(define %left-right-margin% 6pi) - -;;How much indentation for the body? -(define %body-start-indent% - 0pi) - -;;How big is the left margin? (relative to physical page) -(define %left-margin% - 8pi) ;white-paper-column - -;;How big is the right margin? (relative to physical page) -(define %right-margin% - 8pi) ;white-paper-column - -;;How big do you want the margin at the top? -(define %top-margin% - (if (equal? %visual-acuity% "large-type") - 7.5pi - 8pi)) - -;;How big do you want the margin at the bottom? -(define %bottom-margin% - (if (equal? %visual-acuity% "large-type") - 7.5pi - 8pi)) - -;;Define the text width. (Change the elements in the formula rather -;;than the formula itself) -;(define %text-width% (- %page-width% (* %left-right-margin% 2))) -(define %text-width% (- %page-width% (+ %left-margin% %right-margin%))) - -;;Define the body width. (Change the elements in the formula rather -;;than the formula itself) -(define %body-width% - (- %text-width% %body-start-indent%)) - -;;Define distance between paragraphs -(define %para-sep% - (/ %bf-size% 1.0)) - -;;Define distance between block elements (figures, tables, etc.). -(define %block-sep% - (* %para-sep% 1.0)) - -;;Indent block elements? -(define %block-start-indent% - 0pt) -;0pt - -;;====================================== -;;Admon Graphics -;;====================================== - -;;Do you want admon graohics on? -(define %admon-graphics% - #f) - -;;Where are the admon graphics? -(define %admon-graphics-path% - "../images/") - -;;====================================== -;;Quadding -;;====================================== - -;;What quadding do you want by default; start, center, justify, or end? -(define %default-quadding% - 'justify) - -;;What quadding for component titles(Chapter, Appendix, etc)? -(define %component-title-quadding% - 'start) - -;;What quadding for section titles? -(define %section-title-quadding% - 'start) - -;;What quadding for section sub-titles? -(define %section-subtitle-quadding% - 'start) - -;;What quadding for article title? -(define %article-title-quadding% - 'center) - -;;What quadding for article sub-titles? -(define %article-subtitle-quadding% - 'center) - -;;What quadding for division subtitles? -(define %division-subtitle-quadding% - 'start) - -;;What quadding for component subtitles? -(define %component-subtitle-quadding% - 'start) - -;;====================================== -;;Paper Options -;;====================================== - -;;What size paper do you need? A4, USletter, USlandscape, or RedHat? -(define %paper-type% - "USletter") - -;;Now define those paper types' width -(define %page-width% - (case %paper-type% - (("A4") 210mm) - (("USletter") 8.5in) - (("USlandscape") 11in))) - -;;Now define those paper types' height -(define %page-height% - (case %paper-type% - (("A4") 297mm) - (("USletter") 11in) - (("USlandscape") 8.5in))) - -;;====================================== -;;Functions -;;====================================== - -(define (OLSTEP) - (case - (modulo (length (hierarchical-number-recursive "ORDEREDLIST")) 4) - ((1) 1.2em) - ((2) 1.2em) - ((3) 1.6em) - ((0) 1.4em))) - -(define (ILSTEP) 1.0em) - -(define (PROCSTEP ilvl) - (if (> ilvl 1) 1.8em 1.4em)) - -(define (PROCWID ilvl) - (if (> ilvl 1) 1.8em 1.4em)) - -(define ($comptitle$) - (make paragraph - font-family-name: %title-font-family% - font-weight: 'bold - font-size: (HSIZE 2) - line-spacing: (* (HSIZE 2) %line-spacing-factor%) - space-before: (* (HSIZE 2) %head-before-factor%) - space-after: (* (HSIZE 2) %head-after-factor%) - start-indent: 0pt - first-line-start-indent: 0pt - quadding: 'start - keep-with-next?: #t - (process-children-trim))) - -;;Callouts are confusing in Postscript... fix them. -(define %callout-fancy-bug% - #f) - -;;By default perils are centered and dropped into a box with a really -;;big border - I have simply decreased the border thickness - -;;unfortunately it takes all this to do it - sigh. -(define ($peril$) - (let* ((title (select-elements - (children (current-node)) (normalize "title"))) - (has-title (not (node-list-empty? title))) - (adm-title (if has-title - (make sequence - (with-mode title-sosofo-mode - (process-node-list (node-list-first title)))) - (literal - (gentext-element-name - (current-node))))) - (hs (HSIZE 2))) - (if %admon-graphics% - ($graphical-admonition$) - (make display-group - space-before: %block-sep% - space-after: %block-sep% - font-family-name: %admon-font-family% - font-size: (- %bf-size% 1pt) - font-weight: 'medium - font-posture: 'upright - line-spacing: (* (- %bf-size% 1pt) %line-spacing-factor%) - (make box - display?: #t - box-type: 'border - line-thickness: .5pt - start-indent: (+ (inherited-start-indent) (* 2 (ILSTEP)) 2pt) - end-indent: (inherited-end-indent) - (make paragraph - space-before: %para-sep% - space-after: %para-sep% - start-indent: 1em - end-indent: 1em - font-family-name: %title-font-family% - font-weight: 'bold - font-size: hs - line-spacing: (* hs %line-spacing-factor%) - quadding: 'center - keep-with-next?: #t - adm-title) - (process-children)))))) - -;;====================================== -;;Non-printing Elements -;;====================================== -(element TITLEABBREV (empty-sosofo)) -(element SUBTITLE (empty-sosofo)) -(element SETINFO (empty-sosofo)) -(element BOOKINFO (empty-sosofo)) -(element BIBLIOENTRY (empty-sosofo)) -(element BIBLIOMISC (empty-sosofo)) -(element BOOKBIBLIO (empty-sosofo)) -(element SERIESINFO (empty-sosofo)) -(element DOCINFO (empty-sosofo)) -(element ARTHEADER (empty-sosofo)) -;;(element ADDRESS (empty-sosofo)) - -;;Show comment element? -(define %show-comments% - #t) - -;;====================================== -;;Formalpara titles -;;====================================== - -;;Change the way Formal Paragraph titles are displayed. The commented -;;out section will run the titles in the paragraphs. -(element (formalpara title) - ;(make sequence - ;font-weight: 'bold - ;($runinhead$)) - ($lowtitle$ 5 7)) - -;;====================================== -;;Inlines -;;====================================== - -(element application ($mono-seq$)) -(element command ($bold-seq$)) -(element filename ($mono-seq$)) -(element function ($mono-seq$)) -(element guibutton ($bold-seq$)) -(element guiicon ($bold-seq$)) -(element guilabel ($italic-seq$)) -(element guimenu ($bold-seq$)) -(element guimenuitem ($bold-seq$)) -(element hardware ($bold-mono-seq$)) -(element keycap ($bold-seq$)) -(element literal ($mono-seq$)) -(element parameter ($italic-mono-seq$)) -(element prompt ($mono-seq$)) -(element symbol ($charseq$)) -(element emphasis ($italic-seq$)) - - - - - - - diff --git a/Scripts/Functions/Render/Backends/Docbook/Styles/docbook2xhtml-chunks.xsl b/Scripts/Functions/Render/Backends/Docbook/Styles/docbook2xhtml-chunks.xsl deleted file mode 100755 index 9c99ade..0000000 --- a/Scripts/Functions/Render/Backends/Docbook/Styles/docbook2xhtml-chunks.xsl +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/Scripts/Functions/Render/Backends/Docbook/Styles/docbook2xhtml-common.xsl b/Scripts/Functions/Render/Backends/Docbook/Styles/docbook2xhtml-common.xsl deleted file mode 100755 index 2ae3008..0000000 --- a/Scripts/Functions/Render/Backends/Docbook/Styles/docbook2xhtml-common.xsl +++ /dev/null @@ -1,10 +0,0 @@ - - -=REPO_HOME=/trunk/Identity/Webenv/Css/Docbook/default.css - - - -=REPO_HOME=/tags/Identity/Images/Webenv/1.0/ - diff --git a/Scripts/Functions/Render/Backends/Docbook/Styles/docbook2xhtml-single.xsl b/Scripts/Functions/Render/Backends/Docbook/Styles/docbook2xhtml-single.xsl deleted file mode 100755 index 271e624..0000000 --- a/Scripts/Functions/Render/Backends/Docbook/Styles/docbook2xhtml-single.xsl +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/Scripts/Functions/Render/Backends/Docbook/docbook.sh b/Scripts/Functions/Render/Backends/Docbook/docbook.sh deleted file mode 100755 index 4398c75..0000000 --- a/Scripts/Functions/Render/Backends/Docbook/docbook.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -# -# docbook.sh -- This function performs base-rendition actions 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 docbook { - - # Initialize absolute path to Xsl directory. This is the location - # where customization of XSL tranformations are stored in. - DOCBOOK_STYLES_DIR="${RENDER_BACKEND_DIR}/$(cli_getRepoName ${RENDER_BACKEND} -d)/Styles" - - ${RENDER_BACKEND}_convertToXhtmlChunk - ${RENDER_BACKEND}_convertToXhtml - - # WARNING: There are some issues related to DocBook-to-PDF - # transformations that make the whole process not so "clean" as - # DocBook-to-XHTML transformation is. Based on this situation and - # the need of providing a clean output, PDF transformation is - # commented until these issues be corrected. If you have a release - # of CentOS greater than 5.5, uncomment this to see what happen. - #${RENDER_BACKEND}_convertToPdf - -} diff --git a/Scripts/Functions/Render/Backends/Docbook/docbook_convertToPdf.sh b/Scripts/Functions/Render/Backends/Docbook/docbook_convertToPdf.sh deleted file mode 100755 index e1df144..0000000 --- a/Scripts/Functions/Render/Backends/Docbook/docbook_convertToPdf.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# -# docbook_convertToPdf.sh -- This function takes DocBook XML as input -# and produces two different PDF as outputs; one from DocBook XML and -# another from DocBook SGML. We decided to provide support for both -# ways of output production from DocBook XML and DocBook SGML for you -# to evaluate and if possible correct. -# -# 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 docbook_convertToPdf { - - # Tranform DocBook XML to PDF. - ${RENDER_BACKEND}_convertToPdfFromXml - - # Tranform DocBook SGML to PDF. - if [[ $(cli_getCurrentLocale) =~ '^en' ]];then - # FIXME: This is only possible when no localization is - # performed (i.e., xml2po is not involved.) to main DocBook - # file, otherwise there will be errors and the PDF output - # won't be created. The errors come out because when we passed - # the validated DocBook file to xml2po all XML decimal - # entities inside the main DocBook file are expanded and set - # in the msgid field. Such expanded characters are not - # recognized by openjade when they are used as source to - # produce the PDF output. - ${RENDER_BACKEND}_convertToPdfFromSgml - fi - -} diff --git a/Scripts/Functions/Render/Backends/Docbook/docbook_convertToPdfFromSgml.sh b/Scripts/Functions/Render/Backends/Docbook/docbook_convertToPdfFromSgml.sh deleted file mode 100755 index 00e8ce5..0000000 --- a/Scripts/Functions/Render/Backends/Docbook/docbook_convertToPdfFromSgml.sh +++ /dev/null @@ -1,116 +0,0 @@ -#!/bin/bash -# -# docbook_convertToPdfFromSgml.sh -- This function transforms DocBook -# files which have set the SGML DTD in them. To produce PDF from -# DocBook SGML DTD, we take the DocBook XML DTD file and change its -# DTD from XML to SGML. Since XML is SGML shoudn't be any problem. -# Once the DTD has been changed from XML to SGML, we use openjade -# (through `jw' shell script) to convert the SGML-based DocBook file -# to PDF. Customization can be achieved through DSL -# (docbook-style-dsssl-1.79-4.1) shipped in this distribution. -# -# In this configuration and using default configuration settings, I've -# presented the following problems: -# -# 1. It is not possible to produce localized PDF outputs through -# `xml2po', the default way of producing localized content inside -# `centos-art.sh' script. -# -# In this configuration and using default configuration settins, I've -# presented the following advantages: -# -# 1. The PDF output produced from SGML-based files seem to be better -# looking an less buggy than PDF output produced from XML-based -# files, visually I mean. -# -# To make the whole process transparent, a temporal directory is -# created for intermediate works and final files are moved then to -# their final location. -# -# 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 docbook_convertToPdfFromSgml { - - # Print action message. - if [[ -f ${FILE}.sgml.pdf ]];then - cli_printMessage "${FILE}.sgml.pdf" --as-updating-line - else - cli_printMessage "${FILE}.sgml.pdf" --as-creating-line - fi - - local -a STYLE_TEMPLATE - local -a STYLE_INSTANCE - local STYLE_INSTANCE_FINAL='' - - # Define name of temporal directory where the DocBook to PDF - # transformation will take place. - local TMPDIR=$(cli_getTemporalFile "docbook2pdf") - - # Define absolute path to DocBook source file. This is the - # repository documentation manual file where DOCTYPE and ENTITY - # definition lines are set. - local SRC=${INSTANCE} - - # Define absolute path to PDF target file. This is the final - # location the PDF file produced as result of DocBook to PDF - # transformation will be stored in. - local DST="${FILE}.sgml.pdf" - - # Define file name of PDF file. This is the file we were looking - # for and the one moved, once produced. - local PDF=$(basename ${SRC} | sed -r 's!\.docbook$!.pdf!') - - # Replace document definition from XML to SGML. - sed -i -r \ - -e 's!"-//OASIS//DTD DocBook XML!"-//OASIS//DTD DocBook!' \ - -e 's!"http://www\.oasis-open\.org/docbook/xml/([[:digit:]])\.([[:digit:]])/docbookx\.dtd"!"docbook/sgml-dtd-\1.\2-1.0-30.1/docbook.dtd"!' \ - $SRC - - # Prepare style final instance used in transformations. - ${RENDER_BACKEND}_prepareStyles "${DOCBOOK_STYLES_DIR}/docbook2pdf.dsl" - - # Verify temporal directory and create it if doesn't exist. - if [[ ! -d $TMPDIR ]];then - mkdir $TMPDIR - fi - - # Move inside temporal directory. - pushd $TMPDIR > /dev/null - - # Create PDF format. - docbook2pdf --dsl ${STYLE_INSTANCE_FINAL} ${SRC} &> /dev/null - - # Verify `docbook2pdf' exit status and, if everything is ok, move - # PDF file from temporal directory to its target location. - if [[ $? -eq 0 ]];then - mv $PDF $DST - else - cli_printMessage "`gettext "Cannot produce the PDF file."`" --as-error-line - fi - - # Return to where we initially were. - popd > /dev/null - - # Remove temporal directory and temporal style instances created. - rm -r $TMPDIR - rm ${STYLE_INSTANCE[*]} - -} diff --git a/Scripts/Functions/Render/Backends/Docbook/docbook_convertToPdfFromXml.sh b/Scripts/Functions/Render/Backends/Docbook/docbook_convertToPdfFromXml.sh deleted file mode 100755 index b4e61e0..0000000 --- a/Scripts/Functions/Render/Backends/Docbook/docbook_convertToPdfFromXml.sh +++ /dev/null @@ -1,138 +0,0 @@ -#!/bin/bash -# -# docbook_convertToPdfFromXml.sh -- This function transforms DocBook -# files which have set the XML DTD in them. To produce PDF from -# DocBook XML DTD, we need an XSLT engine (e.g., through `xsltproc' -# command) to produce formatting objects (FO), which then must be -# processed with an FO engine (e.g., through `pdfxmltex' command, -# which uses PassiveTex) to produce the PDF output. -# -# In this configuration and using default configuration settings, I've -# presented the following problems: -# -# 1. Something is wrong with headings. They are not expanded along -# the whole page-body. They seem to be rendered in a reduced width -# (1 inch approximatly). This provokes the heading to be broken in a -# two-to-five letters column and sometimes it overlaps the -# sectioning titles (e.g., chatper, section). I tried to customize -# the value of `header.column.widths' and `page.margin.top' but it -# seems to be not there where I need to touch. -# -# 2. TOC's indentation is not rendered. Even the `toc.indent.width' -# property is set to 24 by default. -# -# 3. Inside lists, when items are more than one line, the -# indentation seems to work for the first line only. All other -# lines in the same item are not indented and begin completly -# unaligned. -# -# 4. Long file paths near the end of page-body aren't hyphenated. -# Even the `hyphenate' property is set to `true' by default. -# -# In this configuration and using default configuration settings, I've -# presented the following advantages: -# -# 1. It is possible to produce localized PDF outputs through -# `xml2po', the default way of producing localized content inside -# the `centos-art.sh' script. -# -# To make the whole process transparent, a temporal directory is -# created for intermediate works and final files are moved then to -# their final location. -# -# 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 docbook_convertToPdfFromXml { - - # Print action message. - if [[ -f ${FILE}.sgml.pdf ]];then - cli_printMessage "${FILE}.xml.pdf" --as-updating-line - else - cli_printMessage "${FILE}.xml.pdf" --as-creating-line - fi - - local -a STYLE_TEMPLATE - local -a STYLE_INSTANCE - local STYLE_INSTANCE_FINAL='' - - # Define name of temporal directory where the DocBook to PDF - # transformation will take place. - local TMPDIR=$(cli_getTemporalFile "docbook2pdf") - - # Define absolute path to DocBook source file. This is the - # repository documentation manual file where DOCTYPE and ENTITY - # definition lines are set. - local SRC=${INSTANCE} - - # Define absolute path to PDF target file. This is the final - # location the PDF file produced as result of DocBook to PDF - # transformation will be stored in. - local DST="${FILE}.xml.pdf" - - # Define file name of formatting object (.fo) file. This file is - # an intermediate file needed to produced the PDF. - local FO=$(basename ${FILE}).fo - - # Define file name of PDF file. This is the file we were looking - # for and the one moved, once produced. - local PDF=$(basename ${FILE}).pdf - - # Prepare XSL final instances used in transformations. - ${RENDER_BACKEND}_prepareStyles "${DOCBOOK_STYLES_DIR}/docbook2fo.xsl" - - # Verify temporal directory and create it if doesn't exist. - if [[ ! -d $TMPDIR ]];then - mkdir $TMPDIR - fi - - # Move inside temporal directory. - pushd $TMPDIR > /dev/null - - # Create formatting object supressing output from stderr. - xsltproc --output ${FO} ${STYLE_INSTANCE_FINAL} ${SRC} &> /dev/null - - # Create PDF format from formatting object. The `pdfxmltex' - # command (which use the `PassiveTex' engine) must be executed - # twice in order for the document's cross references to be built - # correctly. - if [[ $? -eq 0 ]];then - pdfxmltex ${FO} > /dev/null - pdfxmltex ${FO} > /dev/null - else - cli_printMessage "`gettext "Cannot produce the formatting object."`" --as-error-line - fi - - # Verify `pdfxmltex' exit status and, if everything is ok, move - # PDF file from temporal directory to its target location. - if [[ $? -eq 0 ]];then - mv $PDF $DST - else - cli_printMessage "`gettext "Cannot produce the PDF file."`" --as-error-line - fi - - # Return to where we initially were. - popd > /dev/null - - # Remove temporal directory and temporal style instances created. - rm -r $TMPDIR - rm ${STYLE_INSTANCE[*]} - -} diff --git a/Scripts/Functions/Render/Backends/Docbook/docbook_convertToText.sh b/Scripts/Functions/Render/Backends/Docbook/docbook_convertToText.sh deleted file mode 100755 index a234cdc..0000000 --- a/Scripts/Functions/Render/Backends/Docbook/docbook_convertToText.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -# -# svg_convertToText.sh -- This function takes the XHTML file produced -# by docbook_convertToXhtml 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 docbook_convertToText { - - # Verify existence of HTML file. If `.xhtml' file doesn't exist - # don't create text file. The `.xhtml' file is required in order - # to create the `.txt' file. - if [[ ! -f ${FILE}.xhtml ]];then - return - fi - - 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 XHTML to plain-text found."`" --as-error-line - fi - -} diff --git a/Scripts/Functions/Render/Backends/Docbook/docbook_convertToXhtml.sh b/Scripts/Functions/Render/Backends/Docbook/docbook_convertToXhtml.sh deleted file mode 100755 index 74b0cb0..0000000 --- a/Scripts/Functions/Render/Backends/Docbook/docbook_convertToXhtml.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash -# -# render_docbook_convertToXhtml.sh -- This function uses DocBook XML -# as input and applies XSL stylesheets to produce a big XHTML files as -# output. The procedure was taken from the documentation of -# `docbook-style-xsl-1.69.1-5.1' package, which says: ---To publish -# HTML from your XML documents, you just need an XSL engine.---. -# -# 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 docbook_convertToXhtml { - - local -a STYLE_TEMPLATE - local -a STYLE_INSTANCE - local STYLE_INSTANCE_FINAL='' - - # 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 absolute path to DocBook source file. This is the - # repository documentation manual file where DOCTYPE and ENTITY - # definition lines are set. - local SRC=${INSTANCE} - - # Define absolute path to PDF target file. This is the final - # location the PDF file produced as result of DocBook to PDF - # transformation will be stored in. - local DST="${FILE}.xhtml" - - # Prepare XSL final instances used in transformations. - ${RENDER_BACKEND}_prepareStyles $(cli_getFilesList \ - ${DOCBOOK_STYLES_DIR} --pattern='.*docbook2xhtml-(single|common)\.xsl') - - # Transform DocBook XML to XHTML supressing all stderr output. - xsltproc --output ${DST} ${STYLE_INSTANCE_FINAL} ${SRC} &> /dev/null - - # Remove XSL instance files. - rm ${STYLE_INSTANCE[*]} - -} diff --git a/Scripts/Functions/Render/Backends/Docbook/docbook_convertToXhtmlChunk.sh b/Scripts/Functions/Render/Backends/Docbook/docbook_convertToXhtmlChunk.sh deleted file mode 100755 index f2df401..0000000 --- a/Scripts/Functions/Render/Backends/Docbook/docbook_convertToXhtmlChunk.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash -# -# render_docbook_convertToXhtmlChunk.sh -- This function uses DocBook -# XML as input and applies XSL stylesheets to produce a directory with -# many XHTML files as output. The procedure was taken from the -# documentation of `docbook-style-xsl-1.69.1-5.1' package, which says: -# ---To publish HTML from your XML documents, you just need an XSLT -# engine.---. -# -# 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 docbook_convertToXhtmlChunk { - - local -a STYLE_TEMPLATE - local -a STYLE_INSTANCE - local STYLE_INSTANCE_FINAL='' - - # Define absolute path to PDF target file. This is the final - # location the PDF file produced as result of DocBook to PDF - # transformation will be stored in. - local DST="${FILE}-xhtml/" - - # Clean up output directory. This is required in order to prevent - # old files from remaining therein when they are no longer needed. - if [[ -d ${DST} ]];then - rm -r "${DST}" - fi - mkdir ${DST} - - # Print action message. - cli_printMessage "${FILE}-xhtml" --as-creating-line - - # Define absolute path to DocBook source file. This is the - # repository documentation manual file where DOCTYPE and ENTITY - # definition lines are set. - local SRC=${INSTANCE} - - # Prepare XSL final instances used in transformations. - ${RENDER_BACKEND}_prepareStyles $(cli_getFilesList \ - ${DOCBOOK_STYLES_DIR} --pattern='.*docbook2xhtml-(chunks|common)\.xsl') - - # Transform DocBook XML to XHTML supressing all stderr output. - xsltproc --output ${DST} ${STYLE_INSTANCE_FINAL} ${SRC} &> /dev/null - - # Remove XSL instance files. - rm ${STYLE_INSTANCE[*]} - -} diff --git a/Scripts/Functions/Render/Backends/Docbook/docbook_doLastActions.sh b/Scripts/Functions/Render/Backends/Docbook/docbook_doLastActions.sh deleted file mode 100755 index d3dc57f..0000000 --- a/Scripts/Functions/Render/Backends/Docbook/docbook_doLastActions.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -# -# docbook_doLastActions.sh -- This function performs last-rendition -# actions for DocBook files. These are the actions that take -# base-rendition and post-rendition output as input to produce output -# from it. -# -# 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 docbook_doLastActions { - - # Presently, there is no last-rendition action for DocBook base - # rendition but the function should exist for consistency with - # other backends. - return - -} diff --git a/Scripts/Functions/Render/Backends/Docbook/docbook_doPostActions.sh b/Scripts/Functions/Render/Backends/Docbook/docbook_doPostActions.sh deleted file mode 100755 index e4e8cea..0000000 --- a/Scripts/Functions/Render/Backends/Docbook/docbook_doPostActions.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -# -# docbook_doPostActions.sh -- This function performs post-rendition -# actions for DocBook files. These are the actions that take -# base-rendition output as input to producing output from it. -# -# 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 docbook_doPostActions { - - ${RENDER_BACKEND}_convertToText - -} diff --git a/Scripts/Functions/Render/Backends/Docbook/docbook_prepareStyles.sh b/Scripts/Functions/Render/Backends/Docbook/docbook_prepareStyles.sh deleted file mode 100755 index 201cb0f..0000000 --- a/Scripts/Functions/Render/Backends/Docbook/docbook_prepareStyles.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash -# -# docbook_prepareStyles.sh -- This function prepares styles' final -# instances used in transformations based on XSL or DSL templates. -# There are translation markers inside the XSL and DSL templates that -# need to be expand before they be used for transformations. This -# function creates temporal instances of XSL and DSL templates with -# translation markers expanded inside so as for transformation -# commands (e.g., `xmltproc' or `openjade' through `docbook2pdf') to -# use as style defintion. -# -# 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 docbook_prepareStyles { - - local STYLE_TEMPLATE_FILE='' - local STYLE_TEMPLATE_FILES=$@ - local STYLE_INSTANCE_COMMON='' - local COUNT=0 - - for STYLE_TEMPLATE_FILE in $STYLE_TEMPLATE_FILES;do - - STYLE_TEMPLATE[((++${#STYLE_TEMPLATE[*]}))]="${STYLE_TEMPLATE_FILE}" - STYLE_INSTANCE[((++${#STYLE_INSTANCE[*]}))]="$(cli_getTemporalFile ${STYLE_TEMPLATE_FILE})" - - # Keep track of array's real index value. Remember, it starts - # at zero but counting starts at 1 instead. So, substracting 1 - # from counting we have the real index value we need to work - # with the information stored in the array. - COUNT=$(( ${#STYLE_INSTANCE[*]} - 1 )) - - # Create style instance from style template. - cp ${STYLE_TEMPLATE[$COUNT]} ${STYLE_INSTANCE[$COUNT]} - - # Define both final an common style instances based on style - # templates. - if [[ $STYLE_TEMPLATE_FILE =~ 'docbook2fo\.xsl$' ]];then - STYLE_INSTANCE_FINAL=${STYLE_INSTANCE[$COUNT]} - elif [[ $STYLE_TEMPLATE_FILE =~ 'docbook2pdf\.dsl$' ]];then - STYLE_INSTANCE_FINAL=${STYLE_INSTANCE[${COUNT}]} - elif [[ $STYLE_TEMPLATE_FILE =~ 'docbook2xhtml-(chunks|single)\.xsl$' ]];then - STYLE_INSTANCE_FINAL=${STYLE_INSTANCE[${COUNT}]} - elif [[ $STYLE_TEMPLATE_FILE =~ 'docbook2xhtml-common\.xsl$' ]];then - STYLE_INSTANCE_COMMON=${STYLE_INSTANCE[${COUNT}]} - fi - - done - - # Verify style final instance. This is the file used by - # transformation command (`xsltproc' or `openjade') to produce the - # specified output. We cannot continue without it. - cli_checkFiles $STYLE_INSTANCE_FINAL - - # Expand common translation markers in the common style instance, - # if it exists. - if [[ -f $STYLE_INSTANCE_COMMON ]];then - cli_replaceTMarkers $STYLE_INSTANCE_COMMON - fi - - # Expand specific translation markers in final style instance. - sed -r -i "s!=STYLE_XHTML_COMMON=!${STYLE_INSTANCE_COMMON}!" ${STYLE_INSTANCE_FINAL} - -} diff --git a/Scripts/Functions/Render/Backends/Svg/svg.sh b/Scripts/Functions/Render/Backends/Svg/svg.sh deleted file mode 100644 index 1746f72..0000000 --- a/Scripts/Functions/Render/Backends/Svg/svg.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -# -# 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 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_BACKEND}_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_BACKEND}_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 deleted file mode 100755 index dc99dba..0000000 --- a/Scripts/Functions/Render/Backends/Svg/svg_checkColorAmount.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -# -# 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 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 deleted file mode 100755 index f84a813..0000000 --- a/Scripts/Functions/Render/Backends/Svg/svg_checkColorFormats.sh +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/bash -# -# 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 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 deleted file mode 100755 index 58bb87d..0000000 --- a/Scripts/Functions/Render/Backends/Svg/svg_checkModelAbsref.sh +++ /dev/null @@ -1,141 +0,0 @@ -#!/bin/bash -# -# 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 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 message. - cli_printMessage "$BG_DST_FILE" --as-checking-line - - # Verify parent directory of absolute files retrived from - # file. This is required to prevent the construction of paths - # to locations that don't exist. For example, when including - # background images in SVG files, it is possible that the path - # information inside SVG files get outdated temporarly. If in - # that exact moment, you try to render the SVG file it won't - # be possible to create the image used for cropping because - # the path build from the location inside SVG file doesn't - # exist. In this case, centos-art.sh script will end up with - # `file ... doesn't exist' errors. - cli_checkFiles "$(dirname ${BG_DST_FILE})" -d - - 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_BACKEND}_getColors) - - # Verify format of color value. - ${RENDER_BACKEND}_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 deleted file mode 100755 index d8ac19d..0000000 --- a/Scripts/Functions/Render/Backends/Svg/svg_checkModelExportId.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash -# -# 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 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 deleted file mode 100755 index 7718ee7..0000000 --- a/Scripts/Functions/Render/Backends/Svg/svg_convertGplToHex.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash -# -# 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 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_BACKEND}_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_BACKEND}_checkColorAmount "$COLORS" "$NUMBER" - - # Verify format of colors. - ${RENDER_BACKEND}_checkColorFormats "$COLORS" --format='rrggbb' - - # Create list of colors to be processed by `pnmtolss16'. - echo "$COLORS" | nl | gawk '{ 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 deleted file mode 100755 index c11305f..0000000 --- a/Scripts/Functions/Render/Backends/Svg/svg_convertGplToPpm.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash -# -# 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 svg_convertGplToPpm { - - 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_BACKEND}_getColors "$PALETTE_GPL" --head=$NUMBER --tail=$NUMBER --format='rrrggbb') - - # Verify amount of colors in the list of colors. - ${RENDER_BACKEND}_checkColorAmount "$COLORS" "$NUMBER" - - # Verify format of colors. - ${RENDER_BACKEND}_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 deleted file mode 100644 index db10df3..0000000 --- a/Scripts/Functions/Render/Backends/Svg/svg_convertPngTo.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -# -# 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 svg_convertPngTo { - - # Initialize image formats. - local FORMAT='' - local FORMATS=$(render_getConfigOption "$ACTION" '2') - - # Convert from PNG to specified formats. - 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 deleted file mode 100644 index dda21aa..0000000 --- a/Scripts/Functions/Render/Backends/Svg/svg_convertPngToBrands.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -# -# svg_convertPngToBrands.sh -- This function provides post-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 svg_convertPngToBrands { - - # Define height dimensions you want to produce brands for. - local SIZE="" - 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 FORMAT="" - 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. Use resize - # support with a value less than 1.0 for sharpening. This - # make resized brands to look better. Otherwise, if the - # resize support is greater than 1.0 or none at all, - # resized brands are blured instead. - 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 deleted file mode 100755 index 19542e8..0000000 --- a/Scripts/Functions/Render/Backends/Svg/svg_convertPngToDm.sh +++ /dev/null @@ -1,182 +0,0 @@ -#!/bin/bash -# -# 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 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 used by display manager theme. - # These are the different screen resolutions a display manager - # theme is built for. The amount of screen resolution a display - # manager theme can be built for is limited to the amount of - # background files provided by the artistic motif used to build - # the display manager theme. - 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 artistic motif's 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. Use the colon character - # (`:') as separator; on the left side we put the file's source - # location and in the right side the file's target location. - # 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}/Symbols/centos-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}/Symbols/centos-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 deleted file mode 100644 index 5f85ea8..0000000 --- a/Scripts/Functions/Render/Backends/Svg/svg_convertPngToGrub.sh +++ /dev/null @@ -1,143 +0,0 @@ -#!/bin/bash -# -# svg_convertPngToGrub.sh -- This function provides post-rendition -# action used to produce GRUB images. -# -# Initially, the color information is defined with GIMP (The GNU Image -# Manipulation Program) as a `.gpl' palette of color. This palette of -# colors contains 14 colors only and is saved in a file named -# `grub.gpl. The `grub.gpl' file is used to build the `grub.ppm' file -# which provide the color information needed to reduce the full color -# PNG image, produced as result of SVG base-rendition, to the amount -# of colors specified (i.e., 14 colors). Later, with the 14 color PNG -# image already created, the `grub.ppm' file is used to build the -# `splash.xpm.gz' file. -# -# In order for this function to work, the `grub.gpl' file should have -# a format similar to the following: -# -# GIMP Palette -# Name: CentOS-TreeFlower-4-Syslinux -# Columns: 14 -# # -# 32 76 141 204c8d -# 36 82 146 245292 -# 52 93 152 345d98 -# 72 108 162 486ca2 -# 102 131 176 6683b0 -# 126 153 190 7e99be -# 146 170 200 92aac8 -# 161 182 209 a1b6d1 -# 182 199 219 b6c7db -# 202 214 228 cad6e4 -# 221 230 238 dde6ee -# 235 241 245 ebf1f5 -# 246 251 254 f6fbfe -# 254 255 252 fefffc -# -# 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 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 through subversion (to keep track - # of the change) and expand translation markers in the copied - # instance. - if [[ ! -f $PALETTE_GPL ]];then - svn 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_BACKEND}_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 deleted file mode 100755 index e56401e..0000000 --- a/Scripts/Functions/Render/Backends/Svg/svg_convertPngToKsplash.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/bash -# -# 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 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 deleted file mode 100755 index 3da4ae9..0000000 --- a/Scripts/Functions/Render/Backends/Svg/svg_convertPngToSyslinux.sh +++ /dev/null @@ -1,184 +0,0 @@ -#!/bin/bash -# -# svg_convertPngToSyslinux.sh -- This function provides post-rendition -# action used to produce LSS16 images, the images used by isolinux. -# -# Initially, the color information is defined with GIMP (The GNU Image -# Manipulation Program) as a `.gpl' 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' provides the color information needed to reduce the -# full color PNG image, produced as result of SVG base-rendition, to -# the amount of colors specified (i.e., 16 colors). Later, with the 16 -# color PNG 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 required -# that both the `syslinux.ppm' and `syslinux.hex' files do contain the -# same color information. This is, both `syslinux.ppm' and -# `syslinux.hex' must represent the same color values and in the same -# color index. -# -# In order for this function to work, the `syslinux.gpl' file should -# have a format similar to the following: -# -# GIMP Palette -# Name: CentOS-TreeFlower-4-Syslinux -# Columns: 16 -# # -# 32 76 141 204c8d -# 37 82 146 255292 -# 52 94 153 345e99 -# 73 110 162 496ea2 -# 91 124 172 5b7cac -# 108 136 180 6c88b4 -# 120 146 186 7892ba -# 131 158 193 839ec1 -# 255 255 255 ffffff -# 146 170 200 92aac8 -# 162 182 209 a2b6d1 -# 183 199 219 b7c7db -# 204 216 230 ccd8e6 -# 221 229 238 dde5ee -# 235 241 245 ebf1f5 -# 246 251 254 f6fbfe -# -# 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 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 through subversion (to keep track - # of the change) and expand translation markers in the copied - # instance. - if [[ ! -f $PALETTE_GPL ]];then - svn 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_BACKEND}_convertGplToPpm "$PALETTE_GPL" "$PALETTE_PPM" "$COLORS" - - # Create HEX palette using GPL palette. - ${RENDER_BACKEND}_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 deleted file mode 100755 index 16d428c..0000000 --- a/Scripts/Functions/Render/Backends/Svg/svg_convertPngToThumbnail.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash -# -# 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 svg_convertPngToThumbnail { - - # Get image size. - local 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 deleted file mode 100644 index 1a3b7a5..0000000 --- a/Scripts/Functions/Render/Backends/Svg/svg_doLastActions.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# -# 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 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[*]}))]='convertPngToDm:Gdm:800x600 1024x768 1280x1024 1360x768 2048x1536 2560x1240' - elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Kdm/.+\.svg$" ]];then - LASTACTIONS[((++${#LASTACTIONS[*]}))]='convertPngToDm:Kdm:800x600 1024x768 1280x1024 1360x768 2048x1536 2560x1240' - elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Ksplash/.+\.svg$" ]];then - LASTACTIONS[((++${#LASTACTIONS[*]}))]='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 - ${RENDER_BACKEND}_$(echo "$ACTION" | cut -d: -f1) - done - -} diff --git a/Scripts/Functions/Render/Backends/Svg/svg_doLastCommand.sh b/Scripts/Functions/Render/Backends/Svg/svg_doLastCommand.sh deleted file mode 100755 index 34f1a2a..0000000 --- a/Scripts/Functions/Render/Backends/Svg/svg_doLastCommand.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash -# -# svg_doLastCommand.sh -- This function standardizes the way -# last-rendition commands are applied to base-rendition and -# post-rendition outputs. -# -# 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 svg_doLastCommand { - - # Define the file extensions. This value is a regular expression - # pattern which must match the file extensions that last-rendition - # actions will be applied to. - local EXTENSION=$(render_getConfigOption "$ACTION" '2') - - # Define the command string that will be evaluated as - # last-rendition action. Only commands that perform in-place - # modifications can be passed here. - local COMMAND=$(render_getConfigOption "$ACTION" '3-') - - # Define the list of files to process. This value contain all the - # files in the output directory which extension match the - # extension pattern previously defined. - local FILE='' - local FILES=$(cli_getFilesList $OUTPUT --pattern=".+\.${EXTENSION}") - - for FILE in $FILES;do - - # Identify file before processing it. Only formats recognized - # by ImageMagick are supported. In case the file isn't - # supported by ImageMagick, continue with the next file in the - # list. - identify -quiet ${FILE} > /dev/null - if [[ $? -ne 0 ]];then - continue - fi - - # Print action message. - cli_printMessage "${FILE}" --as-updating-line - - # Execute mogrify action on all files inside the same - # directory structure. - eval ${COMMAND} ${FILE} - - # Be sure the command was executed correctly. Otherwise stop - # script execution. - if [[ $? -ne 0 ]];then - exit - fi - - done - -} diff --git a/Scripts/Functions/Render/Backends/Svg/svg_doPostActions.sh b/Scripts/Functions/Render/Backends/Svg/svg_doPostActions.sh deleted file mode 100644 index 57f6fb0..0000000 --- a/Scripts/Functions/Render/Backends/Svg/svg_doPostActions.sh +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/bash -# -# 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 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 Artwork 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[*]}))]="doPostCommand:png:mogrify -comment '$COMMENT'" - [[ $FLAG_POSTRENDITION != '' ]] && POSTACTIONS[((++${#POSTACTIONS[*]}))]="doPostCommand: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[*]}))]='convertPngTo:jpg' - POSTACTIONS[((++${#POSTACTIONS[*]}))]='groupBy:png jpg' - elif [[ $TEMPLATE =~ "Concept/.+\.svg$" ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngTo:jpg pdf' - POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToThumbnail:250' - elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Syslinux/.+\.svg$" ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToSyslinux:' - POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToSyslinux:-floyd' - elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Grub/.+\.svg$" ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToGrub:' - POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToGrub:-floyd' - elif [[ $TEMPLATE =~ "Posters/.+\.svg$" ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngTo:jpg pdf' - elif [[ $TEMPLATE =~ "trunk/Identity/Models/Brands/.+\.svg$" ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToBrands' - elif [[ $TEMPLATE =~ "trunk/Identity/Models/Manuals.+\.svg$" ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngTo:jpg pdf' - fi - fi - - # Execute SVG post-rendition actions. - for ACTION in "${POSTACTIONS[@]}"; do - ${RENDER_BACKEND}_$(echo "$ACTION" | cut -d: -f1) - done - -} diff --git a/Scripts/Functions/Render/Backends/Svg/svg_doPostCommand.sh b/Scripts/Functions/Render/Backends/Svg/svg_doPostCommand.sh deleted file mode 100755 index 6892434..0000000 --- a/Scripts/Functions/Render/Backends/Svg/svg_doPostCommand.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -# -# svg_doPostCommand.sh -- This function standardizes the way -# post-rendition commands are applied to base-rendition output. -# -# 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 svg_doPostCommand { - - # Define the file extension of base-rendition output. - local EXTENSION=$(render_getConfigOption "$ACTION" '2') - - # Define the command string. - local COMMAND=$(render_getConfigOption "$ACTION" '3-') - - # Verify the absolute path of base-rendition output. - cli_checkFiles ${FILE}.${EXTENSION} - - # Execute the command string on base-rendition output. - eval $COMMAND ${FILE}.${EXTENSION} - - # Be sure the command string was executed correctly. Otherwise - # stop the script execution. - if [[ $? -ne 0 ]];then - exit - fi - -} diff --git a/Scripts/Functions/Render/Backends/Svg/svg_getColors.sh b/Scripts/Functions/Render/Backends/Svg/svg_getColors.sh deleted file mode 100755 index 157e32b..0000000 --- a/Scripts/Functions/Render/Backends/Svg/svg_getColors.sh +++ /dev/null @@ -1,153 +0,0 @@ -#!/bin/bash -# -# 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 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_BACKEND}_getColors $MOTIF_PALETTE --head=1 --tail=1) - elif [[ -f $MODEL_PALETTE ]];then - COLORS=$(${RENDER_BACKEND}_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 deleted file mode 100755 index 08f5aaf..0000000 --- a/Scripts/Functions/Render/Backends/Svg/svg_groupBy.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -# -# 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 svg_groupBy { - - local SOURCE='' - local TARGET='' - - # Sanitate file types passed from render.conf.sh pre-rendition - # configuration script. - local FORMAT='' - 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/Docbook/Styles/docbook2fo.xsl b/Scripts/Functions/Render/Docbook/Styles/docbook2fo.xsl new file mode 100755 index 0000000..6eac1da --- /dev/null +++ b/Scripts/Functions/Render/Docbook/Styles/docbook2fo.xsl @@ -0,0 +1,6 @@ + + + + diff --git a/Scripts/Functions/Render/Docbook/Styles/docbook2pdf.dsl b/Scripts/Functions/Render/Docbook/Styles/docbook2pdf.dsl new file mode 100644 index 0000000..407a604 --- /dev/null +++ b/Scripts/Functions/Render/Docbook/Styles/docbook2pdf.dsl @@ -0,0 +1,464 @@ + + +]]> +]> + + + + + + +;;====================================== +;;General Options +;;====================================== + +;;Do you want to print on both sides of the paper? +(define %two-side% + #t) + +;;Do you want enumerated sections? (E.g, 1.1, 1.1.1, 1.2, etc.) +(define %section-autolabel% + #t) + +;;Show URL links? If the text of the link and the URL are identical, +;;the parenthetical URL is suppressed. +(define %show-ulinks% + #t) + +;Make Ulinks footnotes to stop bleeding in the edges - this increases +;'jade --> print' time tremendously keep this in mind before +;complaining! +(define %footnote-ulinks% + #t) + +;;Tex Backend on +(define tex-backend + #t) + +;;Define Line Spacing +(define %line-spacing-factor% 1.3) + +;;Define the Paragraph Style +(define para-style + (style + font-size: %bf-size% + font-weight: 'medium + font-posture: 'upright + font-family-name: %body-font-family% + line-spacing: (* %bf-size% %line-spacing-factor%))) + +(define ($object-titles-after$) + (list (normalize "figure"))) + +;;====================================== +;;Book Options +;;====================================== + + +;;Do you want a title page for a Book? +(define %generate-book-titlepage% + #t) + +;;Do you want a separate page for the title? +(define %generate-book-titlepage-on-separate-page% + #t) + +;;Generate Book TOC? +(define %generate-book-toc% + #t) + +;;What depth should the TOC generate? +;;!Only top level of appendixes! +(define (toc-depth nd) + (if (string=? (gi nd) (normalize "book")) + 3 + (if (string=? (gi nd) (normalize "appendix")) + 0 + 1))) + +;;Do you want a TOC for the element part? +(define %generate-part-toc% + #t) + +;;Do you want the part toc on the part titlepage or separate? +(define %generate-part-toc-on-titlepage% + #t) + +;;Generate Part Title Page? +(define %generate-part-titlepage% + #t) + +;;Do you want the Part intro on the part title page? +(define %generate-partintro-on-titlepage% + #t) + +;;What elements should have a LOT? +(define ($generate-book-lot-list$) + (list (normalize "equation"))) + +;;Do you want chapters enumerated? +(define %chapter-autolabel% + #t) + +;;Do you want Chapter's and Appendix's +;;to have automatic labels? +(define %chap-app-running-head-autolabel% + #t) + +;;====================================== +;;Article Options +;;====================================== + +;;Do you want a title page for an Article? +(define %generate-article-titlepage% + #t) + +;;Generate Article TOC? +(define %generate-article-toc% + #t) + +;;Do you want a separate page for the title? +(define %generate-article-titlepage-on-separate-page% + #t) + +;;Do you want the article toc on the titlepage or separate? +(define %generate-article-toc-on-titlepage% + #t) + +;;Do you want to start new page numbers with each article? +(define %article-page-number-restart% + #f) + +;;Titlepage Separate? +(define (chunk-skip-first-element-list) + '()) + +;;Titlepage Not Separate +;(define (chunk-skip-first-element-list) +; (list (normalize "sect1") +; (normalize "section"))) + +;;====================================== +;;Columns +;;====================================== + +;;How many columns do you want? +(define %page-n-columns% + 1) + +;;How much space between columns? +(define %page-column-sep% + 0.2in) + +;;How many Columns on the titlepage? +(define %titlepage-n-columns% + 1) + +;;Balance columns? +(define %page-balance-colums% + #t) + +;;====================================== +;;Fonts +;;====================================== + +;;Defines the general size of the text in the document. normal(10), +;;presbyopic(12), and large-type(24). +(define %visual-acuity% + "presbyopic") + +;;What font would you like for titles? +(define %title-font-family% + "Helvetica") + +;;What font would you like for the body? +(define %body-font-family% + "Palatino") + +;;What font would you like for mono-seq? +(define %mono-font-family% + "Courier New") + +;;If the base fontsize is 10pt, and '%hsize-bump-factor%' is +;; 1.2, hsize 1 is 12pt, hsize 2 is 14.4pt, hsize 3 is 17.28pt, etc +(define %hsize-bump-factor% + 1.1) + +;;What size do you want the body fonts? +(define %bf-size% + (case %visual-acuity% + (("tiny") 8pt) + (("normal") 10pt) + (("presbyopic") 12pt) + (("large-type") 24pt))) + +(define-unit em %bf-size%) + +;;====================================== +;;Margins +;;====================================== + +(define %left-right-margin% 6pi) + +;;How much indentation for the body? +(define %body-start-indent% + 0pi) + +;;How big is the left margin? (relative to physical page) +(define %left-margin% + 8pi) ;white-paper-column + +;;How big is the right margin? (relative to physical page) +(define %right-margin% + 8pi) ;white-paper-column + +;;How big do you want the margin at the top? +(define %top-margin% + (if (equal? %visual-acuity% "large-type") + 7.5pi + 8pi)) + +;;How big do you want the margin at the bottom? +(define %bottom-margin% + (if (equal? %visual-acuity% "large-type") + 7.5pi + 8pi)) + +;;Define the text width. (Change the elements in the formula rather +;;than the formula itself) +;(define %text-width% (- %page-width% (* %left-right-margin% 2))) +(define %text-width% (- %page-width% (+ %left-margin% %right-margin%))) + +;;Define the body width. (Change the elements in the formula rather +;;than the formula itself) +(define %body-width% + (- %text-width% %body-start-indent%)) + +;;Define distance between paragraphs +(define %para-sep% + (/ %bf-size% 1.0)) + +;;Define distance between block elements (figures, tables, etc.). +(define %block-sep% + (* %para-sep% 1.0)) + +;;Indent block elements? +(define %block-start-indent% + 0pt) +;0pt + +;;====================================== +;;Admon Graphics +;;====================================== + +;;Do you want admon graohics on? +(define %admon-graphics% + #f) + +;;Where are the admon graphics? +(define %admon-graphics-path% + "../images/") + +;;====================================== +;;Quadding +;;====================================== + +;;What quadding do you want by default; start, center, justify, or end? +(define %default-quadding% + 'justify) + +;;What quadding for component titles(Chapter, Appendix, etc)? +(define %component-title-quadding% + 'start) + +;;What quadding for section titles? +(define %section-title-quadding% + 'start) + +;;What quadding for section sub-titles? +(define %section-subtitle-quadding% + 'start) + +;;What quadding for article title? +(define %article-title-quadding% + 'center) + +;;What quadding for article sub-titles? +(define %article-subtitle-quadding% + 'center) + +;;What quadding for division subtitles? +(define %division-subtitle-quadding% + 'start) + +;;What quadding for component subtitles? +(define %component-subtitle-quadding% + 'start) + +;;====================================== +;;Paper Options +;;====================================== + +;;What size paper do you need? A4, USletter, USlandscape, or RedHat? +(define %paper-type% + "USletter") + +;;Now define those paper types' width +(define %page-width% + (case %paper-type% + (("A4") 210mm) + (("USletter") 8.5in) + (("USlandscape") 11in))) + +;;Now define those paper types' height +(define %page-height% + (case %paper-type% + (("A4") 297mm) + (("USletter") 11in) + (("USlandscape") 8.5in))) + +;;====================================== +;;Functions +;;====================================== + +(define (OLSTEP) + (case + (modulo (length (hierarchical-number-recursive "ORDEREDLIST")) 4) + ((1) 1.2em) + ((2) 1.2em) + ((3) 1.6em) + ((0) 1.4em))) + +(define (ILSTEP) 1.0em) + +(define (PROCSTEP ilvl) + (if (> ilvl 1) 1.8em 1.4em)) + +(define (PROCWID ilvl) + (if (> ilvl 1) 1.8em 1.4em)) + +(define ($comptitle$) + (make paragraph + font-family-name: %title-font-family% + font-weight: 'bold + font-size: (HSIZE 2) + line-spacing: (* (HSIZE 2) %line-spacing-factor%) + space-before: (* (HSIZE 2) %head-before-factor%) + space-after: (* (HSIZE 2) %head-after-factor%) + start-indent: 0pt + first-line-start-indent: 0pt + quadding: 'start + keep-with-next?: #t + (process-children-trim))) + +;;Callouts are confusing in Postscript... fix them. +(define %callout-fancy-bug% + #f) + +;;By default perils are centered and dropped into a box with a really +;;big border - I have simply decreased the border thickness - +;;unfortunately it takes all this to do it - sigh. +(define ($peril$) + (let* ((title (select-elements + (children (current-node)) (normalize "title"))) + (has-title (not (node-list-empty? title))) + (adm-title (if has-title + (make sequence + (with-mode title-sosofo-mode + (process-node-list (node-list-first title)))) + (literal + (gentext-element-name + (current-node))))) + (hs (HSIZE 2))) + (if %admon-graphics% + ($graphical-admonition$) + (make display-group + space-before: %block-sep% + space-after: %block-sep% + font-family-name: %admon-font-family% + font-size: (- %bf-size% 1pt) + font-weight: 'medium + font-posture: 'upright + line-spacing: (* (- %bf-size% 1pt) %line-spacing-factor%) + (make box + display?: #t + box-type: 'border + line-thickness: .5pt + start-indent: (+ (inherited-start-indent) (* 2 (ILSTEP)) 2pt) + end-indent: (inherited-end-indent) + (make paragraph + space-before: %para-sep% + space-after: %para-sep% + start-indent: 1em + end-indent: 1em + font-family-name: %title-font-family% + font-weight: 'bold + font-size: hs + line-spacing: (* hs %line-spacing-factor%) + quadding: 'center + keep-with-next?: #t + adm-title) + (process-children)))))) + +;;====================================== +;;Non-printing Elements +;;====================================== +(element TITLEABBREV (empty-sosofo)) +(element SUBTITLE (empty-sosofo)) +(element SETINFO (empty-sosofo)) +(element BOOKINFO (empty-sosofo)) +(element BIBLIOENTRY (empty-sosofo)) +(element BIBLIOMISC (empty-sosofo)) +(element BOOKBIBLIO (empty-sosofo)) +(element SERIESINFO (empty-sosofo)) +(element DOCINFO (empty-sosofo)) +(element ARTHEADER (empty-sosofo)) +;;(element ADDRESS (empty-sosofo)) + +;;Show comment element? +(define %show-comments% + #t) + +;;====================================== +;;Formalpara titles +;;====================================== + +;;Change the way Formal Paragraph titles are displayed. The commented +;;out section will run the titles in the paragraphs. +(element (formalpara title) + ;(make sequence + ;font-weight: 'bold + ;($runinhead$)) + ($lowtitle$ 5 7)) + +;;====================================== +;;Inlines +;;====================================== + +(element application ($mono-seq$)) +(element command ($bold-seq$)) +(element filename ($mono-seq$)) +(element function ($mono-seq$)) +(element guibutton ($bold-seq$)) +(element guiicon ($bold-seq$)) +(element guilabel ($italic-seq$)) +(element guimenu ($bold-seq$)) +(element guimenuitem ($bold-seq$)) +(element hardware ($bold-mono-seq$)) +(element keycap ($bold-seq$)) +(element literal ($mono-seq$)) +(element parameter ($italic-mono-seq$)) +(element prompt ($mono-seq$)) +(element symbol ($charseq$)) +(element emphasis ($italic-seq$)) + + + + + + + diff --git a/Scripts/Functions/Render/Docbook/Styles/docbook2xhtml-chunks.xsl b/Scripts/Functions/Render/Docbook/Styles/docbook2xhtml-chunks.xsl new file mode 100755 index 0000000..9c99ade --- /dev/null +++ b/Scripts/Functions/Render/Docbook/Styles/docbook2xhtml-chunks.xsl @@ -0,0 +1,7 @@ + + + + + diff --git a/Scripts/Functions/Render/Docbook/Styles/docbook2xhtml-common.xsl b/Scripts/Functions/Render/Docbook/Styles/docbook2xhtml-common.xsl new file mode 100755 index 0000000..2ae3008 --- /dev/null +++ b/Scripts/Functions/Render/Docbook/Styles/docbook2xhtml-common.xsl @@ -0,0 +1,10 @@ + + +=REPO_HOME=/trunk/Identity/Webenv/Css/Docbook/default.css + + + +=REPO_HOME=/tags/Identity/Images/Webenv/1.0/ + diff --git a/Scripts/Functions/Render/Docbook/Styles/docbook2xhtml-single.xsl b/Scripts/Functions/Render/Docbook/Styles/docbook2xhtml-single.xsl new file mode 100755 index 0000000..271e624 --- /dev/null +++ b/Scripts/Functions/Render/Docbook/Styles/docbook2xhtml-single.xsl @@ -0,0 +1,7 @@ + + + + + diff --git a/Scripts/Functions/Render/Docbook/docbook.sh b/Scripts/Functions/Render/Docbook/docbook.sh new file mode 100755 index 0000000..4398c75 --- /dev/null +++ b/Scripts/Functions/Render/Docbook/docbook.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# +# docbook.sh -- This function performs base-rendition actions 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 docbook { + + # Initialize absolute path to Xsl directory. This is the location + # where customization of XSL tranformations are stored in. + DOCBOOK_STYLES_DIR="${RENDER_BACKEND_DIR}/$(cli_getRepoName ${RENDER_BACKEND} -d)/Styles" + + ${RENDER_BACKEND}_convertToXhtmlChunk + ${RENDER_BACKEND}_convertToXhtml + + # WARNING: There are some issues related to DocBook-to-PDF + # transformations that make the whole process not so "clean" as + # DocBook-to-XHTML transformation is. Based on this situation and + # the need of providing a clean output, PDF transformation is + # commented until these issues be corrected. If you have a release + # of CentOS greater than 5.5, uncomment this to see what happen. + #${RENDER_BACKEND}_convertToPdf + +} diff --git a/Scripts/Functions/Render/Docbook/docbook_convertToPdf.sh b/Scripts/Functions/Render/Docbook/docbook_convertToPdf.sh new file mode 100755 index 0000000..e1df144 --- /dev/null +++ b/Scripts/Functions/Render/Docbook/docbook_convertToPdf.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# +# docbook_convertToPdf.sh -- This function takes DocBook XML as input +# and produces two different PDF as outputs; one from DocBook XML and +# another from DocBook SGML. We decided to provide support for both +# ways of output production from DocBook XML and DocBook SGML for you +# to evaluate and if possible correct. +# +# 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 docbook_convertToPdf { + + # Tranform DocBook XML to PDF. + ${RENDER_BACKEND}_convertToPdfFromXml + + # Tranform DocBook SGML to PDF. + if [[ $(cli_getCurrentLocale) =~ '^en' ]];then + # FIXME: This is only possible when no localization is + # performed (i.e., xml2po is not involved.) to main DocBook + # file, otherwise there will be errors and the PDF output + # won't be created. The errors come out because when we passed + # the validated DocBook file to xml2po all XML decimal + # entities inside the main DocBook file are expanded and set + # in the msgid field. Such expanded characters are not + # recognized by openjade when they are used as source to + # produce the PDF output. + ${RENDER_BACKEND}_convertToPdfFromSgml + fi + +} diff --git a/Scripts/Functions/Render/Docbook/docbook_convertToPdfFromSgml.sh b/Scripts/Functions/Render/Docbook/docbook_convertToPdfFromSgml.sh new file mode 100755 index 0000000..00e8ce5 --- /dev/null +++ b/Scripts/Functions/Render/Docbook/docbook_convertToPdfFromSgml.sh @@ -0,0 +1,116 @@ +#!/bin/bash +# +# docbook_convertToPdfFromSgml.sh -- This function transforms DocBook +# files which have set the SGML DTD in them. To produce PDF from +# DocBook SGML DTD, we take the DocBook XML DTD file and change its +# DTD from XML to SGML. Since XML is SGML shoudn't be any problem. +# Once the DTD has been changed from XML to SGML, we use openjade +# (through `jw' shell script) to convert the SGML-based DocBook file +# to PDF. Customization can be achieved through DSL +# (docbook-style-dsssl-1.79-4.1) shipped in this distribution. +# +# In this configuration and using default configuration settings, I've +# presented the following problems: +# +# 1. It is not possible to produce localized PDF outputs through +# `xml2po', the default way of producing localized content inside +# `centos-art.sh' script. +# +# In this configuration and using default configuration settins, I've +# presented the following advantages: +# +# 1. The PDF output produced from SGML-based files seem to be better +# looking an less buggy than PDF output produced from XML-based +# files, visually I mean. +# +# To make the whole process transparent, a temporal directory is +# created for intermediate works and final files are moved then to +# their final location. +# +# 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 docbook_convertToPdfFromSgml { + + # Print action message. + if [[ -f ${FILE}.sgml.pdf ]];then + cli_printMessage "${FILE}.sgml.pdf" --as-updating-line + else + cli_printMessage "${FILE}.sgml.pdf" --as-creating-line + fi + + local -a STYLE_TEMPLATE + local -a STYLE_INSTANCE + local STYLE_INSTANCE_FINAL='' + + # Define name of temporal directory where the DocBook to PDF + # transformation will take place. + local TMPDIR=$(cli_getTemporalFile "docbook2pdf") + + # Define absolute path to DocBook source file. This is the + # repository documentation manual file where DOCTYPE and ENTITY + # definition lines are set. + local SRC=${INSTANCE} + + # Define absolute path to PDF target file. This is the final + # location the PDF file produced as result of DocBook to PDF + # transformation will be stored in. + local DST="${FILE}.sgml.pdf" + + # Define file name of PDF file. This is the file we were looking + # for and the one moved, once produced. + local PDF=$(basename ${SRC} | sed -r 's!\.docbook$!.pdf!') + + # Replace document definition from XML to SGML. + sed -i -r \ + -e 's!"-//OASIS//DTD DocBook XML!"-//OASIS//DTD DocBook!' \ + -e 's!"http://www\.oasis-open\.org/docbook/xml/([[:digit:]])\.([[:digit:]])/docbookx\.dtd"!"docbook/sgml-dtd-\1.\2-1.0-30.1/docbook.dtd"!' \ + $SRC + + # Prepare style final instance used in transformations. + ${RENDER_BACKEND}_prepareStyles "${DOCBOOK_STYLES_DIR}/docbook2pdf.dsl" + + # Verify temporal directory and create it if doesn't exist. + if [[ ! -d $TMPDIR ]];then + mkdir $TMPDIR + fi + + # Move inside temporal directory. + pushd $TMPDIR > /dev/null + + # Create PDF format. + docbook2pdf --dsl ${STYLE_INSTANCE_FINAL} ${SRC} &> /dev/null + + # Verify `docbook2pdf' exit status and, if everything is ok, move + # PDF file from temporal directory to its target location. + if [[ $? -eq 0 ]];then + mv $PDF $DST + else + cli_printMessage "`gettext "Cannot produce the PDF file."`" --as-error-line + fi + + # Return to where we initially were. + popd > /dev/null + + # Remove temporal directory and temporal style instances created. + rm -r $TMPDIR + rm ${STYLE_INSTANCE[*]} + +} diff --git a/Scripts/Functions/Render/Docbook/docbook_convertToPdfFromXml.sh b/Scripts/Functions/Render/Docbook/docbook_convertToPdfFromXml.sh new file mode 100755 index 0000000..b4e61e0 --- /dev/null +++ b/Scripts/Functions/Render/Docbook/docbook_convertToPdfFromXml.sh @@ -0,0 +1,138 @@ +#!/bin/bash +# +# docbook_convertToPdfFromXml.sh -- This function transforms DocBook +# files which have set the XML DTD in them. To produce PDF from +# DocBook XML DTD, we need an XSLT engine (e.g., through `xsltproc' +# command) to produce formatting objects (FO), which then must be +# processed with an FO engine (e.g., through `pdfxmltex' command, +# which uses PassiveTex) to produce the PDF output. +# +# In this configuration and using default configuration settings, I've +# presented the following problems: +# +# 1. Something is wrong with headings. They are not expanded along +# the whole page-body. They seem to be rendered in a reduced width +# (1 inch approximatly). This provokes the heading to be broken in a +# two-to-five letters column and sometimes it overlaps the +# sectioning titles (e.g., chatper, section). I tried to customize +# the value of `header.column.widths' and `page.margin.top' but it +# seems to be not there where I need to touch. +# +# 2. TOC's indentation is not rendered. Even the `toc.indent.width' +# property is set to 24 by default. +# +# 3. Inside lists, when items are more than one line, the +# indentation seems to work for the first line only. All other +# lines in the same item are not indented and begin completly +# unaligned. +# +# 4. Long file paths near the end of page-body aren't hyphenated. +# Even the `hyphenate' property is set to `true' by default. +# +# In this configuration and using default configuration settings, I've +# presented the following advantages: +# +# 1. It is possible to produce localized PDF outputs through +# `xml2po', the default way of producing localized content inside +# the `centos-art.sh' script. +# +# To make the whole process transparent, a temporal directory is +# created for intermediate works and final files are moved then to +# their final location. +# +# 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 docbook_convertToPdfFromXml { + + # Print action message. + if [[ -f ${FILE}.sgml.pdf ]];then + cli_printMessage "${FILE}.xml.pdf" --as-updating-line + else + cli_printMessage "${FILE}.xml.pdf" --as-creating-line + fi + + local -a STYLE_TEMPLATE + local -a STYLE_INSTANCE + local STYLE_INSTANCE_FINAL='' + + # Define name of temporal directory where the DocBook to PDF + # transformation will take place. + local TMPDIR=$(cli_getTemporalFile "docbook2pdf") + + # Define absolute path to DocBook source file. This is the + # repository documentation manual file where DOCTYPE and ENTITY + # definition lines are set. + local SRC=${INSTANCE} + + # Define absolute path to PDF target file. This is the final + # location the PDF file produced as result of DocBook to PDF + # transformation will be stored in. + local DST="${FILE}.xml.pdf" + + # Define file name of formatting object (.fo) file. This file is + # an intermediate file needed to produced the PDF. + local FO=$(basename ${FILE}).fo + + # Define file name of PDF file. This is the file we were looking + # for and the one moved, once produced. + local PDF=$(basename ${FILE}).pdf + + # Prepare XSL final instances used in transformations. + ${RENDER_BACKEND}_prepareStyles "${DOCBOOK_STYLES_DIR}/docbook2fo.xsl" + + # Verify temporal directory and create it if doesn't exist. + if [[ ! -d $TMPDIR ]];then + mkdir $TMPDIR + fi + + # Move inside temporal directory. + pushd $TMPDIR > /dev/null + + # Create formatting object supressing output from stderr. + xsltproc --output ${FO} ${STYLE_INSTANCE_FINAL} ${SRC} &> /dev/null + + # Create PDF format from formatting object. The `pdfxmltex' + # command (which use the `PassiveTex' engine) must be executed + # twice in order for the document's cross references to be built + # correctly. + if [[ $? -eq 0 ]];then + pdfxmltex ${FO} > /dev/null + pdfxmltex ${FO} > /dev/null + else + cli_printMessage "`gettext "Cannot produce the formatting object."`" --as-error-line + fi + + # Verify `pdfxmltex' exit status and, if everything is ok, move + # PDF file from temporal directory to its target location. + if [[ $? -eq 0 ]];then + mv $PDF $DST + else + cli_printMessage "`gettext "Cannot produce the PDF file."`" --as-error-line + fi + + # Return to where we initially were. + popd > /dev/null + + # Remove temporal directory and temporal style instances created. + rm -r $TMPDIR + rm ${STYLE_INSTANCE[*]} + +} diff --git a/Scripts/Functions/Render/Docbook/docbook_convertToText.sh b/Scripts/Functions/Render/Docbook/docbook_convertToText.sh new file mode 100755 index 0000000..a234cdc --- /dev/null +++ b/Scripts/Functions/Render/Docbook/docbook_convertToText.sh @@ -0,0 +1,70 @@ +#!/bin/bash +# +# svg_convertToText.sh -- This function takes the XHTML file produced +# by docbook_convertToXhtml 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 docbook_convertToText { + + # Verify existence of HTML file. If `.xhtml' file doesn't exist + # don't create text file. The `.xhtml' file is required in order + # to create the `.txt' file. + if [[ ! -f ${FILE}.xhtml ]];then + return + fi + + 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 XHTML to plain-text found."`" --as-error-line + fi + +} diff --git a/Scripts/Functions/Render/Docbook/docbook_convertToXhtml.sh b/Scripts/Functions/Render/Docbook/docbook_convertToXhtml.sh new file mode 100755 index 0000000..74b0cb0 --- /dev/null +++ b/Scripts/Functions/Render/Docbook/docbook_convertToXhtml.sh @@ -0,0 +1,62 @@ +#!/bin/bash +# +# render_docbook_convertToXhtml.sh -- This function uses DocBook XML +# as input and applies XSL stylesheets to produce a big XHTML files as +# output. The procedure was taken from the documentation of +# `docbook-style-xsl-1.69.1-5.1' package, which says: ---To publish +# HTML from your XML documents, you just need an XSL engine.---. +# +# 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 docbook_convertToXhtml { + + local -a STYLE_TEMPLATE + local -a STYLE_INSTANCE + local STYLE_INSTANCE_FINAL='' + + # 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 absolute path to DocBook source file. This is the + # repository documentation manual file where DOCTYPE and ENTITY + # definition lines are set. + local SRC=${INSTANCE} + + # Define absolute path to PDF target file. This is the final + # location the PDF file produced as result of DocBook to PDF + # transformation will be stored in. + local DST="${FILE}.xhtml" + + # Prepare XSL final instances used in transformations. + ${RENDER_BACKEND}_prepareStyles $(cli_getFilesList \ + ${DOCBOOK_STYLES_DIR} --pattern='.*docbook2xhtml-(single|common)\.xsl') + + # Transform DocBook XML to XHTML supressing all stderr output. + xsltproc --output ${DST} ${STYLE_INSTANCE_FINAL} ${SRC} &> /dev/null + + # Remove XSL instance files. + rm ${STYLE_INSTANCE[*]} + +} diff --git a/Scripts/Functions/Render/Docbook/docbook_convertToXhtmlChunk.sh b/Scripts/Functions/Render/Docbook/docbook_convertToXhtmlChunk.sh new file mode 100755 index 0000000..f2df401 --- /dev/null +++ b/Scripts/Functions/Render/Docbook/docbook_convertToXhtmlChunk.sh @@ -0,0 +1,66 @@ +#!/bin/bash +# +# render_docbook_convertToXhtmlChunk.sh -- This function uses DocBook +# XML as input and applies XSL stylesheets to produce a directory with +# many XHTML files as output. The procedure was taken from the +# documentation of `docbook-style-xsl-1.69.1-5.1' package, which says: +# ---To publish HTML from your XML documents, you just need an XSLT +# engine.---. +# +# 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 docbook_convertToXhtmlChunk { + + local -a STYLE_TEMPLATE + local -a STYLE_INSTANCE + local STYLE_INSTANCE_FINAL='' + + # Define absolute path to PDF target file. This is the final + # location the PDF file produced as result of DocBook to PDF + # transformation will be stored in. + local DST="${FILE}-xhtml/" + + # Clean up output directory. This is required in order to prevent + # old files from remaining therein when they are no longer needed. + if [[ -d ${DST} ]];then + rm -r "${DST}" + fi + mkdir ${DST} + + # Print action message. + cli_printMessage "${FILE}-xhtml" --as-creating-line + + # Define absolute path to DocBook source file. This is the + # repository documentation manual file where DOCTYPE and ENTITY + # definition lines are set. + local SRC=${INSTANCE} + + # Prepare XSL final instances used in transformations. + ${RENDER_BACKEND}_prepareStyles $(cli_getFilesList \ + ${DOCBOOK_STYLES_DIR} --pattern='.*docbook2xhtml-(chunks|common)\.xsl') + + # Transform DocBook XML to XHTML supressing all stderr output. + xsltproc --output ${DST} ${STYLE_INSTANCE_FINAL} ${SRC} &> /dev/null + + # Remove XSL instance files. + rm ${STYLE_INSTANCE[*]} + +} diff --git a/Scripts/Functions/Render/Docbook/docbook_doLastActions.sh b/Scripts/Functions/Render/Docbook/docbook_doLastActions.sh new file mode 100755 index 0000000..d3dc57f --- /dev/null +++ b/Scripts/Functions/Render/Docbook/docbook_doLastActions.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# +# docbook_doLastActions.sh -- This function performs last-rendition +# actions for DocBook files. These are the actions that take +# base-rendition and post-rendition output as input to produce output +# from it. +# +# 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 docbook_doLastActions { + + # Presently, there is no last-rendition action for DocBook base + # rendition but the function should exist for consistency with + # other backends. + return + +} diff --git a/Scripts/Functions/Render/Docbook/docbook_doPostActions.sh b/Scripts/Functions/Render/Docbook/docbook_doPostActions.sh new file mode 100755 index 0000000..e4e8cea --- /dev/null +++ b/Scripts/Functions/Render/Docbook/docbook_doPostActions.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# +# docbook_doPostActions.sh -- This function performs post-rendition +# actions for DocBook files. These are the actions that take +# base-rendition output as input to producing output from it. +# +# 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 docbook_doPostActions { + + ${RENDER_BACKEND}_convertToText + +} diff --git a/Scripts/Functions/Render/Docbook/docbook_prepareStyles.sh b/Scripts/Functions/Render/Docbook/docbook_prepareStyles.sh new file mode 100755 index 0000000..201cb0f --- /dev/null +++ b/Scripts/Functions/Render/Docbook/docbook_prepareStyles.sh @@ -0,0 +1,81 @@ +#!/bin/bash +# +# docbook_prepareStyles.sh -- This function prepares styles' final +# instances used in transformations based on XSL or DSL templates. +# There are translation markers inside the XSL and DSL templates that +# need to be expand before they be used for transformations. This +# function creates temporal instances of XSL and DSL templates with +# translation markers expanded inside so as for transformation +# commands (e.g., `xmltproc' or `openjade' through `docbook2pdf') to +# use as style defintion. +# +# 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 docbook_prepareStyles { + + local STYLE_TEMPLATE_FILE='' + local STYLE_TEMPLATE_FILES=$@ + local STYLE_INSTANCE_COMMON='' + local COUNT=0 + + for STYLE_TEMPLATE_FILE in $STYLE_TEMPLATE_FILES;do + + STYLE_TEMPLATE[((++${#STYLE_TEMPLATE[*]}))]="${STYLE_TEMPLATE_FILE}" + STYLE_INSTANCE[((++${#STYLE_INSTANCE[*]}))]="$(cli_getTemporalFile ${STYLE_TEMPLATE_FILE})" + + # Keep track of array's real index value. Remember, it starts + # at zero but counting starts at 1 instead. So, substracting 1 + # from counting we have the real index value we need to work + # with the information stored in the array. + COUNT=$(( ${#STYLE_INSTANCE[*]} - 1 )) + + # Create style instance from style template. + cp ${STYLE_TEMPLATE[$COUNT]} ${STYLE_INSTANCE[$COUNT]} + + # Define both final an common style instances based on style + # templates. + if [[ $STYLE_TEMPLATE_FILE =~ 'docbook2fo\.xsl$' ]];then + STYLE_INSTANCE_FINAL=${STYLE_INSTANCE[$COUNT]} + elif [[ $STYLE_TEMPLATE_FILE =~ 'docbook2pdf\.dsl$' ]];then + STYLE_INSTANCE_FINAL=${STYLE_INSTANCE[${COUNT}]} + elif [[ $STYLE_TEMPLATE_FILE =~ 'docbook2xhtml-(chunks|single)\.xsl$' ]];then + STYLE_INSTANCE_FINAL=${STYLE_INSTANCE[${COUNT}]} + elif [[ $STYLE_TEMPLATE_FILE =~ 'docbook2xhtml-common\.xsl$' ]];then + STYLE_INSTANCE_COMMON=${STYLE_INSTANCE[${COUNT}]} + fi + + done + + # Verify style final instance. This is the file used by + # transformation command (`xsltproc' or `openjade') to produce the + # specified output. We cannot continue without it. + cli_checkFiles $STYLE_INSTANCE_FINAL + + # Expand common translation markers in the common style instance, + # if it exists. + if [[ -f $STYLE_INSTANCE_COMMON ]];then + cli_replaceTMarkers $STYLE_INSTANCE_COMMON + fi + + # Expand specific translation markers in final style instance. + sed -r -i "s!=STYLE_XHTML_COMMON=!${STYLE_INSTANCE_COMMON}!" ${STYLE_INSTANCE_FINAL} + +} diff --git a/Scripts/Functions/Render/Svg/svg.sh b/Scripts/Functions/Render/Svg/svg.sh new file mode 100644 index 0000000..1746f72 --- /dev/null +++ b/Scripts/Functions/Render/Svg/svg.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# +# 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 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_BACKEND}_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_BACKEND}_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/Svg/svg_checkColorAmount.sh b/Scripts/Functions/Render/Svg/svg_checkColorAmount.sh new file mode 100755 index 0000000..dc99dba --- /dev/null +++ b/Scripts/Functions/Render/Svg/svg_checkColorAmount.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# +# 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 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/Svg/svg_checkColorFormats.sh b/Scripts/Functions/Render/Svg/svg_checkColorFormats.sh new file mode 100755 index 0000000..f84a813 --- /dev/null +++ b/Scripts/Functions/Render/Svg/svg_checkColorFormats.sh @@ -0,0 +1,88 @@ +#!/bin/bash +# +# 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 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/Svg/svg_checkModelAbsref.sh b/Scripts/Functions/Render/Svg/svg_checkModelAbsref.sh new file mode 100755 index 0000000..58bb87d --- /dev/null +++ b/Scripts/Functions/Render/Svg/svg_checkModelAbsref.sh @@ -0,0 +1,141 @@ +#!/bin/bash +# +# 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 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 message. + cli_printMessage "$BG_DST_FILE" --as-checking-line + + # Verify parent directory of absolute files retrived from + # file. This is required to prevent the construction of paths + # to locations that don't exist. For example, when including + # background images in SVG files, it is possible that the path + # information inside SVG files get outdated temporarly. If in + # that exact moment, you try to render the SVG file it won't + # be possible to create the image used for cropping because + # the path build from the location inside SVG file doesn't + # exist. In this case, centos-art.sh script will end up with + # `file ... doesn't exist' errors. + cli_checkFiles "$(dirname ${BG_DST_FILE})" -d + + 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_BACKEND}_getColors) + + # Verify format of color value. + ${RENDER_BACKEND}_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/Svg/svg_checkModelExportId.sh b/Scripts/Functions/Render/Svg/svg_checkModelExportId.sh new file mode 100755 index 0000000..d8ac19d --- /dev/null +++ b/Scripts/Functions/Render/Svg/svg_checkModelExportId.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# +# 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 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/Svg/svg_convertGplToHex.sh b/Scripts/Functions/Render/Svg/svg_convertGplToHex.sh new file mode 100755 index 0000000..7718ee7 --- /dev/null +++ b/Scripts/Functions/Render/Svg/svg_convertGplToHex.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# +# 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 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_BACKEND}_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_BACKEND}_checkColorAmount "$COLORS" "$NUMBER" + + # Verify format of colors. + ${RENDER_BACKEND}_checkColorFormats "$COLORS" --format='rrggbb' + + # Create list of colors to be processed by `pnmtolss16'. + echo "$COLORS" | nl | gawk '{ printf "%s=%d ", $2, $1 - 1 }' \ + > $PALETTE_HEX + + # Verify HEX palette existence. + cli_checkFiles $PALETTE_HEX + +} diff --git a/Scripts/Functions/Render/Svg/svg_convertGplToPpm.sh b/Scripts/Functions/Render/Svg/svg_convertGplToPpm.sh new file mode 100755 index 0000000..c11305f --- /dev/null +++ b/Scripts/Functions/Render/Svg/svg_convertGplToPpm.sh @@ -0,0 +1,71 @@ +#!/bin/bash +# +# 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 svg_convertGplToPpm { + + 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_BACKEND}_getColors "$PALETTE_GPL" --head=$NUMBER --tail=$NUMBER --format='rrrggbb') + + # Verify amount of colors in the list of colors. + ${RENDER_BACKEND}_checkColorAmount "$COLORS" "$NUMBER" + + # Verify format of colors. + ${RENDER_BACKEND}_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/Svg/svg_convertPngTo.sh b/Scripts/Functions/Render/Svg/svg_convertPngTo.sh new file mode 100644 index 0000000..db10df3 --- /dev/null +++ b/Scripts/Functions/Render/Svg/svg_convertPngTo.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# +# 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 svg_convertPngTo { + + # Initialize image formats. + local FORMAT='' + local FORMATS=$(render_getConfigOption "$ACTION" '2') + + # Convert from PNG to specified formats. + 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/Svg/svg_convertPngToBrands.sh b/Scripts/Functions/Render/Svg/svg_convertPngToBrands.sh new file mode 100644 index 0000000..dda21aa --- /dev/null +++ b/Scripts/Functions/Render/Svg/svg_convertPngToBrands.sh @@ -0,0 +1,64 @@ +#!/bin/bash +# +# svg_convertPngToBrands.sh -- This function provides post-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 svg_convertPngToBrands { + + # Define height dimensions you want to produce brands for. + local SIZE="" + 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 FORMAT="" + 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. Use resize + # support with a value less than 1.0 for sharpening. This + # make resized brands to look better. Otherwise, if the + # resize support is greater than 1.0 or none at all, + # resized brands are blured instead. + 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/Svg/svg_convertPngToDm.sh b/Scripts/Functions/Render/Svg/svg_convertPngToDm.sh new file mode 100755 index 0000000..19542e8 --- /dev/null +++ b/Scripts/Functions/Render/Svg/svg_convertPngToDm.sh @@ -0,0 +1,182 @@ +#!/bin/bash +# +# 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 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 used by display manager theme. + # These are the different screen resolutions a display manager + # theme is built for. The amount of screen resolution a display + # manager theme can be built for is limited to the amount of + # background files provided by the artistic motif used to build + # the display manager theme. + 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 artistic motif's 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. Use the colon character + # (`:') as separator; on the left side we put the file's source + # location and in the right side the file's target location. + # 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}/Symbols/centos-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}/Symbols/centos-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/Svg/svg_convertPngToGrub.sh b/Scripts/Functions/Render/Svg/svg_convertPngToGrub.sh new file mode 100644 index 0000000..5f85ea8 --- /dev/null +++ b/Scripts/Functions/Render/Svg/svg_convertPngToGrub.sh @@ -0,0 +1,143 @@ +#!/bin/bash +# +# svg_convertPngToGrub.sh -- This function provides post-rendition +# action used to produce GRUB images. +# +# Initially, the color information is defined with GIMP (The GNU Image +# Manipulation Program) as a `.gpl' palette of color. This palette of +# colors contains 14 colors only and is saved in a file named +# `grub.gpl. The `grub.gpl' file is used to build the `grub.ppm' file +# which provide the color information needed to reduce the full color +# PNG image, produced as result of SVG base-rendition, to the amount +# of colors specified (i.e., 14 colors). Later, with the 14 color PNG +# image already created, the `grub.ppm' file is used to build the +# `splash.xpm.gz' file. +# +# In order for this function to work, the `grub.gpl' file should have +# a format similar to the following: +# +# GIMP Palette +# Name: CentOS-TreeFlower-4-Syslinux +# Columns: 14 +# # +# 32 76 141 204c8d +# 36 82 146 245292 +# 52 93 152 345d98 +# 72 108 162 486ca2 +# 102 131 176 6683b0 +# 126 153 190 7e99be +# 146 170 200 92aac8 +# 161 182 209 a1b6d1 +# 182 199 219 b6c7db +# 202 214 228 cad6e4 +# 221 230 238 dde6ee +# 235 241 245 ebf1f5 +# 246 251 254 f6fbfe +# 254 255 252 fefffc +# +# 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 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 through subversion (to keep track + # of the change) and expand translation markers in the copied + # instance. + if [[ ! -f $PALETTE_GPL ]];then + svn 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_BACKEND}_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/Svg/svg_convertPngToKsplash.sh b/Scripts/Functions/Render/Svg/svg_convertPngToKsplash.sh new file mode 100755 index 0000000..e56401e --- /dev/null +++ b/Scripts/Functions/Render/Svg/svg_convertPngToKsplash.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# +# 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 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/Svg/svg_convertPngToSyslinux.sh b/Scripts/Functions/Render/Svg/svg_convertPngToSyslinux.sh new file mode 100755 index 0000000..3da4ae9 --- /dev/null +++ b/Scripts/Functions/Render/Svg/svg_convertPngToSyslinux.sh @@ -0,0 +1,184 @@ +#!/bin/bash +# +# svg_convertPngToSyslinux.sh -- This function provides post-rendition +# action used to produce LSS16 images, the images used by isolinux. +# +# Initially, the color information is defined with GIMP (The GNU Image +# Manipulation Program) as a `.gpl' 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' provides the color information needed to reduce the +# full color PNG image, produced as result of SVG base-rendition, to +# the amount of colors specified (i.e., 16 colors). Later, with the 16 +# color PNG 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 required +# that both the `syslinux.ppm' and `syslinux.hex' files do contain the +# same color information. This is, both `syslinux.ppm' and +# `syslinux.hex' must represent the same color values and in the same +# color index. +# +# In order for this function to work, the `syslinux.gpl' file should +# have a format similar to the following: +# +# GIMP Palette +# Name: CentOS-TreeFlower-4-Syslinux +# Columns: 16 +# # +# 32 76 141 204c8d +# 37 82 146 255292 +# 52 94 153 345e99 +# 73 110 162 496ea2 +# 91 124 172 5b7cac +# 108 136 180 6c88b4 +# 120 146 186 7892ba +# 131 158 193 839ec1 +# 255 255 255 ffffff +# 146 170 200 92aac8 +# 162 182 209 a2b6d1 +# 183 199 219 b7c7db +# 204 216 230 ccd8e6 +# 221 229 238 dde5ee +# 235 241 245 ebf1f5 +# 246 251 254 f6fbfe +# +# 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 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 through subversion (to keep track + # of the change) and expand translation markers in the copied + # instance. + if [[ ! -f $PALETTE_GPL ]];then + svn 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_BACKEND}_convertGplToPpm "$PALETTE_GPL" "$PALETTE_PPM" "$COLORS" + + # Create HEX palette using GPL palette. + ${RENDER_BACKEND}_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/Svg/svg_convertPngToThumbnail.sh b/Scripts/Functions/Render/Svg/svg_convertPngToThumbnail.sh new file mode 100755 index 0000000..16d428c --- /dev/null +++ b/Scripts/Functions/Render/Svg/svg_convertPngToThumbnail.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# +# 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 svg_convertPngToThumbnail { + + # Get image size. + local 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/Svg/svg_doLastActions.sh b/Scripts/Functions/Render/Svg/svg_doLastActions.sh new file mode 100644 index 0000000..1a3b7a5 --- /dev/null +++ b/Scripts/Functions/Render/Svg/svg_doLastActions.sh @@ -0,0 +1,72 @@ +#!/bin/bash +# +# 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 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[*]}))]='convertPngToDm:Gdm:800x600 1024x768 1280x1024 1360x768 2048x1536 2560x1240' + elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Kdm/.+\.svg$" ]];then + LASTACTIONS[((++${#LASTACTIONS[*]}))]='convertPngToDm:Kdm:800x600 1024x768 1280x1024 1360x768 2048x1536 2560x1240' + elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Ksplash/.+\.svg$" ]];then + LASTACTIONS[((++${#LASTACTIONS[*]}))]='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 + ${RENDER_BACKEND}_$(echo "$ACTION" | cut -d: -f1) + done + +} diff --git a/Scripts/Functions/Render/Svg/svg_doLastCommand.sh b/Scripts/Functions/Render/Svg/svg_doLastCommand.sh new file mode 100755 index 0000000..34f1a2a --- /dev/null +++ b/Scripts/Functions/Render/Svg/svg_doLastCommand.sh @@ -0,0 +1,71 @@ +#!/bin/bash +# +# svg_doLastCommand.sh -- This function standardizes the way +# last-rendition commands are applied to base-rendition and +# post-rendition outputs. +# +# 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 svg_doLastCommand { + + # Define the file extensions. This value is a regular expression + # pattern which must match the file extensions that last-rendition + # actions will be applied to. + local EXTENSION=$(render_getConfigOption "$ACTION" '2') + + # Define the command string that will be evaluated as + # last-rendition action. Only commands that perform in-place + # modifications can be passed here. + local COMMAND=$(render_getConfigOption "$ACTION" '3-') + + # Define the list of files to process. This value contain all the + # files in the output directory which extension match the + # extension pattern previously defined. + local FILE='' + local FILES=$(cli_getFilesList $OUTPUT --pattern=".+\.${EXTENSION}") + + for FILE in $FILES;do + + # Identify file before processing it. Only formats recognized + # by ImageMagick are supported. In case the file isn't + # supported by ImageMagick, continue with the next file in the + # list. + identify -quiet ${FILE} > /dev/null + if [[ $? -ne 0 ]];then + continue + fi + + # Print action message. + cli_printMessage "${FILE}" --as-updating-line + + # Execute mogrify action on all files inside the same + # directory structure. + eval ${COMMAND} ${FILE} + + # Be sure the command was executed correctly. Otherwise stop + # script execution. + if [[ $? -ne 0 ]];then + exit + fi + + done + +} diff --git a/Scripts/Functions/Render/Svg/svg_doPostActions.sh b/Scripts/Functions/Render/Svg/svg_doPostActions.sh new file mode 100644 index 0000000..57f6fb0 --- /dev/null +++ b/Scripts/Functions/Render/Svg/svg_doPostActions.sh @@ -0,0 +1,77 @@ +#!/bin/bash +# +# 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 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 Artwork 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[*]}))]="doPostCommand:png:mogrify -comment '$COMMENT'" + [[ $FLAG_POSTRENDITION != '' ]] && POSTACTIONS[((++${#POSTACTIONS[*]}))]="doPostCommand: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[*]}))]='convertPngTo:jpg' + POSTACTIONS[((++${#POSTACTIONS[*]}))]='groupBy:png jpg' + elif [[ $TEMPLATE =~ "Concept/.+\.svg$" ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngTo:jpg pdf' + POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToThumbnail:250' + elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Syslinux/.+\.svg$" ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToSyslinux:' + POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToSyslinux:-floyd' + elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent --release-pattern)/Grub/.+\.svg$" ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToGrub:' + POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToGrub:-floyd' + elif [[ $TEMPLATE =~ "Posters/.+\.svg$" ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngTo:jpg pdf' + elif [[ $TEMPLATE =~ "trunk/Identity/Models/Brands/.+\.svg$" ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngToBrands' + elif [[ $TEMPLATE =~ "trunk/Identity/Models/Manuals.+\.svg$" ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngTo:jpg pdf' + fi + fi + + # Execute SVG post-rendition actions. + for ACTION in "${POSTACTIONS[@]}"; do + ${RENDER_BACKEND}_$(echo "$ACTION" | cut -d: -f1) + done + +} diff --git a/Scripts/Functions/Render/Svg/svg_doPostCommand.sh b/Scripts/Functions/Render/Svg/svg_doPostCommand.sh new file mode 100755 index 0000000..6892434 --- /dev/null +++ b/Scripts/Functions/Render/Svg/svg_doPostCommand.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# +# svg_doPostCommand.sh -- This function standardizes the way +# post-rendition commands are applied to base-rendition output. +# +# 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 svg_doPostCommand { + + # Define the file extension of base-rendition output. + local EXTENSION=$(render_getConfigOption "$ACTION" '2') + + # Define the command string. + local COMMAND=$(render_getConfigOption "$ACTION" '3-') + + # Verify the absolute path of base-rendition output. + cli_checkFiles ${FILE}.${EXTENSION} + + # Execute the command string on base-rendition output. + eval $COMMAND ${FILE}.${EXTENSION} + + # Be sure the command string was executed correctly. Otherwise + # stop the script execution. + if [[ $? -ne 0 ]];then + exit + fi + +} diff --git a/Scripts/Functions/Render/Svg/svg_getColors.sh b/Scripts/Functions/Render/Svg/svg_getColors.sh new file mode 100755 index 0000000..157e32b --- /dev/null +++ b/Scripts/Functions/Render/Svg/svg_getColors.sh @@ -0,0 +1,153 @@ +#!/bin/bash +# +# 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 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_BACKEND}_getColors $MOTIF_PALETTE --head=1 --tail=1) + elif [[ -f $MODEL_PALETTE ]];then + COLORS=$(${RENDER_BACKEND}_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/Svg/svg_groupBy.sh b/Scripts/Functions/Render/Svg/svg_groupBy.sh new file mode 100755 index 0000000..08f5aaf --- /dev/null +++ b/Scripts/Functions/Render/Svg/svg_groupBy.sh @@ -0,0 +1,70 @@ +#!/bin/bash +# +# 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 svg_groupBy { + + local SOURCE='' + local TARGET='' + + # Sanitate file types passed from render.conf.sh pre-rendition + # configuration script. + local FORMAT='' + 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.sh b/Scripts/Functions/Render/render.sh index e53579f..e92163a 100644 --- a/Scripts/Functions/Render/render.sh +++ b/Scripts/Functions/Render/render.sh @@ -72,7 +72,7 @@ function render { # Initialize absolute path to backend's base directory, the place # where backend-specific directories are stored in. - local RENDER_BACKEND_DIR="${FUNCDIR}/${FUNCDIRNAM}/Backends" + local RENDER_BACKEND_DIR="${FUNCDIR}/${FUNCDIRNAM}" # Initialize list of supported file extensions. These file # extensions are used by design model files, the files used as