<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Schadenfreude &#187; yaml</title>
	<atom:link href="http://www.ralree.com/tag/yaml/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ralree.com</link>
	<description>Malicious enjoyment derived from observing someone else's misfortune</description>
	<lastBuildDate>Sun, 28 Feb 2010 04:18:37 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How I converted Typo to Mephisto</title>
		<link>http://www.ralree.com/2007/02/22/how-i-converted-typo-to-mephisto/</link>
		<comments>http://www.ralree.com/2007/02/22/how-i-converted-typo-to-mephisto/#comments</comments>
		<pubDate>Thu, 22 Feb 2007 04:13:00 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[irb]]></category>
		<category><![CDATA[mephisto]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[site5]]></category>
		<category><![CDATA[typo]]></category>
		<category><![CDATA[yaml]]></category>

		<guid isPermaLink="false">http://www.ralree.info/2007/10/13/how-i-converted-typo-to-mephisto</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>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 <strong>./script/console</strong> hacker.  Also, though it took a while to actually get a response, I ended up getting direct help from technoweenie in <strong>#mephisto@irc.freenode.net</strong>, which was a big help.  So, here&#8217;s the situation:</p>
<p>My current host is <a href="http://www.site5.com/affiliates/idevaffiliate.php?id=1570">Site5</a>.  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:</p>
<pre><code>
svn co http://svn.techno-weenie.net/projects/mephisto/trunk mephisto
</code></pre>
<p>Then, I created <strong>config/database.yml</strong>.  Here&#8217;s a template you can use:</p>
<pre><code>
development:
  adapter: mysql
  database: mephisto
  username: meph
  password: &lt;new-pw&gt;
  host: localhost

production:
  adapter: mysql
  database: mephisto
  username: meph
  password: &lt;new-pw&gt;
  host: localhost

typo:
  adapter: mysql
  database: typo
  username: typo
  password: &lt;typo-pass&gt;
  host: localhost
</code></pre>
<p>Next, I installed tzinfo as a gem to my home directory, and froze it in the project root:</p>
<pre><code>
gem install tzinfo
cd mephisto
rake gems:freeze GEM=tzinfo
</code></pre>
<p>Finally, it&#8217;s time to fill the database with stuff:</p>
<pre><code>
rake db:bootstrap
</code></pre>
<p>Now that that&#8217;s done, for CGI and FastCGI to work, we need a <strong>.htaccess</strong> file in <strong>public</strong>:</p>
<pre><code>
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 "&lt;h2&gt;Application error&lt;/h2&gt;Rails application failed to start properly"
</code></pre>
<p>Notice I left it as <strong>dispatch.cgi</strong>.  It&#8217;s up to you, but while I was still converting I left it like this since it didn&#8217;t want to run with FastCGI.</p>
<p>Let&#8217;s make sure log and public can be read and, if need be, written to:</p>
<pre><code>
chmod -R 755 public log
</code></pre>
<p>And finally, the moment we&#8217;ve all be waiting for:</p>
<pre><code>
script/runner "Mephisto.convert_from :typo" -e production
</code></pre>
<p>This connects to the Typo database and runs a converter script in Mephisto&#8217;s <strong>vendor/plugins/</strong> directory.  It takes all the attributes Typo articles and users and comments had and converts them to Mephisto form.  Rockin&#8217;.</p>
<h2>Old Typo Woes</h2>
<p>I did this with Typo trunk <strong>v1246</strong> with migration level <strong>55.</strong>  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.</p>
<p>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:</p>
<pre><code>
./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
</code></pre>
<p>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.</p>
<p>Now here&#8217;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:</p>
<pre><code>
articles
 - id
articles_tags
 - article_id
 - tag_id
tags
 - id
 - name
</code></pre>
<p>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.  <strong>Don&#8217;t do that.</strong></p>
<p>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&#8217;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&#8217;m creative&#8230;).</p>
<p>First, you have to enable the Typo converter in the console.  I did this by adding these 2 lines to the bottom of <strong>vendor/plugins/mephisto_converters/init.rb</strong>:</p>
<pre><code>
require "converters/base"
require "converters/typo"
</code></pre>
<p>Then, it&#8217;s simply a case of the following:</p>
<pre><code>
./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) &lt;&lt; Tag.find_by_name(tag)
  end
end
</code></pre>
<p>Don&#8217;t forget to remove the <strong>requires</strong> you put into <strong>init.rb</strong> above.  Once you do that, you should have a nicely running Typo -> Mephisto conversion.  <strong><em>Congratulations!</strong></em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ralree.com/2007/02/22/how-i-converted-typo-to-mephisto/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.322 seconds -->
