{% load humanize %}
{% load details_link %}
<div id="pkgdetails" class="box">
    <h2>{{ pkg.pkgname }} {{ pkg.full_version }}</h2>

    <div id="detailslinks" class="listing">
        <div id="actionlist">
        <h4>Package Actions</h4>
            <ul class="small">
                <li>
                    <a href="{% scm_link pkg 'tree' %}" title="View source files for {{ pkg.pkgname }}">Source Files</a> /
                    <a href="{% scm_link pkg 'commits' %}" title="View changes for {{ pkg.pkgname }}">View Changes</a>
                </li>
                <li>
                    <a href="{% bugs_list pkg %}" title="View existing bug tickets for {{ pkg.pkgname }}">Bug Reports</a> /
                    <a href="{% bug_report pkg %}" title="Report new bug for {{ pkg.pkgname }}">Add New Bug</a>
                </li>
                <li>
                    <a href="{% wiki_link pkg %}" title="Search wiki for {{ pkg.pkgname }}">Search Wiki</a> /
                    <a href="{% man_link pkg %}" title="List manpages in {{ pkg.pkgname }}">Manual Pages</a>
                </li>
                <li><a href="{% sec_link pkg %}" title="View security issues for {{ pkg.pkgname }}">Security Issues</a></li>
        	{% if user.is_authenticated and notreproducible %}<tr>
                <li>
		    <a href="{% rebuilderd_buildlog_link rbstatus %}" title="View build log for {{ pkg.pkgname }}">Build log</a> /
		    <a href="{% rebuilderd_diffoscope_link rbstatus %}" title="View diffoscope result for {{ pkg.pkgname }}">Diffoscope</a>
		</li>
		{% endif %}
                {% if pkg.flag_date %}
                <li><span class="flagged">Flagged out-of-date on {{ pkg.flag_date|date:"Y-m-d" }}</span></li>
                {% with tp=pkg.in_testing %}{% if tp %}
                <li><span class="flagged">Version
                    <a href="{{ tp.get_absolute_url }}"
                        title="Testing package details for {{ tp.pkgname }}">{{ tp.full_version }}</a>
                    in testing</span></li>
                {% endif %}{% endwith %}
                {% if perms.main.change_package %}
                <li><a href="unflag/" title="Unflag this package">Click here to unflag</a></li>
                {% if pkg.pkgname != pkg.pkgbase or pkg.split_packages %}
                <li><a href="unflag/all/" title="Unflag all matching pkgbase">Click here to unflag all split packages</a></li>
                {% endif %}
                {% endif %}
                {% else %}
                <li><a href="flag/" title="Flag {{ pkg.pkgname }} as out-of-date">Flag Package Out-of-Date</a>
                <a href="/packages/flaghelp/"
                    title="Get help on package flagging"
                    target="_blank"
                    >(?)</a></li>
                {% endif %}
                <li><a href="download/" rel="nofollow" title="Download {{ pkg.pkgname }} from mirror">Download From Mirror</a></li>
            </ul>

            {% if perms.main.change_package %}
            <form id="pkg-action" method="post" action="/packages/update/">{% csrf_token %}
                <div><input type="hidden" name="pkgid" value="{{ pkg.id }}" /></div>
                <p>{% if user in pkg.maintainers %}
                    <input title="Orphan this package" type="submit" name="disown" value="Disown"/>
                    {% elif pkg.repo in user.userprofile.allowed_repos.all %}
                    <input title="Adopt this package" type="submit" name="adopt" value="Adopt"/>
                 {% endif %}</p>
            </form>
            {% endif %}
        </div>

        {% with others=pkg.elsewhere %}{% if others %}
        <div id="elsewhere" class="widget">
            <h4>Versions Elsewhere</h4>
            <ul>
                {% for o in others %}
                <li><a href="{{ o.get_absolute_url }}"
                    title="Package details for {{ o.pkgname }}">{{ o.pkgname }} {{ o.full_version }} [{{ o.repo.name|lower }}] ({{ o.arch.name }})</a></li>
                {% endfor %}
            </ul>
        </div>
        {% endif %}{% endwith %}
    </div>

    <div itemscope itemtype="http://schema.org/SoftwareApplication">
    <meta itemprop="name" content="{{ pkg.pkgname|escape }}"/>
    <meta itemprop="version" content="{{ pkg.full_version|escape }}"/>
    <meta itemprop="softwareVersion" content="{{ pkg.full_version|escape }}"/>
    <meta itemprop="fileSize" content="{{ pkg.compressed_size }}"/>
    <meta itemprop="dateCreated" content="{{ pkg.build_date|date:"Y-m-d" }}"/>
    <meta itemprop="datePublished" content="{{ pkg.last_update|date:"Y-m-d" }}"/>
    <meta itemprop="operatingSystem" content="Arch Linux"/>
    {% if pkg.packager %}<div class="itemprop" itemprop="provider" itemscope itemtype="http://schema.org/Person">
        <meta itemprop="name" content="{{ pkg.packager.get_full_name|escape }}"/>
    </div>{% endif %}
    <table id="pkginfo">
        <tr>
            <th>Architecture:</th>
            <td><a href="/packages/?arch={{ pkg.arch.name }}"
                    title="Browse packages for {{ pkg.arch.name }} architecture">{{ pkg.arch.name }}</a></td>
        </tr><tr>
            <th>Repository:</th>
            <td><a href="/packages/?repo={{ pkg.repo.name|capfirst }}"
                    title="Browse the {{ pkg.repo.name|capfirst }} repository">{{ pkg.repo.name|capfirst }}</a></td>
        </tr>
        {% if pkg.pkgname == pkg.pkgbase %}
        {% with splits=pkg.split_packages %}{% if splits %}
        <tr>
            <th>Split Packages:</th>
            <td class="wrap relatedto">{% for s in splits %}<span class="related">{% details_link s %}{% if not forloop.last %}, {% endif %}</span>{% endfor %}</td>
        </tr>
        {% endif %}{% endwith %}
        {% else %}
        <tr>
            <th>Base Package:</th>
            {% with base=pkg.base_package %}{% if base %}
            <td>{% details_link base %}</td>
            {% else %}
            <td><a href="../{{ pkg.pkgbase }}/"
                    title="Split package details for {{ pkg.pkgbase }}">{{ pkg.pkgbase }}</a></td>
            {% endif %}{% endwith %}
        </tr>
        {% endif %}
        <tr>
            <th>Description:</th>
            <td class="wrap" itemprop="description">{{ pkg.pkgdesc|default:"" }}</td>
        </tr><tr>
            <th>Upstream URL:</th>
            <td>{% if pkg.url %}<a itemprop="url" href="{{ pkg.url }}"
                    title="Visit the website for {{ pkg.pkgname }}">{{ pkg.url|url_unquote }}</a>{% endif %}</td>
        </tr><tr>
            <th>License(s):</th>
            <td class="wrap">{{ pkg.licenses.all|join:", " }}</td>
        </tr>
        {% with groups=pkg.groups.all %}{% if groups %}
        <tr>
            <th>Groups:</th>
            <td class="wrap">{% for g in groups %}
                <a href="/groups/{{ pkg.arch.name }}/{{ g.name }}/"
                    title="Group details for {{ g.name }}">{{ g.name }}</a>{% if not forloop.last %}, {% endif %}{% endfor %}
            </td>
        </tr>
        {% endif %}{% endwith %}
        {% with all_related=pkg.provides.all %}{% if all_related %}
        <tr>
            <th>Provides:</th>
            <td class="wrap relatedto">{% include "packages/details_relatedto.html" %}</td>
        </tr>
        {% endif %}{% endwith %}
        {% with all_related=pkg.replaces.all %}{% if all_related %}
        <tr>
            <th>Replaces:</th>
            <td class="wrap relatedto">{% include "packages/details_relatedto.html" %}</td>
        </tr>
        {% endif %}{% endwith %}
        {% with all_related=pkg.conflicts.all %}{% if all_related %}
        <tr>
            <th>Conflicts:</th>
            <td class="wrap relatedto">{% include "packages/details_relatedto.html" %}</td>
        </tr>
        {% endif %}{% endwith %}
        {% with rev_conflicts=pkg.reverse_conflicts %}{% if rev_conflicts %}
        <tr>
            <th>Reverse Conflicts:</th>
            <td class="wrap relatedto">{% for conflict in rev_conflicts %}
                <span class="related">{% details_link conflict %}{% if not forloop.last %}, {% endif %}</span>{% endfor %}</td>
        </tr>
        {% endif %}{% endwith %}
        <tr>
            <th>Maintainers:</th>
            {% with maints=pkg.maintainers %}
            <td>{% if maints %}{% for m in maints %}
                <a href="/packages/?maintainer={{ m.username }}"
                    title="View packages maintained by {{ m.get_full_name }}">{{ m.get_full_name }}</a><br/>
                {% endfor %}{% else %}Orphan{% endif %}
            </td>
            {% endwith %}
        </tr><tr>
            <th>Package Size:</th>
            <td>{{ pkg.compressed_size|filesizeformat }}</td>
        </tr><tr>
            <th>Installed Size:</th>
            <td>{{ pkg.installed_size|filesizeformat }}</td>
        </tr><tr>
            <th>Last Packager:</th>
            <td>{% with pkgr=pkg.packager %}{% if pkgr %}
            <a href="/packages/?packager={{ pkgr.username }}"
                title="View packages packaged by {{ pkgr.get_full_name }}">{{ pkgr.get_full_name }}</a>
            {% else %}{{ pkg.packager_str }}{% endif %}{% endwith %}</td>
        </tr><tr>
            <th>Build Date:</th>
            <td>{{ pkg.build_date|date:"Y-m-d H:i" }} UTC</td>
        </tr>{% if pkg.signature %}<tr>
            <th>Signed By:</th>
            <td>{% with signer=pkg.signer %}{% if signer %}{% pgp_key_link pkg.signature.key_id signer.get_full_name|safe %}{% else %}Unknown ({% pgp_key_link pkg.signature.key_id|safe %}){% endif %}{% endwith %}</td>
        </tr><tr>
            <th>Signature Date:</th>
            <td>{{ pkg.signature.creation_time|date:"Y-m-d H:i" }} UTC</td>
        </tr>{% else %}<tr>
            <th>Signed By:</th>
            <td>Unsigned</td>
        </tr>{% endif %}<tr>
            <th>Last Updated:</th>
            <td>{{ pkg.last_update|date:"Y-m-d H:i" }} UTC{% if pkg.is_recent %} <span class="recent" title="Your mirror may not yet have this package version">({{ pkg.last_update|naturaltime }})</span>{% endif %}</td>
        </tr>
        {% if user.is_authenticated %}<tr>
            <th>Reproducible Status:</th>
	    {% if rbstatus %}
	    	<td id="rebuilderdstatus" class="rebuilderd-{{ rbstatus.status_str|lower }}">{{ rbstatus.status_str }}</td>
	    {% else %}
	    	<td id="rebuilderdstatus">Unknown</td>
	    {% endif %}
        </tr>
	{% endif %}
        {% if user.is_authenticated %}{% with flag_request=pkg.flag_request %}{% if flag_request %}<tr>
            <th>Last Flag Request:</th>
            <td class="wrap">From {{ flag_request.who }} on {{ flag_request.created|date:"Y-m-d" }}:<br/>
                <div class="userdata">{{ flag_request.message|linebreaksbr|default:"{no message}" }}</div></td>
        </tr>{% endif %}{% endwith %}{% endif %}
    </table>
    </div>

    <div id="metadata">
        {% with deps=pkg.get_depends %}
        <div id="pkgdeps" class="listing">
            <h3 title="{{ pkg.pkgname }} has the following dependencies">
                Dependencies ({{deps|length}})</h3>
            {% if deps %}<ul id="pkgdepslist">
                {% include "packages/details_depend.html" %}
            </ul>{% endif %}
        </div>
        {% endwith %}
        {% with rqdby=pkg.get_requiredby %}
        <div id="pkgreqs" class="listing">
            <h3 title="Packages that require {{ pkg.pkgname }}">
                Required By ({{rqdby|length}})</h3>
            {% if rqdby %}<ul id="pkgreqslist">
                {% include "packages/details_requiredby.html" %}
            </ul>{% endif %}
        </div>
        {% endwith %}
        <div id="pkgfiles" class="listing">
            <h3 title="Complete list of files contained within this package">
                Package Contents</h3>
            <div id="pkgfilelist">
                <p><a id="filelink" href="files/"
                    title="Click to view the complete file list for {{ pkg.pkgname }}">
                    View the file list for {{ pkg.pkgname }}</a></p>
            </div>
        </div>
        <div id="sonames" class="listing">
            <h3 title="Complete list of so-names the package links too">
                Links to so-names</h3>
            <div id="pkgsonamelist">
                <p><a id="sonamelink" href="sonames/"
                    title="Click to view the complete soname list for {{ pkg.pkgname }}">
                    View the soname list for {{ pkg.pkgname }}</a></p>
            </div>
        </div>
    </div>
</div>
