@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.
@@ -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 channel `items` for checkboxes component
13
+ * Get layout `items` for select component
14
14
  * @param {object} publication - Publication configuration
15
- * @returns {object} Items for checkboxes component
15
+ * @returns {Array} Items for select component, or empty array if no layouts configured
16
16
  */
17
- export const getChannelItems = (publication) => {
18
- return Object.entries(publication.channels).map(([uid, channel]) => ({
19
- label: channel.name,
20
- value: uid,
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
@@ -65,8 +65,8 @@
65
65
  "media": {
66
66
  "label": "Dateipfad oder URL"
67
67
  },
68
- "mp-channel": {
69
- "label": "Kanal"
68
+ "layout": {
69
+ "label": "Layout"
70
70
  },
71
71
  "mp-slug": {
72
72
  "label": "Slug"
package/locales/en.json CHANGED
@@ -101,8 +101,8 @@
101
101
  "media": {
102
102
  "label": "File path or URL"
103
103
  },
104
- "mp-channel": {
105
- "label": "Channel"
104
+ "layout": {
105
+ "label": "Layout"
106
106
  },
107
107
  "mp-slug": {
108
108
  "label": "URL slug"
@@ -65,8 +65,8 @@
65
65
  "media": {
66
66
  "label": "Ruta o URL del archivo"
67
67
  },
68
- "mp-channel": {
69
- "label": "Canal"
68
+ "layout": {
69
+ "label": "Layout"
70
70
  },
71
71
  "mp-slug": {
72
72
  "label": "Babosa de URL"
package/locales/es.json CHANGED
@@ -65,8 +65,8 @@
65
65
  "media": {
66
66
  "label": "Ruta o URL del archivo"
67
67
  },
68
- "mp-channel": {
69
- "label": "Canal"
68
+ "layout": {
69
+ "label": "Layout"
70
70
  },
71
71
  "mp-slug": {
72
72
  "label": "URL slug"
package/locales/fr.json CHANGED
@@ -65,8 +65,8 @@
65
65
  "media": {
66
66
  "label": "Chemin du fichier ou URL"
67
67
  },
68
- "mp-channel": {
69
- "label": "Canal"
68
+ "layout": {
69
+ "label": "Layout"
70
70
  },
71
71
  "mp-slug": {
72
72
  "label": "Identifiant unique d’URL (slug)"
package/locales/hi.json CHANGED
@@ -65,8 +65,8 @@
65
65
  "media": {
66
66
  "label": "फ़ाइल पथ या URL"
67
67
  },
68
- "mp-channel": {
69
- "label": "चैनल"
68
+ "layout": {
69
+ "label": "Layout"
70
70
  },
71
71
  "mp-slug": {
72
72
  "label": "URL स्लग"
package/locales/id.json CHANGED
@@ -65,8 +65,8 @@
65
65
  "media": {
66
66
  "label": "Jalur file atau URL"
67
67
  },
68
- "mp-channel": {
69
- "label": "Saluran"
68
+ "layout": {
69
+ "label": "Layout"
70
70
  },
71
71
  "mp-slug": {
72
72
  "label": "URL siput"
package/locales/it.json CHANGED
@@ -65,8 +65,8 @@
65
65
  "media": {
66
66
  "label": "Percorso del file o URL"
67
67
  },
68
- "mp-channel": {
69
- "label": "Canale"
68
+ "layout": {
69
+ "label": "Layout"
70
70
  },
71
71
  "mp-slug": {
72
72
  "label": "Slug dell'URL"
package/locales/nl.json CHANGED
@@ -65,8 +65,8 @@
65
65
  "media": {
66
66
  "label": "Bestandspad of URL"
67
67
  },
68
- "mp-channel": {
69
- "label": "Kanaal"
68
+ "layout": {
69
+ "label": "Layout"
70
70
  },
71
71
  "mp-slug": {
72
72
  "label": "URL-slug"
package/locales/pl.json CHANGED
@@ -65,8 +65,8 @@
65
65
  "media": {
66
66
  "label": "Ścieżka pliku lub adres URL"
67
67
  },
68
- "mp-channel": {
69
- "label": "Kanał"
68
+ "layout": {
69
+ "label": "Layout"
70
70
  },
71
71
  "mp-slug": {
72
72
  "label": "Ślimak URL"
@@ -65,8 +65,8 @@
65
65
  "media": {
66
66
  "label": "Caminho do arquivo ou URL"
67
67
  },
68
- "mp-channel": {
69
- "label": "Canal"
68
+ "layout": {
69
+ "label": "Layout"
70
70
  },
71
71
  "mp-slug": {
72
72
  "label": "Slug da URL"
package/locales/pt.json CHANGED
@@ -65,8 +65,8 @@
65
65
  "media": {
66
66
  "label": "Caminho do arquivo ou URL"
67
67
  },
68
- "mp-channel": {
69
- "label": "Canal"
68
+ "layout": {
69
+ "label": "Layout"
70
70
  },
71
71
  "mp-slug": {
72
72
  "label": "Slug de URL"
package/locales/sr.json CHANGED
@@ -65,8 +65,8 @@
65
65
  "media": {
66
66
  "label": "Putanja ili URL datoteke"
67
67
  },
68
- "mp-channel": {
69
- "label": "Kanal"
68
+ "layout": {
69
+ "label": "Layout"
70
70
  },
71
71
  "mp-slug": {
72
72
  "label": "URL slag"
package/locales/sv.json CHANGED
@@ -65,8 +65,8 @@
65
65
  "media": {
66
66
  "label": "Filsökväg eller URL"
67
67
  },
68
- "mp-channel": {
69
- "label": "Kanal"
68
+ "layout": {
69
+ "label": "Layout"
70
70
  },
71
71
  "mp-slug": {
72
72
  "label": "URL-slug"
@@ -65,8 +65,8 @@
65
65
  "media": {
66
66
  "label": "文件路径或 URL"
67
67
  },
68
- "mp-channel": {
69
- "label": "频道"
68
+ "layout": {
69
+ "label": "Layout"
70
70
  },
71
71
  "mp-slug": {
72
72
  "label": "网址 slug"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rmdes/indiekit-endpoint-posts",
3
- "version": "1.0.0-beta.36",
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",
@@ -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