From 87cf79ba4c6b48b6a06d9a255943603e3d0e4302 Mon Sep 17 00:00:00 2001 From: Ron Stone Date: Fri, 1 Sep 2023 12:20:59 +0000 Subject: [PATCH] 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 Change-Id: Id6fa734c664977606649ff38d7e837fd1f91d178 --- new-topic.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/new-topic.sh b/new-topic.sh index 7f89ef2af..9380d158b 100644 --- a/new-topic.sh +++ b/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}"