# Description: # This script is designed to make editing a text file in a Yahoo Geocities account # simpler. The script relies on 2 other scripts, login-geocities.sh and # upload-geocities.sh which handle the business of getting through the Yahoo geocities # web-upload interface. # # This script performs a series of steps. It gets the file (some kind of text file) from # A particular location on an account of Yahoo Geocities using wget. Then it opens this file # in vim to allow it to be edited. Then once the user exits from vim, this script uploads the # file back to the Yahoo Geocities account. This is slightly tricky since Yahoo does not # allow normal ftp access to its free web accounts. It only allows file uploads through # a logged-in web-interface. But, not to worry, the scripts login-geocities.sh and # upload geocities can take care of this. # # Notes: # If a currently valid cookie file is not available for the Yahoo Geocities account then # this script will not automatically log-in (using the login-geocities.sh script) but instead # this script will simply inform the user that she needs to run this login-geocities.sh script # and then try again. This behaviour may well not be particularly desirable but it is the # the way which I deliberately chose. If this situation occurs then the user needs to run # the login script and then 'manually' upload the previously edited file using the # upload-geocities.sh script. The file which was edited is saved in a file called something # like [filename].vimgeo # # It is quite possible that Yahoo will change the login process for their free Geocities # web-accounts, which will make this current script no longer work (it works as of 4 august 2003) # # Dependencies: # iconv a program to convert between character encodings # plaintext2html-static.sh # A script to convert a plain text file into an HTML file. This script was really just a # quick hack on the plaintext2html-wiki.sh script. The point was that I didnt need the # whole web-editable schmozzle for the work I was doing at the time that I wrote the current # current script. # login-geocities.sh # This script needs to be run by the user before using the current script, unless the user # has already done so very recently (as in a few hours ago). This is because the cookies which # the Yahoo Geocities servers send to the client are set to expire after a certain short amount # of time. # upload-geocities.sh # This is the script which manages to 'get around' the Geocities web-interface upload facility, # or more precisely, manages to use that web-interface from a scripting environment. This is a # reasonably tricky operation involving all sorts of cookings and form posts, in some circumstances # in an https environment. However the curl utility manages all this stuff nicely, so I didnt have # to do very much work. # # Author: # mjb http://www.geocities.com/matth3wbishop/ sFileName="" sFileBaseName="" sFilePath="" sAccountName="matth3wbishop" sPassword="" if [ "$1" = "" ] then echo "usage: $0 filename [password] [account-name] " cat $0 | sed -n "/^[ ]*#[^-]/p" exit 1; else sFileName="$1" fi if [ "$2" != "" ] then sPassword="$2" fi if [ "$3" != "" ] then sAccountName="$3" fi sFileName=$(echo $sFileName | sed "s#^[ ]*/##g") sFileBaseName=$(basename $sFileName) sFileBaseNameNoExt=$(basename $sFileName | sed "s/\.[^\.]\+$//g") sFilePath=$(dirname $sFileName | sed "s/^[ ]*\.//g") #-- get rid of leading or sole dots in file paths since geocities doesnt like them sResourceUrl="http://www.geocities.com/$sAccountName/$sFilePath/$sFileBaseName" #- for debugging bDebug="1" if [ "$bDebug" = "1" ] then echo " sFileName=$sFileName sFileBaseName=$sFileBaseName sFileBaseNameNoExt=$sFileBaseNameNoExt sFilePath=$sFilePath sAccountName=$sAccountName sPassword=$sPassword sResourceUrl=$sResourceUrl " else echo " sFileName=$sFileName sFileBaseName=$sFileBaseName sFileBaseNameNoExt=$sFileBaseNameNoExt sFilePath=$sFilePath sAccountName=$sAccountName sPassword=$sPassword sResourceUrl=$sResourceUrl " > vimgeo.log fi #- I need to do a trick to move an existing file out of the way so that the download #- geocities file which has the same name wont interfer with it or be interfered with by it if [ -f $sFileBaseName ] then if [ "$bDebug" = "1" ] then echo " Local file of same name exists: shuffling" else echo " Local file of same name exists: shuffling" >> vimgeo.log fi mv -f $sFileBaseName $sFileBaseName.shuffle fi wget -O $sFileBaseName $sResourceUrl sUnicodeFlag=$(file $sFileBaseName | sed "/Unicode/!d") #echo "sUnicodeFlag=$sUnicodeFlag" if [ "$sUnicodeFlag" != "" ] then if [ "$bDebug" = "1" ] then echo " File is Unicode" else echo " File is Unicode" >> vimgeo.log fi cp -f $sFileBaseName $sFileBaseName.utf8.original iconv --to-code=ISO-8859-1 --from-code=UTF-8 $sFileBaseName.utf8.original > $sFileBaseName fi vim $sFileBaseName upload-geocities.sh $sFileBaseName $sFilePath #- If the text file looks like its in Invisible Markup language, #- transform it and upload the html version as well sInvisibleWikiFlag=$(expand $sFileBaseName | sed "/^[ ]*$/d" | head -1 | sed -n '/^[ ]*[=]/p') #expand somefile | sed "/^[ ]*$/d" | head -1 | sed "/^[ ]*=/!d" #echo "sInvisibleWikiFlag=$sInvisibleWikiFlag" if [ "$sInvisibleWikiFlag" != "" ] then echo " The file you were editing ($sFileBaseName) has been recognised as an 'invisible markup' document (this is because the first line of text begins with a '='). For this reason it will now be transformed with the script 'plaintext2html-static.sh' into HTML and the resulting HTML file will also be uploaded" cp -f $sFileBaseName $sFileBaseName.latin1.edit iconv --from-code=ISO-8859-1 --to-code=UTF-8 $sFileBaseName.latin1.edit > $sFileBaseName # plaintext2html-static.sh $sFileBaseName | \ # iconv --to-code=ISO-8859-1 --from-code=UTF-8 > $sFileBaseNameNoExt.html plaintext2html-static.sh $sFileBaseName > $sFileBaseNameNoExt.html upload-geocities.sh $sFileBaseNameNoExt.html $sFilePath fi mv -f $sFileBaseName $sFileBaseName.vimgeo if [ -f "$sFileBaseName.shuffle" ] then #echo "unshuffling file:" cp -f $sFileBaseName.shuffle $sFileBaseName fi