by admin on 2007-07-29 3 Comments
filed in Work with tags , ,

Just switched this site/blog from Typo to Mephisto, a process that's taken months to accomplish in spare moments of personal web productivity.

The conversion process didn't work so well at first. It took digging in to the Mephisto Converter code to make it work going from Typo 4.1.1 to Mephisto trunk.

Here's the code that made it WFM.

First patch, to avoid stupid migration failure:

1
2
3
4
5
6
7
8
9
10
11
Index: db/migrate/060_move_theme_path.rb
===================================================================
--- db/migrate/060_move_theme_path.rb   (revision 2936)
+++ db/migrate/060_move_theme_path.rb   (working copy)
@@ -23,5 +23,6 @@
       end
       FileUtils.rmdir new_path
     end
+  rescue
   end
 end

Then, copy Typo's categorizations table to a new table named articles_categories. (See what happens when you ignore Rails' database conventions?!)

Next, create the file vendor/plugins/mephisto_converters/lib/converters/typo/feedback.rb:

1
2
3
4
5
6
7
8
9
10
module Typo
  class Feedback < ActiveRecord::Base
    establish_connection configurations['typo']
    set_table_name 'feedback'
    belongs_to :text_filter, :class_name => 'Typo::TextFilter'
    def filter
      self.text_filter ? self.text_filter.name : nil
    end
  end
end

Two patches to switch over to use the new Feedback class:

1
2
3
4
5
6
7
8
9
10
11
Index: vendor/plugins/mephisto_converters/lib/converters/typo/comment.rb
===================================================================
--- vendor/plugins/mephisto_converters/lib/converters/typo/comment.rb   (revision 2936)
+++ vendor/plugins/mephisto_converters/lib/converters/typo/comment.rb   (working copy)
@@ -1,5 +1,5 @@
 module Typo
-  class Comment < Content
+  class Comment < Feedback
 #    belongs_to :article, :foreign_key => 'parentid', :class_name => 'Typo::Comment'
   end
 end
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Index: vendor/plugins/mephisto_converters/lib/converters/typo.rb
===================================================================
--- vendor/plugins/mephisto_converters/lib/converters/typo.rb   (revision 2936)
+++ vendor/plugins/mephisto_converters/lib/converters/typo.rb   (working copy)
@@ -1,6 +1,7 @@
 require 'converters/typo/content'
 require 'converters/typo/page'
 require 'converters/typo/article'
+require 'converters/typo/feedback'
 require 'converters/typo/comment'
 require 'converters/typo/category'
 require 'converters/typo/user'
@@ -107,4 +108,4 @@
     sec
   end
 
-end
\ No newline at end of file
+end

Finally, start her up:

1
2
%  rake db:bootstrap RAILS_ENV=production
%  script/runner --trace "Mephisto.convert_from :typo" -e production

3 Responses to “Conversion from Typo to Mephisto”

Flinn commented
2007-08-26 at 12:24 PM

Nice fix, your patch makes the conversion go smoothly.

One of the statements you made there is somewhat incorrect.

"Then, copy Typo's categorizations table to a new table named articles_categories. (See what happens when you ignore Rails' database conventions?!)"

The typo author correctly named the categorizations table because it is corresponds to a hasmany :through relationship, not a hasandbelongsto_many which the mephisto conversion plugin relies on. The reason it doesn't work isn't because either developers did anything wrong. The conversion is just out of date.

Mars commented
2007-08-28 at 11:22 AM

Flinn: I've updated the article to strike that aside. Cheers.

Marc commented
2008-04-12 at 05:37 AM

Awesome! Thanks :D

Leave a Reply

Markdown is in effect.



Everything is here.