Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/bash
- OUTPUT="../../open/restful-api-guidelines/legacy";
- RULE=100;
- rm -rf "${OUTPUT}";
- for FILE in $(find -name "*.html"); do
- TARGET="$(echo ${FILE} | cut -c 44-)";
- mkdir -p $(dirname ${OUTPUT}/${TARGET});
- if [[ "${TARGET}" =~ ^index.html$ ]]; then BASE="";
- elif [[ "${TARGET}" =~ ^TOC.html$ ]]; then BASE="./index.html";
- else BASE="../index.html"; fi;
- cat << EOF >> ${OUTPUT}/${TARGET};
- <html>
- <head>
- <script type="text/javascript">
- <!--
- var target = [];
- EOF
- PAGE="";
- for ID in $(cat ${FILE} | grep -o "id=\"[^\"]*\"" | \
- grep -v "id=\"section-\"" | sed "s/id=\"//g; s/\"//g;"); do
- if [[ "${ID}" =~ ^(must|should|may)- ]]; then
- echo " target['${ID}'] = '${BASE}#${RULE}';" >> ${OUTPUT}/${TARGET};
- RULE=$((RULE + 1));
- else
- if [ -z "${PAGE}" ]; then PAGE="${BASE}#${ID}";
- echo " target['page'] = '${BASE}#${ID}';" >> ${OUTPUT}/${TARGET};
- fi;
- echo " target['${ID}'] = '${BASE}#${ID}';" >> ${OUTPUT}/${TARGET};
- fi;
- done;
- cat << EOF >> ${OUTPUT}/${TARGET};
- var fragment = window.location.href.split('#')[1];
- if (!fragment || !target[fragment]) { fragment = 'page' }
- window.location = target[fragment];
- //-->
- </script>
- </head>
- <body>
- You should be redirected to the new location of this page immediately.
- Please check that JavaScript has been enabled in your browser, if you
- are not redirected automatically.
- </body>
- </html>
- EOF
- done;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement