{% comment %}
Copyright (C) 2017-2020  The Software Heritage developers
See the AUTHORS file at the top-level directory of this distribution
License: GNU Affero General Public License version 3, or any later version
See top-level LICENSE file for more information
{% endcomment %}

{% load swh_templatetags %}

{% if 'metadata' in swh_object_metadata and swh_object_metadata.metadata != '{}' %}

<button id="swh-metadata-toggler" class="btn btn-default btn-sm swh-popover-toggler"
        data-toggle="popover" data-popover-content="#swh-metadata-popover">
  <i class="mdi mdi-table mdi-fw" aria-hidden="true"></i>
  Show metadata
</button>

<div id="swh-metadata-popover" style="display:none;">
  <div class="popover-heading">{{ swh_object_name }} metadata</div>
  <div class="popover-body">
    <pre class="bg-white">{{ swh_object_metadata.metadata | escape }}</pre>
  </div>
</div>

{% endif %}

<script>
  swh.webapp.setBrowsedSwhObjectMetadata({{ swh_object_metadata|jsonify }})
</script>
