{% extends "base.html" %}
{% block title %}Semiphemeral Settings{% endblock %}
{% block header_text %}Semiphemeral Settings{% endblock %}
{% block content %}

<div class="settings">
  <form method="post" action="{{ url_for('edit_settings') }}">

    <h3>Twitter settings</h3>

    <p>See <a href="https://python-twitter.readthedocs.io/en/latest/getting_started.html">here</a> for documentation on how to get these Twitter API credentials.</p>

    <ul>
      <li>
        <label for="api_key">API key</label>
        <input type="text" name="api_key" value="{{ api_key }}" \>
      </li>
      <li>
        <label for="api_secret">API secret</label>
        <input type="text" name="api_secret" value="{{ api_secret }}" \>
      </li>
      <li>
        <label for="access_token_key">Access token key</label>
        <input type="text" name="access_token_key" value="{{ access_token_key }}" \>
      </li>
      <li>
        <label for="access_token_secret">Access token secret</label>
        <input type="text" name="access_token_secret" value="{{ access_token_secret }}" \>
      </li>
      <li>
        <label for="username">Twitter username</label>
        <input type="text" name="username" value="{{ username }}" \>
      </li>
    </ul>
    
    <p>
      <label class="checkbox">
        <input type="checkbox" class="log-to-file-checkbox" name="log_to_file" {%if log_to_file %}checked="checked" {% endif %} />
        Log events (last_fetch, deleted tweets/RTs/favorites) to a file
      </label>
    </p>
    <fieldset class="log-to-file-fieldset">
      <legend>Logging</legend>
      <p>
        <label for="log_filename">Log file name: </label>
        <input type="text" name="log_filename" value="{{ log_filename }}" \ />
      </p>
      <p>
        <label for="log_format">Log format: </label>
        <input type="text" name="log_format" value="{{ log_format }}" \ />
      </p>
    </fieldset>

    <p>
      <label class="checkbox">
        <input type="checkbox" class="delete-tweets-checkbox" name="delete_tweets" {% if delete_tweets %}checked="checked"{% endif %} />
        Delete old tweets
      </label>
    </p>
    <fieldset class="delete-tweets-fieldset">
      <legend>Tweets</legend>
      <p>
        Delete tweets older than
        <input class="small" type="number" min="0"  name="tweets_days_threshold" value="{{ tweets_days_threshold }}" \>
        days
      </p>
      <p>
        Unless they have at least
        <input class="small" type="number" min="0"  name="tweets_retweet_threshold" value="{{ tweets_retweet_threshold }}" \>
        retweets
      </p>
      <p>
        Or at least
        <input class="small" type="number" min="0"  name="tweets_like_threshold" value="{{ tweets_like_threshold }}" \>
        likes
      </p>
      <p>
        <label class="checkbox">
          <input type="checkbox" name="tweets_threads_threshold" {% if tweets_threads_threshold %}checked="checked"{% endif %} />
          Don't delete tweets that are part of a thread that contains at least one tweet that meets these thresholds
        </label>
      </p>
    </fieldset>

    <p>
      <label class="checkbox">
        <input type="checkbox" class="retweets-likes-checkbox" name="retweets_likes" {% if retweets_likes %}checked="checked"{% endif %} />
        Unretweet and unlike old tweets
      </label>
    </p>

    <fieldset class="retweets-likes-fieldset">
      <legend>Retweets and likes</legend>

      <p>
        <label class="checkbox">
          <input type="checkbox" name="retweets_likes_delete_retweets" {% if retweets_likes_delete_retweets %}checked="checked"{% endif %} />
          Unretweet tweets
        </label>
        older than
        <input class="small" type="number" min="0"  name="retweets_likes_retweets_threshold" value="{{ retweets_likes_retweets_threshold }}" \>
        days
      </p>

      <p>
        <label class="checkbox">
          <input type="checkbox" name="retweets_likes_delete_likes" {% if retweets_likes_delete_likes %}checked="checked"{% endif %} />
          Unlike tweets
        </label>
        older than
        <input class="small" type="number" min="0"  name="retweets_likes_likes_threshold" value="{{ retweets_likes_likes_threshold }}" \>
        days
      </p>

    </fieldset>

    <p><input type="submit" value="Save" /></p>

  </form>
</div>

<script src="/static/js/settings.js"></script>
{% endblock %}
