OpenGamma Releases RouteMap.js, JavaScript URL-Mapping Library

11 April 2011 By Kirk Wylie In Open Source

Today we've started releasing some more of the components (like the FudgeMsg project which was our first release) that we've used to build up the OpenGamma Platform before its full, Open Source, release. The next of these is RouteMap.js, a URL mapping library for both client-side and server-side JavaScript programming.

In the words of Afshin Darian, one of our employees and one of the initial authors of RouteMap:

We needed a way to map URL fragments (window.location.hash values) to JavaScript functions without buying into a complete MVC framework. Our application uses our own light-weight module framework to load the functionality of different parts of the UI. The UI itself is fairly stateless, almost all state information (except authentication) is encapsulated within the URL. Because of this, we wanted the URL patterns to be fairly sophisticated, with both named and unnamed parameter swapping and wildcard values.

We realized that we wouldn't have access to the HTML5 History API in all the browsers we support, so we wanted our library to be agnostic about where these URLs actually came from. For the time being, we bind onhashchange events to the router, but at some later date, we can bind HTML5 history methods without touching the underlying code.

Since our application is a single-page app and we don't need it to be indexed by search engines, we do not use the hashbang convention, but we recognized that others would, so our library allows for an arbitrary prefix to be configured into the routing rules.

Since the functionality of the library is limited in its scope, it's not tied to being used exclusively within the browser. It can also be used in a server-side context like node.js as a very bare-bones web app framework.

The OpenGamma Platform requires a significant number of technologies be developed, from our Analytics library (with mathematical primitives and pricing libraries for a number of asset classes) through to our Excel Integration Module (which can actually be used to expose any arbitrary Java code to Excel worksheets, not just OpenGamma-developed technology), not to mention our full calculation engine in the middle. I'm glad we can start releasing components in the lowest level reasonable and as early as possible.

If you're working with modern JavaScript-heavy web applications Fork it on GitHub today!

About the Author

Kirk Wylie

Kirk is OpenGamma's Chief Executive Officer and Chief Technology Officer.

Prior to co-founding OpenGamma, Kirk was the head of software architecture for the Front Office Technology division of KBC Financial Products. While there, Kirk was responsible for developing integration and interoperability solutions across KBCFP's disparate lines of business (including Convertible Bonds, Equity Derivatives, Structured Credit and Fund Derivatives).

Read more

Follow us on Twitter