Tuesday 19 May 2009

New project 'svgmate'

svgmate is a web application which is able to produce PNG images from SVG documents.
The documents can either be uploaded or defined as a request parameter.

See the "full" documentation and examples in my wiki.

Friday 15 May 2009

Started my personal wiki

I started my personal wiki using confluence.
The wiki will contain news and information about my projects.

Have a look at www.banapple.de.

Thursday 5 February 2009

A firefox extension allowing to run operating system commands

CommandRun is a firefox extension which allows to run operating system commands from javascript.
At least it is tested with firefox 3.0.5 on Linux.

It allows javascript code like this:

CommandRun.run("/usr/bin/touch",["/tmp/commandruntest"]);

which will create the file /tmp/commandruntest or update its timestamp.

Allowed commands must be defined in the preferences. The preference "extensions.commandrun.allowedcommands" expects a JSON array containing the allowed commands, e.g.

["/usr/bin/touch","/usr/bin/ls"]

Other commands are rejected.

So why did I develop this extension at all?
For an intranet web application I searched for a possibility to raise the firefox window from within javascript. The web application is a GWT application, that means it is a javascript client running in a browser. The nature of the application is that it may idle for a long time until it gets an event pushed by a server. The user of the application may do other things while she is waiting for an event to arrive, she may even work with other applications, reading mails, etc. The focus of the web application may be lost, firefox may be hidden by other windows. When an event arrives firefox should immediately raise to the front such that the user can react on the event.
I did not find a simple javascript solution to raise firefox to the front. If anybody knows, please tell me.
wmctrl is a linux tool which allows to raise windows (and do other things to the window manager).
The next step is then to find a possibility to call wmctrl from within javascript. And there comes the CommandRun extension.
(puh, long speech)

The extension is based on code snippets from two other extensions:
callout contains code which adds an object to a document's window with which new operations can be called. In my extension's case the CommandRun object is added which allows to invoke 'run'.
TerminalRun allows to execute selected text in a terminal. It contains code to create an operating system process.

The source can be downloaded via anonymous svn from http://subversion.banapple.de/public/commandrun/.

Additionally I dared to publish the extension on addons.mozilla.org where it can be downloaded with better update support. The current version 0.2.0 is only a start. It is enough for my needs but other people might want the output of the command available in javascript.

Wednesday 5 November 2008

A maven2 plugin for Apache FOP

I googled for a maven2 plugin which uses Apache FOP for converting xml files into pdf files.

Since my search was not successful I made my own plugin.

Quick start:


  1. Download the source:
    $ svn co http://subversion.banapple.de/public/maven-fop-plugin

  2. Install the plugin:

    $ cd maven-fop-plugin
    $ mvn install

  3. Get some xml file and an xsl file which transforms your xml to fo. I suppose these files are now somewhere in your maven project.

  4. Configure your project to use the fop plugin:

    <plugins>
    ...
    <plugin>
    <groupId>de.banapple.mojo</groupId>
    <artifactId>maven-fop-plugin</artifactId>
    <version>1.0-SNAPSHOT</version>
    <configuration>
    <inputFiles>
    <basedir>src/main/xml</basedir>
    </inputFiles>
    <xslFile>src/main/xsl-fo/foobar-fo.xsl</xslFile>
    </configuration>
    </plugin>
    ...
    </plugins>


  5. Start maven:
    $ mvn de.banapple.mojo:maven-fop-plugin:1.0-SNAPSHOT:fop



You should now have some pdf files in the target folder.

The plugin is simple. I followed the plugin development guide.
Not documented in the development guide is the usage of the DirectoryScanner with which filesets can be defined as parameters.
The rest of the code is mostly taken from the Apache FOP documentation.

The plugin has minimal functionality and only allows to convert to pdf. Apache FOP allows a lot of other configuration which may be added in future versions of this plugin.

If you like it a comment here would be nice. If you are missing a feature please comment here, too, and I will fix it if I find the time.

The official documentation is now at www.banapple.de.

Wednesday 8 October 2008

twitterfeed feeds your twitter with entries from rss

This is just a test for twitterfeed.com.

If it works this entry should also appear in my twitter.


...some time later: it works, I got a tweet.

Monday 29 September 2008

Greasemonkey improves google search result navigation

I like using the keyboard and I therefore like the possibility to navigate through google's search result with the keyboard.

Google has an experimental feature which can be activated here. But I was not able to activate this feature when a search was started from my igoogle page.

Now I found another solution: Greasemonkey together with the Google Ctrl-Arrow user script.

I learned that "Greasemonkey is a Firefox extension that allows you to write scripts that alter the web pages you visit".

Greasemonkey does nothing by itself but uses user scripts. There is a big library of user scripts.

Greasemonkey seems to be a very useful extension.

Friday 26 September 2008

My second firefox extension

Once I had a development problem and googled for a solution.
I found a page were my problem was exactly described but the solution was hidden. It was only available for registered users. Registration was not free.

So I asked my boss to get an account for this service.
In the meanwhile a colleague of mine found another solution. He checked whether the page containing the solution was in the google cache and so it was. Probably google has an account which is used by the google crawler.

Searching for a firefox extension which load the google cache for a given page I found nothing working for firefox 3, so I started an extension myself.

The extension wizard completed most of the work. It defined an entry in the context menu and the only work left was to implement the functionality behind the context menu entry. After some searching on the mozilla developer page I found the necessary snippets. This is the resulting function:

onMenuItemCommand: function(e) {
/*
* get the recently used browser window
* http://developer.mozilla.org/en/Code_snippets/Tabbed_browser
*/
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
getService(Components.interfaces.nsIWindowMediator);
var recentWindow = wm.getMostRecentWindow("navigator:browser");
if (recentWindow) {
var googleCacheUrl = "http://google.com/search?q=cache:"
+recentWindow.content.document.location;
/* open the url in a new current tab */
gBrowser.selectedTab = gBrowser.addTab(googleCacheUrl);
}
}


That's all.

The source code is available via anonymous svn with

svn co http://subversion.banapple.de/public/getgooglecache/


The extension can be installed from www.banapple.de.

Meanwhile I found an old extension which seems to do the same. It only works for Firefox 1.5.