{% 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 }}">
    <div class="field">
      <label for="feed-scope">Scope</label>
      <select id="feed-scope" name="scope">
        <option value="watched">Watched activity</option>
        <option value="assignments">Assignments</option>
        <option value="mentions">Mentions</option>
        <option value="repository">One repository</option>
      </select>
    </div>
    <div class="field">
      <label for="feed-owner">Repository owner</label>
      <input id="feed-owner" name="owner" autocomplete="off" autocapitalize="none" spellcheck="false">
    </div>
    <div class="field">
      <label for="feed-repository">Repository name</label>
      <input id="feed-repository" name="repository" autocomplete="off" autocapitalize="none" spellcheck="false">
    </div>
    <p>Supply the owner and repository name only for a one-repository token.</p>
    <button type="submit">Create feed 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> for {{ token.target }}, created at {{ token.created_at }}.
{% if token.active %}
      <form method="post" action="/feeds/tokens/{{ token.id }}/rotate">
        <input type="hidden" name="csrf" value="{{ csrf }}">
        <button type="submit">Rotate</button>
      </form>
      <form method="post" action="/feeds/tokens/{{ token.id }}/revoke">
        <input type="hidden" name="csrf" value="{{ csrf }}">
        <button type="submit">Revoke</button>
      </form>
{% else %}
      Revoked.
{% endif %}
    </li>
{% endfor %}
  </ul>
{% endif %}
{% endblock %}
