{% load static %}
{% load solo_tags %}
{% load markdown %}
{% get_solo 'portal.SiteConfiguration' as site_conf %}

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="{{ site_conf.site_author }}">
    <meta name="generator" content="Django Framework">
    <title>{{ site_conf.site_name }}</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="{% static "css/main.css" %}" rel="stylesheet">
    <style>
      .bd-placeholder-img {
        font-size: 1.125rem;
        text-anchor: middle;
        -webkit-user-select: none;
        -moz-user-select: none;
        user-select: none;
      }

      @media (min-width: 768px) {
        .bd-placeholder-img-lg {
          font-size: 3.5rem;
        }
      }
    </style>
  </head>
  <body>
    <header>
      <div class="navbar navbar-light bg-light shadow-sm">
        <div class="container">
          <a href="{% url 'index' %}" class="navbar-brand d-flex align-items-center">
            <svg class="me-2" width="26" height="16" enable-background="new 0 0 26 26" version="1" viewBox="0 0 26 16" xmlns="http://www.w3.org/2000/svg">
              <path d="m2.8125 0.0010991a1.0001 1.0001 0 0 0-0.8125 1c0 0.55455-0.44545 1-1 1a1.0001 1.0001 0 0 0-1 1v10a1.0001 1.0001 0 0 0 1 1c0.55455 0 1 0.44546 1 1a1.0001 1.0001 0 0 0 1 1h20a1.0001 1.0001 0 0 0 1-1c0-0.55454 0.44546-1 1-1a1.0001 1.0001 0 0 0 1-1v-10a1.0001 1.0001 0 0 0-1-1c-0.55454 0-1-0.44545-1-1a1.0001 1.0001 0 0 0-1-1h-20a1.0001 1.0001 0 0 0-0.09375 0 1.0001 1.0001 0 0 0-0.09375 0zm0.78125 2h14.406v1h2v-1h2.4062c0.30628 0.76906 0.82469 1.2875 1.5938 1.5938v8.8125c-0.76906 0.30628-1.2875 0.82469-1.5938 1.5938h-2.4062v-1h-2v1h-14.406c-0.30628-0.76906-0.82469-1.2875-1.5938-1.5938v-8.8125c0.76906-0.30628 1.2875-0.82469 1.5938-1.5938zm14.406 2v2h2v-2zm0 3v2h2v-2zm0 3v2h2v-2z" enable-background="accumulate" fill="#000" overflow="visible" stroke-width="2" style="text-indent:0;text-transform:none"/>
            </svg>
            <strong>{{ site_conf.site_name }}</strong>
          </a>
        {% include 'includes/login.html' %}
        </div>
      </div>
    </header>
    <main>
      <div class="container py-2">
        <nav class="navbar navbar-expand-lg navbar-light">
          <div class="container-fluid g-0">
              <a class="navbar-brand" href="{% url 'index' %}">Home</a>
            <div class="collapse navbar-collapse" id="navbarSupportedContent">
              <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                <li class="nav-item">
                  <a class="nav-link" href="{% url 'index' %}">Roster</a>
                </li>
                <li class="nav-item">
                  <a class="nav-link" href="{% url 'consists' %}">Consists</a>
                </li>
              </ul>
                    {% include 'includes/search.html' %}
            </div>
          </div>
        </nav>
      </div>
      <section class="py-4 text-center container">
        <div class="row">
          <div class="mx-auto">
            {% block header %}{% endblock %}
          </div>
        </div>
      </section>
      <div class="album py-5 bg-light">
        <div class="container">
          <a id="rolling-stock"></a>
          <div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 g-3">
            {% block cards %}
            {% for r in rolling_stock %}
            <div class="col">
              <div class="card shadow-sm">
                {% for i in r.image.all %}
                {% if i.is_thumbnail %}<a href="{{r.get_absolute_url}}"><img src="{{ i.image.url }}" alt="Card image cap"></a>{% endif %}
                {% endfor %}
                <div class="card-body">
                  <p class="card-text"><strong>{{ r }}</strong></p>
                  {% if r.tags.all %}
                  <p class="card-text"><small>Tags:</small>
                   {% for t in r.tags.all %}<span class="badge bg-primary">
                    {{ t.name }}</span>{# new line is required #}
                    {% endfor %}
                  </p>
                  {% endif %}
                  <table class="table table-striped">
                    <thead>
                      <tr>
                        <th colspan="2" scope="row">Data</th>
                      </tr>
                    </thead>
                    <tbody>
                      <tr>
                        <th width="35%" scope="row">Type</th>
                        <td>{{ r.rolling_class.type }}</td>
                      </tr>
                      <tr>
                        <th scope="row">Company</th>
                        <td><abbr title="{{ r.rolling_class.company.extended_name }}">{{ r.rolling_class.company }}</abbr></td>
                      </tr>
                      <tr>
                        <th scope="row">Class</th>
                        <td>{{ r.rolling_class.identifier }}</td>
                      </tr>
                      <tr>
                        <th scope="row">Road number</th>
                        <td>{{ r.road_number }}</td>
                      </tr>
                      <tr>
                        <th scope="row">Era</th>
                        <td>{{ r.era }}</td>
                      </tr>
                      <tr>
                        <th width="35%" scope="row">Manufacturer</th>
                        <td>{% if r.manufacturer.website %}<a href="{{ r.manufacturer.website }}">{% endif %}{{ r.manufacturer }}{% if r.manufacturer.website %}</a>{% endif %}</th>
                      </tr>
                      <tr>
                        <th scope="row">Scale</th>
                        <td><abbr title="{{ r.scale.ratio }} - {{ r.scale.gauge }}">{{ r.scale }}</abbr></td>
                      </tr>
                      <tr>
                        <th scope="row">SKU</th>
                        <td>{{ r.sku }}</td>
                      </tr>
                    </tbody>
                  </table>
                  {% if r.decoder %}
                  <table class="table table-striped">
                    <thead>
                      <tr>
                        <th colspan="2" scope="row">DCC data</th>
                      </tr>
                    </thead>
                    <tbody>
                      <tr>
                        <th width="35%" scope="row">Decoder</th>
                        <td>{{ r.decoder }}</td>
                      </tr>
                      <tr>
                        <th scope="row">Address</th>
                        <td>{{ r.address }}</td>
                      </tr>
                    </tbody>
                  </table>
                  {% endif %}
                  <div class="btn-group mb-4">
                   <a class="btn btn-sm btn-outline-primary" href="{{r.get_absolute_url}}">Show all data</a>
                    {% if request.user.is_staff %}<a class="btn btn-sm btn-outline-danger" href="{% url 'admin:roster_rollingstock_change' r.pk %}">Edit</a>{% endif %}
                  </div>
                  <div class="d-flex justify-content-between align-items-center">
                    <small class="text-muted">Updated {{ r.updated_time | date:"M d, Y H:m" }}</small>
                  </div>
                </div>
              </div>
            </div>
            {% endfor %}
            {% endblock %}
          </div>
        </div>
        <div class="container">{% block pagination %}{% endblock %}</div>
      </div>
      {% block extra_content %}{% endblock %}
    </main>
    {% include 'includes/footer.html' %}
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/masonry-layout@4.2.2/dist/masonry.pkgd.min.js" integrity="sha384-GNFwBvfVxBkLMJpYMOABq3c+d3KnQxudP/mGPkzpZSTYykLBNsZEnG2D9G/X/+7D" crossorigin="anonymous" async></script>
  </body>
</html>
