<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Blog of Max Horvath</title>
    <link rel="alternate" type="text/html" href="http://www.maxhorvath.com/" />
    <link rel="self" type="application/atom+xml" href="http://www.maxhorvath.com/atom.xml" />
    <id>tag:www.maxhorvath.com,2008-03-19://1</id>
    <updated>2008-10-31T17:52:50Z</updated>
    <subtitle>For more quality in software products ...</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type Open Source 4.1</generator>

<entry>
    <title>Gotcha&apos;s when running Movable Type on FastCGI</title>
    <link rel="alternate" type="text/html" href="http://www.maxhorvath.com/2008/08/gotchas-when-running-movable-type-on-fastcgi.html" />
    <id>tag:www.maxhorvath.com,2008://1.18</id>

    <published>2008-08-29T14:46:01Z</published>
    <updated>2008-10-31T17:52:50Z</updated>

    <summary>Movable Type is a large application with a lot of files. In a CGI context that application is loaded into memory every single time, and there is no ability to leverage a cache across a session or multiple requests. When using FastCGI, the application is loaded into memory so that it doesn&apos;t have to be reparsed and interpreted every single request. This dramatically increases performance. Unfortuantly some scripts of Movable Type are not compatible with FastCGI. A few of those scripts are i.e. mt-check.cgi or mt-xmlrpc.cgi (which is needed for XmlRPC transactions with your blog).</summary>
    <author>
        <name>Max Horvath</name>
        <uri>http://www.maxhorvath.com</uri>
    </author>
    
        <category term="Apache" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Movable Type" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="apache" label="Apache" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="fastcgi" label="FastCGI" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="movabletype" label="Movable Type" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.maxhorvath.com/">
        <![CDATA[<p>
<a href="http://www.movabletype.org/" onClick="javascript: pageTracker._trackPageview ('/outgoing/movabletype.org');">Movable Type</a> is a large application with a lot of files. In a CGI context that application is loaded into memory every single time, and there is no ability to leverage a cache across a session or multiple requests.
</p>

<p>
When using <a href="http://www.fastcgi.com/" onClick="javascript: pageTracker._trackPageview ('/outgoing/fastcgi.com');">FastCGI</a>, the application is loaded into memory so that it doesn't have to be reparsed and interpreted every single request. This dramatically increases performance.
</p>

<p>
Unfortuantly some scripts of Movable Type are not compatible with FastCGI. A few of those scripts are i.e. mt-check.cgi or mt-xmlrpc.cgi (which is needed for XmlRPC transactions with your blog).
</p>

<h3><strong><big>How to get the FastCGI-incompatible files up and running</big></strong></h3>

<p>
In the end the solution is quite easy. You just need to tell Apache to not run some of Movable Type's scripts through FastCGI, but through classic CGI.
</p>

<p>
In your Apache configuration you need to activate add the following lines to the directives handling the Movable Type direcory:
</p>

<textarea name="code" class="php:nogutter:nocontrols" cols="60" rows="10">
<FilesMatch "^mt-(check|config|testbg|upgrade|xmlrpc)\.cgi$">
    SetHandler cgi-script
</FilesMatch>
</textarea>

<p>
That's all you need to do - Movable Type will run flawlessly.
</p>

<h3><strong><big>What if you don't have direct access to your Apache configuration?</big></strong></h3>

<p>
To ease up things you can also just create a template for a .htaccess file. It may also be much easier to use and maintainable this way. Just make sure you don't rebuild it each time you rebuild your site.
</p>]]>
        
    </content>
</entry>

