diff --git a/assets/styles.css b/assets/styles.css
index 52bc98c..bfbe20b 100644
--- a/assets/styles.css
+++ b/assets/styles.css
@@ -421,6 +421,12 @@
margin-left: auto;
}
+/* Save for later button */
+.item-actions__save-later--saved {
+ color: var(--color-accent, #4a9eff);
+ opacity: 0.6;
+}
+
/* ==========================================================================
Single Item View
========================================================================== */
diff --git a/package.json b/package.json
index cc7276b..b5761ff 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@rmdes/indiekit-endpoint-microsub",
- "version": "1.0.40",
+ "version": "1.0.41",
"description": "Microsub endpoint for Indiekit. Enables subscribing to feeds and reading content using the Microsub protocol.",
"keywords": [
"indiekit",
diff --git a/views/channel.njk b/views/channel.njk
index b666e65..0aa3e27 100644
--- a/views/channel.njk
+++ b/views/channel.njk
@@ -173,6 +173,39 @@
button.disabled = false;
}
});
+
+ // Handle save-for-later buttons
+ timeline.addEventListener('click', async (e) => {
+ const button = e.target.closest('.item-actions__save-later');
+ if (!button) return;
+
+ e.preventDefault();
+ e.stopPropagation();
+
+ const url = button.dataset.url;
+ const title = button.dataset.title;
+ if (!url) return;
+
+ button.disabled = true;
+
+ try {
+ const response = await fetch('/readlater/save', {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ url, title: title || url, source: 'microsub' }),
+ credentials: 'same-origin'
+ });
+
+ if (response.ok) {
+ button.classList.add('item-actions__save-later--saved');
+ button.title = 'Saved';
+ } else {
+ button.disabled = false;
+ }
+ } catch {
+ button.disabled = false;
+ }
+ });
}
{% endblock %}
diff --git a/views/partials/item-card.njk b/views/partials/item-card.njk
index a8e98f1..f21c1bd 100644
--- a/views/partials/item-card.njk
+++ b/views/partials/item-card.njk
@@ -208,5 +208,16 @@
Mark read
{% endif %}
+ {% if application.readlaterEndpoint %}
+
+ {% endif %}
diff --git a/views/timeline.njk b/views/timeline.njk
index c32cb7f..4b0a83a 100644
--- a/views/timeline.njk
+++ b/views/timeline.njk
@@ -150,6 +150,39 @@
button.disabled = false;
}
});
+
+ // Handle save-for-later buttons
+ timeline.addEventListener('click', async (e) => {
+ const button = e.target.closest('.item-actions__save-later');
+ if (!button) return;
+
+ e.preventDefault();
+ e.stopPropagation();
+
+ const url = button.dataset.url;
+ const title = button.dataset.title;
+ if (!url) return;
+
+ button.disabled = true;
+
+ try {
+ const response = await fetch('/readlater/save', {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ url, title: title || url, source: 'microsub' }),
+ credentials: 'same-origin'
+ });
+
+ if (response.ok) {
+ button.classList.add('item-actions__save-later--saved');
+ button.title = 'Saved';
+ } else {
+ button.disabled = false;
+ }
+ } catch {
+ button.disabled = false;
+ }
+ });
}
{% endblock %}