{% extends "spider_base/uc_base.html" %}
{% load i18n static spider_base spider_rdf %}

{% block title %}{% if scope == "add" %}{% blocktrans trimmed with name=object %}
  Create Content: {{name}}
{% endblocktrans %}{% elif scope == "update" %}{% blocktrans trimmed with name=object %}
  Update Content: {{name}}
{% endblocktrans %}{% else %}{% blocktrans trimmed with name=object %}
  Content: {{name}}
{% endblocktrans %}{% endif %}{% endblock %}


{% block public_meta %}
  {{block.super}}
  {% if scope != "add" %}
    <meta name="description" content="{{object.description|escape}}" />
  {% endif %}
{% endblock %}


{% block main_classes %}{{block.super}}{% if scope == "add" %} w3-animate-bottom{% endif %}{% endblock %}
{% block main_attributes %}{{block.super}} {% if component_feature_type in object.ctype or content_feature_type in object.ctype %}typeof="spkc:Feature"{% else %}typeof="spkc:Content"{% endif %}{% endblock %}

{% block content %}
  <div class="w3-padding" style="min-height:140px">
    <data hidden="hidden" property="spkc:action:view" datatype="xsd:anyURI">{% action_view %}</data>
    {% if machine_variants and request.is_owner %}
      <data hidden="hidden" typeof="spkc:Component" resource="{{hostpart}}{% url 'spider_base:ucontent-list' token=uc.token %}">
        {% for name in machine_variants %}
          <data hidden="hidden" property="spkc:create:name" datatype="xsd:string">{{name}}</data>
        {% endfor %}
      </data>
    {% endif %}
    {% for f in active_listed_features %}
      {% for action in f.feature_urls %}
        <data hidden="hidden" typeof="spkc:action:feature" resource="{{hostpart}}{{action.url}}">
          <data hidden="hidden" property="spkc:feature:name" datatype="xsd:string">{{action.name}}</data>
        </data>
      {% endfor %}
    {% endfor %}
    {% for ability in abilities %}
      <data hidden="hidden" property="spkc:ability:name" datatype="xsd:string">{{ability}}</data>
    {% endfor %}
    {% if request.is_special_user or uc.public %}
      {# index is redirected in view #}
      <a class="w3-left" href="{% url 'spider_base:ucontent-list' token=uc.token %}?{{request.GET.urlencode}}">
        <i class="fas fa-arrow-up" style="margin-right:10px" aria-hidden="true"></i>{% trans 'Index' %}
      </a>
    {% endif %}
    <span class="w3-right">
      {% if scope != "add" and request.is_special_user %}
      <div class="actionbar_user w3-left-align" style="margin-bottom:5px">
        {% if scope != "view" %}
          <a class="w3-block" style="margin-bottom:5px" href="{% url 'spider_base:ucontent-access' token=object.token access='view' %}">
            <i class="fas fa-eye" style="margin-right:10px" aria-hidden="true"></i>{% trans "View" %}
          </a>
        {% endif %}
        {% if scope != "update" %}
          <a rel="nofollow" class="w3-block" style="margin-bottom:5px" href="{% url 'spider_base:ucontent-access' token=object.token access='update' %}?{{sanitized_GET}}">
            <i class="fas fa-edit" style="margin-right:10px" aria-hidden="true"></i>{% trans "Update" %}
          </a>
        {% endif %}
        <div style="margin-bottom:5px">
          <a rel="nofollow" href="{% url 'spider_base:ucontent-delete' token=object.token %}">
            <i class="fas fa-trash" style="margin-right:10px" aria-hidden="true"></i>{% trans 'Delete' %}
          </a>
        </div>
      </div>
      {% endif %}
      {% if scope != "add" %}
        <a rel="nofollow" class="w3-block" style="margin-bottom:5px" onclick="if(document.readyState === 'complete'){return open_qrmodal(event);}; return false;" href="#">
          <i class="fas fa-file-export" style="margin-right:10px" aria-hidden="true"></i>{% trans 'Share' %}
        </a>
      {% endif %}
      {% if scope != "add" and request.is_special_user and no_export_type not in object.ctype.ctype %}
      <a rel="nofollow" class="w3-block" style="margin-bottom:5px" href="{% url 'spider_base:ucontent-access' token=object.token access='export' %}">
        <i class="fas fa-cloud-download-alt" style="margin-right:10px" aria-hidden="true"></i>{% trans 'Export' %}
      </a>
      {% endif %}
      <div>
        <i class="fas fa-lock" style="margin-right:10px" aria-hidden="true"></i>{% trans "Strength:" %} <data property="spkc:strength" datatype="xsd:integer">{% if request.is_special_user %}{{uc.strength}}{% else %}{{uc.untrusted_strength}}{% endif %}</data>
      </div>
    </span>
    <h1 class="w3-center">
      {% if scope == "add" %}
        <data hidden="hidden" property="spkc:type" datatype="xsd:string">{{object.name}}</data>
        {% blocktrans trimmed %}
          Create Content
        {% endblocktrans %}: <em>{{object}}</em>
      {% elif scope == "update" %}
        <data hidden="hidden" property="spkc:type" datatype="xsd:string">{{object.ctype.name}}</data>
        {% blocktrans trimmed %}
          Update
        {% endblocktrans %} "<b>{{object}}</b>" <small {% if uc.public or uc.user == request.user %}title="{% trans 'User Component' %}: {{uc}}"{% endif %}><em>({{object.ctype}})</em></small>
      {% else %}
        <data hidden="hidden" property="spkc:type" datatype="xsd:string">{{object.ctype.name}}</data>
        <b>{{object}}</b> <small {% if uc.public or uc.user == request.user %}title="{% trans 'User Component:' %} {{uc}}"{% endif %}><em>({{object.ctype}})</em></small>
      {% endif %}
    </h1>
    {% if object %}
      <data hidden="hidden" rel="spkc:properties">
        <data hidden="hidden" typeof="spkc:Property">
          <data hidden="hidden" property="spkc:name" datatype="xsd:string">info</data>
          <data hidden="hidden" property="spkc:hashable" datatype="xsd:boolean">false</data>
          <data hidden="hidden" property="spkc:value" datatype="xsd:string">{{object.info}}</data>
        </data>
        {% if uc.primary_anchor %}
        <data hidden="hidden" typeof="spkc:Property">
          <data hidden="hidden" property="spkc:name" datatype="xsd:string">primary_anchor</data>
          <data hidden="hidden" property="spkc:hashable" datatype="xsd:boolean">false</data>
          <data hidden="hidden" property="spkc:value" datatype="xsd:anyURI">{{hostpart}}{{uc.primary_anchor.get_absolute_url}}</data>
        </data>
        {% endif %}

        <data hidden="hidden" typeof="spkc:Property">
          <data hidden="hidden" property="spkc:name" datatype="xsd:string">id</data>
          <data hidden="hidden" property="spkc:value" datatype="xsd:integer">{{object.id}}</data>
        </data>
        <data hidden="hidden" typeof="spkc:Property">
          <data hidden="hidden" property="spkc:name" datatype="xsd:string">features</data>
          <data hidden="hidden" property="spkc:hashable" datatype="xsd:boolean">false</data>
          {% for f in active_listed_features %}
            <data hidden="hidden" datatype="xsd:string" property="spkc:value">{{f.name}}</data>
          {% empty %}
            <data hidden="hidden" rel="spkc:value" resource="rdf:nil"></data>
          {% endfor %}
        </data>
        <data hidden="hidden" typeof="spkc:Property">
          <data hidden="hidden" property="spkc:name" datatype="xsd:string">intentions</data>
          <data hidden="hidden" property="spkc:hashable" datatype="xsd:boolean">false</data>
          {% for i in intentions %}
            <data hidden="hidden" datatype="xsd:string" property="spkc:value">{{i}}</data>
          {% empty %}
            <data hidden="hidden" resource="rdf:nil" rel="spkc:value"></data>
          {% endfor %}
        </data>
      </data>
    {% endif %}
    {% if request.token_expires %}
    <div>
      {% include 'spider_base/partials/token_lifetime.html' with rtime=request.token_expires %}
    </div>
    {% endif %}
  </div>
  {% if scope == "view" %}
    {% if uc.public or request.is_special_user %}
      {% if object.previous_object or object.next_object %}
        <div class="w3-padding" style="min-height: 40px">
          {% if object.previous_object %}
          <a class="" href="{% url 'spider_base:ucontent-access' token=object.previous_object.token access='view' %}?{{sanitized_GET}}">
            {% trans "previous" %}
          </a>
          {% endif %}
          {% if object.next_object %}
          <a class="w3-right" href="{% url 'spider_base:ucontent-access' token=object.next_object.token access='view' %}?{{sanitized_GET}}">
            {% trans "Next" %}
          </a>
          {% endif %}
        </div>
      {% endif %}
    {% endif %}
  {% endif %}
  {% if active_listed_features.exists %}
  <div class="w3-padding">
    <div class="w3-white w3-padding">
      <h4>{% trans 'Active Features' %}:</h4>
      <div>
        {% for f in active_listed_features %}
          <span class="" style="display:inline-block;white-space:nowrap;">{{f}}{% if not forloop.last %}, {% endif %}</span>
        {% endfor %}
      </div>
    </div>
  </div>
  {% endif %}
{% block render_content %}
{{content|safe}}
{% endblock %}
{% endblock %}

{% block outercontent %}
{% if scope != "add" %}
  {# remotelink generated in view #}
  {% include "spider_base/partials/share_presenter.html" %}
{% endif %}
{% endblock %}
