Shorten long file names (r8, r7, r6, r5)
https://review.opendev.org/c/starlingx/docs/+/893405 revealed a problem with very long file names not being linkable in some browsing contexts. The problem was corrected by shortening the filename to 75 chars + extension. This review checks for and trims long filename input to 'tox -e newfile' to 75 chars + extension. (62 + dash + UUID fragment) Signed-off-by: Ron Stone <ronald.stone@windriver.com> Change-Id: Id6fa734c664977606649ff38d7e837fd1f91d178
This commit is contained in:
parent
0df05f304c
commit
87cf79ba4c
12
new-topic.sh
12
new-topic.sh
@ -5,9 +5,11 @@ if [[ -z ${utils_loaded+x} ]]; then echo "Could not load utilities"; exit 1; fi
|
||||
|
||||
check_util_deps uuidgen
|
||||
|
||||
INCLUDEDIR="$2/doc/source/_includes"
|
||||
|
||||
declare INCLUDEDIR="$2/doc/source/_includes"
|
||||
declare -A charReplacements
|
||||
# max basename lenght *before* appending UUID
|
||||
declare MAX_LEN=62
|
||||
|
||||
|
||||
charReplacements=(
|
||||
["-"]="minus"
|
||||
@ -123,6 +125,12 @@ do
|
||||
filename=`sed "s/$c/${charReplacements[$c]}/g" <<< $filename`
|
||||
done
|
||||
|
||||
if [[ ${#filename} -gt ${MAX_LEN} ]]; then
|
||||
filename=${filename:0:$MAX_LEN}
|
||||
declare FULL_LEN=$(($MAX_LEN + 13))
|
||||
echo -e "\nFilename and label shortend to $FULL_LEN chars"
|
||||
fi
|
||||
|
||||
filename="${filename//[^[:alnum:]]/-}"
|
||||
filename=$(echo $filename | tr -s -)
|
||||
filename="${filename}-${myuuid}"
|
||||
|
Loading…
Reference in New Issue
Block a user