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 (cherry picked from commit 87cf79ba4c6b48b6a06d9a255943603e3d0e4302)
This commit is contained in:
parent
4840f18260
commit
ef88a033e2
12
new-topic.sh
12
new-topic.sh
@ -5,9 +5,11 @@ if ! hash uuidgen 2>/dev/null; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
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"
|
||||
@ -128,6 +130,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…
x
Reference in New Issue
Block a user