<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:i18n="http://genshi.edgewall.org/i18n"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude">
  <xi:include href="layout.html" />
  <head>
    <title>${title or _('Error')}</title>
    <link rel="stylesheet" type="text/css" href="${chrome.htdocs_location}css/code.css"/>
    <script py:if="frames" type="text/javascript">/*<![CDATA[*/
      jQuery(document).ready(function($) {
        $("#traceback a").click(function() {
          $("div", this.parentNode).slideToggle("fast");
          return false;
        });
        $("#plugins td.file a").click(function() {
          var idx = parseInt($(this).attr("href").substring(6));
          $("#traceback li").eq(idx).children("div").slideDown("fast");
          return true;
        });
        $("#tbtoggle").click(function() {
          if (this.value.indexOf("interactive") < 0) {
            this.value = "Switch to interactive view";
            $("#traceback ul").fadeOut("fast", function() {
              $("#traceback pre").fadeIn("fast");
            });
          } else {
            this.value = "Switch to plain text view";
            $("#traceback pre").fadeOut("fast", function() {
              $("#traceback ul").fadeIn("fast");
            });
          }
          return false;
        });
       /* Only activate interactive view if Javascript is enabled */
       $("#traceback ul").show();
       $("#traceback pre").hide();
       $("#tbtoggle").parent().show();

       $("#systeminfo").append("<tr><th>jQuery</th><td>" + $().jquery + "</td></tr>");
       $("#systeminfo").before("<p>User Agent: <tt>" + navigator.userAgent + "</tt></p>");
      });
    /*]]>*/</script>
    <script type="text/javascript">/*<![CDATA[*/
      jQuery(document).ready(function($) {
        $("form.newticket textarea").each(function() {
          $(this).text($(this).text()
                         .replace(/#USER_AGENT#/m, navigator.userAgent)
                         .replace(/#JQUERY#/m, $().jquery));
        });
      });
    /*]]>*/</script>
  </head>

  <py:def function="create_ticket(url=None)">
    <input type="hidden" name="reporter" value="${get_reporter_id(req)}" />
    <input py:if="url == trac.homepage.strip('/')" type="hidden" name="version"
           value="${'dev' in trac.version and trac.version.split('-', 1)[0] or trac.version}" />
    <input type="hidden" name="$arg" value="$value" py:for="arg, value in tracker_args.iteritems()" />
    <input type="hidden" name="summary" value="$message" />
    <textarea name="description" rows="3" cols="10">
${url and description_en or description}</textarea>
    <span class="inlinebuttons">
      <input type="submit" name="create" value="${_('Create')}" />
    </span>
  </py:def>

  <body>
    <div id="content" class="error">
      <py:choose test="type">
        <py:when test="'TracError'">
          <h1>$title</h1>
          <py:choose test="">
            <p py:when="istext(message)" class="message">$message</p>
            <py:otherwise>$message</py:otherwise>
          </py:choose>
        </py:when>
        <py:when test="'internal'">
          <h1>Oops&hellip;</h1>
          <div class="message">
            <strong>Trac detected an internal error:</strong>
            <pre>$message</pre>
          </div>
          <py:choose>
            <py:when test="not defined('trac_error_rendering') and 'TRAC_ADMIN' not in perm">
              <p i18n:msg="">There was an internal error in Trac.
                It is recommended that you notify your local
                <a py:strip="not project.admin" href="mailto:${project.admin}">
                    Trac administrator</a> with the information needed to
                reproduce the issue.
              </p>
              <form py:if="project.admin_href"
                    class="newticket" method="get" action="${project.admin_href.newticket()}#">
                <p i18n:msg="create">To that end, you could ${create_ticket()} a ticket.</p>
              </form>
              <p>The action that triggered the error was:</p>
              <pre>${req.method}: ${req.path_info}</pre>
            </py:when>
            <py:otherwise py:choose="">
              <p py:when="not project.admin_href or project.admin_trac_url == '.'">
                This is probably a local installation issue.
              </p>
              <form py:otherwise=""
                    class="newticket" method="get" action="${project.admin_href.newticket()}#">
                <p>This is probably a local installation issue.
                  <i18n:msg params="create">
                    You should ${create_ticket()} a ticket at the admin Trac to report
                    the issue.
                  </i18n:msg>
                </p>
              </form>
              <h2>Found a bug in Trac?</h2>
              <p>If you think this should work and you can reproduce the problem,
              you should consider creating a bug report.</p>
              <p py:if="faulty_plugins" py:choose="len(faulty_plugins)">
                <py:when test="1"><i18n:msg params="name">
                  Note that the ${faulty_plugins[0].name} plugin seems to be involved.
                </i18n:msg></py:when>
                <py:otherwise>
                  Note that the following plugins seem to be involved:
                  ${', '.join([p.name for p in faulty_plugins])}
                </py:otherwise>
                <strong>Please report this issue to the plugin maintainer.</strong>
              </p>
              <p i18n:msg="" py:with="q = quote_plus(message[:80])">Before you do that, though, please first try
                <strong><a href="${tracker}/search?ticket=yes&amp;noquickjump=1&amp;q=$q">searching</a>
                for similar issues</strong>, as it is quite likely that this problem
                has been reported before. For questions about installation
                and configuration of Trac or its plugins, please try the
                <a href="${trac.homepage}wiki/MailingList">mailing list</a>
                instead of creating a ticket.
              </p>
              <form class="newticket" method="get" action="${tracker}/newticket">
                <p i18n:msg="create">Otherwise, please ${create_ticket(tracker)} a new bug report
                describing the problem and explain how to reproduce it.</p>
              </form>
              <py:if test="traceback">
                <h2>Python Traceback</h2>
                <div id="traceback">
                  Most recent call last:
                  <ul py:if="frames" style="display: none">
                    <li class="frame" py:for="idx, frame in enumerate(frames)">
                      <a href="#frame${idx}" id="frame${idx}"><span i18n:msg="file, line, function" py:strip="">
                        <span class="file">File "${frame.filename}",
                        line <b>${frame.lineno + 1}</b>, in</span>
                        <var>${frame.function}</var></span>
                      </a>
                      <div py:if="frame.line" class="source" style="display: none">
                        <h3>Code fragment:</h3>
                        <table class="code">
                          <thead><tr><th class="lineno">Line</th><th class="content"></th></tr></thead>
                          <tbody>
                            <tr py:for="i, line in enumerate(frame.lines_before + [frame.line] + frame.lines_after)"
                                class="${i == len(frame.lines_before) and 'current' or None}">
                              <th>${frame.lineno + i + 1 - len(frame.lines_before)}</th><td>${line or u'\xa0'}</td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div py:if="frame.vars" class="vars" style="display: none">
                        <h3>Local variables:</h3>
                        <table class="listing">
                          <thead><tr><th>Name</th><th>Value</th></tr></thead>
                          <tbody>
                            <tr py:for="idx, (name, value) in enumerate(sorted(frame.vars.items()))"
                                class="${idx % 2 and 'odd' or None}">
                              <th scope="row"><var>$name</var></th>
                              <td><code>${shorten_line(repr(value))}</code></td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                    </li>
                  </ul>
                  <pre><py:for each="frame in frames"><i18n:msg params="file, line, function">File "${frame.filename}", line ${frame.lineno + 1}, in ${frame.function}</i18n:msg><py:if test="frame.line">
  ${frame.line.lstrip()}
</py:if></py:for><py:if test="not frames">${traceback}</py:if></pre>
                  <p style="display: none"><input type="button" id="tbtoggle" value="${_('Switch to plain text view')}" /></p>
                </div>
              </py:if>
              <h2>System Information:</h2>
              <table class="listing" id="systeminfo">
                <tr py:for="name, value in get_systeminfo()">
                  <th>$name</th>
                  <td>$value</td>
                </tr>
              </table>
              <py:if test="plugins">
                <h2>Enabled Plugins:</h2>
                <table class="listing" id="plugins">
                  <tr py:for="plugin in plugins">
                    <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>
                </table>
              </py:if>
            </py:otherwise>
          </py:choose>
        </py:when>
      </py:choose>
      <p>
        <a href="${href.wiki('TracGuide')}">TracGuide</a> &mdash; The Trac User and Administration Guide
      </p>
    </div>
  </body>
</html>
