<!--!
Display a list of attachments.

Arguments:
 - alist: the data for the list of attachments
 - compact=False: if True, show the list in compact format (e.g. as used in the wiki view)
 - add_button_title=None: the title of the "Attach" button
 - foldable=False: if True, make the list of attachments foldable
-->

<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="compact = value_of('compact', False);
               add_button_title = value_of('add_button_title', None);
               foldable = value_of('foldable', False)" py:strip="">
<py:def function="show_one_attachment(attachment)">
    <a href="${url_of(attachment.resource, format='raw')}" class="trac-rawlink" title="Download"></a>
    <i18n:msg params="file, size, author, date">
        <a href="${url_of(attachment.resource)}" title="View attachment">${attachment.filename}</a>
       <span class="attachment-info">(<span title="${_('%(size)s bytes', size=attachment.size)}">${pretty_size(attachment.size)}
       </span>) - added by <em>${authorinfo(attachment.author)}</em> ${pretty_dateinfo(attachment.date)}.</span>
    </i18n:msg>
</py:def>

<py:if test="alist.attachments or alist.can_create">
    <div id="attachments" class="span12" style="margin-bottom: 10px;" py:choose="">
        <py:when test="compact and alist.attachments">
            <h3 class="${'foldable' if foldable else None}">Attachments<span class="trac-count">(${len(alist.attachments)})</span></h3>
            <div>
                <ul>
                    <py:for each="attachment in alist.attachments">
                        <li>
                            ${show_one_attachment(attachment)}
                            <q py:if="compact and attachment.description">${wiki_to_oneliner(context, attachment.description)}</q>
                        </li>
                    </py:for>
                </ul>
                <p py:if="alist.download_href">
                    <span class="label round secondary">Download</span>
                    all attachments as: <a rel="nofollow" href="$alist.download_href">.zip</a>
                </p>
            </div>
        </py:when>
        <py:when test="not compact">
            <span id="comment:attachments" class="h3attachment ${'foldable' if foldable else None}">Attachments <span class="trac-count">(${len(alist.attachments)})</span></span>
            <div py:if="alist.attachments or alist.can_create" class="attachments">
                <dl py:if="alist.attachments" class="attachments">
                    <div py:for="attachment in alist.attachments"
                         class="template-download fade in" data-id="${attachment.filename}">
                        <dt>${show_one_attachment(attachment)}</dt>
                        <dd py:if="attachment.description">
                            ${wiki_to_oneliner(context, attachment.description)}
                        </dd>
                    </div>
                </dl>
                <xi:include href="bh_fu_attach_file_form.html" py:with="advanced = True; qtyattachment = len(alist.attachments); files_container = '#attachments dl.attachments'"/>
                <span py:if="alist.attachments and alist.download_href" style="margin-left: 10px;">Download all attachments as: <a rel="nofollow" href="$alist.download_href">.zip</a></span>
            </div>
        </py:when>
    </div>
</py:if>
</html>
