@rmdes/indiekit-endpoint-activitypub 2.0.35 → 2.0.36

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/reader.css CHANGED
@@ -752,6 +752,12 @@
752
752
  color: var(--color-green50);
753
753
  }
754
754
 
755
+ .ap-card__action--save.ap-card__action--active {
756
+ background: #4a9eff22;
757
+ border-color: #4a9eff;
758
+ color: #4a9eff;
759
+ }
760
+
755
761
  .ap-card__action:disabled {
756
762
  cursor: wait;
757
763
  opacity: 0.6;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rmdes/indiekit-endpoint-activitypub",
3
- "version": "2.0.35",
3
+ "version": "2.0.36",
4
4
  "description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.",
5
5
  "keywords": [
6
6
  "indiekit",
@@ -151,8 +151,31 @@
151
151
  x-data="{
152
152
  liked: {{ 'true' if isLiked else 'false' }},
153
153
  boosted: {{ 'true' if isBoosted else 'false' }},
154
+ saved: false,
154
155
  loading: false,
155
156
  error: '',
157
+ async saveLater() {
158
+ if (this.saved) return;
159
+ const el = this.$root;
160
+ const itemUrl = el.dataset.itemUrl;
161
+ try {
162
+ const res = await fetch('/readlater/save', {
163
+ method: 'POST',
164
+ headers: { 'Content-Type': 'application/json' },
165
+ body: JSON.stringify({
166
+ url: itemUrl,
167
+ title: el.closest('article')?.querySelector('p')?.textContent?.substring(0, 80) || itemUrl,
168
+ source: 'activitypub'
169
+ }),
170
+ credentials: 'same-origin'
171
+ });
172
+ if (res.ok) this.saved = true;
173
+ else this.error = 'Failed to save';
174
+ } catch (e) {
175
+ this.error = e.message;
176
+ }
177
+ if (this.error) setTimeout(() => this.error = '', 3000);
178
+ },
156
179
  async interact(action) {
157
180
  if (this.loading) return;
158
181
  this.loading = true;
@@ -213,6 +236,16 @@
213
236
  <a href="{{ itemUrl }}" class="ap-card__action ap-card__action--link" target="_blank" rel="noopener">
214
237
  🔗 {{ __("activitypub.reader.actions.viewOriginal") }}
215
238
  </a>
239
+ {% if application.readlaterEndpoint %}
240
+ <button class="ap-card__action ap-card__action--save"
241
+ :class="{ 'ap-card__action--active': saved }"
242
+ :disabled="saved"
243
+ @click="saveLater()"
244
+ :title="saved ? 'Saved' : 'Save for later'">
245
+ <span x-text="saved ? '🔖' : '📑'"></span>
246
+ <span x-text="saved ? 'Saved' : 'Save'"></span>
247
+ </button>
248
+ {% endif %}
216
249
  <div x-show="error" x-text="error" class="ap-card__action-error" x-transition></div>
217
250
  </footer>
218
251
  {# Close moderation content warning wrapper #}