Roxen Application Launcher 1.0.3

This is not the latest version of Roxen Application Launcher. You’ll find the latest version at the download page.


In this release of Roxen Application Launcher (come again?) for Linux I’ve gotten rid of a few dependencies, namely: gconf, libgee and libgnome. The reason I dumped gconf and libgnome was to make it easier to install in KDE. I’ve verified it installs in KDE, although I noticed the translation doesn’t work and the Roxen SVG logo doesn’t show up in the window top border.

Roxen Application Launcher in KDE

Libgee is a collections API written in Vala and since I used a newer version than what is available in most package managers, and I’m not sure all Linux distros provide libgee, I decided to dump it and implement the same functionality with the generic collection classes in Vala. And since the collections used in RAL is quite simple that worked out just fine.

I have also tried to implement bundled download, which is only used in Roxen Editorial Portal. Since I don’t have access to such an installation I haven’t been able to verify it works as expected. I re-implemented the same behavior as in the launcher written in Pike by the Roxen guys.

Oh, and if you already have an installation of my RAL your previously downloaded files and settings will not be available to the new install. Since I dumped gconf I now store the settings in a plain text file and I have put the RAL application directory in ~/.conf/roxenlauncher since ~/.conf is where you should put application specific data according to In previous versions of RAL I stored application data in ~/.roxenlauncher so if you want your previously downloaded files copy ~/.roxenlauncher/files to ~/.conf/roxenlauncher/files.

The sources is available at Github.

Roxen Appliction Launcher 1.0.3 00:43, Fri 24 September 2010 :: 384.8 kB

Pike project – module stub creator


I recently began learning how to create Pike modules in C. The Pike module C API seems great and once you’ve sorted things out the modules are easy to build and install. Non the less, when creating a C module from scratch there’s a couple of files you need and some configurations of those before everything is set for go. And here comes “pike-project” into play.

Pike-project is a simple GTK program (works as command line tool also) written in Pike it self. The program will create the basics for a running Pike C module, or a plain installable Pike module. Then it’s just starting programming.

The program is available at my Github repository.

BTW! At the moment it only works on Linux I suppose.

Pingly – a Roxen module for automatic Twingly pinging

Twingly is a blog search engine that focus on indexing the “blogosphere” rather than being a generic search engine. Twingly has a ping service that let you ping Twingly when you have new content on your blog so that Twingly can head over there and index the new content asap.

Since Roxen CMS have event hooks this module listens for newly published files and when found automatically notifies Twingly about it.

The only thing needed is to set up a config file in the SiteBuilder’s workarea so that this module knows under which paths newly published content should notify Twingly and with which arguments. But all this is documented in the module.

One note! If you run a replicated environment install this module on one of the frontend servers, not the backend. If installed on a backend Twingly might head over to your site before the new content has been replicated.

The Pingly Roxen module 11:32, Fri 09 July 2010 :: 15.4 kB

JavaScript minifier filter module for Roxen

Nowadays web sites and web applications tend to be more and more JavaScript driven which results in humongous JavaScript files. It’s not uncommon to have several 100 of bytes of JavaScript on a site. Of course web browsers cache stuff like JavaScript so that it only is requested from the server once. But judging from the visitor logs at work most people only visit our site once a month or so which means that cache will expire and all those scripts has to be requested upon the first visit.

Now, there are several ways to compact JavaScripts: Packer, YUI Compressor, Shrink Safe, jsmin and many more. Some of these just remove redundant white space and comments, some obfuscates the code and shortens variable and function names and what not. Many of these scripts and programs are very fine but they require you to manually minify your scripts, and that’s just a hassle!

But since we use Roxen CMS at work things get much easier if you write your own Roxen filter module which automatically minifies JavaScripts on the fly, given they meet certain criteria. And so I did!

I ported the original jsmin code written in C to Pike. Then it was just a matter of creating a simple filter module for Roxen. And then it was all done.

You can use two criteria to determine if a script should be minified or not:

  1. Path glob: In the module settings you can specify any number of directory globs or full paths. If a requested JavaScript either is in a directory matching a glob or is a direct match it will be minified.
  2. Query string variable: In the module settings you can define a variable name that if exists as a query string variable in the request the JavaScript will be minified. So:

    <script type="text/javascript" src="myscript.js?jsmin=1"></script>

    will minify myscript.js

And that’s that!

jsmin Roxen filter module 13:34, Mon 28 June 2010 :: 6.1 kB

GTK hacking in Pike

Tweepi, the Twitter client written in PikeI’ve found out that it’s great fun programming desktop applications and of course it gets more fun the more you learn. Now I’m doing a Twitter client in Pike – my favorite programming language – mostly because I wanted to try out GTK programming in Pike. I use the good Twitter client Pino – written in Vala – and I have borrowed the concept and layout from it. I call it Tweepi.

The only major difference between Tweepi and Pino – besides they are written in different programming languages – is that Pino uses WebKit to draw the status messages where I am using good old GTK widgets – and I guess there are no bindings to WebKit in Pike for that matter ;)

One thing I noticed is that the Gtk.Label widget sucks at displaying longer texts that line wraps. Since the label widget handles some HTML formatting I thought that it would be suitable for displaying the status messages, but the text looked like shit, line wrapping where ever it felt like. And the Gtk.TextView widget doesn’t handle formatting per default so I Googled some and found that you can format text in Gtk.TextViews by inserting Gtk.TextTags at desired positions. And since Pike has the most awesome HTML parser It was just a matter of sending the text through the parser and create some Gtk.TextTags and inserting them at the same position in the text buffer. (Well, actually it wasn’t that easy but with some help from a Python class I found on the web it was doable).

So now I have a start at something that is a Gtk.HtmlTextView – actually it inherits Gtk.TextView but has an additional method insert_html_text(string text) – and albeit quite simple at the moment it’s worth continuing on. The code for the HtmlTextView is available at my Github repository.

In general I find the GTK implementation in Pike to be pretty OK, but there exist some verbose, and tedious, stuff like getting the text from a Gtk.TextView:

2 lines of Pike
  1. Gtk.TextBuffer b = my_textview>get_buffer();
  2. string text = b>get_text(b>get_start_iter(), b>get_end_iter(), 0);

which in Vala and C# would be done like:

5 lines of Vala
  1. // Vala
  2. string text = my_textview.get_buffer().text;
  3. // C#
  4. string text = myTextView.Buffer.Text;

Anyway! Tweepi isn’t done yet but I think I have solved the most tedious stuff and it’s starting to become useful. It’ll probably be done in a couple of weeks and I will of course release the sources then.

Gravatar module for Roxen

Although I’m working on some social web related Pike modules where a Gravatar module is included I needed a Gravatar module right now at work so I hacked up a standalone Gravatar Roxen module.

This is how it works

12 lines of RoXen Macro Language
  1. <ul>
  2. <emit source=“sql” host=“mydb”
  3. query=“SELECT name, email, `date`, body FROM my_comments”
  4. >
  5. <li>
  6. <gravatar-img email=“&;” rating=“pg” size=“32”
  7. default-image=“/path/to/icon.png”
  8. /> &; wrote at <date iso-time=“&;” />
  9. <wash-html paragraphify=“”>&_.body;</wash-html>
  10. </li>
  11. </emit>
  12. </ul>

Download the Gravatar Roxen module 14:20, Wed 09 December 2009 :: 7 kB

Merging associative arrays in PHP

It’s nice when serendipity is your friend! I was porting my Bitly class from Pike to PHP – I know there’s probably a hundred PHP classes already out there, but mine is better coded ;) – and noted by accident that I had used some Pike syntax in my PHP class but it was working anyway. So what was I doing? In Pike there’s separate data type for associative arrays called mapping. In Pike, in general, when merging two objects you just join them with a + sign. Thus merging two mappings you do like

9 lines of Pike
  1. mapping m1 = ([ “key1” : “Value 1”, “key2” : “Value 2” ]);
  2. mapping m2 = ([ “key3” : “Value 3” ]);
  3. write(“My mapping: %O\n”, m1 + m2);
  4. //> My mapping: ([ /* 3 elements */
  5. //> “key1”: “Value 1”,
  6. //> “key2”: “Value 2”,
  7. //> “key3”: “Value 3”
  8. //> ])

And I noted that I had done the same thing in PHP and the result was perfectly valid:

11 lines of PHP
  1. $a1 = array(“key1” => “Value 1”, “key2” => “Value 2”);
  2. $a2 = array(“key3” => “Value 3”);
  3. echo “My mapping: “;
  4. print_r($a1 + $a2);
  5. //> My mapping: Array
  6. //> (
  7. //> [key1] => Value 1
  8. //> [key2] => Value 2
  9. //> [key3] => Value 3
  10. //> )

This method doesn’t work on flat array though so there you’ll still have to use array_merge(), but pretty nice anyway.

And oh, the PHP Bitly class will be part of the new PLib release once done!

Roxen User Conference (cont’d)

So the Roxen User Conference has come to an end. It’s always nice to meet with people who speak the same “language” (the language of the geeks perhaps), to share experiences and solutions. And of course it was nice to see the Roxen Editorial Portal in action. That’s a pretty cool piece of web based software. It was also nice to get a preview of Roxen CMS 5.0. It will have a few new features that will be nice and perhaps the greatest thing is that it will incorporate Pike 7.8 (which in it self hasn’t been released yet).

Anyway! For me it was a great experience talking to other Roxen customers and share some ideas and views. Oh, and one more nice thing: during the conference Roxen released a community site – I hope it will be a great resource for us Roxen customers and users.

Bug fix for Syntaxer.pmod

It didn’t take too long to notice that I had f–ked up the HTMLParser class a little bit. It was how entities was handled that didn’t really worked as expected – entities in tag attributes was duplicated and inserted in the tag content – but the good side of it is that I learned about the HTMLParser method of the HTMLParser Pike class. I only want to match entities in the data section – i.e. tag content – and not in attributes and the HTMLParser method tells you, as the name implies, in what context the entity is found. So my entity callback function now looks like:

6 lines of Pike
  1. //! Entity callback
  2. protected void ecb(Parser.HTML p, string _data)
  3. {
  4. if (p>context() == “data”)
  5. line += colorize(entify(_data), “entity”);
  6. }

which hopefully will be completely bug free now. So one down 854 to go ;)

Codify RXML tag and Syntaxer.pmod 17:31, Sat 17 October 2009 :: 183.9 kB