HowTo: Create Fortune Files
With these steps you should be able to create your own fortune files, which can be used with the Fortune Widget I created for Wordpress. This does get a little tricky for Windows users, as the applications needed to create these files are not as readily available as in Linux, but hopefully it shouldn’t be to painful.
So first create a text file with all of your quotes separated by a ‘%’:
Example:
I reject your reality and substitute my own...
%
This is one of those "What the hell am I doing?" moments, over!
%
We got a robot in the water, he's stuffed with tuna and it's just another day here at Mythbusters.
In this example I named the file “quotes”. Now we need to create the .dat random-access data file, to assist the fortune application or any fortune based scripts / apps in randomly selecting a quote.
In Linux, as long as you have installed the fortune-mod package you can execute the following to create your .dat file:
strfile quotes quotes.dat
Here are a few examples of how to get the fortune-mod package on your Linux installation:
Debian: apt-get install fortune-mod
Fedora: yum install fortune-mode
Gentoo: emerge fortune-mod
In Windows, you have a few options, all of which require a few steps. First you could install cygwin, which is a Unix system overlay that can install onto Windows giving you basic to extensive Unix functionality (even X11). During the installation you can select fortune-mod as a package you wish to have installed, giving you access to the same strfile command listed previously.
Another Windows option is, if you have or don’t mind installing python, I came across a python interpretation of the strfile command.
Then, last but not least, there is a fairly old application written for Windows95 (which some people claim to still work) called wFortune. This app includes a windows viewer, and a dos executable strfile.
Now that you have created your fortune file, lets install this to where your Fortune Widget can use it. First, make sure you have the Fortune Widget properly installed into your Wordpress plugins directory. As of this post, the widget was designed for the original automatic widgets plugin. Once the plugin is available in your Wordpress widgets manager, copy the fortune file just created into the fortune directory under plugins:
cp quotes quotes.dat ~/www/wordpress/plugins/fortune/quotes.dat
Now, bring up the customization window for the Fortune widget under the Wordpress widgets manager. From her you can set a title, and you should be able to select your newly created fortune file.
If you have any questions, definitely comment, otherwise I plan to have better instructions on my next release, as the Fortune Widget 0.3 still needs to be updated for Wordpress 2.2.x.
I hope that helps everyone interested in create those fortune files or how to use them with the Fortune Widget.
Popularity: 10% [?]


October 9th, 2008 at 12:07 pm
[...] add vim cheats to fortune, you can either make your own .dat file (directions here), fill it with vim commands, and add it to your fortunes directory, or you can download mine. Mine [...]