<!--!  Copyright (C) 2014-2020 Edgewall Software

  This software is licensed as described in the file COPYING, which
  you should have received as part of this distribution. The terms
  are also available at https://trac.edgewall.org/wiki/TracLicense.

  This software consists of voluntary contributions made by many
  individuals. For the exact contribution history, see the revision
  history and logs, available at https://trac.edgewall.org/.

Display system information.

Arguments:
 - system_info: the output of `Environment.system_info`.
 - plugins: the output of `get_plugin_info`.
 - config: the output of `get_configinfo`.
-->

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:i18n="http://genshi.edgewall.org/i18n"
      xmlns:xi="http://www.w3.org/2001/XInclude"
      py:strip="">

  <div py:if="system_info or plugins or config" id="environmentinfo">
    <hr />

    <div py:if="system_info" id="systeminfo">
      <script>//<![CDATA[
        jQuery(function($) {
          $("#systeminfo table").before("<p>User Agent: <code>" + navigator.userAgent + "</code></p>")
                                .append("<tr><th>jQuery</th><td>" + $().jquery + "</td></tr>" +
                                        "<tr><th>jQuery UI</th><td>" + $.ui.version + "</td></tr>" +
                                        "<tr><th>jQuery Timepicker</th><td>" + $.timepicker.version + "</td></tr>");
        });
      //]]></script>

      <h2>System Information</h2>
      <table class="listing">
        <thead><tr><th>Package</th><th>Version</th></tr></thead>
        <tbody>
          <tr py:for="name, value in system_info">
            <th>$name</th>
            <td>$value</td>
          </tr>
        </tbody>
      </table>
    </div>

    <div py:if="plugins" id="plugins">
      <h2>Installed Plugins</h2>
      <table class="listing">
        <thead><tr><th>Name</th><th>Version</th><th>Location</th></tr></thead>
        <tbody>
          <tr py:for="plugin in plugins"
              class="${'disabled' if all(not component.enabled for module in plugin.modules.itervalues()
                                         for component in module.components.itervalues()) else None}">
            <th py:with="url = plugin.info.home_page or plugin.info.author_email and 'mailto:' + plugin.info.author_email">
              <a py:strip="not url" href="$url">$plugin.name</a>
            </th>
            <td>${plugin.version or _('N/A')}</td>
            <td class="file"><a py:strip="'frame_idx' not in plugin" href="#frame$plugin.frame_idx">$plugin.path</a></td>
          </tr>
        </tbody>
      </table>
    </div>

    <div py:if="interface" id="interface">
      <h2>Interface Customization</h2>
      <table class="listing">
        <tr>
          <th class="section">Site templates</th>
          <td class="file">${' '.join(interface['site-templates'])}</td>
        </tr>
        <tr>
          <th class="section">Shared templates</th>
          <td class="file">${' '.join(interface['shared-templates'])}</td>
        </tr>
        <tr>
          <th class="section">Site static resources</th>
          <td class="file">${' '.join(interface['site-htdocs'])}</td>
        </tr>
        <tr>
          <th class="section">Shared static resources</th>
          <td class="file">${' '.join(interface['shared-htdocs'])}</td>
        </tr>
      </table>
    </div>

    <div py:if="config" id="config">
      <h2>Configuration</h2>
      <table class="listing">
        <thead>
          <tr>
            <th class="section">Section</th>
            <th class="name">Name</th>
            <th class="value">Value</th>
          </tr>
        </thead>
        <tbody>
          <py:for each="section in config">
            <tr py:for="idx,option in enumerate(section.options)"
                class="${'modified' if option.modified else None}">
              <th py:if="idx == 0" class="section"
                  rowspan="${len(section.options)}">${section.name}</th>
              <td class="name">${option.name}</td>
              <td class="value">${option.value}</td>
            </tr>
          </py:for>
        </tbody>
      </table>
    </div>
  </div>

</html>
