[% WRAPPER page.tt %]

[% FOREACH modules %]
  [% IF name == module %]
  <h2>Module: [% name %]</h2>

  <table id="summary">
    <tr>
      <th>Log file:</th>
      <td class="logfile"><a href="logs/[% logFilename %]">[% logFilename %]</a></td>
    </tr>
    <tr>
      <th>Build time:</th>
      <td>[% buildTime %]</td>
    </tr>
    [% IF status == 'success' or status == 'cache' %]
      [% IF links.size > 0 %]
      [% FOREACH links %]
      <tr>
        <th>[%IF loop.index() == 0 %]Links[%END%]</th>
        <td><a href="[% href %]">[% label %]</a></td>
      </tr>
      [% END %]
      [% END %]

      [% IF artifacts.size > 0 %]
      [% FOREACH artifacts %]
      <tr>
        <th>[%IF loop.index() == 0 %]Artifacts[%END%]</th>
        <td><a href="artifacts/[% path %]">[% label %]</a></td>
      </tr>
      [% END %]
      [% END %]
    [% END %]
  </table>

  [% IF status == 'success' or status == 'cache' %]
    [% IF packages.size > 0 %]
      <h3>Packages</h3>

      <table id="packages">
        <thead>
          <tr>
            <th>Filename</th>
            <th>Size</th>
            <th>MD5 Sum</th>
          </tr>
        <tbody>
          [% FOREACH packages %]
            <tr class="[% IF loop.index() % 2 == 0 %]odd[%ELSE%]even[%END%]">
              <td class="filename"><a href="dist/[% filename %]">[% filename %]</a></td>
              <td class="size">[% prettysize %]</td>
              <td class="md5sum">[% md5sum %]</td>
            </tr>
          [% END %]
        </tbody>
      </table>
    [% ELSE %]
      <p>No packages were built/found for this module</p>
    [% END %]

  [% ELSE %]
    [% IF status == 'failed' %]
      <p class="failed">Build failed on this module</p>
    [% ELSIF status %] eq 'skipped')$
      <p class="skipped">Module skipped because dependency failed during build</p>
    [% ELSE %]
      <p>Module not built. Status: [% status %]</p>
    [% END %]
  [% END %]
  [% END %]
  [% END %]
[% END %]
