{% extends "base.html" %}

{% block title %}Link '{{ title }}' in '{{ hit_title }}'{% endblock %}

{% block style %}
<link href="{{ url_for("static", filename="css/diff.css") }}" rel="stylesheet"/>
{% endblock %}

{% block content %}
  <div class="container">
    <h1>Link '{{ title }}' in '{{ hit_title }}'</h1>
    <form action="{{ url_for("index") }}">
      <input name="q">
      <input type="submit" value="search">
    </form>

    <div>Username: {{ g.user }}</div>

    <div><a href="https://en.wikipedia.org/wiki/{{ title }}" target="_blank">view article</a></div>

    <div><a href="{{ url_for('index') }}">back to index </a></div>

    <div>total: {{ total }}</div>
    <div>with link: {{ with_link }}</div>
    <div>ratio: {{ "{:.1%}".format(with_link / total) }}</div>
    {# <div>hit: {{ hit }}</div> #}
    <div>replacement: {{ found.replacement }}</div>
    <div>section: {{ found.section }}</div>
    <table>
      {{ diff | safe }}
    </table>
    <form method="POST">
      <input type="hidden" name="hit" value="{{ hit_title }}">
      <div class="my-3">
        <input type="submit" class="btn btn-primary" value="save"/>
        <a href="{{url_for("article_page", url_title=url_title, after=hit_title)}}" class="btn btn-primary">skip</a>
      </div>
    </form>

    <ol>
    {% for hit in hits %}
      {% set url = url_for("article_page", url_title=url_title, title=hit.title) %}
      <li><a href="{{ url }}">{{ hit.title }}</a> &ndash; {{ hit.snippet | safe }}</li>
    {% endfor %}
    </ol>
  </div>
{% endblock %}