#!/bin/bash
# Integrate AdSense advertising
sed -i -e 's|<div id="page" lang="en" dir="ltr">|<div id="page" lang="en" dir="ltr">\
<div style="float:right;">\
<!--AdSense advertisement snippet, begin -->\
<script type="text/javascript"><!--\
google_ad_client = "pub-0237937445704641";\
/* sdlwiki default */\
google_ad_slot = "8536480085";\
google_ad_width = 300;\
google_ad_height = 250;\
//-->\
</script>\
<script type="text/javascript"\
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">\
</script>\
<!--AdSense, end -->\
</div>|' ../data/pages.new/*

# Integrate AdSense search engine integration
# http://austinmatzko.com/2008/04/26/sed-multi-line-search-and-replace/
sed -n -i -e '1h;1!H;${;g;s|<form id="searchform".*</form>|<div style="float: right;">\
<form action="http://www.google.com/cse" id="cse-search-box">\
  <div>\
    <input type="hidden" name="cx" value="partner-pub-0237937445704641:1cqbykgh1jl" />\
    <input type="hidden" name="ie" value="UTF-8" />\
    <input type="text" name="q" size="20" />\
    <input type="submit" name="sa" value="Search" />\
  </div>\
</form>\
<script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box\&amp;lang=en"></script>\
</div>|g;p;}' ../data/pages.new/*

# Integrate Analytics
sed -i -e 's!</head>!<script type="text/javascript">\
\
  var _gaq = _gaq || [];\
  _gaq.push(['\''_setAccount'\'', '\''UA-27151164-1'\'']);\
  _gaq.push(['\''_trackPageview'\'']);\
\
  (function() {\
    var ga = document.createElement('\''script'\''); ga.type = '\''text/javascript'\''; ga.async = true;\
    ga.src = ('\''https:'\'' == document.location.protocol ? '\''https://ssl'\'' : '\''http://www'\'') + '\''.google-analytics.com/ga.js'\'';\
    var s = document.getElementsByTagName('\''script'\'')[0]; s.parentNode.insertBefore(ga, s);\
  })();\
\
</script>\
</head>!' ../data/pages.new/*

