Add link to the user's home page

Notice: This plugin is unmaintained and available for adoption.


Ever wonder why Trac doesn't link to the user's home page from the first metanav "logged in as" item?

Of course you could do this sort of thing with Genshi, something I'm still trying to wrap my head around and, frankly, I'm not a big fan of these XML/XSLT-based templating languages.

Since Trac loads jQuery, I thought, why not let the browser do some of the work? You might think, since you are parsing the DOM and checking for certain attributes and values, won't your code break if Trac changes something in the future? While this concern certainly has some merit, it's essentially the same as a Python/Genshi approach by manipulating the page on the fly.

This hack has no repository or download link and offers only a code snippet. This goes in your site.html template and it does use Genshi template markup.

Javascript code implementation

<html xmlns=""
      xmlns:py="" py:strip="">
 <head py:match="head" py:attrs="select('@*')">
  <script type="text/javascript">
   jQuery(document).ready(function($) {
     $('#metanav li.first:contains("logged in as")').each(function() {
       var path = $('#mainnav li.first a').attr('href').split('/')[1];
       var user = $(this).text().split(' ').pop();
       var link = '<a href="/' + path + '/wiki/' + user + '">' + user + '</a>';
       $(this).html('logged in as ' + link);
       return false;

Bugs/Feature Requests

Existing bugs and feature requests for LoggedInScript are here.

If you have any issues, create a new ticket.


0 / 1

Recent Changes

5048 by dwclifton on 2008-12-22 22:11:12
New hack LoggedInScript, created by dwclifton


Author: dwclifton
Maintainer: none (needsadoption)
Contributors: John Resig

Last modified 8 months ago Last modified on Feb 17, 2017, 10:42:11 PM