diff options
author | jak1 <mike.wollmann@gmail.com> | 2021-03-18 17:33:47 +0100 |
---|---|---|
committer | jak1 <mike.wollmann@gmail.com> | 2021-03-18 17:33:47 +0100 |
commit | a8db49ef5de4f2cacd2317c25ae1859879533831 (patch) | |
tree | 7ccaa8e883efb71b11bce4af00aba798c6da11de /pages.sh | |
parent | c4a59a989f655d08a97cfaabdb318431f0c2285b (diff) | |
download | docker-windows-builder-a8db49ef5de4f2cacd2317c25ae1859879533831.tar.gz docker-windows-builder-a8db49ef5de4f2cacd2317c25ae1859879533831.tar.bz2 docker-windows-builder-a8db49ef5de4f2cacd2317c25ae1859879533831.tar.xz docker-windows-builder-a8db49ef5de4f2cacd2317c25ae1859879533831.zip |
Json
- added .json file (still needs a validator/linter)
- fixed escaping backslash
Diffstat (limited to 'pages.sh')
-rw-r--r-- | pages.sh | 28 |
1 files changed, 25 insertions, 3 deletions
@@ -27,14 +27,21 @@ if [[ ! -d $deploy_dir ]]; then mkdir -p $deploy_dir fi - +# buffer for .html _b(){ BUFFER_HTML=${BUFFER_HTML}${1} } + +# buffer for .xml _x(){ BUFFER_XML=${BUFFER_XML}${1} } +# buffer for .json +_j(){ + BUFFER_JSON=${BUFFER_JSON}${1} +} + gen_page(){ _b "<!DOCTYPE html><html>" _b "<head><title>MirrorList</title></head>" @@ -49,20 +56,34 @@ gen_page(){ _b "</tr>" _x "<?xml version='1.0' encoding='utf-8'?>\n" _x "<!--\n Authors: jak1\n Copyright: (C) 2021 TheManaWorld Developers\n Generated by: Gitlab deploy (manual changes will get overwritten)\n-->\n" + _j "{\n" + _j " \"#comment\": \"Authors: jak1 Copyright: (C) 2021 TheManaWorld Developers Generated by: Gitlab deploy (manual changes will get overwritten)\",\n" + _j " \"versions\": {\n" _x "<versions>\n"; while IFS= read -r line; do # ${line#* } = checksum # ${line% *} = filename _b "<tr>" _x " <version file='${line#* }' checksum='${line% *}'>\n"; + _j " \"version\": {\n \"-file\": \"${line#* }\",\n \"-checksum\": \"${line% *}\",\n \"mirror\": [\n" + c=0 for mirror_url in $mirror_urls; do _b "<td><a title='sha256:${line% *}' href='${mirror_url}${line#* }'>${line#* }</a></td>"; - _x $" <mirror url='${mirror_url}${line#* }' />\n"; + _x " <mirror url='${mirror_url}${line#* }' />\n"; + _j " {\n \"-url\": \"${mirror_url}${line#* }\"\n }" + if [[ $c == ${#mirror_urls[@]} ]]; then + _j "\n" + else + _j ",\n" + fi + ((c++)) done + _j " ]\n }\n }\n" _x " </version>\n"; _b "</tr>" done < $version_file _x "</versions>\n"; + _j "}\n" _b "</table>" _b "<a href='$version_file'>versions.txt</a>" _b "</center></body>" @@ -71,6 +92,7 @@ gen_page(){ #write out files (keep source formating for xml) echo $BUFFER_HTML > $deploy_dir/mirrorlist.html echo -e "$BUFFER_XML" > $deploy_dir/mirrorlist.xml + echo -e "$BUFFER_JSON" > $deploy_dir/mirrorlist.json } add_new_release(){ @@ -110,4 +132,4 @@ gen_page xmllint --schema $deploy_dir/mirrorlist.xsd $deploy_dir/mirrorlist.xml --noout || exit 1 mv $version_file $deploy_dir || exit 1 -echo "deploy passed \o/" +echo "deploy passed \\o/" |