#!/bin/sh
# remove code violating user privacy

if [ $# -ne 1 ] ; then
    echo "Usage: $0 <file>"
    exit 1
fi
if [ ! -e $1 ] ; then
    echo "File $1 not found"
    exit 1
fi
sed -i -e '/<\!-- Start of StatCounter Code -->/,/<\!-- End Google Analytics -->/d' \
       -e '/<script type="text\/javascript">/{;N;s/\n//;}' \
       -e "/flattr_btn='compact'/{;N;s/\n//;}" \
       -e '/<script type="text\/javascript">.*flattr_url/,/lattr_btn.*<\/script>/d' \
       -e '/<script src="http:\/\/api.flattr.com\/button\/load.js.*javascript"><\/script>/d' \
       -e '/<a href="http:\/\/sourceforge.net\/donate\/index.php?group_id=[0-9]\+"><img src="http:\/\/images.sourceforge.net\/images\/project-support.jpg".* alt="Support This Project".*a>/d' \
    $1

# use local logo
INSERT=""
if echo $1 | grep -q 'reference/[^/]\+$' ; then
    INSERT="../"
fi
sed -i "s?http://cimg.sourceforge.net/img/CImgLogo2.jpg?${INSERT}CImgLogo2.jpg?" $1
