| #!/bin/bash |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| function svg_updateMetadata { |
| |
| local TEMPLATES='' |
| local INSTANCE='' |
| local COUNT=0 |
| local NAM='' |
| local URL='' |
| local KEYS='' |
| local -a TITLE |
| local -a VALUE |
| local -a PATTERN |
| local -a PATTERN_MSG |
| local -a MARKER |
| local -a DEFAULT |
| |
| |
| TEMPLATE="/home/centos/artwork/trunk/Scripts/Bash/Functions/Svg/Config/tpl_forMetadata.sed" |
| |
| |
| cli_checkFiles $TEMPLATE 'f' |
| |
| |
| TITLE[0]="`gettext "Title"`" |
| TITLE[1]="`gettext "Date"`" |
| TITLE[2]="`gettext "Creator"`" |
| TITLE[3]="`gettext "Rights"`" |
| TITLE[4]="`gettext "Publisher"`" |
| TITLE[5]="`gettext "Identifier"`" |
| TITLE[6]="`gettext "Source"`" |
| TITLE[7]="`gettext "Relation"`" |
| TITLE[8]="`gettext "Language"`" |
| TITLE[9]="`gettext "Keywords"`" |
| TITLE[10]="`gettext "Coverage"`" |
| TITLE[11]="`gettext "Description"`" |
| TITLE[12]="`gettext "Contributor"`" |
| |
| |
| MARKER[0]='=TITLE=' |
| MARKER[1]='=DATE=' |
| MARKER[2]='=CREATOR=' |
| MARKER[3]='=RIGHTS=' |
| MARKER[4]='=PUBLISHER=' |
| MARKER[5]='=IDENTIFIER=' |
| MARKER[6]='=SOURCE=' |
| MARKER[7]='=RELATION=' |
| MARKER[8]='=LANGUAGE=' |
| MARKER[9]='=KEYWORDS=' |
| MARKER[10]='=COVERAGE=' |
| MARKER[11]='=DESCRIPTION=' |
| MARKER[12]='=CONTRIBUTOR=' |
| |
| |
| |
| PATTERN[0]='^([[:alnum:] _-.]+)?$' |
| PATTERN[1]='^([0-9]{4}-(0[1-9]|1[0-2])-([0-2][1-9]|3[0-1]))?$' |
| PATTERN[2]=${PATTERN[0]} |
| PATTERN[3]=${PATTERN[0]} |
| PATTERN[4]=${PATTERN[0]} |
| PATTERN[5]='^(https://projects.centos.org/svn/artwork/[[:alnum:]/._-]+)?$' |
| PATTERN[6]=${PATTERN[5]} |
| PATTERN[7]=${PATTERN[5]} |
| PATTERN[8]='^([a-z]{2}(_[A-Z]{2})?)?$' |
| PATTERN[9]=${PATTERN[0]} |
| PATTERN[10]=${PATTERN[0]} |
| PATTERN[11]=${PATTERN[0]} |
| PATTERN[12]=${PATTERN[0]} |
| |
| |
| |
| PATTERN_MSG[0]="`gettext "Try using alphanumeric characters."`" |
| PATTERN_MSG[1]="`gettext "Try using 'YYYY-MM-DD' date format."`" |
| PATTERN_MSG[2]=${PATTERN_MSG[0]} |
| PATTERN_MSG[3]=${PATTERN_MSG[0]} |
| PATTERN_MSG[4]=${PATTERN_MSG[0]} |
| PATTERN_MSG[5]="`gettext "Only locations under https://projects.centos.ort/svn/artwork are supported."`" |
| PATTERN_MSG[6]=${PATTERN_MSG[0]} |
| PATTERN_MSG[7]=${PATTERN_MSG[0]} |
| PATTERN_MSG[8]="`gettext "Try using 'LL' or 'LL_CC' locale format."`" |
| PATTERN_MSG[9]=${PATTERN_MSG[0]} |
| PATTERN_MSG[10]=${PATTERN_MSG[0]} |
| PATTERN_MSG[11]=${PATTERN_MSG[0]} |
| PATTERN_MSG[12]=${PATTERN_MSG[0]} |
| |
| |
| DEFAULT[1]=$(date +%Y-%m-%d) |
| DEFAULT[2]="The CentOS Project" |
| DEFAULT[3]=${DEFAULT[2]} |
| DEFAULT[4]=${DEFAULT[2]} |
| DEFAULT[8]=$(cli_getCurrentLocale) |
| DEFAULT[10]=${DEFAULT[2]} |
| |
| |
| cli_printMessage "`gettext "Enter metadata information you want to apply:"`" |
| while [[ $COUNT -ne ${#TITLE[*]} ]];do |
| |
| |
| cli_printMessage "${TITLE[$COUNT]}" 'AsRequestLine' |
| read VALUE[$COUNT] |
| |
| |
| |
| until [[ ${VALUE[$COUNT]} =~ ${PATTERN[$COUNT]} ]];do |
| cli_printMessage "${PATTERN_MSG[$COUNT]}" |
| cli_printMessage "${TITLE[$COUNT]}" 'AsRequestLine' |
| read VALUE[$COUNT] |
| done |
| |
| |
| if [[ ${VALUE[$COUNT]} == '' ]];then |
| VALUE[$COUNT]=${DEFAULT[$COUNT]} |
| fi |
| |
| |
| COUNT=$(($COUNT + 1)) |
| |
| done |
| |
| |
| local ARGSS="" |
| |
| |
| local ARGSL="filter:" |
| |
| |
| cli_doParseArguments |
| |
| |
| |
| eval set -- "$ARGUMENTS" |
| |
| |
| while true; do |
| case "$1" in |
| --filter ) |
| REGEX="$2" |
| shift 2 |
| ;; |
| * ) |
| break |
| esac |
| done |
| |
| |
| |
| REGEX=$(echo "${REGEX}.*\.(svgz|svg)") |
| |
| |
| cli_getFilesList |
| |
| |
| for FILE in $FILES;do |
| |
| |
| cli_printMessage $FILE 'AsUpdatingLine' |
| |
| |
| NAM=$(basename $FILE) |
| |
| |
| URL=$(echo $FILE | sed 's!/home/centos!https://projects.centos.org/svn!') |
| |
| |
| |
| KEYS=$(dirname $FILE | cut -d/ -f6- | tr '/' '\n') |
| |
| |
| |
| |
| |
| |
| |
| |
| KEYS=$(\ |
| for KEY in $KEYS;do |
| echo " <rdf:li>$KEY</rdf:li>\\" |
| done) |
| |
| |
| INSTANCE=$(cli_getTemporalFile $TEMPLATE) |
| |
| |
| cp $TEMPLATE $INSTANCE |
| |
| |
| |
| cli_checkFiles $INSTANCE 'f' |
| |
| |
| COUNT=0 |
| |
| while [[ $COUNT -ne ${#TITLE[*]} ]];do |
| |
| |
| if [[ $COUNT -eq 0 ]];then |
| VALUE[$COUNT]=$NAM |
| elif [[ $COUNT -eq 5 ]];then |
| VALUE[$COUNT]=$URL |
| elif [[ $COUNT -eq 6 ]];then |
| VALUE[$COUNT]=$URL |
| elif [[ $COUNT -eq 7 ]];then |
| VALUE[$COUNT]=$URL |
| elif [[ $COUNT -eq 9 ]];then |
| VALUE[$COUNT]=$KEYS |
| fi |
| |
| |
| if [[ $COUNT -eq 9 ]];then |
| sed -i -r "/${MARKER[$COUNT]}/c\\${VALUE[$COUNT]}" $INSTANCE |
| else |
| sed -i -r "s!${MARKER[$COUNT]}!${VALUE[$COUNT]}!g" $INSTANCE |
| fi |
| |
| |
| COUNT=$(($COUNT + 1)) |
| |
| done |
| |
| |
| sed -i -r -e 's/>$/>\\/g' $INSTANCE |
| |
| |
| |
| sed -i -f $INSTANCE $FILE |
| |
| |
| cli_checkFiles "${INSTANCE}" 'f' |
| rm $INSTANCE |
| |
| |
| sed -i -r '/^[[:space:]]*$/d' $FILE |
| |
| done \ |
| | awk -f /home/centos/artwork/trunk/Scripts/Bash/Styles/output_forTwoColumns.awk |
| |
| |
| |
| cli_commitRepoChanges |
| |
| } |