{% extends "base.html" %}
{% block title %}Feed tokens · tit{% endblock %}
{% block content %}
  <h1>Feed tokens</h1>
  <p>Feed URLs are credentials. A person who has a URL can read its scoped feed.</p>

  <h2>Create token</h2>
  <form method="post" action="/feeds/tokens">
    <input type="hidden" name="csrf" value="{{ csrf }}">
    <button type="submit">Create watched activity RSS token</button>
  </form>

  <h2>Existing tokens</h2>
{% if tokens.is_empty() %}
  <p>You do not have a feed token.</p>
{% else %}
  <ul>
{% for token in tokens %}
    <li>
      <strong>{{ token.scope }}</strong>, created at <time datetime="{{ token.created_at }}">{{ token.created_at|human_time }}</time>.
{% if token.active %}
      <form method="post" action="/feeds/tokens/{{ token.id }}/rotate">
        <input type="hidden" name="csrf" value="{{ csrf }}">
        <fieldset class="confirmation">
          <legend>Rotate this token?</legend>
          <label><input type="radio" name="confirm" value="no" checked> No</label>
          <label><input type="radio" name="confirm" value="yes"> Yes</label>
        </fieldset>
        <button type="submit">Rotate</button>
      </form>
      <form method="post" action="/feeds/tokens/{{ token.id }}/revoke">
        <input type="hidden" name="csrf" value="{{ csrf }}">
        <fieldset class="confirmation">
          <legend>Revoke this token?</legend>
          <label><input type="radio" name="confirm" value="no" checked> No</label>
          <label><input type="radio" name="confirm" value="yes"> Yes</label>
        </fieldset>
        <button type="submit">Revoke</button>
      </form>
{% else %}
      Revoked.
{% endif %}
    </li>
{% endfor %}
  </ul>
{% endif %}
{% endblock %}
