Typo patches

Tagged:

While deploying typo weblog system I had to make changes there to fix some problems and add features I needed.

While possibly I’ll send some of these patches to typo developers, most likely they’re a bit hacky to include in the main typo branch - but still, I think, useful as “quick hacks” for those who need it “right here and now”.

There are 3 different patches for typo 4.1.1:

Internationalization

As far as I understood, typo 4.2 release should handle i18n natively. However, meanwhile this patch provides UTF-8 support in “Live search”, permalinks generation and other places.

Typically, this is achieved just by substituting non UTF-8 compliant function “downcase” by “chars.downcase.to_s” expression, which handles UTF-8 encoded strings correctly. Also escape() JS call is replaced by encodeURIComponent() one.

Please note that in order to support UTF-8 correctly you will also need to adjust your database settings. Please see excellent RoR Unicode Strings HowTo on that subject.

Updated on 2007.10.08: regenerated patch to include the fix to views/articles/read.rhtml: before the fix “dc:description” field for RDF was generated as taking first 255 characters of article content, but this may break UTF8 encoded characters in-between - thus the code was changed to seek backwards until the first space instead.

Gravacacher support

This patch provides possibility to switch typo from using gravatar.com directly to use of Gravacacher to improve the speed of avatars loading.

Don’t forget to edit config/gravacacher.yaml!

To switch typo back on using gravatar.com directly just rename or remove config file.

Autofilling support

This patch allows you to avoid entering your name and e-mail each time when posting comments in the case you’re typo admin - when you login to typo admin interface your name and e-mail are stored as cookies in your browser, so that they can be autofilled.

You will need also to adjust your theme (or main typo HTML templates if your theme didn’t override them) by adding into your views/articles/_comment_box.rhtml the following section:

<script type="text/javascript">
  Event.observe(window, 'load',
    function() {
      if (getCookie('is_admin') == 'yes') {
        var username = getCookie('username');
        var email = getCookie('email');
        if (username) {
          document.getElementById('comment_author').value = username;
        }
        if (email) {
          document.getElementById('comment_email').value = email;
        }
      }
    }
  );
</script>
Syndicate content