| 1 | #!/bin/sh |
| 2 | # This script builds and minifies CSS and JS that we bundle to HTML report and guide. |
| 3 | set -e |
| 4 | |
| 5 | if ! type yuicompressor > /dev/null; then |
| 6 | echo "Please install yuicompressor utility" |
| 7 | exit 1 |
| 8 | fi |
| 9 | |
| 10 | ALL_CSS=`mktemp` |
| 11 | ALL_CSS_MIN=`mktemp` |
| 12 | ALL_JS=`mktemp` |
| 13 | ALL_JS_MIN=`mktemp` |
| 14 | |
| 15 | echo "" > $ALL_CSS |
| 16 | cat xccdf-resources/jquery.treetable.css >> $ALL_CSS |
| 17 | cat xccdf-resources/jquery.treetable.theme.css >> $ALL_CSS |
| 18 | cat xccdf-resources/openscap.css >> $ALL_CSS |
| 19 | yuicompressor --type css $ALL_CSS > $ALL_CSS_MIN |
| 20 | rm $ALL_CSS |
| 21 | echo "" > $ALL_JS |
| 22 | cat xccdf-resources/jquery.treetable.js >> $ALL_JS |
| 23 | cat xccdf-resources/bootstrap.min.js >> $ALL_JS |
| 24 | cat xccdf-resources/openscap.js >> $ALL_JS |
| 25 | yuicompressor --type js $ALL_JS > $ALL_JS_MIN |
| 26 | rm $ALL_JS |
| 27 | |
| 28 | XCCDF_RESOURCES="xccdf-resources.xsl" |
| 29 | |
| 30 | echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" > $XCCDF_RESOURCES |
| 31 | echo "<!-- This file was autogenerated! See the xccdf-resources/ folder! -->" >> $XCCDF_RESOURCES |
| 32 | |
| 33 | echo "<xsl:stylesheet version=\"1.1\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">" >> $XCCDF_RESOURCES |
| 34 | echo "<xsl:template name=\"css-sources\"><![CDATA[" >> $XCCDF_RESOURCES |
| 35 | # bootstrap.min.css can't be minified further without breaking behavior |
| 36 | cat xccdf-resources/bootstrap.min.css >> $XCCDF_RESOURCES |
| 37 | cat $ALL_CSS_MIN >> $XCCDF_RESOURCES |
| 38 | echo "]]></xsl:template>" >> $XCCDF_RESOURCES |
| 39 | echo "<xsl:template name=\"js-sources\"><![CDATA[" >> $XCCDF_RESOURCES |
| 40 | # jquery.min.js can't be minified further without breaking behavior |
| 41 | cat xccdf-resources/jquery.min.js >> $XCCDF_RESOURCES |
| 42 | cat $ALL_JS_MIN >> $XCCDF_RESOURCES |
| 43 | echo "]]></xsl:template>" >> $XCCDF_RESOURCES |
| 44 | |
| 45 | echo "</xsl:stylesheet>" >> $XCCDF_RESOURCES |
| 46 | |
| 47 | rm $ALL_CSS_MIN |
| 48 | rm $ALL_JS_MIN |