@rmdes/indiekit-endpoint-posts 1.0.0-beta.36 → 1.0.0-beta.38
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/form.js +5 -0
- package/lib/middleware/post-data.js +28 -3
- package/lib/utils.js +14 -7
- package/locales/de.json +2 -2
- package/locales/en.json +2 -2
- package/locales/es-419.json +2 -2
- package/locales/es.json +2 -2
- package/locales/fr.json +2 -2
- package/locales/hi.json +2 -2
- package/locales/id.json +2 -2
- package/locales/it.json +2 -2
- package/locales/nl.json +2 -2
- package/locales/pl.json +2 -2
- package/locales/pt-BR.json +2 -2
- package/locales/pt.json +2 -2
- package/locales/sr.json +2 -2
- package/locales/sv.json +2 -2
- package/locales/zh-Hans-CN.json +2 -2
- package/package.json +1 -1
- package/views/post-form.njk +17 -10
package/lib/controllers/form.js
CHANGED
|
@@ -88,6 +88,11 @@ export const formController = {
|
|
|
88
88
|
// Easy MDE appends `image` value to formData for last image uploaded
|
|
89
89
|
delete values.image;
|
|
90
90
|
|
|
91
|
+
// Remove empty layout selection (user chose "Default")
|
|
92
|
+
if (!values.layout) {
|
|
93
|
+
delete values.layout;
|
|
94
|
+
}
|
|
95
|
+
|
|
91
96
|
const mf2 = jf2ToMf2({ properties: sanitise(values) });
|
|
92
97
|
|
|
93
98
|
let jsonBody = mf2;
|
|
@@ -4,8 +4,8 @@ import { IndiekitError } from "@indiekit/error";
|
|
|
4
4
|
|
|
5
5
|
import { statusTypes } from "../status-types.js";
|
|
6
6
|
import {
|
|
7
|
-
getChannelItems,
|
|
8
7
|
getGeoValue,
|
|
8
|
+
getLayoutItems,
|
|
9
9
|
getPostName,
|
|
10
10
|
getPostProperties,
|
|
11
11
|
getSyndicateToItems,
|
|
@@ -20,6 +20,31 @@ export const postData = {
|
|
|
20
20
|
const postType = request.query.type || "note";
|
|
21
21
|
const properties = request.body || {};
|
|
22
22
|
|
|
23
|
+
// Pre-fill from query params (used by "Post" button in reader UIs)
|
|
24
|
+
const prefillUrl = request.query.url;
|
|
25
|
+
const prefillName = request.query.name;
|
|
26
|
+
|
|
27
|
+
if (prefillUrl) {
|
|
28
|
+
const urlFieldMap = {
|
|
29
|
+
bookmark: "bookmark-of",
|
|
30
|
+
reply: "in-reply-to",
|
|
31
|
+
like: "like-of",
|
|
32
|
+
repost: "repost-of",
|
|
33
|
+
};
|
|
34
|
+
const urlField = urlFieldMap[postType];
|
|
35
|
+
if (urlField) {
|
|
36
|
+
properties[urlField] = properties[urlField] || prefillUrl;
|
|
37
|
+
} else if (postType === "note" || postType === "article") {
|
|
38
|
+
properties.content = properties.content || prefillUrl;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (prefillName) {
|
|
43
|
+
if (postType === "bookmark" || postType === "article") {
|
|
44
|
+
properties.name = properties.name || prefillName;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
23
48
|
// Get post type config
|
|
24
49
|
const { name, fields, h } = publication.postTypes[postType];
|
|
25
50
|
|
|
@@ -29,8 +54,8 @@ export const postData = {
|
|
|
29
54
|
response.locals = {
|
|
30
55
|
accessToken: access_token,
|
|
31
56
|
action: "create",
|
|
32
|
-
channelItems: getChannelItems(publication),
|
|
33
57
|
fields,
|
|
58
|
+
layoutItems: getLayoutItems(publication),
|
|
34
59
|
name,
|
|
35
60
|
postsPath: path.dirname(request.baseUrl + request.path),
|
|
36
61
|
postType,
|
|
@@ -68,11 +93,11 @@ export const postData = {
|
|
|
68
93
|
accessToken: access_token,
|
|
69
94
|
action: action || "create",
|
|
70
95
|
allDay,
|
|
71
|
-
channelItems: getChannelItems(publication),
|
|
72
96
|
draftMode: scope?.includes("draft"),
|
|
73
97
|
fields,
|
|
74
98
|
geo,
|
|
75
99
|
h,
|
|
100
|
+
layoutItems: getLayoutItems(publication),
|
|
76
101
|
name,
|
|
77
102
|
postName: getPostName(publication, properties),
|
|
78
103
|
postsPath: path.dirname(request.baseUrl + request.path),
|
package/lib/utils.js
CHANGED
|
@@ -10,15 +10,22 @@ import { endpoint } from "./endpoint.js";
|
|
|
10
10
|
import { statusTypes } from "./status-types.js";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* Get
|
|
13
|
+
* Get layout `items` for select component
|
|
14
14
|
* @param {object} publication - Publication configuration
|
|
15
|
-
* @returns {
|
|
15
|
+
* @returns {Array} Items for select component, or empty array if no layouts configured
|
|
16
16
|
*/
|
|
17
|
-
export const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
export const getLayoutItems = (publication) => {
|
|
18
|
+
if (!publication.layouts || !Array.isArray(publication.layouts)) {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return [
|
|
23
|
+
{ text: "Default", value: "", selected: true },
|
|
24
|
+
...publication.layouts.map((layout) => ({
|
|
25
|
+
text: layout.name,
|
|
26
|
+
value: layout.path,
|
|
27
|
+
})),
|
|
28
|
+
];
|
|
22
29
|
};
|
|
23
30
|
|
|
24
31
|
/**
|
package/locales/de.json
CHANGED
package/locales/en.json
CHANGED
package/locales/es-419.json
CHANGED
package/locales/es.json
CHANGED
package/locales/fr.json
CHANGED
package/locales/hi.json
CHANGED
package/locales/id.json
CHANGED
package/locales/it.json
CHANGED
package/locales/nl.json
CHANGED
package/locales/pl.json
CHANGED
package/locales/pt-BR.json
CHANGED
package/locales/pt.json
CHANGED
package/locales/sr.json
CHANGED
package/locales/sv.json
CHANGED
package/locales/zh-Hans-CN.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rmdes/indiekit-endpoint-posts",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.38",
|
|
4
4
|
"description": "Post management endpoint for Indiekit with syndicate form fix. View posts published by your Micropub endpoint and publish new posts to it.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"indiekit",
|
package/views/post-form.njk
CHANGED
|
@@ -52,16 +52,6 @@
|
|
|
52
52
|
}]
|
|
53
53
|
}) }}
|
|
54
54
|
|
|
55
|
-
{{ checkboxes({
|
|
56
|
-
name: "mp-channel",
|
|
57
|
-
values: properties["mp-channel"],
|
|
58
|
-
fieldset: {
|
|
59
|
-
legend: __("posts.form.mp-channel.label"),
|
|
60
|
-
optional: true
|
|
61
|
-
},
|
|
62
|
-
items: channelItems
|
|
63
|
-
}) | indent(2) if publication.channels }}
|
|
64
|
-
|
|
65
55
|
{{ radios({
|
|
66
56
|
inline: true,
|
|
67
57
|
name: "visibility",
|
|
@@ -89,6 +79,23 @@
|
|
|
89
79
|
label: __("posts.form.mp-slug.label"),
|
|
90
80
|
optional: true
|
|
91
81
|
}) | indent(4) }}
|
|
82
|
+
|
|
83
|
+
{% if layoutItems and layoutItems.length %}
|
|
84
|
+
{% set layoutSelectItems = [] %}
|
|
85
|
+
{% for item in layoutItems %}
|
|
86
|
+
{% set _ = layoutSelectItems.push({
|
|
87
|
+
text: item.text,
|
|
88
|
+
value: item.value,
|
|
89
|
+
selected: item.value === properties.layout
|
|
90
|
+
}) %}
|
|
91
|
+
{% endfor %}
|
|
92
|
+
{{ select({
|
|
93
|
+
name: "layout",
|
|
94
|
+
label: __("posts.form.layout.label"),
|
|
95
|
+
optional: true,
|
|
96
|
+
items: layoutSelectItems
|
|
97
|
+
}) | indent(4) }}
|
|
98
|
+
{% endif %}
|
|
92
99
|
{% endcall %}
|
|
93
100
|
{% endblock %}
|
|
94
101
|
|