{% if g.value(targetres, SDO.name) or g.value(targetres, STYPE.executableName) or g.value(targetres, SDO.url) %}
<div class="targetProduct {{ get_last_component(g.value(targetres, RDF.type)) }}" about="{{ targetres }}" typeof="{{ g.value(targetres, RDF.type) }}">

    {% if g.value(targetres, SDO.name) %}
    <h2 property="schema:name">{{ g.value(targetres, SDO.name) }}</h2>
    {% elif g.value(targetres, STYPE.executableName) %}
    <h2 property="stype:executableName">{{ g.value(targetres, STYPE.executableName) }}</h2>
    {% endif %}

    {% if g.value(targetres, SDO.description) and g.value(targetres, SDO.description) != g.value(res, SDO.description) %}
    <div property="schema:description">{{ g.value(targetres, SDO.description) }}</div>
    {% endif %}

    {% if (targetres, RDF.type, SDO.WebApplication) in g or
      (targetres, RDF.type, SDO.WebSite) in g or
      (targetres, RDF.type, SDO.NotebookApplication) in g or
      (targetres, RDF.type, SDO.WebPage) in g %}

        {% if (targetres, SDO.url, None) in g %}
        <div class="go">
            <i class="fa fa-globe"></i>
            <a rel="schema:url" href="{{ g.value(targetres, SDO.url) }}">
                <strong>Go to the {{ type_label(g, targetres) }}</strong>
                <tt>{{ g.value(targetres, SDO.url) }}</tt>
            </a>
        </div>
        {% else %}
        <div class="warning"><strong>Note:</strong> No URL was registered for this service (yet)</div>
        {% endif %}

    {% elif (targetres, RDF.type, SDO.WebAPI) in g %}

        {% if (targetres, SDO.url, None) in g %}
        <div class="go">
            <i class="fa fa-cog"></i>
            <a rel="schema:url" href="{{ g.value(targetres, SDO.url) }}">
                <strong>Go to the {{ type_label(g, targetres) }}</strong>
                <tt>{{ g.value(targetres, SDO.url) }}</tt>
            </a>
        </div>
        {% else %}
        <div class="warning"><strong>Note:</strong> No URL was registered for this service (yet)</div>
        {% endif %}

    {% endif %}

    {% if g.value(targetres, SDO.screenshot)  %}
    <h3>Screenshots</h3>

    <div class="screenshots">
        {% for url, res2 in get_triples(g, targetres, SDO.screenshot, SDO.url) %}
            {% if g.value(res2, SDO.caption) %}
                <img src="{{ url }}" alt="screenshot: {{ g.value(res2, SDO.caption) }}" title="{{ g.value(res2, SDO.caption) }}" />
            {% else %}
                <img src="{{ url }}" alt="screenshot" />
            {% endif %}
        {% endfor %}
    </div>
    {% endif %}

    {% if g.value(targetres, CODEMETA.referencePublication) or g.value(targetres, SDO.citation) %}

    <h3>References</h3>

    <div class="references">
        <ul>
        {% for title, ref in get_triples(g, targetres, CODEMETA.referencePublication, contextgraph=contextgraph) %}
        {% if ref %}
        <li>{% include 'reference.html' %}</li>
        {% else %}
        <li>{{ title }}</li>
        {% endif %}
        {% endfor %}

        {% for title, ref in get_triples(g, targetres, SDO.citation, contextgraph=contextgraph) %}
        {% if ref %}
        <li>{% include 'reference.html' %}</li>
        {% else %}
        <li>{{ title }}</li>
        {% endif %}
        {% endfor %}
        </ul>
    </div>

    {% endif %}

    <div class="properties">
        <dl>
            <dt class="type">Type</dt>
            <dd class="type interface">
            <ul>
            {% for label, comment in get_interface_types(g, targetres, contextgraph, fallback=True) %}
            <li{% if comment %} title="{{ comment }}"{% endif %}>{{ label }}</li>
            {% endfor %}
            </ul>
            </dd>

            {% if g.value(targetres, STYPE.executableName) %}
            <dt class="executableName" title="Name of the program or module as used when invoked">Executable name</dt>
            <dd class="executableName"><span property="stype:executableName"> {{ g.value(targetres, STYPE.executableName) }}</span>
            </dd>
            {% endif %}

            {% if g.value(targetres, SDO.version) %}
            <dt class="version" title="Version of the tool/service">Version</dt>
            <dd class="version"><span property="schema:version"> {{ g.value(targetres, SDO.version) }}</span>
            {% if res and g.value(res, SDO.version) != g.value(targetres, SDO.version) %}
            <div class="warning"><strong>Note:</strong> Version does not match latest source release (<tt>{{ g.value(res, SDO.version) }}</tt>), service may be out of date</div>
            {% endif %}
            </dd>
            {% endif %}

            {% if (targetres, SDO.isAccessibleForFree, None) in g or (targetres, SDO.publicAccess, None) in g %}
            <dt class="access" title="Are there limitations regarding access to the service?">Access</dt>
            <dd class="access">
            <ul>
            {% if g.value(targetres, SDO.isAccessibleForFree) is None %}
            {% elif g.value(targetres, SDO.isAccessibleForFree) %}
            <li><span property="schema:isAccessibleForFree" content="true" class="positive">accessible for free</span></li>
            {% else %}
            <span property="schema:isAccessibleForFree" content="false" class="negative">only accessible at a cost</span>
            {% endif %}
            {% if g.value(targetres, SDO.publicAccess) is None %}
            {% elif g.value(targetres, SDO.publicAccess) %}
            <span property="schema:publicAccess" content="true" class="positive">public access</span>
            {% else %}
            <span property="schema:publicAccess" content="false" class="negative">private access only</span>
            {% endif %}
            </ul>
            </dd>
            {% endif %}

            {% if g.value(targetres, CODEMETA.developmentStatus) %}
            <dt class="developmentStatus" title="Indication of the state of this software project regarding ongoing development and/or support">Development Status</dt>
            <dd class="developmentStatus">
                <ul>
                    {% for _,_, devstatres in g.triples((targetres, CODEMETA.developmentStatus, None)) %}
                    {% include 'developmentstatus.html' %}
                    {% endfor %}
                </ul>
            </dd>
            {% endif %}

            {% if (targetres, SDO.softwareHelp, None) in g or (targetres, SDO.documentation, None) in g  %}
            <dt class="documentation">Documentation</dt>
            <dd class="documentation">
            <ul>
            {% if g.value(targetres, SDO.softwareHelp) %}
            {% for _,_, res2 in g.triples((targetres, SDO.softwareHelp, None)) %}
                {% if g.value(res2, SDO.name) and g.value(res2, SDO.url) %}
                <li about="{{ res2 }}" typeof="{{ g.value(res2, RDF.type) }}"><i class="fa fa-book"></i>&nbsp;<a rel="schema:url" href="{{ g.value(res2, SDO.url) }}"><span property="schema:name">{{ g.value(res2, SDO.name) }}</span></a></li>
                {% elif g.value(res2, SDO.url) %}
                <li about="{{ res2 }}" typeof="{{ g.value(res2, RDF.type) }}"><i class="fa fa-book"></i>&nbsp;<a rel="schema:url" href="{{ g.value(res2, SDO.url) }}">{{ g.value(res2, SDO.url) }}</a></li>
                {% endif %}
            {% endfor %}
            {% endif %}
            {% if g.value(targetres, SDO.documentation) %}
            {% for _,_, res2 in g.triples((targetres, SDO.documentation, None)) %}
                {% if g.value(res2, SDO.name) and g.value(res2, SDO.url) %}
                <li about="{{ res2 }}" typeof="{{ g.value(res2, RDF.type) }}"><i class="fa fa-book"></i>&nbsp;<a rel="schema:url" href="{{ g.value(res2, SDO.url) }}"><span property="schema:name">{{ g.value(res2, SDO.name) }}</span></a></li>
                {% elif g.value(res2, SDO.url) %}
                <li about="{{ res2 }}" typeof="{{ g.value(res2, RDF.type) }}"><i class="fa fa-book"></i>&nbsp;<a rel="schema:url" href="{{ g.value(res2, SDO.url) }}">{{ g.value(res2, SDO.url) }}</a></li>
                {% elif res2 and res2.startswith("http") %}
                <li><i class="fa fa-book"></i>&nbsp;<a rel="schema:documentation" href="{{ res2 }}">{{ res2 }}</a></li>
                {% elif res2  %}
                <li><i class="fa fa-book"></i>&nbsp;{{ res2 }}</li>
                {% endif %}
            {% endfor %}
            {% endif %}
            </ul>
            </dd>
            {% endif %}


            {% if g.value(targetres, SDO.termsOfService) %}
            <dt class="termsOfService" title="The terms under which the service is offered">Terms of Service</dt>
            <dd class="termsOfService">
                <ul>
                    {% for _,_, tos in g.triples((targetres, SDO.termsOfService, None)) %}
                    {% if tos.startswith("http") %}
                    <li><a rel="schema:termsOfService" href="{{ tos }}">{{ tos }}</a></li>
                    {% else %}
                    <li>{{ tos }}</li>
                    {% endif %}
                    {% endfor %}
                </ul>
            </dd>
            {% endif %}

            {% if g.value(targetres, SDO.provider)  %}
            <dt class="provider" title="The organisation (or person) that provides the service">Service Provider</dt>
            <dd class="provider">
                <ul>
                 {% for label, pores in get_triples(g, targetres, SDO.provider) %}
                     {% include 'person_or_org.html' %}
                 {% endfor %}
                </ul>
            </dd>
            {% endif %}

            {% if g.value(targetres, SDO.publisher)  %}
            <dt class="publisher" title="The organisation (or person) that publishes the software">Publisher</dt>
            <dd class="publisher">
                <ul>
                 {% for label, pores in get_triples(g, targetres, SDO.publisher) %}
                 <li>{% include 'person_or_org.html' %}</li>
                 {% endfor %}
                </ul>
            </dd>
            {% endif %}

            {% if g.value(targetres, SDO.maintainer)  %}
            <dt class="maintainer" title="The person or organisation that is responsible for maintaining the service">Maintainer(s)</dt>
            <dd class="maintainer">
                <ul>
                 {% for label, pores in get_triples(g, targetres, SDO.maintainer) %}
                     {% include 'person_or_org.html' %}
                 {% endfor %}
                </ul>
            </dd>
            {% endif %}

            {% if g.value(targetres, SDO.funder) %}
            <dt class="funder" title="funder source (e.g. specific grant)">Funder</dt>
            <dd class="funder">
                <ul>
                     {% for label, pores in get_triples(g, targetres, SDO.funder, abcsort=True) %}
                     <li>{% include 'person_or_org.html' %}</li>
                     {% endfor %}
                </ul>
            </dd>
            {% endif %}

            {% if g.value(targetres, CODEMETA.funding) %}
            <dt class="funding" title="Funding source (e.g. specific grant)">Funding</dt>
            <dd class="funding">
                <ul>
                     {% for label, res2 in get_triples(g, targetres, CODEMETA.funding, abcsort=True) %}
                         {% if res2 and g.value(res2, SDO.url) %}
                            <li property="codemeta:funding"><a href="{{ g.value(res2, SDO.url) }}">{{ label }}</a></li>
                         {% else %}
                            <li property="codemeta:funding">{{ label }}</li>
                         {% endif %}
                     {% endfor %}
                </ul>
            </dd>
            {% endif %}

            {% if g.value(targetres, SDO.permissions) %}
            <dt class="permissions" title="Permissions that are needed to run the software">Permissions</dt>
            <dd class="permissions">
                <ul>
                     {% for label, _ in get_triples(g, targetres, SDO.permissions) %}
                        <li property="schema:permissions">{{ label }}</li>
                     {% endfor %}
                </ul>
            </dd>
            {% endif %}

            {% if g.value(targetres, SOFTWAREIODATA.consumesData) %}
            <dt class="iodata" title="High-level overview of the type(s) of data that the software consumes as input">Input data</dt>
            <dd class="iodata">
            {% for label, iores in get_triples(g, targetres, SOFTWAREIODATA.consumesData) %}
                <div>{% include 'iodata.html' %}</div>
            {% endfor %}
            </dd>
            {% endif %}

            {% if g.value(targetres, SOFTWAREIODATA.producesData) %}
            <dt class="iodata" title="High-level overview of the type(s) of data that the software produces as output">Output data</dt>
            <dd class="iodata">
            {% for label, iores in get_triples(g, targetres, SOFTWAREIODATA.producesData) %}
                <div>{% include 'iodata.html' %}</div>
            {% endfor %}
            </dd>
            {% endif %}

            {% if g.value(targetres, SDO.dateCreated) %}
            <dt class="dateCreated" title="The date and time at which the software/service (all versions) was first created">Created</dt>
            <dd class="dateCreated">
                {{ g.value(targetres, SDO.dateCreated).replace("T"," ").replace("Z"," ") }}
            </dd>
            {% endif %}

            {% if g.value(targetres, SDO.dateModified) %}
            <dt class="dateModified" title="The date and time at which the software/service was last modified">Last modified</dt>
            <dd class="dateModified">
                {{ g.value(targetres, SDO.dateModified).replace("T"," ").replace("Z"," ")  }}
            </dd>
            {% endif %}

        </dl>
    </div>

</div>
{% endif %}
