[% BLOCK makeLinkWrapped %]
  <li [% IF curUri == uri %]class="active"[% END %]>
    <div class="title"><a href="[% uri %]">[% title %]</a></div>
    [% content %]
  </li>
[% END %]


[% BLOCK menuItem %]
  <li [% IF "${root}${curUri}" == uri %]class="active"[% END %]>
    <a href="[% uri %]">[% title %]</a>
  </li>
[% END %]

[% BLOCK makeLink -%]
[% INCLUDE makeLinkWrapped content="" -%]
[% END %]

[% BLOCK makeSubMenu %]
  [% extra = collapsed ? "collapsed" : "" %]
  <div id="left-title">[% title %]</div>
  <ul id="left-menu">
      [% content %]
  </ul>
[% END %]

[% IF project || admin %]

<div id="left-bar">  

  [% IF project %]
    [% WRAPPER makeSubMenu title="Project" collapsed=(jobset || job)  %]
      [% INCLUDE menuItem uri = c.uri_for(c.controller('Project').action_for('view'), [project.name]) title = "Overview" %]
      [% INCLUDE menuItem uri = c.uri_for(c.controller('Project').action_for('releases'), [project.name]) title = "Releases" %]
      [% INCLUDE menuItem uri = c.uri_for(c.controller('Project').action_for('all'), [project.name]) title = "All builds" %]
      [% INCLUDE menuItem uri = c.uri_for(c.controller('Project').action_for('jobstatus'), [project.name]) title = "Job status" %]
      [% INCLUDE menuItem uri = c.uri_for(c.controller('Project').action_for('errors'), [project.name]) title = "Errors" %]
    [% END %]
  [% END %]
  

  [% IF jobset %]
    [% WRAPPER makeSubMenu title="Jobset" collapsed=job %]
      [% INCLUDE makeLink
        uri = c.uri_for(c.controller('Jobset').action_for('index'), [project.name, jobset.name])
        title = "Overview" %]
      [% INCLUDE makeLink
        uri = c.uri_for(c.controller('Jobset').action_for('all'), [project.name, jobset.name])
        title = "All builds" %]
      [% INCLUDE makeLink
        uri = c.uri_for(c.controller('Jobset').action_for('jobstatus'), [project.name, jobset.name])
        title = "Job status" %]
      [% INCLUDE makeLink
        uri = c.uri_for(c.controller('Jobset').action_for('errors'), [project.name, jobset.name])
        title = "Errors" %]
    [% END %]
  [% END %]
  

  [% IF job %]
    [% WRAPPER makeSubMenu title="Job" %]
      [% INCLUDE makeLink
        uri = c.uri_for(c.controller('Job').action_for('overview'), [project.name, jobset.name, job.name])
        title = "Overview" %]
      [% INCLUDE makeLink
        uri = c.uri_for(c.controller('Job').action_for('all'), [project.name, jobset.name, job.name])
        title = "All builds" %]
      [% INCLUDE makeLink
        uri = c.uri_for(c.controller('Job').action_for('jobstatus'), [project.name, jobset.name, job.name])
        title = "Job status" %]
      [% INCLUDE makeLink
        uri = c.uri_for(c.controller('Job').action_for('errors'), [project.name, jobset.name, job.name])
        title = "Errors" %]
    [% END %]
  [% END %]

  [% IF admin %]
    [% WRAPPER makeSubMenu title="Admin" %]
      [% INCLUDE makeLink
        uri = c.uri_for(c.controller('Admin').action_for('machines'))
        title = "Machines" %]
      [% INCLUDE makeLink
        uri = c.uri_for(c.controller('Admin').action_for('managenews'))
        title = "News" %]
      [% INCLUDE makeLink
        uri = c.uri_for(c.controller('Admin').action_for('users'))
        title = "Users" %]
    [% END %]
  [% END %]
  
</div>
[% END %]


