Foxy Roxy

One of the first things I’ve come across whilst working at MarkLogic is the Roxy Framework. This was developed by a few of our guys to make building web applications in XQuery easier, and to introduce a more MVC style framework.

They decided to approach this by a convention over configuration paradigm. This means that particular URLs will invoke particular functions. So /analysis/search.html would invoke the analysis controller’s search function, which in turn would be displayed as a whole xhtml webpage. replacing .html with .json would give a json representation. Leaving html off would still render html as the default. Leaving an action of would invoke the analysis controller’s main method (and main.html view) instead. Pretty straightforward stuff.

They also included a few helper functions and libraries too. There’s a built in facet display and search performing library, with sensible basic defaults for search options to be passed to search:search, the ability to provide human readable facet names, and overwrite the default routes for your own purposes.

They also include the ability to specify more than one layout. The default can of course be set globally, but the layout and view can be overridden by the controller function as necessary.

It’s all very familiar to anyone like myself who has used Ruby on Rails in anger. There’s a few Rails things missing, but they’ll probably be added in the future. When a controller is created only a main function is created. Might be useful to create all CRUD methods like RoR does, and indeed a pre-defined search() method as an ML extra. Most of our demo apps are single controller, so that’s probably why it wasn’t included. It’s also pretty trivial to type in your own too.

Also not included is the ability to lock down URLs by role or user name. ML can run a web visitor as a default user you specify on the app server. This would have zero rights to see content. Having a login page and locked down routes would be cool. The login page form helper and hooks are there, but not the security controller for login/logout. I’ve rolled my own and will contribute this to the Roxy guys once I’ve tested it in anger.

I’m rapidly coming to love Roxy though. In the future the ability to plugin modules like RoR should make adding new functionality easier. Also means new innovations can be distributed alongside but separate from Roxy itself. Altogether a great experience to use though. Very quick to get up and running.

The main benefit of Roxy though isn’t in the MVC architecture or helper libraries – it’s in the deployment tool. Like RoR there is a command line tool and create command, as well as a deploy and bootstrap command. These can create you a MarkLogic app server, content and modules databases, and app specific user account. The ml deploy local modules command also deploys your code changes to the server, so you can immediately test them. No messing with WebDav at all. Great way to develop code.

All in all Roxy is a great framework. If you need a quick MarkLogic application, need to go beyond what appbuilder can provide, and know a bit of XQuery, it’s well worth getting to know Roxy.

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.