{% extends "documents/base.html" %}

{% load i18n %}
{% load documents book_list wall %}
{% load pipeline %}

{% block add_js %}
  {% javascript 'book_list' %}
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-contextmenu/2.7.1/jquery.contextMenu.min.js"></script>
{% endblock %}

{% block add_css %}
  {% stylesheet 'book_list' %}
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-contextmenu/2.7.1/jquery.contextMenu.min.css">
{% endblock %}

{% block titleextra %}{% trans "My page" %}{% endblock %}


{% block leftcolumn %}
    {% book_list request.user %}
{% endblock leftcolumn %}

{% block rightcolumn %}
  <div class="card mb-4">
    <div class="card-header">
      <h2>Konto WL</h2>
    </div>
    <div class="card-body">
      {% if wllogin %}
        <p>
          Podłączone konto na Wolnych Lekturach:
          <strong>{{ wllogin }}</strong>
        </p>
        <form method="post" action="{% url 'apiclient_disconnect' %}">
          {% csrf_token %}
          <button class="btn btn-danger">
            Odłącz
          </button>
        </form>
      {% else %}
        <form method="post" action="{% url 'apiclient_oauth' %}">
          {% csrf_token %}
          <button class="btn btn-primary">
            Podłącz konto
          </button>
        </form>
      {% endif %}
    </div>
  </div>

  <div class="card">
	<div class="card-header">
        <h2>{% trans "Your last edited documents" %}</h2>
	</div>
	<div class="card-body">
        <ol>
            {% for edit_url, item in last_books %}
                <li><a
                {% if edit_url|length == 2 %}
                    {# Temporary support for old-style last_books. #}
                    href="{% url 'wiki_editor' edit_url.0 edit_url.1 %}"
                {% else %}
                    href="{{ edit_url }}"
                {% endif %}
                target="_blank">{{ item.title }}</a><br/><span class="date">({{ item.time|date:"H:i:s, d/m/Y" }})</span></li>
            {% endfor %}
        </ol>
    </div>
</div>

<div class="card mt-4">
	<div class="card-header">
    <h2>{% trans "Recent activity for" %} {{ request.user|nice_name }}</h2>
	</div>
	<div class="card-body">
    {% wall request.user 10 %}
	</div></div>
{% endblock rightcolumn %}