<entry>
    <title>Smart URLs for your Movable Type blog</title>
    <link rel="alternate" type="text/html" href="http://www.maxhorvath.com/2008/03/smart-urls-for-your-movable-type-blog.html" />
    <id>tag:www.maxhorvath.com,2008://1.8</id>

    <published>2008-03-19T14:47:32Z</published>
    <updated>2008-10-31T18:07:00Z</updated>

    <summary>Moveable Type is great when it comes to being lightweight on your webserver, because it creates most of your blog&apos;s functions as static content. It also creates a really nice URL structure, which comes in very nice when you are an URL fetishist like me. But you certainly have been bugged by the fact that MovableType&apos;s installation URL kicks in when you need to use MovableType&apos;s search function. Today I&apos;d like to show you, how to configure your Moveable Type installation and your Apache Webserver to display smart URLs everywhere (expect the administration interface).</summary>
    <author>
        <name>Max Horvath</name>
        <uri>http://www.maxhorvath.com</uri>
    </author>
    
        <category term="Apache" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Movable Type" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="apache" label="Apache" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="mod_rewrite" label="mod_rewrite" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="movabletype" label="Movable Type" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.maxhorvath.com/">
        <![CDATA[<p>
Moveable Type is great when it comes to being lightweight on your webserver, because it creates most of your blog's functions as static content. It also creates a really nice URL structure, which comes in very nice when you are an URL fetishist like me. But you certainly have been bugged by the fact that MovableType's installation URL kicks in when you need to use MovableType's search function. Today I'd like to show you, how to configure your Moveable Type installation and your <a href="http://httpd.apache.org/" onClick="javascript: pageTracker._trackPageview ('/outgoing/apache.org');">Apache Webserver</a> to display smart URLs everywhere (expect the administration interface).
</p>

<p>
My blog makes use of what follows. Although I don't offer Movable Type's internal search function, but Google webpage search, my blog does have a tags page, with all tags being linked to related posts. This feature typically uses MovableType's search engine.
</p>

<h3><strong><big>Editing your templates</big></strong></h3>

<p>
First you should edit three related widget templates: <em>Search</em>, <em>Syndication</em> and <em>Tag Cloud</em>. You will find those templates by visiting the web administration interface of your Moveable Type installation. Click <em>Design</em> &gt; <em>Templates</em>, then in the right sidebar on <em>Widgets</em>.
</p>

<p>
Using the <em>Tag Cloud</em> template, I will show you exemplary, how to edit all three templates:
</p>

<textarea name="code" class="html:nogutter:nocontrols" cols="60" rows="10">
<div class="widget-tag-cloud widget">
    <h3 class="widget-header">Tag Cloud</h3>
    <div class="widget-content">
        <ul class="widget-list">
            <mt:Tags limit="20" sort_by="rank">
                <li class="rank-<$mt:TagRank max="10"$>
                           widget-list-item">
                    <a href="<$MTBlogURL$>tag/<$MTTagName$>">
                        <$mt:TagName$>
                    </a>
                </li>
            </mt:Tags>
        </ul>
    </div>
</div>
</textarea>

<p>
The important part to look for is <code>&lt;a href="&lt;$MTBlogURL$&gt;tag/&lt;$MTTagName$&gt;"&gt;&lt;$mt:TagName$&gt;&lt;/a&gt;</code>. What I'm doing is to point the tags to an URL like: <code>http://www.example.com/tag/SampleTag</code>.
</p>

<h3><strong><big>Telling Apache to understand the changes</big></strong></h3>

<p>
Now we need our webserver to understand, what those new links mean. In your Apache configuration you need to activate <a href="http://httpd.apache.org/docs/2.2/rewrite/" onClick="javascript: pageTracker._trackPageview ('/outgoing/apache.org');">mod_rewrite</a>. Next we need to provide a rewrite rule, so the Apache knows where to redirect a call to the URL to.
</p>

<p>
In our particular case it would look like this:
</p>

<textarea name="code" class="php:nogutter:nocontrols" cols="60" rows="10">
RewriteEngine on
RewriteRule ^tag/(.*)$ /cgi-bin/mt-search.cgi?tag=$1&blog_id=$$$&IncludeBlogs=$$$
</textarea>

<p>
Remember to replace both <code><strong>$$$</strong></code> with your current IDs (just click a tag and see, which IDs are being used).
</p>

<h3><strong><big>Where to repeat those changes</big></strong></h3>

<p>
To also apply those changes to <em>Search </em>and <em>Syndication</em>, you need to modify the templates <em>Search</em> and <em>Syndication</em> accordingly.
</p>

<p>
In Apache you should add those two lines:
</p>

<textarea name="code" class="php:nogutter:nocontrols" cols="60" rows="10">
RewriteRule ^/search/(.*)$ /cgi-bin/mt-search.cgi?q=$1&blog_id=$$$&IncludeBlogs=$$$
RewriteRule ^/feed/(.*)$ /cgi-bin/mt-search.cgi?tag=$1&Template=feed&blog_id=$$$&IncludeBlogs=$$$
</textarea>

<p>
Again, remember to replace both <code><strong>$$$</strong></code> with your current IDs (should be the same ones you have had to use for the tags rewrite rule).
</p>

<h3><strong><big>What if you don't have direct access to your Apache configuration?</big></strong></h3>

<p>
To ease up things you can also just create a template for a .htaccess file. It may also be much easier to use and maintainable this way. Just make sure you don't rebuild it each time you rebuild your site.
</p>]]>
        
    </content>
