<!--
SPDX-FileCopyrightText: 2022 PeARS Project, <community@pearsproject.org>, 

SPDX-License-Identifier: AGPL-3.0-only
-->

{% extends "base/base.html" %}
{% block body %}
<div class="container">
  <div class="row">
    <div class="col">
      <div class="alert alert-success text-center">
        <b>{{num_entries}} pages recorded</b>
      </div>
    </div>
  </div>
  
  <div class="row p-3">
    <div class="card-group">
      <div class="card">
        <div class="card-header text-center"><b>Index a single URL</b></div>
        <div class="card-body">
          <p>Think you should index your favourite webpage? Enter its URL here! 
          </p>

          <form method="POST" accept-charset="UTF-8" enctype="multipart/form-data"
            action="{{url_for('indexer.from_url')}}">
            <div class="input-group p-2">
              <span class="input-group-text">URL</span>
              <input required type="text" class="form-control" placeholder="Enter a URL" name='url' id='url'>
            </div>
            <div class="input-group p-2">
              <span class="input-group-text">Keyword</span>
              <input class="form-control input-s" title="Enter a keyword." placeholder="Enter a keyword" type="text"
                name='url_keyword' id='url_keyword' required>
            </div>
        </div>
        <div class="card-footer clearfix">
          <span class="input-group-btn float-end">
            <input id="submit_button" type="submit" class="btn btn-success" value="Index URL">
          </span>
        </div>
        </form>
      </div>
    </div>
  </div>


  <div class="row p-3">
    <div class="card-group">
      <div class="card">
        <div class="card-header text-center"><b>Index from a URL list</b></div>
        <div class="card-body">
          <p>This option requires a .txt file containing the URLs you would like to index, with associated keywords.
            Please make sure to follow <a href="{{url_for('pages.return_faq', _anchor='indexfile')}}">the right format</a>.</p>

          <form method="POST" accept-charset="UTF-8" enctype="multipart/form-data"
            action="{{url_for('indexer.from_file')}}">
            <div class="input-group p-2">
              <input required type="file" class="form-control input-s" accept="text/plain" name='file_source'
                id='file_source'>
              {% with messages = get_flashed_messages(category_filter=["text"]) %}
              {% if messages %}
              {% for message in messages %}
              {{message}}
              {% endfor %}
              {% endif %}
              {% endwith %}
            </div>
        </div>
        <div class="card-footer clearfix">
          <span class="input-group-btn float-end">
            <input id="submit_button" type="submit" class="btn btn-success" value="Index file">
          </span>
        </div>
        </form>
    </div>

      <div class="card">
        <div class="card-header text-center"><b>Index from browser bookmarks</b></div>
        <div class="card-body">
          <p>Index from a bookmark export file! Just indicate your bookmarks.html location, and the tag you would like
            to
            index.</p>

          <form method="POST" accept-charset="UTF-8" enctype="multipart/form-data"
            action="{{url_for('indexer.from_bookmarks')}}">
            <div class="input-group p-2">
              <input required type="file" class="form-control input-s" accept="text/html" name='file_source'
                id='bookmark_source'>
              {% with messages = get_flashed_messages(category_filter=["html"]) %}
              {% if messages %}
              {% for message in messages %}
              {{message}}
              {% endfor %}
              {% endif %}
              {% endwith %}
            </div>
            <div class="input-group p-2">
              <span class="input-group-text">Keyword</span>
              <input class="form-control input-s" title="Enter a keyword." placeholder="Enter a keyword" type="text"
                name='bookmark_keyword' id='bookmark_keyword' required>
            </div>
        </div>
        <div class="card-footer clearfix">
          <span class="input-group-btn float-end">
            <input id="submit_button" type="submit" class="btn btn-success" value="Index bookmarks">
          </span>
        </div>
        </form>
      </div>
    </div>

  </div>
</div>

  <div class="row p-3">
    <div class="card-group">
      <div class="card">
        <div class="card-header text-center"><b>Index a document collection</b></div>
        <div class="card-body">
	<p>This option lets you index a local document collection in format &lt;doc&gt;.</p>

          <form method="POST" accept-charset="UTF-8" enctype="multipart/form-data"
            action="{{url_for('indexer.from_docs')}}">
            <div class="input-group p-2">
              <input required type="file" class="form-control input-s" accept="text/plain" name='file_source'
                id='file_source'>
              {% with messages = get_flashed_messages(category_filter=["text"]) %}
              {% if messages %}
              {% for message in messages %}
              {{message}}
              {% endfor %}
              {% endif %}
              {% endwith %}
            </div>
            <div class="input-group p-2">
              <span class="input-group-text">Keyword</span>
              <input class="form-control input-s" title="Enter a keyword." placeholder="Enter a keyword" type="text"
                name='docs_keyword' id='docs_keyword' required>
            </div>
            <div class="input-group p-2">
              <span class="input-group-text">Optional doctype</span>
              <input class="form-control input-s" title="Enter a document type." placeholder="Enter a document type" type="text"
                name='docs_type' id='docs_type'>
            </div>
        </div>

        <div class="card-footer clearfix">
          <span class="input-group-btn float-end">
            <input id="submit_button" type="submit" class="btn btn-success" value="Index local file">
          </span>
        </div>
        </form>
    </div>

      <div class="card">
        <div class="card-header text-center"><b>Index a CSV file</b></div>
        <div class="card-body">
          <p>Index a local CSV file.
          </p>

          <form method="POST" accept-charset="UTF-8" enctype="multipart/form-data"
            action="{{url_for('indexer.from_csv')}}">
            <div class="input-group p-2">
              <input required type="file" class="form-control input-s" accept=".csv" name='file_source'
                id='file_source'>
              {% with messages = get_flashed_messages(category_filter=["all"]) %}
              {% if messages %}
              {% for message in messages %}
              {{message}}
              {% endfor %}
              {% endif %}
              {% endwith %}
            </div>
            <div class="input-group p-2">
              <span class="input-group-text">Keyword</span>
              <input class="form-control input-s" title="Enter a keyword." placeholder="Enter a keyword" type="text"
                name='csv_keyword' id='csv_keyword' required>
            </div>
            <div class="input-group p-2">
              <span class="input-group-text">Optional doctype</span>
              <input class="form-control input-s" title="Enter a document type." placeholder="Enter a document type" type="text"
                name='docs_type' id='docs_type'>
            </div>
        </div>
        <div class="card-footer clearfix">
          <span class="input-group-btn float-end">
            <input id="submit_button" type="submit" class="btn btn-success" value="Index CSV">
          </span>
        </div>
        </form>
      </div>
    </div>
  </div>

</div><!-- /.container -->
{% endblock %}
