@rmdes/indiekit-endpoint-microsub 1.0.4 → 1.0.6
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/lib/controllers/reader.js +33 -4
- package/package.json +1 -1
- package/views/compose.njk +21 -21
|
@@ -310,14 +310,24 @@ export async function item(request, response) {
|
|
|
310
310
|
* @returns {Promise<void>}
|
|
311
311
|
*/
|
|
312
312
|
export async function compose(request, response) {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
response.render("compose", {
|
|
316
|
-
title: request.__("microsub.compose.title"),
|
|
313
|
+
// Support both long-form (replyTo) and short-form (reply) query params
|
|
314
|
+
const {
|
|
317
315
|
replyTo,
|
|
316
|
+
reply,
|
|
318
317
|
likeOf,
|
|
318
|
+
like,
|
|
319
319
|
repostOf,
|
|
320
|
+
repost,
|
|
320
321
|
bookmarkOf,
|
|
322
|
+
bookmark,
|
|
323
|
+
} = request.query;
|
|
324
|
+
|
|
325
|
+
response.render("compose", {
|
|
326
|
+
title: request.__("microsub.compose.title"),
|
|
327
|
+
replyTo: replyTo || reply,
|
|
328
|
+
likeOf: likeOf || like,
|
|
329
|
+
repostOf: repostOf || repost,
|
|
330
|
+
bookmarkOf: bookmarkOf || bookmark,
|
|
321
331
|
baseUrl: request.baseUrl,
|
|
322
332
|
});
|
|
323
333
|
}
|
|
@@ -336,6 +346,19 @@ export async function submitCompose(request, response) {
|
|
|
336
346
|
const repostOf = request.body["repost-of"];
|
|
337
347
|
const bookmarkOf = request.body["bookmark-of"];
|
|
338
348
|
|
|
349
|
+
// Debug logging
|
|
350
|
+
console.info(
|
|
351
|
+
"[Microsub] submitCompose request.body:",
|
|
352
|
+
JSON.stringify(request.body),
|
|
353
|
+
);
|
|
354
|
+
console.info("[Microsub] Extracted values:", {
|
|
355
|
+
content,
|
|
356
|
+
inReplyTo,
|
|
357
|
+
likeOf,
|
|
358
|
+
repostOf,
|
|
359
|
+
bookmarkOf,
|
|
360
|
+
});
|
|
361
|
+
|
|
339
362
|
// Get Micropub endpoint
|
|
340
363
|
const micropubEndpoint = application.micropubEndpoint;
|
|
341
364
|
if (!micropubEndpoint) {
|
|
@@ -381,6 +404,12 @@ export async function submitCompose(request, response) {
|
|
|
381
404
|
micropubData.append("content", content || "");
|
|
382
405
|
}
|
|
383
406
|
|
|
407
|
+
// Debug: log what we're sending
|
|
408
|
+
console.info("[Microsub] Sending to Micropub:", {
|
|
409
|
+
url: micropubUrl,
|
|
410
|
+
body: micropubData.toString(),
|
|
411
|
+
});
|
|
412
|
+
|
|
384
413
|
try {
|
|
385
414
|
const micropubResponse = await fetch(micropubUrl, {
|
|
386
415
|
method: "POST",
|
package/package.json
CHANGED
package/views/compose.njk
CHANGED
|
@@ -8,57 +8,57 @@
|
|
|
8
8
|
|
|
9
9
|
<h2>{{ __("microsub.compose.title") }}</h2>
|
|
10
10
|
|
|
11
|
-
{% if replyTo
|
|
11
|
+
{% if replyTo %}
|
|
12
12
|
<div class="compose__context">
|
|
13
13
|
{{ icon("reply") }} {{ __("microsub.compose.replyTo") }}:
|
|
14
|
-
<a href="{{ replyTo
|
|
15
|
-
{{
|
|
14
|
+
<a href="{{ replyTo }}" target="_blank" rel="noopener">
|
|
15
|
+
{{ replyTo | replace("https://", "") | replace("http://", "") }}
|
|
16
16
|
</a>
|
|
17
17
|
</div>
|
|
18
18
|
{% endif %}
|
|
19
19
|
|
|
20
|
-
{% if likeOf
|
|
20
|
+
{% if likeOf %}
|
|
21
21
|
<div class="compose__context">
|
|
22
22
|
{{ icon("like") }} {{ __("microsub.compose.likeOf") }}:
|
|
23
|
-
<a href="{{ likeOf
|
|
24
|
-
{{
|
|
23
|
+
<a href="{{ likeOf }}" target="_blank" rel="noopener">
|
|
24
|
+
{{ likeOf | replace("https://", "") | replace("http://", "") }}
|
|
25
25
|
</a>
|
|
26
26
|
</div>
|
|
27
27
|
{% endif %}
|
|
28
28
|
|
|
29
|
-
{% if repostOf
|
|
29
|
+
{% if repostOf %}
|
|
30
30
|
<div class="compose__context">
|
|
31
31
|
{{ icon("repost") }} {{ __("microsub.compose.repostOf") }}:
|
|
32
|
-
<a href="{{ repostOf
|
|
33
|
-
{{
|
|
32
|
+
<a href="{{ repostOf }}" target="_blank" rel="noopener">
|
|
33
|
+
{{ repostOf | replace("https://", "") | replace("http://", "") }}
|
|
34
34
|
</a>
|
|
35
35
|
</div>
|
|
36
36
|
{% endif %}
|
|
37
37
|
|
|
38
|
-
{% if bookmarkOf
|
|
38
|
+
{% if bookmarkOf %}
|
|
39
39
|
<div class="compose__context">
|
|
40
40
|
{{ icon("bookmark") }} {{ __("microsub.compose.bookmarkOf") }}:
|
|
41
|
-
<a href="{{ bookmarkOf
|
|
42
|
-
{{
|
|
41
|
+
<a href="{{ bookmarkOf }}" target="_blank" rel="noopener">
|
|
42
|
+
{{ bookmarkOf | replace("https://", "") | replace("http://", "") }}
|
|
43
43
|
</a>
|
|
44
44
|
</div>
|
|
45
45
|
{% endif %}
|
|
46
46
|
|
|
47
47
|
<form method="post" action="{{ baseUrl }}/compose">
|
|
48
|
-
{% if replyTo
|
|
49
|
-
<input type="hidden" name="in-reply-to" value="{{ replyTo
|
|
48
|
+
{% if replyTo %}
|
|
49
|
+
<input type="hidden" name="in-reply-to" value="{{ replyTo }}">
|
|
50
50
|
{% endif %}
|
|
51
|
-
{% if likeOf
|
|
52
|
-
<input type="hidden" name="like-of" value="{{ likeOf
|
|
51
|
+
{% if likeOf %}
|
|
52
|
+
<input type="hidden" name="like-of" value="{{ likeOf }}">
|
|
53
53
|
{% endif %}
|
|
54
|
-
{% if repostOf
|
|
55
|
-
<input type="hidden" name="repost-of" value="{{ repostOf
|
|
54
|
+
{% if repostOf %}
|
|
55
|
+
<input type="hidden" name="repost-of" value="{{ repostOf }}">
|
|
56
56
|
{% endif %}
|
|
57
|
-
{% if bookmarkOf
|
|
58
|
-
<input type="hidden" name="bookmark-of" value="{{ bookmarkOf
|
|
57
|
+
{% if bookmarkOf %}
|
|
58
|
+
<input type="hidden" name="bookmark-of" value="{{ bookmarkOf }}">
|
|
59
59
|
{% endif %}
|
|
60
60
|
|
|
61
|
-
{% set isAction =
|
|
61
|
+
{% set isAction = likeOf or repostOf or bookmarkOf %}
|
|
62
62
|
|
|
63
63
|
{% if not isAction %}
|
|
64
64
|
{{ textarea({
|