diff --git a/assets/reader.css b/assets/reader.css index 6ceb5e8..1b688e2 100644 --- a/assets/reader.css +++ b/assets/reader.css @@ -752,6 +752,12 @@ color: var(--color-green50); } +.ap-card__action--save.ap-card__action--active { + background: #4a9eff22; + border-color: #4a9eff; + color: #4a9eff; +} + .ap-card__action:disabled { cursor: wait; opacity: 0.6; diff --git a/package.json b/package.json index 8ab61b7..b3d8eb9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rmdes/indiekit-endpoint-activitypub", - "version": "2.0.35", + "version": "2.0.36", "description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.", "keywords": [ "indiekit", diff --git a/views/partials/ap-item-card.njk b/views/partials/ap-item-card.njk index 3c41e19..ed9e2b9 100644 --- a/views/partials/ap-item-card.njk +++ b/views/partials/ap-item-card.njk @@ -151,8 +151,31 @@ x-data="{ liked: {{ 'true' if isLiked else 'false' }}, boosted: {{ 'true' if isBoosted else 'false' }}, + saved: false, loading: false, error: '', + async saveLater() { + if (this.saved) return; + const el = this.$root; + const itemUrl = el.dataset.itemUrl; + try { + const res = await fetch('/readlater/save', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + url: itemUrl, + title: el.closest('article')?.querySelector('p')?.textContent?.substring(0, 80) || itemUrl, + source: 'activitypub' + }), + credentials: 'same-origin' + }); + if (res.ok) this.saved = true; + else this.error = 'Failed to save'; + } catch (e) { + this.error = e.message; + } + if (this.error) setTimeout(() => this.error = '', 3000); + }, async interact(action) { if (this.loading) return; this.loading = true; @@ -213,6 +236,16 @@ 🔗 {{ __("activitypub.reader.actions.viewOriginal") }} + {% if application.readlaterEndpoint %} + + {% endif %}
{# Close moderation content warning wrapper #}