Hacking the web.motd configuration for fun and profit

Angel Ezquerra Moreu angel.ezquerra at gmail.com
Fri Mar 9 00:43:11 CST 2012


At my work we use mercurial and we also use Jira as our issue tracker.
For a while now we\ve wanted to integrate both a little better. In
particular we wanted to add a link to the Jira server from the
mercurial web interface.

There were several approaches that we could take to do this. I guess
that the most conventional one would have been to create a new hgweb
template and add the link to the server in there. However I was not
particularly fond of that solution because I felt that it may be a bit
brittle. If we ever upgraded mercurial maybe we'd need to modify the
template again. So I wanted to find a simpler and hopefully more
robust solution.

What ended up doing is to "abuse" the web.motd configuration key of
the web interface. Basically that key lets you inject any html into
all your mercurial pages. Thus I simply added a link to our Jira and
to our review servers in there. This is quite simple and works well.

The only problem I had is that the motd is injected _at the end_ of
the pages that the mercurial servers generates (I guess that this may
depend on the template, but I think that all current builtin templates
place it at the bottom). Instead I wanted to place my links at the
top, were they are easier to find by our users.

My solution was to place the links inside a div html element, and
style the div with some CSS which includes "position:fixed; left:0px;
top:0px; width: 100%;".

This works like a charm so I thought that it may be interested to
some. This is a simplified version of our motd configuration key:

motd = Place your regular MOTD here, followed by the code that shows
the link bar at the top of the page
	<div style="position:fixed;left:0px;top:0px" width="100%">
	| <a href="/">Home</a>
	| <a href="http://jira">
	JIRA</a>
	| <a href="http://fisheye">
	FishEye & Crucible</a>
	| <a href="create_repo_form.html">
	Create new repository</a> |
	</div>

You can obviously improve this to show a nice CSS menu, etc (which is
what we did).

Although this works well, this _is_ a hack. I'd rather have a way to
directly inject some HTML at the top of the page. For example, one of
the consequences of the motd being injected at the end is that the
links do not appear until the whole web page is loaded, which for the
repository index page may take a while.

So I wonder if it would be ok to add a new configuration key to the
web section, called perhaps web.menu, which could be used to add a
"menu" section to the hgweb pages, and which could be used to better
integrate hgweb with other tools that you may have on your intranet.
It can also be used to add links to scripts to create new repos, etc
(which is what we did).

I think this would make it much easier to integrate hgweb with other tools.

What do you guys think?

Cheers,

Angel


More information about the Mercurial-devel mailing list