scox.info - Random Thoughts

To content | To menu | To search

Tag - mephisto

Entries feed - Comments feed

Tuesday, June 10 2008

Migrating from Mephisto to Dotclear 2

It's been a while since my last post. Beside the fact that I was busy, the reason preventing me from posting is that the blogging engine I was using (Mephisto) was in a bad shape. It seemed unmaintaned, managed to consume all the server memory and didn't survive a rails upgrade.

That's why I've decided to migrate to Dotclear 2, which seems to be a nice and clean blogging engine. However, in the migration process, I didn't want to lose:

  • All my previsous posts (both published and pending)
  • All the comments
  • Associated metadata (categories, tags and so on)

Dotclear has a nice builtin plugin called Import/Export which let you save and restore backups of your blog. All I did was writing a Ruby script that generates a dump of the Mephisto database using ActiveRecord in the same format as Import/Export, ready to be imported. It is available here and works in the following way:

  • Place it under the script directory of your Mephisto rails root
  • Edit the first lines (set your Dotclear 2 login and blog id)
  • Run it and redirect the output to your favorite location:

ruby script/migrate_to_dc2.rb > public/dump.dc2

  • Retrieve the dump file (e.g. dump.dc2) and import it in the "Import/Export" area, under the Import a single blog section.

That's it, you're done. It should have imported all your blog posts (and preserved publish dates as well as many other attributes), comments, metadatas etc.

I also wanted to maintain backward URL compatibility with Mephisto. A couple of mod_rewrite rules did the trick:

# Mephisto URL compatiblity
RewriteEngine On
# Feeds
RewriteRule ^/feed/atom.xml /feed/atom [L,R=301]
RewriteRule ^/feed/all_comments.xml$ /feed/atom/comments [L,R=301]
# Posts
RewriteRule (^/200\d.*) /post$1 [QSA,L,R=301]

That's all. I hope it will be useful to anyone wishing to migrate to Dotclear 2, as the process of creating that script is quite annoying :)

Sunday, April 22 2007

Mephisto Obfuscation Plugin

Being tired of receiving tons of spam everyday, I wanted to hide my e-mail address in a more efficient way than the usual user at example dot com. I needed to obfuscate my address to spam crawlers while keeping it readable by human beings. I've created a simple Mephisto plugin to help me do so, called MephistoObfuscate.

Basically, this plugin encodes email addresses (or any text you'd like) into Base64 and lets the browser decode them using some JavaScript on the client side. That way, the address is protected from crawlers blindly scanning the HTML page but is still readable by JavaScript-enabled browsers.

Example

Using MephistoObfuscate is pretty straightforward, you can either use a Liquid filter on your templates (useful to show a contact address on the layout, just like the one on the right sidebar of this page):

{{ "user@example.com" | obfuscate }}
Or you can use a macro filter within your blog posts:

<filter:obfuscate>user@example.com</filter:obfuscate>


Both of these will be obfuscated into something like:

<span class="obfuscated">dXNlckBleGFtcGxlLmNvbQ==l</span>


Which is not something most if not all spam crawlers will understand. While loading the page the JavaScript code will restore the address back into a human readable fashion.

Installing

To install just run

script/plugin install svn://svn.sig11.org/mephisto_obfuscate


After this, add the javascript include statements into your layout:

{{ 'obfuscate' | javascript }}

That's it, you're done.