March 2008 Archives

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 Apache Webserver to display smart URLs everywhere (expect the administration interface).

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.

Editing your templates

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

Using the Tag Cloud template, I will show you exemplary, how to edit all three templates:

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

Telling Apache to understand the changes

Now we need our webserver to understand, what those new links mean. In your Apache configuration you need to activate mod_rewrite. Next we need to provide a rewrite rule, so the Apache knows where to redirect a call to the URL to.

In our particular case it would look like this:

Remember to replace both $$$ with your current IDs (just click a tag and see, which IDs are being used).

Where to repeat those changes

To also apply those changes to Search and Syndication, you need to modify the templates Search and Syndication accordingly.

In Apache you should add those two lines:

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

What if you don't have direct access to your Apache configuration?

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.

Yes! Sebastian Bergmann did it: just one day after requesting a colorful output of PHPUnit's command line interface, he committed a patch to PHPUnit's trunk, which should be released with the next release. Thank you!

feature-request-completed.jpg

Update

Sebastian seems to like "the feature", too - he just blogged about it. Horray!

phpunit-output-success.jpg phpunit-output-failure.jpg

A few days ago I came across Josh Carters blog. I saw a very nice suggestion have your unit tests output the results in green or red bar - depending if the tests passed or failed.

unit_test_green_red_bar.jpg

I really like the idea and will be requesting the inclusion of ansi coloring to Sebastian Bergmann - I'd really like to see this feature being added to PHPUnit.

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.

The Moveable Type candidates

First I was checking out the official Movable Type Plugin Directory. Two solutions were listed: CodeBeautifier and MT Colorer.

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 colorer library. But both plugins do not support the current version 4 line of Movable Type. So both were a no go.

Using Google, I found another plugin called MT Highlight. It uses the highlight library 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.

The JavaScript candidates

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.

I found two solutions using Google: star-light and SyntaxHighlighter.

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 Yahoo Developer Network.

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

How to install the syntax highlighter

First download SyntaxHighlighter. Upload all files to your mt-static folder on your server.

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

After saving the template you should be editing the Footer template and add the following lines right before the <body> tag:

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

To even optimize performance, I'd suggest to combine all of SyntaxHighlighter's JavaScript files via YUI Compressor, a JavaScript Minimizer.

How to use the syntax highlighter in your posts

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

For more options using SyntaxHighlighter, see the supported languages documentation and the configuration options documentation.

While it's absolutly correct that direct access to private properties is strictly forbidden in PHP, it's quite disturbing that even reflection cannot do it when you're writing Unit Tests. Sometimes you just want to test whether a private property contains the correct data. With the normal visibility rules you cannot access those from your Unit Tests.

Luckily, as I just read at Tobias Schlitt's Blog, Derick Rethans committed a patch to the PHP 5.3 repository, which allows you to get things done quite easily. You still need to explicitly state that you want to access the value of a protected/private property through reflection by the new method setAccessible(). It's a good thing to avoid people doing stupid things accidentally, but you finally get the access to it.

PHP 5.3 you'll be able to access private properties like this:

But until we'll see a stable PHP 5.3, there we're many working "hacks", which worked for some versions of PHP 5.x - the most current one would be this:

This should get you up and running for PHP 5.2.5 ("older hacks" won't work).

So how could you use it?

I hope those lines of code will help you until PHP 5.3 arrives, as it helps our developers.

Update

As Sebastian points out in his comment to this post, PHPUnit has had support for testing private and protected attributes for quite a while. It can be used via:

I should be reading the documentation much more thoroughly next time (even though I must admit, that none of our developers has known this method, too).

Motivation for Testing

| | Comments (0) | TrackBacks (0)

Sometimes it seems writing tests with a good coverage is easier to be done than keeping your folks doing them, actually.

Truth be told, during the last four months our software developers had a rather easy life when it came to writing tests. We've been engineering our two platforms (with about 12 billion PI in January 2008) studiVZ and schuelerVZ from the ground up. We've also created our third platform, meinVZ.

With really tight timelines it's extremely hard to do extensive testing. Nonetheless we've been really succesful in (re)launching the platforms. But now it's time time to remind our engineers that we will extent our testing efforts again.

testing-motivation-01.jpgA few days ago Sebstian Bergmann contacted me via ICQ about a now very popular photo over at Mayflower GmbH.

After I saw this photo, I thought: "what a perfect match"! It's just a funny way to motivate our engineers even more. Just a few moments later the first copy was printed and attached to our QA walls.

Just a few days later Sebastian released another two motivating pictures that made their way onto our walls.

Sebastian: Thank you very much!

testing-motivation-02.jpgtesting-motivation-03.jpg

Welcome to my new blog

| | Comments (0) | TrackBacks (0)

Hey everybody, I've just decided to restart my blog.

I plan to post about topics regarding Quality Assurance, especially focusing on PHP web applications.

Due to my position as Quality Manager at studiVZ Ltd., Europes largest social network, I hope to give you valuable insights of our testing strategies which you can use in one of your current or next projects.

Recent Activity

Tuesday

  • I tweeted, "Just published a new blog post:Problems when upgrading to Ubuntu 8.10 - Kernel panic - Unable to mount root fs http://tinyurl.com/5fbb6j"
  • I tweeted, "Dear american voters - don't be silly to vote for McCain ... thanks!"
  • I tweeted, "@janl Just ping me, I've Hot leads ..."

More ...

Conferences

Conferences I presented at:

Programming Blogs - BlogCatalog Blog Directory
Creative Commons License
This weblog is licensed under a Creative Commons License. blogoscoop

About this Archive

This page is an archive of entries from March 2008 listed from newest to oldest.

August 2008 is the next archive.

Find recent content on the main index or look in the archives to find all content.