Originally published on: 7/21/2005 9:49:47 PM
So, what I wanted was a way for any installation of WikidPad to use the most current version of my Wiki. The most obvious solution was an FTP synchronization setup. By keeping the most current version of the data on my dev FTP server, I could grab it, work with it, and upload it when I was done.
Approach:
1. FTP download of wiki data from FTP server (assumes it's been manually uploaded once).
2. Run WikidPad.
3. Wait for WikidPad to close.
4. Upload the newly updated wiki data to the server.
Requires:
* Windows (XP tested, 2K and NT should work, no idea about 9x/ME). We'll actually be using the commandline FTP client that comes with Windows.
* AutoHotkey - free and open source automation tool.
* WikidPad itself
* A WikidPad wiki. The paths assume that you have a directory tree that looks like this if yours doesn't, you'll have to adjust:
WikidPad
--WikidPad.exe
--YourWiki
----YourWiki.wiki
----download.ftp (we'll create this)
----upload.ftp(we'll create this)
----ftp_wikidpad.ahk(we'll create this)
----data
Preparation:
0. Before anything else, make a real backup of your wiki somewhere outside the WikidPad directory. While this setup has been working for me for a week or so with no real problems, I won't be responsible for you losing your entire wiki.
1. Install WikidPad.
2. Install AutoHotkey.
3. Make sure the commandline FTP client works. Open a command prompt: Start->Run->cmd and run ftp.exe.
4. Set up your FTP directory. It needs to be writable and should be dedicated to this purpose. I set one up under my dev server website FTP directory called, orginally enough: wikidpad. Into this directory will go the .wiki file and the "data" directory. If this directory is on a public webserver and you don't want it read, make sure you secure the directory. There are plenty of sites explaining how to do this. A quick "Deny from all" stuck in an .htaccess file will take care of it for Apache servers.
5. Do an initial FTP upload. You want the .wiki file and the "data" subdirectory. This assumes that you created a dedicated local directory for your local wiki (which is a really good idea). If this isn't the case, you're kind of on your own as this solution assumes a clean directory structure to work with.
The Windows FTP client has a file input mode where, instead of typing all of the individual commands, you feed it a list of commands and it follows it, in order.
We'll be creating 2 of them: one for the download, run before launching WikidPad and the other for uploading, after WikidPad closes.
Set up FTP Session Files:
1. Create a new text file, called download.ftp and save it in the same directory as your .wiki file.
2. In that file, put a modified version of the following snippet. Change the servername, username, password and subdirectory path (relative to where the default login directory is). If you are unsure what that will be, run the ftp client manually and see where you need to "cd" to in order to get to your directory.
open ftp.example.com
ftpusername
ftppassword
cd subdirectory/to/wiki/directory
prompt
mget *.*
mkdir data
cd data
lmkdir data
lcd data
mget *.*
bye
3. Create another text file in the same place, called upload.ftp. Modify and save the following snippet into that file.
open ftp.example.com
ftpusername
ftppassword
cd subdirectory/to/wiki/directory
prompt
mput *.wiki
mkdir data
cd data
lcd data
mput *.*
bye
These files will be fed to the FTP client to take care of synchronizing our data. We could just open a command prompt and manually run "ftp -s:download.ftp" before working and "ftp -s:upload.ftp" after. However, I know that my use of WikidPad is to make my life more organized and make better use of my time. So, adding an extra step seems a bad idea. Fortunately, AutoHotkey makes this kind of automation brain-dead simple.
Set up the .ahk file
1. In the same place as the .ftp files, create a file called ftp_wikidpad.ahk.
2. Put the following snippet in that file:
RunWait, ftp -s:download.ftp
RunWait, ..\WikidPad.exe, Max
RunWait, ftp -s:upload.ftp
At this point, just double-clicking your .ahk should bring up a DOS window that does the FTP transfer and then WikiPad. After you close it, another DOS box should pop up, doing the upload.
Now, if you want to distribute this to other PC's without installing AutoHotkey, just use the compiler that comes with it to make an EXE out of the .ahk. You will still need the .ftp files, but will be able to easily bundle your entire WikidPad installation into a ZIP file, and unzip as necessary on new machines.
* SVN, CVS or other source code control
* Encrypt and decrypt the file storage
* Compact and uncompact the file storage
etc.
Also, technically, the license for netdrive doesn't allow for those of us not owners of the bigger Novell license to use. Many universities have the link up, making it defacto free, but it's technically not licensed for the rest of us to use.