Posted by hank, Wed Feb 21 23:13:00 UTC 2007
I had some difficulty along the way, and I have some fixes for those of you who are having trouble converting. I found that Mephisto is actually very friendly to the ./script/console hacker. Also, though it took a while to actually get a response, I ended up getting direct help from technoweenie in #mephisto@irc.freenode.net, which was a big help. So, here’s the situation:
My current host is Site5. I have gems set up in my home directory, and I have rails 1.2.2 installed as a gem. I tried using it, but just ended up freezing edge rails because I ran into some trouble. I created a db, subdomain, and .htaccess entry for the site. Then, I actually checked it out:
svn co http://svn.techno-weenie.net/projects/mephisto/trunk mephisto
Then, I created config/database.yml. Here’s a template you can use:
development:
adapter: mysql
database: mephisto
username: meph
password: <new-pw>
host: localhost
production:
adapter: mysql
database: mephisto
username: meph
password: <new-pw>
host: localhost
typo:
adapter: mysql
database: typo
username: typo
password: <typo-pass>
host: localhost
Next, I installed tzinfo as a gem to my home directory, and froze it in the project root:
gem install tzinfo
cd mephisto
rake gems:freeze GEM=tzinfo
Finally, it’s time to fill the database with stuff:
rake db:bootstrap
Now that that’s done, for CGI and FastCGI to work, we need a .htaccess file in public:
AddHandler fastcgi-script .fcgi
AddHandler cgi-script .cgi
Options +FollowSymLinks +ExecCGI
RewriteEngine On
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"
Notice I left it as dispatch.cgi. It’s up to you, but while I was still converting I left it like this since it didn’t want to run with FastCGI.
Let’s make sure log and public can be read and, if need be, written to:
chmod -R 755 public log
And finally, the moment we’ve all be waiting for:
script/runner "Mephisto.convert_from :typo" -e production
This connects to the Typo database and runs a converter script in Mephisto’s vendor/plugins/ directory. It takes all the attributes Typo articles and users and comments had and converts them to Mephisto form. Rockin’.
Old Typo Woes
I did this with Typo trunk v1246 with migration level 55. If you are at a similar Typo state, then you may definitely want to continue reading as the next steps I took will be necessary for you as well.
First of all, I saw that my Markdown with SmartyPants formatting was not being interpreted at all! This was, of course, easy to fix because Mephisto is awesome:
./script/console
# Don't do this unless you ALWAYS used Markdown with SmartyPants
# Refer to vendor/plugins/filtered_column if you use Textile or straight up Markdown
# It's just a different a.filter= line below.
Article.find(:all).each {|a|a.filter='smartypants_filter';a.save};1
What this does is find all the Mephisto articles and set their filter to Markdown with SmartyPants. The 1 on the end just prevents it from spewing every article to the console.
Now here’s where I ran into some trouble. Typo has changed its Tag storage technique at least twice, and the way my tags happened to be stored is as follows:
articles
- id
articles_tags
- article_id
- tag_id
tags
- id
- name
Someone else had posted a small loop to cure another type of Typo tagging scheme, where there was just one tag grouping string per article. I ran that. Don’t do that.
I noticed that each one of my articles only had one tag, which made me a sad monkey. To remedy this, I wrote a small loop to find all the tags of a Typo article and set them up for the same article in Mephisto. Now, since the id’s on articles and tags are not kept constant in the conversion scripts, this was a bit tricky. Luckily, I never have duplicate permalinks (I guess that means I’m creative…).
First, you have to enable the Typo converter in the console. I did this by adding these 2 lines to the bottom of vendor/plugins/mephisto_converters/init.rb:
require "converters/base"
require "converters/typo"
Then, it’s simply a case of the following:
./script/console
# Remove All Mephisto Taggings as to not make dupes
Tagging.find(:all).each{|t|t.destroy}
# Loop through every Typo article
# Find the associated Mephisto article
# Loop through all the Typo Tags
# Append each tag to the Mephisto tag array
Typo::Article.find(:all).each do |ta|
a = Article.find_by_permalink(ta.permalink)
ta.tags(true).collect{|b|b.name}.each do |tag|
a.tags(true) << Tag.find_by_name(tag)
end
end
Don’t forget to remove the requires you put into init.rb above. Once you do that, you should have a nicely running Typo -> Mephisto conversion. Congratulations!

Blog Posts