forked from ehcache/ehcache.org-site
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd-analytics.sh
More file actions
24 lines (20 loc) · 827 Bytes
/
add-analytics.sh
File metadata and controls
24 lines (20 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env bash
# This script should only be used for building the production copy of the site
if [ -z "$2" ] ; then
echo "Usage: $0 SOURCE_DIR TARGET_DIR"
echo " target dir can be the same as source"
exit 3
fi
SOURCE=$1
TARGET=$2
# Manual post-processing - add tracking code to javadoc where it's easy to do
# for Javadoc for 3.x
for s in $TARGET/apidocs/*/script.js ; do
echo "Adding analytics to $s"
cat $SOURCE/_includes/analytics.js >> $s
done
# for Javadoc for 2.x
echo "Adding Analytics to apidocs/2.x"
echo -e "<!--Added by publisher -->\\n<script>$(cat $SOURCE/_includes/analytics.js)\\n</script>" > $SOURCE/_includes/analytics.html
for foo in $(find $TARGET/apidocs/2.* -name '*.html') ; do sed -i -e "/<HEAD>/r $SOURCE/_includes/analytics.html" $foo ; done
rm $SOURCE/_includes/analytics.html