{#
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#}

{% extends "base.html.twig" %}

{% block content %}

<h3>Books</h3>
<a href="/books/add" class="btn btn-success btn-sm">
  <i class="glyphicon glyphicon-plus"></i>
  Add book
</a>

{% for book in books %}
<div class="media">
  <a href="/books/{{book.id}}">
    <div class="media-left">
      {% if book.image_url %}
        <img src="{{book.image_url}}">
      {% else %}
        <img src="http://placekitten.com/g/128/192">
      {% endif %}
    </div>
    <div class="media-body">
      <h4>{{book.title}}</h4>
      <p>{{book.author}}</p>
    </div>
  </a>
</div>
{% else %}
<p>No books found</p>
{% endfor %}

{% if next_page_token %}
<nav>
  <ul class="pager">
    <li><a href="?page_token={{next_page_token}}">More</a></li>
  </ul>
</nav>
{% endif %}

{% endblock %}