</entry>

<entry>
    <title>Syntax Highlighting for your Movable Type blog</title>
    <link rel="alternate" type="text/html" href="http://www.maxhorvath.com/2008/03/syntax-highlighting-for-your-movable-type-blog.html" />
    <id>tag:www.maxhorvath.com,2008://1.7</id>

    <published>2008-03-16T13:55:00Z</published>
    <updated>2008-10-31T18:14:21Z</updated>

    <summary>I write about tech stuff and include code snippets. I was hoping to highlight syntax in my posts. While looking for a solution for my Movable Type 4.1 blog, I came across a few alternatives, of which I&apos;d like to give you a review.</summary>
    <author>
        <name>Max Horvath</name>
        <uri>http://www.maxhorvath.com</uri>
    </author>
    
        <category term="Movable Type" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="html" label="HTML" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="javascript" label="JavaScript" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="movabletype" label="Movable Type" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="syntaxhighlighting" label="Syntax Highlighting" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="syntaxhighlighter" label="SyntaxHighlighter" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="yuicompressor" label="YUI Compressor" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.maxhorvath.com/">
        <![CDATA[<p>
I write about tech stuff and include code snippets. I was hoping to highlight syntax in my posts. While looking for a solution for my Movable Type 4.1 blog, I came across a few alternatives, of which I'd like to give you a review.
</p>

<h3><strong><big>The Moveable Type candidates</big></strong></h3>

<p>
First I was checking out the official <a href="http://plugins.movabletype.org/" onClick="javascript: pageTracker._trackPageview ('/outgoing/movabletype.org');">Movable Type Plugin Directory</a>. Two solutions were listed:  <a href="http://plugins.movabletype.org/codebeautifier/" onClick="javascript: pageTracker._trackPageview ('/outgoing/movabletype.org');">CodeBeautifier</a> and  <a href="http://plugins.movabletype.org/mt-colorer/" onClick="javascript: pageTracker._trackPageview ('/outgoing/movabletype.org');">MT Colorer</a>.
</p>

<p>
CodeBeautifier was the first solution for Movable Type (supporting version 2.6 to 3.3), based on its own highlighting backed. MT Colorer supports version 3.2 and 3.3 of Movable Type and uses the <a href="http://colorer.sf.net/" onClick="javascript: pageTracker._trackPageview ('/outgoing/colorer.sourceforge.net');">colorer library</a>. But both plugins do not support the current version 4 line of Movable Type. So both were a no go.
</p>

<p>
Using Google, I found another plugin called <a href="http://www.andre-simon.de/dokuwiki/doku.php?id=en:movabletype" onClick="javascript: pageTracker._trackPageview ('/outgoing/andre-simon.de');">MT Highlight</a>. It uses the <a href="http://www.andre-simon.de/dokuwiki/doku.php" onClick="javascript: pageTracker._trackPageview ('/outgoing/andre-simon.de');">highlight library</a> by the author of MT Highlight. The highlight library seems to be quite outdated, so does the plugin, too. It also supports the version 3 line of Movable Type.
</p>

<h3><strong><big>The JavaScript candidates</big></strong></h3>

<p>
The next approach was to use a JavaScript based source code highlighter, which highlightes any code snippets on the fly while a browser is displaying a blog entry.
</p>

<p>
I found two solutions using Google: <a href="http://dean.edwards.name/weblog/2005/06/star-light/" onClick="javascript: pageTracker._trackPageview ('/outgoing/dean.edwards.name');">star-light</a> and <a href="http://code.google.com/p/syntaxhighlighter/" onClick="javascript: pageTracker._trackPageview ('/outgoing/google.com');">SyntaxHighlighter</a>.
</p>

<p>
star-light seemed to be too unflexible to me, supporting just a few languages. SyntaxHighlighter on the other hand is even used for syntax highlighting at the <a href="http://developer.yahoo.com/yui/" onClick="javascript: pageTracker._trackPageview ('/outgoing/yahoo.com');">Yahoo Developer Network</a>.
</p>

<p>
Too cut a long story short, I chose SyntaxHighlighter. Now I'd like to show you, how to integrate the JavaScript library very easily.
</p>

<h3><strong><big>How to install the syntax highlighter</big></strong></h3>

<p>
First <a href="http://code.google.com/p/syntaxhighlighter/downloads/list" onClick="javascript: pageTracker._trackPageview ('/outgoing/google.com');">download SyntaxHighlighter</a>. Upload all files to your <em>mt-static</em> folder on your server.
</p>

<p>
Next open your Movable Type web administration interface and open up the templates section. Choose the <em>Template Modules</em> filter. Editing the <em>Header</em> template, you should add the following lines right after <code>&lt;$mt:var name="html_head"$&gt;</code>:
</p>

<textarea name="code" class="html:nogutter:nocontrols" cols="60" rows="10">
<link type="text/css" rel="stylesheet"
      href="/mt-static/Styles/SyntaxHighlighter.css" />
</textarea>

<p>
After saving the template you should be editing the <em>Footer</em> template and add the following lines right before the <code>&lt;body&gt;</code> tag:
</p>

<textarea name="code" class="html:nogutter:nocontrols" cols="60" rows="10">
<script language="javascript"
        src="/static/highlight/shCore.js"></script>
<script language="javascript"
        src="/mt-static/Scripts/shBrushPhp.js"></script>
<script language="javascript">
    dp.SyntaxHighlighter.ClipboardSwf =
        '/mt-static/Scripts/clipboard.swf';
    dp.SyntaxHighlighter.HighlightAll('code');
</script>
</textarea>

<p>
Regarding the <code>&lt;script language="javascript" src="/mt-static/Scripts/shBrushPhp.js"&gt;&lt;/script&gt;</code> section you need to decide, which languages you want SyntaxHighlighter to display.
</p>

<p>
To even optimize performance, I'd suggest to combine all of SyntaxHighlighter's JavaScript files via <a href="http://developer.yahoo.com/yui/compressor/" onClick="javascript: pageTracker._trackPageview ('/outgoing/yahoo.com');">YUI Compressor</a>, a JavaScript Minimizer.
</p>

<h3><strong><big>How to use the syntax highlighter in your posts</big></strong></h3>

<p>
To display a code snippet all you need to do while writing a post is to surround the snippet with:
</p>

<textarea name="code" class="html:nogutter:nocontrols" cols="60" rows="10">
<textarea name="code" class="html" cols="60" rows="10">
    ... Post your code ...
&lt;/textarea&gt;
</textarea>

<p>
For more options using SyntaxHighlighter, see the <a href="http://code.google.com/p/syntaxhighlighter/wiki/Languages" onClick="javascript: pageTracker._trackPageview ('/outgoing/google.com');">supported languages documentation</a> and the <a href="http://code.google.com/p/syntaxhighlighter/wiki/Configuration" onClick="javascript: pageTracker._trackPageview ('/outgoing/google.com');">configuration options documentation</a>.
</p>]]>
        
    </content>
</entry>

</feed> 