Commit 58f771d4 authored by Sébastien Villemot's avatar Sébastien Villemot

setup-download-links.sh: various minor stylistic improvements

In particular:
— always use double bracket operator
— remove unneeded quotes around constant strings, when assigning variables or
  within the double bracket operator
— use consistent indentation style for compound constructs
parent cc4f6f06
......@@ -4,8 +4,7 @@ set -e
cd _includes
for branch in release snapshot
do
for branch in release snapshot; do
mkdir -p "$branch"
cd "$branch"
......@@ -14,32 +13,28 @@ do
wget --no-verbose "https://www.dynare.org/$branch/windows.json"
wget --no-verbose "https://www.dynare.org/$branch/windows-zip.json"
arr=("macosx" "source" "windows" "windows-zip")
for dir in "${arr[@]}"
do
for dir in macosx source windows windows-zip; do
readarray -t filenames < <(jq .[].filename "$dir.json")
readarray -t timestamps < <(jq .[].date "$dir.json")
readarray -t size < <(jq .[].size "$dir.json")
n=$(jq length "$dir.json")
includeFilename="download-$branch-$dir.html"
echo "" > "$includeFilename"
for ((i = 0; i < n; i++))
do
filename="${filenames[i]%\"}"
filename="${filename#\"}"
echo > "$includeFilename"
for ((i = 0; i < n; i++)); do
filename=${filenames[i]%\"}
filename=${filename#\"}
mb=$((size[i] / (10 ** 6)))
if [ "$branch" = "release" ]; then
if [[ $branch == release ]]; then
IFS='-' read -ra split <<< "$filename"
if [ "$dir" = "windows" ] || [ "$dir" = "windows-zip" ]; then
version="${split[1]}"
if [[ $dir == windows* ]]; then
version=${split[1]}
ext=${filename##*.}
elif [ "$dir" = "macosx" ]; then
elif [[ $dir == macosx ]]; then
version=${split[1]%.*}
ext=${filename##*.}
else
ext="$(echo "${split[1]}" | rev | cut -d. -f2,1 | rev)"
version="$(echo "${split[1]}" | cut -d. -f1,2,3)"
ext=$(echo "${split[1]}" | rev | cut -d. -f2,1 | rev)
version=$(echo "${split[1]}" | cut -d. -f1,2,3)
echo "{% assign dynare_stable_version = \"$version\" %}" > ../dynare_stable_version.md
fi
{
......@@ -47,12 +42,12 @@ do
echo "<a href=\"https://www.dynare.org/$branch/$dir/$filename.sig\">[signature]</a>"
} >> "$includeFilename"
else
timestamp="${timestamps[i]%\"}"
timestamp="${timestamp#\"}"
if [[ "$OSTYPE" == "darwin"* ]]; then
datestr="$(date -r "$timestamp")"
timestamp=${timestamps[i]%\"}
timestamp=${timestamp#\"}
if [[ $OSTYPE == darwin* ]]; then
datestr=$(date -r "$timestamp")
else
datestr="$(date -d @"$timestamp")"
datestr=$(date -d @"$timestamp")
fi
{
echo "<div class=\"download_row\" onclick=\"document.location = 'https://www.dynare.org/$branch/$dir/$filename'\" onkeypress=\"document.location = 'https://www.dynare.org/$branch/$dir/$filename'\">"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment