{% extends "_root.html" %}

{% block content %}
<h2>Received Webmentions</h2>

{% if webmentions %}
<table>
	<thead>
		<tr>
			<th>Timestamp</th>
			<th>Source</th>
			<th>Target</th>
			<th>Vouch</th>
			<th>Status</th>
		</tr>
	</thead>
	<tbody>
		{% for webmention in webmentions %}
		<tr>
			<td>{{ webmention.timestamp }}</td>
			<td><a href="{{ webmention.source }}" target="_blank">{{ webmention.source }}</a></td>
			<td><a href="{{ webmention.target }}" target="_blank">{{ webmention.target }}</a></td>
			<td>
				{% if webmention.vouch %}
				<a href="{{ webmention.vouch }}" target="_blank">{{ webmention.vouch }}</a>
				{% else %}
				<em>None</em>
				{% endif %}
			</td>
			<td>{{ webmention.status }}</td>
		</tr>
		{% endfor %}
	</tbody>
</table>
{% else %}
<p>No webmentions received yet.</p>
{% endif %}

<h2>Send a Test Webmention</h2>
<p>Use curl to test the server:</p>

<h3>From Approved Authority (will be accepted)</h3>
<pre class="copyable"><code>curl -X POST http://localhost:8081/webmention \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "source=https://aaronparecki.com/notes/2024/01/01/1&target=http://localhost:8081/post/1"</code></pre>

<h3>From Unapproved Authority (will return 449)</h3>
<pre class="copyable"><code>curl -X POST http://localhost:8081/webmention \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "source=https://unknown-site.com/post/1&target=http://localhost:8081/post/1"</code></pre>

<h3>From Unapproved Authority with Vouch (will be rejected in example)</h3>
<pre class="copyable"><code>curl -X POST http://localhost:8081/webmention \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "source=https://unknown-site.com/post/1&target=http://localhost:8081/post/1&vouch=https://aaronparecki.com/notes/2024/01/01/1"</code></pre>

<p><strong>Note:</strong> This example server uses AlwaysAllow for domain approval, so all authorities are approved. In a real implementation, you would check against a list of approved domains.</p>
{% endblock %}