Source

bloodhound-trac / trac / templates / attachment.html

Full commit
<!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:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude"
      xmlns:i18n="http://genshi.edgewall.org/i18n"
      py:with="parent = attachments.parent if attachments else attachment.resource.parent">
  <xi:include href="layout.html" />
  <head>
    <title py:choose="mode">
      <py:when test="'new'">${name_of(parent)} &ndash; Attachment</py:when>
      <py:when test="'list'">${name_of(parent)} &ndash; Attachments</py:when>
      <py:otherwise><i18n:msg params="filename, parent">${attachment.filename} on ${name_of(parent)} &ndash; Attachment</i18n:msg></py:otherwise>
    </title>
    <py:if test="preview">
      <script type="text/javascript" src="${chrome.htdocs_location}js/folding.js"></script>
      <script type="text/javascript">
        jQuery(document).ready(function($) {
          $('#preview table.code').enableCollapsibleColumns($('#preview table.code thead th.content'));
        });
      </script>
    </py:if>
  </head>

  <body>
    <div py:choose="mode" id="content" class="attachment">
      <py:when test="'new'">
        <h1 i18n:msg="parent">Add Attachment to <a href="${url_of(parent)}">${name_of(parent)}</a></h1>
        <form id="attachment" method="post" enctype="multipart/form-data" action="">
          <div class="field">
            <label>File<py:if test="max_size >= 0">
              <i18n:msg params="value">(size limit ${pretty_size(max_size)})</i18n:msg></py:if>:<br />
              <input type="file" name="attachment" /></label>
          </div>
          <fieldset>
            <legend>Attachment Info</legend>
            <py:if test="authname == 'anonymous'">
              <div class="field">
                <label>Your email or username:<br />
                  <input type="text" name="author" size="30" value="${attachment.author or author}" />
                </label>
              </div>
              </py:if>
            <div class="field">
              <label>Description of the file (optional):<br />
                <input type="text" name="description" size="60" value="$attachment.description"/></label>
            </div>
            <br />
            <py:if test="authname and authname != 'anonymous'">
              <div class="options">
                <label><input type="checkbox" name="replace" checked="${is_replace or None}" />
                  Replace existing attachment of the same name</label>
              </div>
              <br />
            </py:if>
          </fieldset>
          <div class="buttons">
            <input type="hidden" name="action" value="new" />
            <input type="hidden" name="realm" value="$parent.realm" />
            <input type="hidden" name="id" value="$parent.id" />
            <input type="submit" value="${_('Add attachment')}" />
            <input type="submit" name="cancel" value="${_('Cancel')}" />
          </div>
        </form>
      </py:when>

      <py:when test="'delete'">
        <h1><a href="${url_of(parent)}">${name_of(parent)}</a>: $attachment.filename</h1>
        <p><strong>Are you sure you want to delete this attachment?</strong><br />
          This is an irreversible operation.</p>
        <div class="buttons">
          <form method="post" action="">
            <div id="delete">
              <input type="hidden" name="action" value="delete" />
              <input type="submit" name="cancel" value="${_('Cancel')}" />
              <input type="submit" value="${_('Delete attachment')}" />
            </div>
          </form>
        </div>
      </py:when>

      <py:when test="'list'">
        <h1><a href="${url_of(parent)}">${name_of(parent)}</a></h1>
        <py:with vars="context = context.child(parent)">
          <?python add_button_title = _('Attach another file') ?>
          <xi:include href="list_of_attachments.html" py:with="alist = attachments"/>
        </py:with>
      </py:when>

      <py:otherwise> <!--! 'render' mode -->
        <h1><a href="${url_of(parent)}">${name_of(parent)}</a>: $attachment.filename</h1>
        <table id="info" summary="Description">
          <tbody>
            <tr>
              <th scope="col" i18n:msg="file,size,author,date">
                File $attachment.filename,
                <span title="${_('%(size)s bytes', size=attachment.size)}">${pretty_size(attachment.size)}</span>
                (added by ${authorinfo(attachment.author)}, ${pretty_dateinfo(attachment.date)})
              </th>
            </tr>
            <tr>
              <td class="message searchable" xml:space="preserve">
                ${wiki_to_html(context.child(parent), attachment.description)}
              </td>
            </tr>
          </tbody>
        </table>

        <div py:if="preview" id="preview" class="searchable">
          <xi:include href="preview_file.html" py:with="preview = preview"/>
        </div>

        <py:if test="attachment and 'ATTACHMENT_DELETE' in perm(attachment.resource)">
          <div class="buttons">
            <form method="get" action="">
              <div id="delete">
                <input type="hidden" name="action" value="delete" />
                <input type="submit" value="${_('Delete attachment')}" />
              </div>
            </form>
          </div>
        </py:if>
      </py:otherwise>

    </div>
  </body>
</html>