@rmdes/indiekit-endpoint-microsub 1.0.40 → 1.0.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/assets/styles.css CHANGED
@@ -421,6 +421,12 @@
421
421
  margin-left: auto;
422
422
  }
423
423
 
424
+ /* Save for later button */
425
+ .item-actions__save-later--saved {
426
+ color: var(--color-accent, #4a9eff);
427
+ opacity: 0.6;
428
+ }
429
+
424
430
  /* ==========================================================================
425
431
  Single Item View
426
432
  ========================================================================== */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rmdes/indiekit-endpoint-microsub",
3
- "version": "1.0.40",
3
+ "version": "1.0.41",
4
4
  "description": "Microsub endpoint for Indiekit. Enables subscribing to feeds and reading content using the Microsub protocol.",
5
5
  "keywords": [
6
6
  "indiekit",
package/views/channel.njk CHANGED
@@ -173,6 +173,39 @@
173
173
  button.disabled = false;
174
174
  }
175
175
  });
176
+
177
+ // Handle save-for-later buttons
178
+ timeline.addEventListener('click', async (e) => {
179
+ const button = e.target.closest('.item-actions__save-later');
180
+ if (!button) return;
181
+
182
+ e.preventDefault();
183
+ e.stopPropagation();
184
+
185
+ const url = button.dataset.url;
186
+ const title = button.dataset.title;
187
+ if (!url) return;
188
+
189
+ button.disabled = true;
190
+
191
+ try {
192
+ const response = await fetch('/readlater/save', {
193
+ method: 'POST',
194
+ headers: { 'Content-Type': 'application/json' },
195
+ body: JSON.stringify({ url, title: title || url, source: 'microsub' }),
196
+ credentials: 'same-origin'
197
+ });
198
+
199
+ if (response.ok) {
200
+ button.classList.add('item-actions__save-later--saved');
201
+ button.title = 'Saved';
202
+ } else {
203
+ button.disabled = false;
204
+ }
205
+ } catch {
206
+ button.disabled = false;
207
+ }
208
+ });
176
209
  }
177
210
  </script>
178
211
  {% endblock %}
@@ -208,5 +208,16 @@
208
208
  <span class="visually-hidden">Mark read</span>
209
209
  </button>
210
210
  {% endif %}
211
+ {% if application.readlaterEndpoint %}
212
+ <button type="button"
213
+ class="item-actions__button item-actions__save-later"
214
+ data-action="save-later"
215
+ data-url="{{ item.url }}"
216
+ data-title="{{ item.name or '' }}"
217
+ title="Save for later">
218
+ {{ icon("bookmark") }}
219
+ <span class="visually-hidden">Save for later</span>
220
+ </button>
221
+ {% endif %}
211
222
  </div>
212
223
  </article>
@@ -150,6 +150,39 @@
150
150
  button.disabled = false;
151
151
  }
152
152
  });
153
+
154
+ // Handle save-for-later buttons
155
+ timeline.addEventListener('click', async (e) => {
156
+ const button = e.target.closest('.item-actions__save-later');
157
+ if (!button) return;
158
+
159
+ e.preventDefault();
160
+ e.stopPropagation();
161
+
162
+ const url = button.dataset.url;
163
+ const title = button.dataset.title;
164
+ if (!url) return;
165
+
166
+ button.disabled = true;
167
+
168
+ try {
169
+ const response = await fetch('/readlater/save', {
170
+ method: 'POST',
171
+ headers: { 'Content-Type': 'application/json' },
172
+ body: JSON.stringify({ url, title: title || url, source: 'microsub' }),
173
+ credentials: 'same-origin'
174
+ });
175
+
176
+ if (response.ok) {
177
+ button.classList.add('item-actions__save-later--saved');
178
+ button.title = 'Saved';
179
+ } else {
180
+ button.disabled = false;
181
+ }
182
+ } catch {
183
+ button.disabled = false;
184
+ }
185
+ });
153
186
  }
154
187
  </script>
155
188
  {% endblock %}