aboutsummaryrefslogtreecommitdiff
path: root/webmentions_ssg/templates/received.html
blob: 2edf8818adc2b67fa0515b3327c96e5b5eb02301 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<!--
SPDX-FileCopyrightText: 2026 Dennis Fink <me+coding@dennisfink.me>

SPDX-License-Identifier: BSD-3-Clause
-->
{% extends "base.html" %}

{% from "bootstrap5/pagination.html" import render_pagination %}
{% set received_status_presentation = {
  "received": {
    "row_class": "table-info",
    "badge_class": "text-bg-info",
    "label": "Pending"
  },
  "verifying": {
    "row_class": "table-warning",
    "badge_class": "text-bg-warning",
    "label": "Verifying"
  },
  "verified": {
    "row_class": "table-success",
    "badge_class": "text-bg-success",
    "label": "Verified"
  },
  "failed": {
    "row_class": "table-danger",
    "badge_class": "text-bg-danger",
    "label": "Declined"
  },
  "source_removed": {
    "row_class": "table-danger",
    "badge_class": "text-bg-danger",
    "label": "Declined"
  }
} %}

{% macro sortable_header(label, column, responsive_class="") %}
  {% set active = sort_key == column %}
  <th scope="col"
      class="{{ responsive_class }}"
      aria-sort="{{ ('ascending' if sort_order == 'asc' else 'descending') if active else 'none' }}">
    <a href="{{ sort_urls[column] }}"
       class="link-body-emphasis text-decoration-none">
      {{ label }}
      {% if active %}<span aria-hidden="true">{{ "↑" if sort_order == "asc" else "↓" }}</span>{% endif %}
    </a>
  </th>
{% endmacro %}

