Michal Čihař - Blog Archives for Coding

Můj první modul pro Drupal

Jakmile jsem se rozhodl používat Drupal pro české stránky o phpMyAdminovi , bylo mi jasné, že si časem nevystačím s tím co už pro něj někdo napsal, ale budu muset vytvořit něco sám. Naštěstí dokumentace k Drupalu je celkem dobrá (rozhodně patří k tomu lepšímu co se mezi open source vyskytuje), tak vytvoření jednoduchého modulu nebylo až tak složité.

Chtěl jsem na phpMyAdmin.cz začít používat některé ze služeb měřící návštěvnost. Místo upravování šablon mi jako lepší řešení přišlo napsat si modul, který udělá co potřebuju a nebudu muset zasahovat do originálních šablon (a tím se vyhnu problémům při aktualizaci). Vzal jsem existující modul pro Google analytics, protože mi připadal podobný, ale nakonec toho z něj moc nezůstalo :-). Asi po hodině už jsem měl verzi, která fungovala celkem dobře a tak jsem si říkal, že by nebylo od věci to někde zveřejnit.

Jako logické místo se jeví Drupal.org a i tento postup je tam vzorně zdokumentován. Žádost o CVS přístup byla vyřízena během pár dnů, a já už mohl commitovat svůj první kód do jejich repository. K mému překvapení commity někdo sleduje, protože asi hodinu po prvním commitu už mi přišla reakce od někoho, že přesně takový modul potřeboval :-). Tak jsem jenom dokončil vyčištění a další den vyšla první verze modulu Český audit .

My first Drupal module

As I use Drupal for Czech phpMyAdmin pages, it was only a matter of time till I will have (or want) to add some functionality. My first Drupal module is quite trivial, but anyway I already got positive feedback on it just after committing to Drupal CVS :-). Today I finished little cleanup which my initial version required and I decided to make a first release out of it.

And what I'm still talking about? It's a module for adding measuring code for various web auditing systems used in Czechia. I didn't wanted to hack this somehow into templates and module which will provide block with those looks as best solution to me. You can get it on Drupal pages.

When to release 1.0?

This is not about any particular project, but more a generic thought. When should be something considered to be stable enough to be released as 1.0? Over ages I started several projects which are in different quality right now and this is maybe not completely related to version they use.

Let's take one of older ones - Wammu. It was started long time ago, it really does not get any major code changes for several years and I still don't want to make 1.0 release there. The reason is that I think that many things could be done better there. However there are quite lot of users which use it and they probably consider it stable enough :-). But they will have to live with 0.x versions as I do not plan 1.0 at all for now even if it maybe deserves it :-).

Different case is Ukolovnik. It does not have tons of features, but it's enough for me and it will be 1.0 soon. I have features to add, but I don't thing that RPC interface has to be in 1.0, it can be just thing added later.

Toshiba ACPI keys, HAL and friends

Long time ago I used FnFX to handle events from ACPI keys on my Toshiba notebook. However when reinstalling notebook because of disk crash, I thought there must be a cleaner way to handle these and I found patch for acpid which added handling of these special events.

However I really didn't like patching acpid on every update and there didn't seem to be chance to merge it upstream, so I started to look for better solution. After another amount of googling, I found that HAL already has some support for Toshiba hotkeys. Unfortunately it is now disabled in Debian because most key did not emit anything using HAL.

Okay, let's fix the HAL, maybe it will get later enabled. Converting FnFX keymap to C code was quite easy and I made a patch for HAL to add support for all keys. Hopefully it get merged soon and I can then file bug on Debian package to reenable Toshiba support in HAL.

Meanwhile I'd like to find some generic way of configuring what happens on these events. For now I hacked simple Python script which listens to DBUS events and invokes appropriate commands for keys, but I hope that some such tool already exists and I just missed it. If you know something, please let me know at michal@cihar.com.

Ukolovnik 0.9

New version of simple todo manager called Ukolovnik has been just released. Version 0.9 comes with following changes:

  • Fixed double SQL escaping in some cases.
  • New Swedish translation.

Nice to see PyICQ-t back alive

I just noticed, that Python Jabber transports have been migrated this weekend to Google Code and first people started to contribute. I especially like the fact, that first contributors are Czech guys and they're fixing encoding problems :-).

Let's hope that this activity will also help to improve Debian package which is not really in good state, but I promised not to hijack it till the end of year ;-) (so for now I temporarily hack it in my repository).

PS: I know ICQ is evil, but I don't have enough power to force all my contacts to start using Jabber.

Time to move from Nanoblogger?

After more than year and half of blogging with Nanoblogger, I'm still more and more thinking about trying something else. With almost 500 entries I currently have, generating blog takes more and more time. Otherwise there is not anything I'd miss, but something with comments might be also better.

I didn't yet find time to investigate currently available blog engines, but from what I remember in past, it was hard to choose something. What is thing which many engines fail to fulfill is ability to use text editor instead of writing text in browser. The other thing I'd like to see is to have more than category (or tag) per post. Maybe ikiwiki would be good candidate for this...

However what to do with old content? Should it be migrated to new system? I doubt it will be able to keep old URLs what is something I'd like...

Photo uploader 0.5

Good news everyone, new version of Photo uploader has been just released. If you don't know this tool yet, it is helper to upload photos (or images) over net. It was created when I became too lazy to upload hundreds of photos to digilab, but generally it can support any service which allows you uploading of whatever using HTML forms.

News in this release:

  • Added generic helper for ILikePhoto service.
  • Added some error checking.
  • Fixed handling of wrong parameters passed (non files).

Too lazy to manually upload to PPA

As I wrote before, I tried to use Ubuntu Personal Package Archive for distributing up to date Gammu, python-gammu and Wammu packages. For first time I failed because I expected it to behave more like OpenSUSE build service than like Debian archives, but I was wrong, so I have to upload different version to each Ubuntu suite.

Well that sounds like a work which should be automated. So I hacked a little shell script, which takes current version from unstable, updates changelog and injects it into my PPA. The hacky script is called deb2ppa. It requires dput to be configured for ppa same way as I have it and maybe has some other tricky dependencies which I do not realize right now.

Anyway you can now use current Wammu/Gammu versions even on older Ubuntu releases if you wish :-). (Well you have to wait till it is rebuild, but I hope it will not take much time.)

Lets automate the work

Fixing bugs in code and committing it to VCS usually also means that you need to interact somehow with BTS you use to let it know that the bug has been fixed. This is manual work which could be done by some clever commit scripts, right? All what is needed is just spend some time to set it up.

Most of my development currently goes to Gammu/Wammu which uses own Mantis bug tracker. It is already a bit prepared for integration with VCS, but I never found their documentation sufficient. Fortunately somebody wrote tutorial on integrating Mantis and Subversion, which made it quite easy to set up. All what was needed was to put little commit hook into SVN.

Now the logical step was to make it also for Debian packages. A bit of Googling revealed discussion on debian-devel. Unfortunately no example for SVN, but ripping out needed things from Manoj's script for Arch was quite easy and I made my own commit hook. While looking at this, I also found wonderful tool called debcommit, which commits changes to Debian package using changelog entries as commit message. I still wonder how many useful tools are hidden to me.

The only thing I don't know is why Google didn't show me yesterday svnlog, which seems to have support for Debian BTS out of the box. Maybe I just entered slightly different keywords than today when trying to find the mentioned thread on debian-devel.