|
|
0a3f74 |
#!/bin/bash
|
|
|
0a3f74 |
#
|
|
|
0a3f74 |
# tuneup_doSvgMetadata.sh -- This function updates metadata values
|
|
|
0a3f74 |
# inside scalable vector graphic (SVG) files using The CentOS Project
|
|
|
0a3f74 |
# default values.
|
|
|
0a3f74 |
#
|
|
|
0a3f74 |
# Copyright (C) 2009-2011 Alain Reguera Delgado
|
|
|
fa95b1 |
#
|
|
|
fa95b1 |
# This program is free software; you can redistribute it and/or modify
|
|
|
fa95b1 |
# it under the terms of the GNU General Public License as published by
|
|
|
dcd347 |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
|
dcd347 |
# your option) any later version.
|
|
|
fa95b1 |
#
|
|
|
74a058 |
# This program is distributed in the hope that it will be useful, but
|
|
|
74a058 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
0a3f74 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
0a3f74 |
# General Public License for more details.
|
|
|
0a3f74 |
#
|
|
|
0a3f74 |
# You should have received a copy of the GNU General Public License
|
|
|
0a3f74 |
# along with this program; if not, write to the Free Software
|
|
|
dcd347 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
0a3f74 |
# ----------------------------------------------------------------------
|
|
|
0a3f74 |
# $Id$
|
|
|
0a3f74 |
# ----------------------------------------------------------------------
|
|
|
0a3f74 |
|
|
|
0a3f74 |
function tuneup_doSvgMetadata {
|
|
|
0a3f74 |
|
|
|
0a3f74 |
local NAM=''
|
|
|
0a3f74 |
local URL=''
|
|
|
0a3f74 |
local KEYS=''
|
|
|
0a3f74 |
local INSTANCE=''
|
|
|
0a3f74 |
local TEMPLATES=''
|
|
|
0a3f74 |
|
|
|
0a3f74 |
# Define template file name.
|
|
|
0a3f74 |
TEMPLATE="${FUNCCONFIG}/svg_metadata.sed"
|
|
|
0a3f74 |
|
|
|
0a3f74 |
# Check template file existence.
|
|
|
0a3f74 |
cli_checkFiles $TEMPLATE 'f'
|
|
|
0a3f74 |
|
|
|
0a3f74 |
# Build title from file path.
|
|
|
0a3f74 |
NAM=$(basename "$FILE")
|
|
|
0a3f74 |
|
|
|
0a3f74 |
# Build url from file path.
|
|
|
0a3f74 |
URL=$(echo $FILE | sed 's!/home/centos!https://projects.centos.org/svn!')
|
|
|
0a3f74 |
|
|
|
0a3f74 |
# Build keywords from file path. Do not include filename, it is
|
|
|
0a3f74 |
# already on title.
|
|
|
0a3f74 |
KEYS=$(dirname "$FILE" | cut -d/ -f6- | tr '/' '\n')
|
|
|
0a3f74 |
|
|
|
0a3f74 |
# Build keywords using SVG standard format. Note that this
|
|
|
0a3f74 |
# information is inserted inside template file. The template file
|
|
|
0a3f74 |
# is a replacement set of sed commands so we need to escape the
|
|
|
0a3f74 |
# new line of each line using one backslash (\). As we are doing
|
|
|
0a3f74 |
# this inside bash, it is required to escape the backslash with
|
|
|
0a3f74 |
# another backslash so one of them passes literally to template
|
|
|
0a3f74 |
# file.
|
|
|
0a3f74 |
KEYS=$(\
|
|
|
0a3f74 |
for KEY in $KEYS;do
|
|
|
0a3f74 |
echo " <rdf:li>$KEY</rdf:li>\\"
|
|
|
0a3f74 |
done)
|
|
|
0a3f74 |
|
|
|
0a3f74 |
# Redefine template instance file name.
|
|
|
0a3f74 |
INSTANCE=$(cli_getTemporalFile $TEMPLATE)
|
|
|
0a3f74 |
|
|
|
0a3f74 |
# Create template instance.
|
|
|
0a3f74 |
cp $TEMPLATE $INSTANCE
|
|
|
0a3f74 |
|
|
|
0a3f74 |
# Check template instance. We cannot continue if the template
|
|
|
0a3f74 |
# instance couldn't be created.
|
|
|
0a3f74 |
cli_checkFiles $INSTANCE 'f'
|
|
|
0a3f74 |
|
|
|
0a3f74 |
# Expand translation markers inside template instance.
|
|
|
0a3f74 |
cli_replaceTMarkers $INSTANCE
|
|
|
0a3f74 |
sed -r -i \
|
|
|
0a3f74 |
-e "s!=TITLE=!$NAM!" \
|
|
|
0a3f74 |
-e "s!=URL=!$URL!" \
|
|
|
0a3f74 |
-e "s!=DATE=!$(date "+%Y-%m-%d")!" $INSTANCE
|
|
|
0a3f74 |
sed -i -r "/=KEYWORDS=/c\\${KEYS}" $INSTANCE
|
|
|
0a3f74 |
sed -i -r 's/>$/>\\/g' $INSTANCE
|
|
|
0a3f74 |
|
|
|
0a3f74 |
# Update scalable vector graphic using template instance.
|
|
|
0a3f74 |
sed -i -f $INSTANCE $FILE
|
|
|
0a3f74 |
|
|
|
0a3f74 |
# Remove template instance.
|
|
|
0a3f74 |
if [[ -f $INSTANCE ]];then
|
|
|
0a3f74 |
rm $INSTANCE
|
|
|
0a3f74 |
fi
|
|
|
0a3f74 |
|
|
|
0a3f74 |
# Sanitate scalable vector graphic.
|
|
|
0a3f74 |
sed -i -r '/^[[:space:]]*$/d' $FILE
|
|
|
0a3f74 |
|
|
|
0a3f74 |
}
|