{% block content %}
  <div class="d-flex justify-content-between align-items-center mb-3">
    <h1 class="mb-0">Received Webmentions</h1>
    <span class="text-body-secondary">{{ webmentions.total }} total</span>
  </div>
  <form action="{{ url_for('webmentions.received_list') }}"
        method="get"
        class="row g-2 align-items-end mb-4"
        role="search">
    <input id="sort" name="sort" type="hidden" value="{{ sort_key }}">
    <input id="order" name="order" type="hidden" value="{{ sort_order }}">
    <div class="col-sm-6 col-lg">
      <label class="form-label" for="status">Status</label>
      <select class="form-select" id="status" name="status">
        {% for value, label in status_choices.items() %}
          <option value="{{ value }}"
                  {% if filters.get("status", "") == value %} selected{% endif %}>{{ label }}</option>
        {% endfor %}
      </select>
    </div>
    <div class="col-sm-6 col-lg">
      <label class="form-label" for="q">Source or target</label>
      <input class="form-control"
             id="q"
             name="q"
             type="search"
             value="{{ filters.get('q', '') }}"
             placeholder="Search URLs">
    </div>
    <div class="col-sm-6 col-lg">
      <label class="form-label" for="date_from">Updated from (UTC)</label>
      <input class="form-control"
             id="date_from"
             name="date_from"
             type="date"
             value="{{ filters.get('date_from', '') }}">
    </div>
    <div class="col-sm-6 col-lg">
      <label class="form-label" for="date_to">Updated to (UTC)</label>
      <input class="form-control"
             id="date_to"
             name="date_to"
             type="date"
             value="{{ filters.get('date_to', '') }}">
    </div>
    <div class="col-sm-6 col-lg-auto">
      <label class="form-label" for="per_page">Rows per page</label>
      <input class="form-control"
             id="per_page"
             name="per_page"
             type="number"
             value="{{ page_size }}"
             min="1"
             max="{{ max_received_page_size }}"
             step="1">
    </div>
    <div class="col-auto d-flex gap-2 ms-auto">
      <button type="submit" class="btn btn-primary">Filter</button>
      <a href="{{ url_for('webmentions.received_list') }}"
         class="btn btn-outline-secondary">Clear</a>
    </div>
  </form>
  <div class="d-flex flex-wrap align-items-center gap-2 mb-3"
       aria-label="Received Webmention actions">
    {% if webmentions.items %}
      <span id="received-selected-count"
            class="text-body-secondary d-none d-md-inline"
            role="status"
            aria-live="polite">0 selected</span>
      <button type="button"
              class="btn btn-sm btn-outline-primary d-none d-md-inline-block"
              disabled
              data-bs-toggle="modal"
              data-bs-target="#confirmation-modal"
              data-received-bulk-action="reverify"
              data-action="{{ url_for('webmentions.reverify_selected_received_webmentions', page=webmentions.page, **filters) }}"
              data-title="Reverify selected webmentions?"
              data-message="All selected webmentions will be fetched and verified again."
              data-confirm-label="Reverify selected"
              data-confirm-class="btn-primary">Reverify selected</button>
      <button type="button"
              class="btn btn-sm btn-outline-warning d-none d-md-inline-block"
              disabled
              data-bs-toggle="modal"
              data-bs-target="#confirmation-modal"
              data-received-bulk-action="block-sources"
              data-action="{{ url_for('webmentions.block_selected_received_sources', page=webmentions.page, **filters) }}"
              data-title="Block selected source domains?"
              data-message="Selected source domains and their subdomains will be blocked from future Webmentions. Existing Webmentions will be kept."
              data-confirm-label="Block selected domains"
              data-confirm-class="btn-warning">Block selected source domains</button>
      <button type="button"
              class="btn btn-sm btn-outline-danger d-none d-md-inline-block"
              disabled
              data-bs-toggle="modal"
              data-bs-target="#confirmation-modal"
              data-received-bulk-action="delete"
              data-action="{{ url_for('webmentions.delete_selected_received_webmentions', page=webmentions.page, **filters) }}"
              data-title="Delete selected webmentions?"
              data-message="This permanently deletes all selected webmentions and cannot be undone."
              data-confirm-label="Delete selected"
              data-confirm-class="btn-danger">Delete selected</button>
    {% endif %}
    <button type="button"
            class="btn btn-sm btn-danger ms-auto"
            data-bs-toggle="modal"
            data-bs-target="#confirmation-modal"
            data-action="{{ url_for('webmentions.delete_all_declined_received_webmentions', page=webmentions.page, **filters) }}"
            data-title="Delete all declined webmentions?"
            data-message="This permanently deletes all declined webmentions across every page, without waiting for automatic retention, regardless of the current filters. This cannot be undone."
            data-confirm-label="Delete all declined"
            data-confirm-class="btn-danger">Delete all declined</button>
  </div>
  {% if webmentions.items %}
    <div class="table-responsive">
      <table class="table table-bordered table-striped table-hover align-middle">
        <thead>
          <tr>
            <th scope="col" class="d-none d-md-table-cell">
              <input type="checkbox"
                     class="form-check-input"
                     id="received-select-all"
                     aria-label="Select all Webmentions on this page">
            </th>
            {{ sortable_header('Status', 'status') }}
            {{ sortable_header('Source', 'source') }}
            {{ sortable_header('Target', 'target', 'd-none d-md-table-cell') }}
            {{ sortable_header('Received', 'received', 'd-none d-md-table-cell') }}
            {{ sortable_header('Updated', 'updated', 'd-none d-md-table-cell') }}
            <th scope="col">Details</th>
          </tr>
        </thead>
        <tbody>
          {% for webmention in webmentions %}
            {% set style = received_status_presentation.get(webmention.status, {"row_class": "table-danger", "badge_class": "text-bg-danger", "label": "Declined"}) %}
            <tr class="{{ style.row_class }}">
              <td class="d-none d-md-table-cell">
                <input type="checkbox"
                       class="form-check-input received-select"
                       value="{{ webmention.uuid }}"
                       aria-label="Select webmention {{ webmention.uuid }}">
              </td>
              <td><span class="badge {{ style.badge_class }}">{{ style.label }}</span></td>
              <td class="text-break">
                <a href="{{ webmention.source }}">{{ webmention.source }}</a>
                <div class="small mt-1 d-md-none">
                  Received
                  <time datetime="{{ webmention.created_at.isoformat() }}">
                    {{ webmention.created_at.strftime("%Y-%m-%d %H:%M:%S") }}
                  </time>
                </div>
              </td>
              <td class="d-none d-md-table-cell text-break">
                <a href="{{ webmention.target }}">{{ webmention.target }}</a>
              </td>
              <td class="text-nowrap d-none d-md-table-cell">
                <time datetime="{{ webmention.created_at.isoformat() }}"
                      title="{{ webmention.created_at.strftime('%Y-%m-%d %H:%M:%S') }} UTC">
                  {{ webmention.created_at.strftime("%Y-%m-%d %H:%M:%S") }}
                </time>
              </td>
              <td class="text-nowrap d-none d-md-table-cell">
                <time datetime="{{ webmention.updated_at.isoformat() }}"
                      title="{{ webmention.updated_at.strftime('%Y-%m-%d %H:%M:%S') }} UTC">
                  {{ webmention.updated_at.strftime("%Y-%m-%d %H:%M:%S") }}
                </time>
              </td>
              <td>
                <a class="btn btn-sm btn-primary"
                   href="{{ url_for('webmentions.received_detail', webmention_uuid=webmention.uuid, page=webmentions.page, **filters) }}"
                   aria-label="Details for Webmention {{ webmention.uuid }}">Details</a>
              </td>
            </tr>
          {% endfor %}
        </tbody>
      </table>
    </div>
    {% if webmentions.pages > 1 %}
      <div class="mt-3">{{ render_pagination(webmentions, args=filters) }}</div>
    {% endif %}
  {% else %}
    {% if filters %}
      <p class="text-body-secondary">No Webmentions match these filters.</p>
    {% else %}
      <p class="text-body-secondary">No Webmentions have been received yet.</p>
    {% endif %}
  {% endif %}
  {% include "includes/confirmation_modal.html" %}
{% endblock %}

{% block scripts %}
  {{ super() }}
  <script src="{{ url_for('static', filename='js/confirmation-modal.js') }}"></script>
  <script src="{{ url_for('static', filename='js/received-bulk-actions.js') }}"></script>
{% endblock %}