{% extends "base.html" %}
{% load i18n %}
{% block extratitle %}{{ source.name }} - {% endblock %}
{% block content %}
      <nav aria-label="breadcrumb">
  <ol class="breadcrumb">
    <li class="breadcrumb-item"><a href="{% url 'quotes:group_list' %}">{% translate "Groups" %}</a></li>
    <li class="breadcrumb-item"><a href="{% url 'quotes:group_detail' group=source.group.slug %}">{{ source.group.name }}</a></li>
    <li class="breadcrumb-item"><a href="{% url 'quotes:source_list' group=source.group.slug %}">{% translate "Sources" %}</a></li>
    <li class="breadcrumb-item active" aria-current="page">{{ source.name }}</li>
  </ol>
  </nav>
<h1>{% translate "Source Details" %}: {{ source.name }}</h1>
  <div class="card">
  <h2 class="card-header">{{ source.name }}</h2>
    <div class="card-body">
  {{ source.description_rendered|safe }}
    </div>
    <div class="card-footer text-muted">
  <small>{% translate "Created at" %} {{ source.created }} {% translate "Last modified" %} {{ source.modified }}</small>
    </div>
  </div>
  <p></p>
  <p><a href="{% url 'quotes:source_update' source=source.slug %}" class="btn btn-primary">{% translate "Edit source" %}</a> <a href="{% url 'quotes:source_list' group=source.group.slug %}" class="btn btn-secondary">{% translate "Back to source list" %}</a></p>
  <h2>{% translate "Sample of Quotes" %}</h2>
  <table class="table table-striped caption-top">
  <caption>{% translate "Showing" %} {{ samp_quotes|length }} {% translate "of" %} {{ source.quote_set.count }} {% translate "quotes" %}. <a href="{% url 'quotes:quote_list' source=source.slug %}">{% translate "See all." %}</a></caption>
  <thead>
  <tr>
    <th scope="col" class="text-right">#</th>
    <th scope="col">{% translate "Quote" %}</th>
    <th scope="col">{% translate "Cite" %}</th>
    <th scope="col" class="text-end">{% translate "# Times Used" %}</th>
    <th scope="col">{% translate "Tools" %}</th>
    <th></th>
  </tr>
  </thead>
  <tbody>
  {% for quote in samp_quotes %}
  <tr>
  <th scope="row" class="text-right"><a href="{% url 'quotes:quote_detail' quote=quote.id %}">{{ quote.id }}</a></th>
  <td>{{ quote.quote_rendered|truncatewords_html:10|safe }}</td>
  <td>
    {% if quote.citation or quote.citation_url %}
    {% if quote.citation_url %}<a href="{{ quote.citation_url }}" target="_blank">{% endif %}{% if quote.citation %}{{ quote.citation }}{% else %}{{ quote.citation_url }}{% endif %}{% if quote.citation_url %}</a>{% endif %}
  {% endif %}
  </td>
  <td class="text-end">{{ quote.stats.times_used }}</td>
    <td><a class="btn btn-primary" href="{% url 'quotes:quote_update' quote=quote.id %}">{% translate "Edit" %}</a></td><td><a href="{% url 'quotes:quote_delete' quote=quote.id %}" class="btn btn-danger">{% translate "Delete" %}</a></td>
  </tr>
  {% empty %}
  {% endfor %}
  </tbody>
  </table>
  <p><a href="{% url 'quotes:quote_create' source=source.slug %}" class="btn btn-success">{% translate "Add new quote" %}</a></p>
  <h2>{% translate "Source Statistics" %}</h2>
  <table class="table">
  <thead>
  <tr>
    <th scope="col" class="text-end">{% translate "Total quotes" %}</th>
    <th scope="col" class="text-end">{% translate "Random quotes requested" %}</th>
    <th scope="col" class="text-end">{% translate "Markov sentences generated" %}</th>
  </tr>
  </thead>
  <tbody>
  <tr>
    <td class="text-end">{{ source.quote_set.count }}</td>
    <td class="text-end">{{ source.stats.quotes_requested }}</td>
    <td class="text-end">{{ source.stats.quotes_generated }}</td>
  </tr>
  </tbody>
  </table>
  <p class="text-end"><a href="{% url 'quotes:source_delete' source=source.slug %}" class="btn btn-danger">{% translate "Delete source" %}</a></p>
{% endblock %}
