|
|
878a2b |
#!/bin/bash
|
|
|
878a2b |
#
|
|
|
878a2b |
# svg_doMetadata.sh -- This function updates metadata values inside
|
|
|
878a2b |
# scalable vector graphic (SVG) files using default values from The
|
|
|
878a2b |
# CentOS Project.
|
|
|
878a2b |
#
|
|
|
03486a |
# Copyright (C) 2009, 2010, 2011, 2012 The CentOS Project
|
|
|
878a2b |
#
|
|
|
878a2b |
# This program is free software; you can redistribute it and/or modify
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
#
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
# General Public License for more details.
|
|
|
878a2b |
#
|
|
|
878a2b |
|
|
|
878a2b |
# along with this program; if not, write to the Free Software
|
|
|
878a2b |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
878a2b |
#
|
|
|
878a2b |
# ----------------------------------------------------------------------
|
|
|
878a2b |
# $Id$
|
|
|
878a2b |
# ----------------------------------------------------------------------
|
|
|
878a2b |
|
|
|
878a2b |
function svg_doMetadata {
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
local TEMPLATE="${TUNEUP_CONFIG_DIR}/metadata.sed"
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
eb0622 |
cli_checkFiles -e $TEMPLATE
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
local TITLE=$(basename "$FILE")
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
local URL=$(echo $FILE | sed 's!/home/centos!https://projects.centos.org/svn!')
|
|
|
878a2b |
|
|
|
878a2b |
# Build keywords from file path. Do not include filename, it is
|
|
|
878a2b |
|
|
|
878a2b |
local KEY=''
|
|
|
878a2b |
local KEYS=$(dirname "$FILE" | cut -d/ -f6- | tr '/' '\n')
|
|
|
878a2b |
|
|
|
878a2b |
# Build keywords using SVG standard format. Note that this
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
# new line of each line using one backslash (\). As we are doing
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
KEYS=$(\
|
|
|
878a2b |
for KEY in $KEYS;do
|
|
|
878a2b |
echo " <rdf:li>$KEY</rdf:li>\\"
|
|
|
878a2b |
done)
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
local INSTANCE=$(cli_getTemporalFile $TEMPLATE)
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
cp $TEMPLATE $INSTANCE
|
|
|
878a2b |
|
|
|
878a2b |
# Check template instance. We cannot continue if the template
|
|
|
878a2b |
|
|
|
eb0622 |
cli_checkFiles -e $INSTANCE
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
sed -r -i \
|
|
|
878a2b |
-e "s!=TITLE=!$TITLE!" \
|
|
|
878a2b |
-e "s!=URL=!$URL!" \
|
|
|
878a2b |
-e "s!=DATE=!$(date "+%Y-%m-%d")!" $INSTANCE
|
|
|
878a2b |
sed -i -r "/=KEYWORDS=/c\\${KEYS}" $INSTANCE
|
|
|
878a2b |
sed -i -r 's/>$/>\\/g' $INSTANCE
|
|
|
878a2b |
cli_expandTMarkers $INSTANCE
|
|
|
878a2b |
|
|
|
878a2b |
# Update scalable vector graphic using template instance.
|
|
|
878a2b |
sed -i -f $INSTANCE $FILE
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
if [[ -f $INSTANCE ]];then
|
|
|
878a2b |
rm $INSTANCE
|
|
|
878a2b |
fi
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
sed -i -r '/^[[:space:]]*$/d' $FILE
|
|
|
878a2b |
|
|
|
878a2b |
}
|