Motorcycle Adventures and Free Software

Weblog: Archive

2008-09-01 - 2008-09-30

MidCOM 3 and context injectors

Posted on 2008-09-02 14:50:16 UTC in 41° 3.108 N 29° 1.578 E 6km N of Istanbul, TR to . 0 comments.

Context-aware life coaching ad
I know, according to roadmap we all should be now focusing in hammering out bugs in Midgard 8.09, or as we call it, "Ragnaroek" instead of working on MidCOM 3. But Tero had a specific problem he needed to solve, and I wanted to ensure it was done right. And so I ended up adding support for context injectors into MidCOM 3.

What about contexts anyway?

Context in MidCOM is an object that contains all useful information related to the request at hand: arguments, URL, templating information. And the plan is to make it much more.

Context is the main way for controllers to find out about their environment, and for the templating system to decide which views to run and how. As we want to make the new MidCOM lean and efficient, we did not want to stick everything possible into the context. But in order to solve problems developers will need more stuff there. And so the idea of context injectors was born.

Context injectors are a new API components can use to add or modify information in the current context. The injectors will be run in two places:

  • Process injectors will be called before dispatcher loads the component and calls the controller
  • Template injectors will be called after controller has finished and before a template is collected and displayed

There are many things you can do there. Some immediate use cases are:

  • Geopositioning injector could add user's current location to the context so that a controller can fetch nearby data
  • Theming injector could switch the template entry point (in old Midgard term's the ROOT element) according to user's wishes
  • Mobile optimization injector could also switch the template entry point if user is accessing the site with an iPhone or OpenMoko


Using context injectors

The way this works is relatively simple. To create an injector, you create a component and create an injector class to it. Depending which injector you want to provide, you either implement a inject_process or inject_template public method there. The method will have full access to the current context (in $_MIDCOM->context) and can add or change things there. The just declare that you have the class in the component's manifest by adding a key process_injector or template_injector with value being the class name.

MidCOM will take care of loading the component in question in the right time, and of calling the injector method. This will all happen automatically once the component is installed.

If your controller or template uses context information that is not part of the default context data, then make sure to first check that the data is available via an isset(). This way your component will be able to work around missing context information if applicable to your scenario, or throw an error.

Written outside in the Platonik waterpipe cafe in Beşiktaş, Istanbul, while vine leaves above keep the air cool enough for working. The picture is from the Freds House blog.

Sponsored links

Microsoft Certification Exams save money using, phone card

Freedom Fry on GNU's 25th anniversary

Posted on 2008-09-07 16:57:34 UTC in 60° 10.512 N 24° 55.152 E Helsinki, FI to . 0 comments.

The Free Software Foundation's GNU project turned 25 last week, and the English humorist Stephen Fry made a video to commemorate it:

Stephen Fry on 25 years of Free Software

Benjamin Mako Hill posted some thoughts on how the first generation of free software developers has grown:

Certainly, GNU has matured and accomplished wonderful things in last quarter-century. More importantly perhaps, it's produced wonderful progeny. It has spawned hundreds of thousands of free software projects, thousands of free or nearly-free operating systems, and an unbelievably vibrant global free and open source software community. Beyond the software realm, the free culture movement, most free licensing projects, and much of the access to knowledge movement can trace a connection back to GNU. We are living, and building, a new generation of the free software movement.

As computers are becoming more and more ubiquitous, and affect more and more every aspect of our lives, software freedom becomes a strong necessity. I personally have been involved with free software since late 90s. It gives me the operating system for our servers, our programming language, and our toolkit. It also gives me an amazing community to work and share ideas with. It is hard to imagine working in a world without them.

To support free software, write some code, use a free operating system, join the Fellowship, and celebrate the Software Freedom Day on September 20th!

Ragnaroek is coming

Posted on 2008-09-08 20:15:06 UTC in 60° 10.512 N 24° 55.152 E Helsinki, FI to . 0 comments.

With beta2 out today, the new Midgard 8.09, or "Ragnaroek LTS" is finally coming. PHP4 has been dropped, many optimizations made, and now that Prototype has been dropped in favor of jQuery, I think we will finally be able to live with it as the Long Term Support release.

But before Ragnaroek is stable a lot of testing has to happen, as should polishing here and there. Piotras is fixing the site wizard, and I've been adding more information about the installed components.

Unlike eZComponents which are just libraries, components in Midgard are the building blocks of a website. Each of them is its own PHP application that the MidCOM MVC framework runs when a folder associated with that component is accessed. They all supply their own templates, localizations, and load whatever libraries needed.

Currently we have some 120 components in the MidCOM repository, and most of them have releases on the PEAR channel. The components range from simple things like a news listing to very specific applications like event registration or invoice processing.

One way to make components more visual was to add icons for them. MidCOM has had support for component icons for a while now, but they haven't really been used anywhere. So I made them used more widely:

Icons clarify component selection when creating a new folder:

MidCOM icons in component selector

Icons visualize how many components a developer has contributed to:

MidCOM icons in Ragnaroek credits screen

...and icons also make the localization tool more visual:

MidCOM icons in the Babel translation tool

Finding good icons for many of the components is quite difficult. We're working with Kalle Persson from the Tango project to create new ones as needed.

Where will desktop applications and web services meet?

Posted on 2008-09-09 21:38:56 UTC in 60° 10.512 N 24° 55.152 E Helsinki, FI to . 0 comments.

Midgard follows Ubuntu's synchronized release schedule, and releases packages for that platform, but otherwise we have little to do with the distribution. Still, I found the following in Mark Shuttleworth's Jaunty Jackalope announcement interesting:

Another goal is the the blurring of web services and desktop applications. "Is it a deer? Is it a bunny? Or is it a weblication - a desktop application that seamlessly integrates the web!" This hare has legs - and horns - and we'll be exploring it in much more detail for Jaunty.

This echos quite well with our plans to take Midgard much further than just the web. As Everaldo often reminds me, Midgard may soon become very interesting to developers of desktop and mobile applications. What we provide to them is:

And on top of all this, Midgard comes with a pretty efficient MVC framework for PHP. This means that the desktop applications can be coupled with a nice social web service, all built using same storage and replication mechanisms. Replicated, peer-to-peer applications could be a free software answer to the risk of cloud taking control of your data.

Meme time: picture right now

Posted on 2008-09-20 05:10:14 UTC in 35° 9.534 N 129° 3.840 E 7km NE of Pusan, KR to . 0 comments.

As seen on Planet GNOME:

Bergie in Saha Dojang

  1. Take a picture of yourself right now.
  2. Don’t change your clothes, don’t fix your hair…just take a picture.
  3. Post that picture with NO editing.
  4. Post these instructions with your picture.

My picture was taken with Photo Booth in the Saha Haedong Kumdo dojang in Busan, Korea after a bamboo cutting seminar. I'm here for the 2008 Haedong Kumdo Performance, not for any dan tests like Dave suggested ;-)

Spontaneous adventures: some autumn geohashing

Posted on 2008-09-27 19:26:46 UTC in 60° 10.512 N 24° 55.152 E Helsinki, FI to . 0 comments.

Land Geohash
Geohashing, as introduced by the awesome web comic xkcd, is an spontaneous adventure generator. The geohashing algorithm uses the current date and the day's Dow Jones Industrial Average to generate a new location for each region in the world. Geohashers then use various means to reach that location in search for fun and adventure.

As out there was beautiful autumn weather, and I needed to go somewhere to air my thoughts, I decided to hunt down today's geohash of the Helsinki region. To do so, I fired up the Geohashing iPhone application, and let it count me the coordinates. As it happens, the spot was in the end of a gravel forest road between Renko and Hämeenlinna.

iPhone calculates 108km to the hash

Calculating the route with iPhone's map software to be 108km, I put on some warmer clothes and jumped on my bike, heading leisurely north on smaller side roads. I had a lunch stop at Roosa, and then made my way to the destination.

Royal Enfield - the ultimate geohashing machine

The moose hunting season has just started and some gunshots could be heard in the woods. This worried me a bit, especially as the road's sign had some bullet holes, but the locals I passed on the gravel roads seemed friendly enough.

Bergie: a proud new geohasher

While Google Maps didn't show it, the spot was actually easier to reach, as it was just some ten meters from a small gravel road. I took the necessary picture proof, had a chocolate bar, and then headed back.

This was my first geohash. Definitely a fun way to experience your surroundings spiced up with some randomness!

Back