@rmdes/indiekit-endpoint-activitypub 1.1.12 → 1.1.14
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/README.md +267 -0
- package/assets/reader-links.css +151 -0
- package/assets/reader-links.js +88 -0
- package/index.js +2 -0
- package/lib/controllers/post-detail.js +300 -0
- package/lib/controllers/reader.js +2 -0
- package/lib/inbox-listeners.js +9 -0
- package/lib/lookup-cache.js +38 -0
- package/lib/og-unfurl.js +250 -0
- package/lib/storage/timeline.js +10 -0
- package/locales/en.json +13 -0
- package/package.json +3 -2
- package/views/activitypub-post-detail.njk +61 -0
- package/views/activitypub-reader.njk +1 -1
- package/views/activitypub-remote-profile.njk +2 -1
- package/views/layouts/ap-reader.njk +4 -0
- package/views/partials/ap-item-card.njk +10 -3
- package/views/partials/ap-link-preview.njk +34 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{% extends "layouts/ap-reader.njk" %}
|
|
2
|
+
|
|
3
|
+
{% from "heading/macro.njk" import heading with context %}
|
|
4
|
+
|
|
5
|
+
{% block readercontent %}
|
|
6
|
+
{{ heading({
|
|
7
|
+
text: title,
|
|
8
|
+
level: 1,
|
|
9
|
+
parent: { text: __("activitypub.reader.title"), href: mountPath + "/admin/reader" }
|
|
10
|
+
}) }}
|
|
11
|
+
|
|
12
|
+
<div class="ap-post-detail" data-mount-path="{{ mountPath }}">
|
|
13
|
+
{# Back button #}
|
|
14
|
+
<div class="ap-post-detail__back">
|
|
15
|
+
<a href="{{ mountPath }}/admin/reader" class="ap-post-detail__back-link">
|
|
16
|
+
← {{ __("activitypub.reader.post.back") }}
|
|
17
|
+
</a>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
{% if notFound %}
|
|
21
|
+
{# Post not found — show message with external link #}
|
|
22
|
+
<div class="ap-post-detail__not-found">
|
|
23
|
+
<p>{{ __("activitypub.reader.post.notFound") }}</p>
|
|
24
|
+
{% if objectUrl %}
|
|
25
|
+
<p><a href="{{ objectUrl }}" target="_blank" rel="noopener noreferrer">{{ __("activitypub.reader.post.openExternal") }} →</a></p>
|
|
26
|
+
{% endif %}
|
|
27
|
+
</div>
|
|
28
|
+
{% else %}
|
|
29
|
+
{# Parent posts (thread context above main post) #}
|
|
30
|
+
{% if parentPosts and parentPosts.length > 0 %}
|
|
31
|
+
<div class="ap-post-detail__parents">
|
|
32
|
+
<h2 class="ap-post-detail__section-title">{{ __("activitypub.reader.post.parentPosts") }}</h2>
|
|
33
|
+
{% for parentItem in parentPosts %}
|
|
34
|
+
{% set item = parentItem %}
|
|
35
|
+
<div class="ap-post-detail__parent-item">
|
|
36
|
+
{% include "partials/ap-item-card.njk" %}
|
|
37
|
+
</div>
|
|
38
|
+
{% endfor %}
|
|
39
|
+
</div>
|
|
40
|
+
{% endif %}
|
|
41
|
+
|
|
42
|
+
{# Main post #}
|
|
43
|
+
<div class="ap-post-detail__main">
|
|
44
|
+
{% include "partials/ap-item-card.njk" %}
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
{# Replies (below main post) #}
|
|
48
|
+
{% if replyPosts and replyPosts.length > 0 %}
|
|
49
|
+
<div class="ap-post-detail__replies">
|
|
50
|
+
<h2 class="ap-post-detail__section-title">{{ __("activitypub.reader.post.replies") }}</h2>
|
|
51
|
+
{% for replyItem in replyPosts %}
|
|
52
|
+
{% set item = replyItem %}
|
|
53
|
+
<div class="ap-post-detail__reply-item">
|
|
54
|
+
{% include "partials/ap-item-card.njk" %}
|
|
55
|
+
</div>
|
|
56
|
+
{% endfor %}
|
|
57
|
+
</div>
|
|
58
|
+
{% endif %}
|
|
59
|
+
{% endif %}
|
|
60
|
+
</div>
|
|
61
|
+
{% endblock %}
|
|
@@ -46,7 +46,8 @@
|
|
|
46
46
|
<div class="ap-profile__info">
|
|
47
47
|
<div class="ap-profile__avatar-wrap">
|
|
48
48
|
{% if icon %}
|
|
49
|
-
<img src="{{ icon }}" alt="{{ name }}" class="ap-profile__avatar"
|
|
49
|
+
<img src="{{ icon }}" alt="{{ name }}" class="ap-profile__avatar"
|
|
50
|
+
onerror="this.replaceWith(Object.assign(document.createElement('div'),{className:'ap-profile__avatar ap-profile__avatar--placeholder',textContent:'{{ name[0] }}'}))">
|
|
50
51
|
{% else %}
|
|
51
52
|
<div class="ap-profile__avatar ap-profile__avatar--placeholder">{{ name[0] }}</div>
|
|
52
53
|
{% endif %}
|
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
|
|
7
7
|
{# Reader stylesheet — loaded in body is fine for modern browsers #}
|
|
8
8
|
<link rel="stylesheet" href="/assets/@rmdes-indiekit-endpoint-activitypub/reader.css">
|
|
9
|
+
<link rel="stylesheet" href="/assets/@rmdes-indiekit-endpoint-activitypub/reader-links.css">
|
|
10
|
+
|
|
11
|
+
{# AP link interception for internal navigation #}
|
|
12
|
+
<script defer src="/assets/@rmdes-indiekit-endpoint-activitypub/reader-links.js"></script>
|
|
9
13
|
|
|
10
14
|
{% block readercontent %}
|
|
11
15
|
{% endblock %}
|
|
@@ -17,14 +17,15 @@
|
|
|
17
17
|
{# Reply context if this is a reply #}
|
|
18
18
|
{% if item.inReplyTo %}
|
|
19
19
|
<div class="ap-card__reply-to">
|
|
20
|
-
↩ {{ __("activitypub.reader.replyingTo") }} <a href="{{ item.inReplyTo }}">{{ item.inReplyTo }}</a>
|
|
20
|
+
↩ {{ __("activitypub.reader.replyingTo") }} <a href="{{ mountPath }}/admin/reader/post?url={{ item.inReplyTo | urlencode }}">{{ item.inReplyTo }}</a>
|
|
21
21
|
</div>
|
|
22
22
|
{% endif %}
|
|
23
23
|
|
|
24
24
|
{# Author header #}
|
|
25
25
|
<header class="ap-card__author">
|
|
26
26
|
{% if item.author.photo %}
|
|
27
|
-
<img src="{{ item.author.photo }}" alt="{{ item.author.name }}" class="ap-card__avatar"
|
|
27
|
+
<img src="{{ item.author.photo }}" alt="{{ item.author.name }}" class="ap-card__avatar"
|
|
28
|
+
onerror="this.replaceWith(Object.assign(document.createElement('span'),{className:'ap-card__avatar ap-card__avatar--default',textContent:'{{ item.author.name[0] | upper if item.author.name else "?" }}'}))">
|
|
28
29
|
{% else %}
|
|
29
30
|
<span class="ap-card__avatar ap-card__avatar--default" aria-hidden="true">{{ item.author.name[0] | upper if item.author.name else "?" }}</span>
|
|
30
31
|
{% endif %}
|
|
@@ -50,7 +51,7 @@
|
|
|
50
51
|
{# Post title (articles only) #}
|
|
51
52
|
{% if item.name %}
|
|
52
53
|
<h2 class="ap-card__title">
|
|
53
|
-
<a href="{{ item.
|
|
54
|
+
<a href="{{ mountPath }}/admin/reader/post?url={{ item.uid | urlencode }}">{{ item.name }}</a>
|
|
54
55
|
</h2>
|
|
55
56
|
{% endif %}
|
|
56
57
|
|
|
@@ -71,6 +72,9 @@
|
|
|
71
72
|
</div>
|
|
72
73
|
{% endif %}
|
|
73
74
|
|
|
75
|
+
{# Link previews #}
|
|
76
|
+
{% include "partials/ap-link-preview.njk" %}
|
|
77
|
+
|
|
74
78
|
{# Media hidden behind CW #}
|
|
75
79
|
{% include "partials/ap-item-media.njk" %}
|
|
76
80
|
</div>
|
|
@@ -83,6 +87,9 @@
|
|
|
83
87
|
</div>
|
|
84
88
|
{% endif %}
|
|
85
89
|
|
|
90
|
+
{# Link previews #}
|
|
91
|
+
{% include "partials/ap-link-preview.njk" %}
|
|
92
|
+
|
|
86
93
|
{# Media visible directly #}
|
|
87
94
|
{% include "partials/ap-item-media.njk" %}
|
|
88
95
|
{% endif %}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{# Link preview cards for external links (OpenGraph) #}
|
|
2
|
+
{% if item.linkPreviews and item.linkPreviews.length > 0 %}
|
|
3
|
+
<div class="ap-link-previews">
|
|
4
|
+
{% for preview in item.linkPreviews %}
|
|
5
|
+
<a href="{{ preview.url }}"
|
|
6
|
+
rel="noopener"
|
|
7
|
+
target="_blank"
|
|
8
|
+
class="ap-link-preview"
|
|
9
|
+
aria-label="{{ __('activitypub.reader.linkPreview.label') }}: {{ preview.title }}">
|
|
10
|
+
|
|
11
|
+
<div class="ap-link-preview__text">
|
|
12
|
+
<p class="ap-link-preview__title">{{ preview.title }}</p>
|
|
13
|
+
|
|
14
|
+
{% if preview.description %}
|
|
15
|
+
<p class="ap-link-preview__desc">{{ preview.description }}</p>
|
|
16
|
+
{% endif %}
|
|
17
|
+
|
|
18
|
+
<p class="ap-link-preview__domain">
|
|
19
|
+
{% if preview.favicon %}
|
|
20
|
+
<img src="{{ preview.favicon }}" alt="" class="ap-link-preview__favicon" loading="lazy" />
|
|
21
|
+
{% endif %}
|
|
22
|
+
{{ preview.domain }}
|
|
23
|
+
</p>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
{% if preview.image %}
|
|
27
|
+
<div class="ap-link-preview__image">
|
|
28
|
+
<img src="{{ preview.image }}" alt="" loading="lazy" decoding="async" />
|
|
29
|
+
</div>
|
|
30
|
+
{% endif %}
|
|
31
|
+
</a>
|
|
32
|
+
{% endfor %}
|
|
33
|
+
</div>
|
|
34
|
+
{% endif %}
|