@rmdes/indiekit-endpoint-activitypub 1.1.16 → 1.1.17
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 +48 -0
- package/index.js +2 -0
- package/lib/controllers/followers.js +1 -1
- package/lib/controllers/following.js +1 -1
- package/lib/controllers/resolve.js +109 -0
- package/locales/en.json +7 -0
- package/package.json +1 -1
- package/views/activitypub-activities.njk +0 -2
- package/views/activitypub-compose.njk +0 -2
- package/views/activitypub-dashboard.njk +0 -2
- package/views/activitypub-featured-tags.njk +0 -2
- package/views/activitypub-featured.njk +0 -2
- package/views/activitypub-followers.njk +0 -2
- package/views/activitypub-following.njk +0 -2
- package/views/activitypub-migrate.njk +0 -2
- package/views/activitypub-moderation.njk +0 -2
- package/views/activitypub-notifications.njk +0 -2
- package/views/activitypub-post-detail.njk +0 -2
- package/views/activitypub-profile.njk +0 -2
- package/views/activitypub-reader.njk +7 -1
- package/views/activitypub-remote-profile.njk +0 -2
package/assets/reader.css
CHANGED
|
@@ -4,6 +4,54 @@
|
|
|
4
4
|
* Uses Indiekit CSS custom properties for automatic dark mode support
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
/* ==========================================================================
|
|
8
|
+
Fediverse Lookup
|
|
9
|
+
========================================================================== */
|
|
10
|
+
|
|
11
|
+
.ap-lookup {
|
|
12
|
+
display: flex;
|
|
13
|
+
gap: var(--space-xs);
|
|
14
|
+
margin-bottom: var(--space-m);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.ap-lookup__input {
|
|
18
|
+
flex: 1;
|
|
19
|
+
padding: var(--space-s) var(--space-m);
|
|
20
|
+
border: var(--border-width-thin) solid var(--color-outline);
|
|
21
|
+
border-radius: var(--border-radius-small);
|
|
22
|
+
background: var(--color-offset);
|
|
23
|
+
color: var(--color-on-background);
|
|
24
|
+
font-size: var(--font-size-m);
|
|
25
|
+
font-family: inherit;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.ap-lookup__input::placeholder {
|
|
29
|
+
color: var(--color-on-offset);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.ap-lookup__input:focus {
|
|
33
|
+
outline: 2px solid var(--color-primary);
|
|
34
|
+
outline-offset: -1px;
|
|
35
|
+
border-color: var(--color-primary);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.ap-lookup__btn {
|
|
39
|
+
padding: var(--space-s) var(--space-m);
|
|
40
|
+
border: var(--border-width-thin) solid var(--color-primary);
|
|
41
|
+
border-radius: var(--border-radius-small);
|
|
42
|
+
background: var(--color-primary);
|
|
43
|
+
color: var(--color-on-primary);
|
|
44
|
+
font-size: var(--font-size-m);
|
|
45
|
+
font-family: inherit;
|
|
46
|
+
font-weight: 600;
|
|
47
|
+
cursor: pointer;
|
|
48
|
+
white-space: nowrap;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.ap-lookup__btn:hover {
|
|
52
|
+
opacity: 0.9;
|
|
53
|
+
}
|
|
54
|
+
|
|
7
55
|
/* ==========================================================================
|
|
8
56
|
Tab Navigation
|
|
9
57
|
========================================================================== */
|
package/index.js
CHANGED
|
@@ -57,6 +57,7 @@ import {
|
|
|
57
57
|
featuredTagsAddController,
|
|
58
58
|
featuredTagsRemoveController,
|
|
59
59
|
} from "./lib/controllers/featured-tags.js";
|
|
60
|
+
import { resolveController } from "./lib/controllers/resolve.js";
|
|
60
61
|
import {
|
|
61
62
|
refollowPauseController,
|
|
62
63
|
refollowResumeController,
|
|
@@ -202,6 +203,7 @@ export default class ActivityPubEndpoint {
|
|
|
202
203
|
router.post("/admin/reader/unlike", unlikeController(mp, this));
|
|
203
204
|
router.post("/admin/reader/boost", boostController(mp, this));
|
|
204
205
|
router.post("/admin/reader/unboost", unboostController(mp, this));
|
|
206
|
+
router.get("/admin/reader/resolve", resolveController(mp, this));
|
|
205
207
|
router.get("/admin/reader/profile", remoteProfileController(mp, this));
|
|
206
208
|
router.get("/admin/reader/post", postDetailController(mp, this));
|
|
207
209
|
router.post("/admin/reader/follow", followController(mp, this));
|
|
@@ -32,7 +32,7 @@ export function followersController(mountPath) {
|
|
|
32
32
|
const cursor = buildCursor(page, totalPages, mountPath + "/admin/followers");
|
|
33
33
|
|
|
34
34
|
response.render("activitypub-followers", {
|
|
35
|
-
title: response.locals.__("activitypub.followers")
|
|
35
|
+
title: `${totalCount} ${response.locals.__("activitypub.followers")}`,
|
|
36
36
|
followers,
|
|
37
37
|
followerCount: totalCount,
|
|
38
38
|
mountPath,
|
|
@@ -32,7 +32,7 @@ export function followingController(mountPath) {
|
|
|
32
32
|
const cursor = buildCursor(page, totalPages, mountPath + "/admin/following");
|
|
33
33
|
|
|
34
34
|
response.render("activitypub-following", {
|
|
35
|
-
title: response.locals.__("activitypub.following")
|
|
35
|
+
title: `${totalCount} ${response.locals.__("activitypub.following")}`,
|
|
36
36
|
following,
|
|
37
37
|
followingCount: totalCount,
|
|
38
38
|
mountPath,
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve controller — accepts any fediverse URL or handle, resolves it
|
|
3
|
+
* via lookupObject(), and redirects to the appropriate internal view.
|
|
4
|
+
*/
|
|
5
|
+
import {
|
|
6
|
+
Article,
|
|
7
|
+
Note,
|
|
8
|
+
Person,
|
|
9
|
+
Service,
|
|
10
|
+
Application,
|
|
11
|
+
Organization,
|
|
12
|
+
Group,
|
|
13
|
+
} from "@fedify/fedify";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* GET /admin/reader/resolve?q=<url-or-handle>
|
|
17
|
+
* Resolves a fediverse URL or @user@domain handle and redirects to
|
|
18
|
+
* the post detail or remote profile view.
|
|
19
|
+
*/
|
|
20
|
+
export function resolveController(mountPath, plugin) {
|
|
21
|
+
return async (request, response, next) => {
|
|
22
|
+
try {
|
|
23
|
+
const query = (request.query.q || "").trim();
|
|
24
|
+
|
|
25
|
+
if (!query) {
|
|
26
|
+
return response.redirect(`${mountPath}/admin/reader`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (!plugin._federation) {
|
|
30
|
+
return response.status(503).render("error", {
|
|
31
|
+
title: "Error",
|
|
32
|
+
content: "Federation not initialized",
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const handle = plugin.options.actor.handle;
|
|
37
|
+
const ctx = plugin._federation.createContext(
|
|
38
|
+
new URL(plugin._publicationUrl),
|
|
39
|
+
{ handle, publicationUrl: plugin._publicationUrl },
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const documentLoader = await ctx.getDocumentLoader({
|
|
43
|
+
identifier: handle,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Determine if input is a URL or a handle
|
|
47
|
+
// lookupObject accepts: URLs, @user@domain, user@domain, acct:user@domain
|
|
48
|
+
let lookupInput;
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
// If it parses as a URL, pass as URL object
|
|
52
|
+
const parsed = new URL(query);
|
|
53
|
+
lookupInput = parsed;
|
|
54
|
+
} catch {
|
|
55
|
+
// Not a URL — treat as handle (strip leading @ if present)
|
|
56
|
+
lookupInput = query;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
let object;
|
|
60
|
+
|
|
61
|
+
try {
|
|
62
|
+
object = await ctx.lookupObject(lookupInput, { documentLoader });
|
|
63
|
+
} catch (error) {
|
|
64
|
+
console.warn(
|
|
65
|
+
`[resolve] lookupObject failed for "${query}":`,
|
|
66
|
+
error.message,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (!object) {
|
|
71
|
+
return response.status(404).render("error", {
|
|
72
|
+
title: response.locals.__("activitypub.reader.resolve.notFoundTitle"),
|
|
73
|
+
content: response.locals.__(
|
|
74
|
+
"activitypub.reader.resolve.notFound",
|
|
75
|
+
),
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Determine object type and redirect accordingly
|
|
80
|
+
const objectUrl =
|
|
81
|
+
object.id?.href || object.url?.href || query;
|
|
82
|
+
|
|
83
|
+
if (
|
|
84
|
+
object instanceof Person ||
|
|
85
|
+
object instanceof Service ||
|
|
86
|
+
object instanceof Application ||
|
|
87
|
+
object instanceof Organization ||
|
|
88
|
+
object instanceof Group
|
|
89
|
+
) {
|
|
90
|
+
return response.redirect(
|
|
91
|
+
`${mountPath}/admin/reader/profile?url=${encodeURIComponent(objectUrl)}`,
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (object instanceof Note || object instanceof Article) {
|
|
96
|
+
return response.redirect(
|
|
97
|
+
`${mountPath}/admin/reader/post?url=${encodeURIComponent(objectUrl)}`,
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Unknown type — try post detail as fallback
|
|
102
|
+
return response.redirect(
|
|
103
|
+
`${mountPath}/admin/reader/post?url=${encodeURIComponent(objectUrl)}`,
|
|
104
|
+
);
|
|
105
|
+
} catch (error) {
|
|
106
|
+
next(error);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
package/locales/en.json
CHANGED
|
@@ -191,6 +191,13 @@
|
|
|
191
191
|
"loadingThread": "Loading thread...",
|
|
192
192
|
"threadError": "Could not load full thread"
|
|
193
193
|
},
|
|
194
|
+
"resolve": {
|
|
195
|
+
"placeholder": "Paste a fediverse URL or @user@domain handle…",
|
|
196
|
+
"label": "Look up a fediverse post or account",
|
|
197
|
+
"button": "Look up",
|
|
198
|
+
"notFoundTitle": "Not found",
|
|
199
|
+
"notFound": "Could not find this post or account. The URL may be invalid, the server may be unavailable, or the content may have been deleted."
|
|
200
|
+
},
|
|
194
201
|
"linkPreview": {
|
|
195
202
|
"label": "Link preview"
|
|
196
203
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rmdes/indiekit-endpoint-activitypub",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.17",
|
|
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",
|
|
@@ -7,8 +7,6 @@
|
|
|
7
7
|
{% from "pagination/macro.njk" import pagination with context %}
|
|
8
8
|
|
|
9
9
|
{% block content %}
|
|
10
|
-
{{ heading({ text: followingCount + " " + __("activitypub.following"), level: 1 }) }}
|
|
11
|
-
|
|
12
10
|
{% if following.length > 0 %}
|
|
13
11
|
{% for account in following %}
|
|
14
12
|
{% if account.source === "import" %}
|
|
@@ -4,7 +4,13 @@
|
|
|
4
4
|
{% from "prose/macro.njk" import prose with context %}
|
|
5
5
|
|
|
6
6
|
{% block readercontent %}
|
|
7
|
-
{
|
|
7
|
+
{# Fediverse lookup #}
|
|
8
|
+
<form action="{{ mountPath }}/admin/reader/resolve" method="get" class="ap-lookup">
|
|
9
|
+
<input type="text" name="q" class="ap-lookup__input"
|
|
10
|
+
placeholder="{{ __('activitypub.reader.resolve.placeholder') }}"
|
|
11
|
+
aria-label="{{ __('activitypub.reader.resolve.label') }}">
|
|
12
|
+
<button type="submit" class="ap-lookup__btn">{{ __("activitypub.reader.resolve.button") }}</button>
|
|
13
|
+
</form>
|
|
8
14
|
|
|
9
15
|
{# Tab navigation #}
|
|
10
16
|
<nav class="ap-tabs" role="tablist">
|