<!--!  Copyright (C) 2006-2023 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/.
-->
<!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>
    <script py:if="frames" type="text/javascript">/*<![CDATA[*/
      jQuery(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();
      });
    /*]]>*/</script>
    <script>/*<![CDATA[*/
      jQuery(function($) {
        $("form.newticket textarea").each(function() {
          $(this).val($(this).val()
                             .replace(/#USER_AGENT#/m, navigator.userAgent)
                             .replace(/#JQUERY#/m, $().jquery)
                             .replace(/#JQUERYUI#/m, $.ui.version)
                             .replace(/#JQUERYTP#/m, $.timepicker.version));
        });
      });
    /*]]>*/</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="${trac.version.split('-', 1)[0] if 'dev' in trac.version else 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">
${description_en if url else 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="not find_element(message, tag='p') and
                        not find_element(message, tag='div')"
               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 <strong>${frame.lineno + 1}</strong>, 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="${'current' if i == len(frame.lines_before) else 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="${'odd' if idx % 2 else 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>
              <xi:include href="environment_info.html" py:with="system_info = env.system_info" />
            </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>
