{% extends "base.html" %}
{% load i18n %}
{% load shaarpy_extras %}
<title>{% block title %}{{ SHAARPY_NAME }} :: {{ object.title }} {% endblock %}</title>
{% block og_title %}{{ object.title }}{% endblock %}
{% if object.title %}
{% block description %}{{ SHAARPY_DESCRIPTION }}{% endblock %}
{% block og_description %}{{ SHAARPY_DESCRIPTION }}{% endblock %}
{% endif %}
{% if object.tags %}
{% block keywords %}<meta name="keywords" content="{{ object.tags }}">{% endblock %}
{% endif %}
{% if object.image %}
{% block og_image %}<meta property="og:image" content="{{ object.image }}">{% endblock %}
{% endif %}
{% block content %}
<div class="col-xs-8 col-md-8 col-lg-8 offset-xs-2 offset-md-2 offset-lg-2 mt-3">
<div class="card">
  <div class="card-body">
    {% if object.image %}
    <img src="{{ object.image }}" class="card-img-top"/>
    {% endif %}
    <h5 class="card-title">
    {% if object.url %}
      <a href="{{ object.url }}">{% if object.title %}{{ object.title }}{% else %}{{ object.url }}{% endif %}</a>
    {% else %}
      <a href="{% url 'link_detail' object.url_hashed %}">{{ object.title }}</a>
    {% endif %}
    </h5>
    <div class="card-text">{{ object.text | markdown | safe }}
    </div>
  </div>
  <div class="card-footer text-muted">
    {% if object.private %}
    <i class="fas fa-key"> {% trans 'Private' %}</i> -
    {% endif %}
    <i class="far fa-clock"> {{ object.date_created }}</i>
    {% if user.is_authenticated %}
    <a role="button" href="{% url 'link_edit' object.id %}" class="btn btn-outline-primary btn-sm">
      <i class="far fa-edit"> {% trans 'edit' %}</i>
    </a>
    <a role="button" class="btn btn-outline-danger btn-sm" data-bs-toggle="modal" data-bs-target="#deleteModal{{ object.id }}">
      <i class="far fa-trash-alt"> {% trans 'delete' %}</i>
    </a> -
    <!-- Modal -->
    <div class="modal fade" id="deleteModal{{ object.id }}" tabindex="-1" aria-labelledby="deleteModalLabel{{ object.id }}" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <h5 class="modal-title" id="deleteModalLabel{{ object.id }}">{% trans 'Deletion of your link' %}</h5>
            <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
          </div>
          <div class="modal-body">
            {% blocktrans %}
                Are you sure you want to remove this link ?
            {% endblocktrans %}
            <p>
            {% if object.link %}{{ object.link }}{% endif %}
            {% if object.title %}{{ object.title }}{% endif %}
            </p>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-primary" data-bs-dismiss="modal">No</button>
            <a role="button" class="btn btn-danger" href="{% url 'link_delete' object.id %}">Yes</a>
          </div>
        </div>
      </div>
    </div>
    {% endif %}
    <a href="{% url 'link_detail' object.url_hashed %}">{% trans 'Permalink' %}</a> - {% if object.url %}{{ object.url }}{% else %}{% url 'link_detail' object.url_hashed %}{% endif %}
    {% if object.tags %}
    - <i class="fas fa-tags"> {{ object.tags | tags | safe }}</i>
    {% endif %}
  </div>
</div>
{% endblock %}
