#!/bin/bash
# input should be a csv
# each line should contain the rdoc file path and the wiki page name seperated by a :
# /path/to/rdoc/test.html:test-wiki-page
#
# only the div description part will be imported

# your github session cookie. extracted with firebug:
export GHCOOKIE="_github_ses=YOUR_GITHUB_SESSION_COOKIE"

#export GHPROJ="jwagener/oauth-active-resource"

# your username/projectname
export GHPROJ="soundcloud/ruby-api-wrapper"

# keep it like that
export GHWURL="http://github.com/$GHPROJ/wikis/"


while  read LINE 
     do
    export PAGE=`echo $LINE | cut -d : -f 2` 
    export FILE=`echo $LINE | cut -d : -f 1`

    echo "--------------------------------------------"
    echo "uploading to $PAGE :"
    xmllint $FILE | xpath -e "//div[@id='description']" | sed -e 's/&lt;/</g' | curl -X PUT -b $GHCOOKIE -F "wiki[body]=<-" $GHWURL$PAGE
#    echo $PAGE $FILE
done
