Blame Manuals/Repository/trunk/Scripts/Bash/Functions/Svg.texi

ad1d7b
@subsection Goals
ad1d7b
ad1d7b
This section exists to organize files related to @code{svg}
ad1d7b
functionality of @file{centos-art.sh} script.
ad1d7b
ad1d7b
@subsection Description
ad1d7b
ad1d7b
The @code{svg} functionality of @file{centos-art.sh} script helps you
ad1d7b
to maintain scalable vector graphics (SVG) inside repository. For
ad1d7b
example, suppose you've been working in CentOS default design models
ad1d7b
under @file{trunk/Identity/Themes/Models/}, and you want to set common
ad1d7b
metadata to all of them, and later remove all unused SVG defintions
ad1d7b
from @samp{*.svg} files. Doing so file by file may be a tedious task,
ad1d7b
so the @file{centos-art.sh} script provides the @code{svg}
ad1d7b
functionality to aid you maintain such actions.
ad1d7b
ad1d7b
@cindex Metadata maintainance
ad1d7b
@subsubsection Metadata maintainance
ad1d7b
ad1d7b
The metadata used is defined by Inkscape 0.46 using the SVG standard
ad1d7b
markup. The @file{centos-art.sh} script replaces everything
ad1d7b
in-between @code{<metadata} and @code{</metadata>} tags with a
ad1d7b
predefined metadata template we've set for this purpose.
ad1d7b
ad1d7b
The metadata template was created using the metadata information of a
ad1d7b
file which, using Inkscape 0.46, all metadata fields were set. This
ad1d7b
created a complete markup representation of how SVG metadata would
ad1d7b
look like. Later, we replaced every single static value with a
ad1d7b
translation marker in the form @samp{=SOMETEXT=}, where
ad1d7b
@code{SOMETEXT} is the name of its main opening tag. Later, we
ad1d7b
transform the metadata template into a sed replacement set of commads
ad1d7b
escaping new lines at the end of each line.
ad1d7b
ad1d7b
With metadata template in place, the @file{centos-art.sh} script uses
ad1d7b
it to create a metadata template instance for the file being processed
ad1d7b
currently.  The metadata template instance contains the metadata
ad1d7b
portion of sed replacement commands with translation markers already
ad1d7b
traduced.  In this action, instance creation, is where we take
ad1d7b
advantage of automation and generate metadata values like title, date,
ad1d7b
keywords, source, identifier, and relation dynamically, based on the
ad1d7b
file path @file{centos-art.sh} script is currently creating metadata
ad1d7b
information for.
ad1d7b
ad1d7b
With metadata template instance in place, the @file{centos-art.sh}
ad1d7b
script uses it to replace real values inside all @samp{.svg} files
ad1d7b
under the current location you're running the @file{centos-art.sh}
ad1d7b
script on.  Default behaviour is to ask user to enter each metadatum
ad1d7b
required, one by one. If user leaves metadatum empty, by pressing
ad1d7b
@key{RET} key, @file{centos-art.sh} uses its default value.
ad1d7b
ad1d7b
The @file{centos-art.sh} script modifies the following metadata:
ad1d7b
ad1d7b
@table @samp
ad1d7b
@item Title
ad1d7b
Name by which this document is formally known. If no value is set
ad1d7b
here, @file{centos-art.sh} script uses the file name as title.
ad1d7b
ad1d7b
@item Date
ad1d7b
Date associated with the creation of this document (YYYY-MM-DD). If no
ad1d7b
value is set here, @file{centos-art.sh} script uses the current date
ad1d7b
information as in @command{date +%Y-%m-%d}.
ad1d7b
ad1d7b
@item Creator
ad1d7b
Name of entity primarily responsible for making the content of this
ad1d7b
document. If no value is set here, @file{centos-art.sh} script uses
ad1d7b
the string @samp{The CentOS Project}.
ad1d7b
ad1d7b
@item Rights
ad1d7b
Name of entity with rights to the intellectual Property of this
ad1d7b
document. If no value is set here, @file{centos-art.sh} script uses
ad1d7b
the string @samp{The CentOS Project}.
ad1d7b
ad1d7b
@item Publisher
ad1d7b
Name of entity responsible for making this document available. If no
ad1d7b
value is set here, @file{centos-art.sh} script uses the string
ad1d7b
@samp{The CentOS Project}.
ad1d7b
ad1d7b
@item Identifier
ad1d7b
Unique URI to reference this document. If no value is set here,
ad1d7b
@file{centos-art.sh} script uses the current file path to build the
ad1d7b
related url that points to current file location inside repository
ad1d7b
central server.
ad1d7b
ad1d7b
@item Source
ad1d7b
Unique URI to reference the source of this document. If no value is
ad1d7b
set here, @file{centos-art.sh} script uses current file path to build
ad1d7b
the related url that points to current file location inside repository
ad1d7b
central server.
ad1d7b
ad1d7b
@item Relation
ad1d7b
Unique URI to a related document. If no value is set here,
ad1d7b
@file{centos-art.sh} script uses current file path to build the
ad1d7b
related url that points to current file location inside repository
ad1d7b
central server.
ad1d7b
ad1d7b
@item Language
ad1d7b
Two-letter language tag with optional subtags for the language of this
ad1d7b
document. (e.g. @samp{en-GB}). If no value is set here,
ad1d7b
@file{centos-art.sh} script uses the current locale information as in
ad1d7b
@code{cli_getCurrentLocale} function.
ad1d7b
ad1d7b
@item Keywords
ad1d7b
The topic of this document as comma-separated key words, prhases, or
ad1d7b
classifications. If no value is set here, @file{centos-art.sh} script
ad1d7b
uses file path to build 
ad1d7b
ad1d7b
@item Coverage
ad1d7b
Extent or scope of this document. If no value is set here,
ad1d7b
@file{centos-art.sh} script uses the string @samp{The CentOS Project}.
ad1d7b
ad1d7b
@item Description
ad1d7b
Description about the document. If no value is set here,
ad1d7b
@file{centos-art.sh} script uses uses empty value as default.
ad1d7b
ad1d7b
@item Contributors
ad1d7b
People that contributes in the creation/maintainance of the document.
ad1d7b
If no value is set here, @file{centos-art.sh} script uses uses empty
ad1d7b
value as default.
ad1d7b
@end table
ad1d7b
ad1d7b
The @samp{License} metadatum is not set as a choise, by now. It is
ad1d7b
fixed @url{http://creativecommons.org/licenses/by-sa/3.0/, Creative
ad1d7b
Common Attribution Share-Alike 3.0 License}. This is done in order to
ad1d7b
grant license consistency among all SVG files we manage inside CentOS
ad1d7b
Artwork Repository.
ad1d7b
ad1d7b
@cindex Unused definitions
ad1d7b
@subsubsection Unused definitions 
ad1d7b
ad1d7b
Many of the no-longer-used gradients, patterns, and markers (more
ad1d7b
precisely, those which you edited manually) remain in the
ad1d7b
corresponding palettes and can be reused for new objects. However if
ad1d7b
you want to optimize your document, use the @samp{Vacuum Defs} command
ad1d7b
in @samp{File} menu. It will remove any gradients, patterns, or
ad1d7b
markers which are not used by anything in the document, making the
ad1d7b
file smaller. 
ad1d7b
ad1d7b
If you have one or two couple of files, removing unused definitions
ad1d7b
using the graphical interface may be enough to you.  In contrast, if
ad1d7b
you have dozens or even houndreds of scalable vector graphics files to
ad1d7b
maintain it is not a fun task to use the graphical interface to remove
ad1d7b
unused definitions editing those files one by one.
ad1d7b
ad1d7b
To remove unused definitions from several scalable vector graphics
ad1d7b
files, the @file{centos-art.sh} script uses Inkscape command-line
ad1d7b
interface, specifically with the @option{--vaccum-defs} option.
ad1d7b
ad1d7b
@subsection Usage
ad1d7b
ad1d7b
@table @command
ad1d7b
@item centos-art svg --update-metadata='path/to/dir'
ad1d7b
@item centos-art svg --update-metadata='path/to/dir' --filter='regex'
ad1d7b
Use these commands to update metadata information to @samp{.svg} files
ad1d7b
under @samp{path/to/dir} directory.
ad1d7b
ad1d7b
@item centos-art svg --vacuum-defs='path/to/dir'
ad1d7b
@item centos-art svg --vacuum-defs='path/to/dir' --filter='regex'
ad1d7b
Use these commands to remove unused definitions inside @samp{.svg}
ad1d7b
files under @samp{path/to/dir} directory. 
ad1d7b
@end table
ad1d7b
ad1d7b
When you provide @option{--filter='regex'} argument, the list of files
ad1d7b
to process is reduced as specified in @samp{regex} regular expression.
ad1d7b
Inside @file{centos-art.sh} script, the @samp{regex} regular
ad1d7b
expression is used in combination with @command{find} command to look
ad1d7b
for files matching the regular expression path pattern.
ad1d7b
ad1d7b
@quotation
ad1d7b
@strong{Warning} In order for @samp{regex} regular expression to match
ad1d7b
a file, the @samp{regex} regular expresion must match the whole file
ad1d7b
path not just the file name. 
ad1d7b
@end quotation
ad1d7b
ad1d7b
For example, if you want to match all @file{summary.svg} files inside
ad1d7b
@file{path/to/dir}, use the @code{.+/summary} regular expression.
ad1d7b
Later, @file{centos-art.sh} script uses this value inside
ad1d7b
@code{^$REGEX\.svg$} expression in order to build the final regular
ad1d7b
expression (i.e., @code{^.+/summary\.svg$}) that is evaluated against
ad1d7b
available file paths inside the list of files to process.
ad1d7b
ad1d7b
Exceptionally, when you provide @option{--filter='regex'} in the way
ad1d7b
that @samp{regex}, appended to @samp{path/to/dir/} (i.e.
ad1d7b
@samp{path/to/dir/regex}), matches a regular file; the
ad1d7b
@file{centos-art.sh} script uses the file matching as only file in the
ad1d7b
list of files to process. 
ad1d7b
ad1d7b
@subsection See also
ad1d7b
ad1d7b
@menu
ad1d7b
* trunk Scripts Bash::
ad1d7b
* trunk Scripts Bash Functions::
ad1d7b
@end menu