@plank-cms/plank 0.21.3 → 0.23.0
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/dist/admin/assets/index-BSi0iXTe.css +2 -0
- package/dist/admin/assets/{index-Dwwt-EaN.js → index-C86iT0Bf.js} +38 -38
- package/dist/admin/index.html +2 -2
- package/dist/index.js +3 -3
- package/dist/migrations/030_public_author_slug.sql +79 -0
- package/dist/migrations/031_public_author_slug_uid_rebuild.sql +82 -0
- package/dist/{server-CW3GRBTB.js → server-M2KTICST.js} +241 -52
- package/package.json +4 -4
- package/dist/admin/assets/index-CE2YLL9F.css +0 -2
package/dist/admin/index.html
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
href="https://fonts.googleapis.com/css2?family=Google+Sans:ital,opsz,wght@0,17..18,400..700;1,17..18,400..700&display=swap"
|
|
13
13
|
rel="stylesheet"
|
|
14
14
|
/>
|
|
15
|
-
<script type="module" crossorigin src="/admin/assets/index-
|
|
16
|
-
<link rel="stylesheet" crossorigin href="/admin/assets/index-
|
|
15
|
+
<script type="module" crossorigin src="/admin/assets/index-C86iT0Bf.js"></script>
|
|
16
|
+
<link rel="stylesheet" crossorigin href="/admin/assets/index-BSi0iXTe.css">
|
|
17
17
|
</head>
|
|
18
18
|
<body>
|
|
19
19
|
<div id="root"></div>
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { randomBytes } from "crypto";
|
|
|
7
7
|
import { resolve, join } from "path";
|
|
8
8
|
import fs from "fs-extra";
|
|
9
9
|
import { execa } from "execa";
|
|
10
|
-
var PACKAGE_VERSION = "0.
|
|
10
|
+
var PACKAGE_VERSION = "0.23.0";
|
|
11
11
|
function generateSecret() {
|
|
12
12
|
return randomBytes(32).toString("hex");
|
|
13
13
|
}
|
|
@@ -101,7 +101,7 @@ import { dirname, join as join2, resolve as resolve2 } from "path";
|
|
|
101
101
|
async function start() {
|
|
102
102
|
config({ path: resolve2(process.cwd(), ".env") });
|
|
103
103
|
process.env.PLANK_ADMIN_DIST = join2(dirname(fileURLToPath(import.meta.url)), "admin");
|
|
104
|
-
const { start: startServer } = await import("./server-
|
|
104
|
+
const { start: startServer } = await import("./server-M2KTICST.js");
|
|
105
105
|
await startServer();
|
|
106
106
|
}
|
|
107
107
|
|
|
@@ -135,7 +135,7 @@ async function publishScheduled() {
|
|
|
135
135
|
`UPDATE ${table_name} SET
|
|
136
136
|
status = 'published',
|
|
137
137
|
published_data = ${snapshotExpr(table_name)},
|
|
138
|
-
published_at = NOW(),
|
|
138
|
+
published_at = COALESCE(published_at, NOW()),
|
|
139
139
|
scheduled_for = NULL,
|
|
140
140
|
updated_at = NOW()
|
|
141
141
|
WHERE id = $1`,
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
ALTER TABLE plank_users
|
|
2
|
+
ADD COLUMN IF NOT EXISTS public_author_slug VARCHAR(255);
|
|
3
|
+
|
|
4
|
+
DO $$
|
|
5
|
+
DECLARE
|
|
6
|
+
usr RECORD;
|
|
7
|
+
base_slug TEXT;
|
|
8
|
+
next_slug TEXT;
|
|
9
|
+
suffix_num INTEGER;
|
|
10
|
+
BEGIN
|
|
11
|
+
FOR usr IN
|
|
12
|
+
SELECT id, email, first_name, last_name
|
|
13
|
+
FROM plank_users
|
|
14
|
+
WHERE public_author_slug IS NULL OR btrim(public_author_slug) = ''
|
|
15
|
+
ORDER BY created_at, id
|
|
16
|
+
LOOP
|
|
17
|
+
base_slug := lower(
|
|
18
|
+
trim(
|
|
19
|
+
both '-'
|
|
20
|
+
FROM regexp_replace(
|
|
21
|
+
regexp_replace(
|
|
22
|
+
regexp_replace(
|
|
23
|
+
coalesce(
|
|
24
|
+
nullif(trim(concat_ws(' ', usr.first_name, usr.last_name)), ''),
|
|
25
|
+
nullif(split_part(usr.email, '@', 1), ''),
|
|
26
|
+
'author'
|
|
27
|
+
),
|
|
28
|
+
'[áàäâãåÁÀÄÂÃÅ]',
|
|
29
|
+
'a',
|
|
30
|
+
'g'
|
|
31
|
+
),
|
|
32
|
+
'[éèëêÉÈËÊ]',
|
|
33
|
+
'e',
|
|
34
|
+
'g'
|
|
35
|
+
),
|
|
36
|
+
'\s+',
|
|
37
|
+
'-',
|
|
38
|
+
'g'
|
|
39
|
+
)
|
|
40
|
+
)
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
base_slug := regexp_replace(base_slug, '[íìïîÍÌÏÎ]', 'i', 'g');
|
|
44
|
+
base_slug := regexp_replace(base_slug, '[óòöôõÓÒÖÔÕ]', 'o', 'g');
|
|
45
|
+
base_slug := regexp_replace(base_slug, '[úùüûÚÙÜÛ]', 'u', 'g');
|
|
46
|
+
base_slug := regexp_replace(base_slug, '[ñÑ]', 'n', 'g');
|
|
47
|
+
base_slug := regexp_replace(base_slug, '[çÇ]', 'c', 'g');
|
|
48
|
+
base_slug := regexp_replace(base_slug, '[^a-z0-9-]', '', 'g');
|
|
49
|
+
base_slug := trim(both '-' FROM base_slug);
|
|
50
|
+
|
|
51
|
+
IF base_slug IS NULL OR base_slug = '' THEN
|
|
52
|
+
base_slug := 'author';
|
|
53
|
+
END IF;
|
|
54
|
+
|
|
55
|
+
next_slug := base_slug;
|
|
56
|
+
suffix_num := 2;
|
|
57
|
+
|
|
58
|
+
WHILE EXISTS (
|
|
59
|
+
SELECT 1
|
|
60
|
+
FROM plank_users
|
|
61
|
+
WHERE public_author_slug = next_slug
|
|
62
|
+
AND id <> usr.id
|
|
63
|
+
) LOOP
|
|
64
|
+
next_slug := base_slug || '-' || suffix_num;
|
|
65
|
+
suffix_num := suffix_num + 1;
|
|
66
|
+
END LOOP;
|
|
67
|
+
|
|
68
|
+
UPDATE plank_users
|
|
69
|
+
SET public_author_slug = next_slug
|
|
70
|
+
WHERE id = usr.id;
|
|
71
|
+
END LOOP;
|
|
72
|
+
END;
|
|
73
|
+
$$;
|
|
74
|
+
|
|
75
|
+
ALTER TABLE plank_users
|
|
76
|
+
ALTER COLUMN public_author_slug SET NOT NULL;
|
|
77
|
+
|
|
78
|
+
CREATE UNIQUE INDEX IF NOT EXISTS idx_plank_users_public_author_slug
|
|
79
|
+
ON plank_users(public_author_slug);
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
DO $$
|
|
2
|
+
DECLARE
|
|
3
|
+
usr RECORD;
|
|
4
|
+
base_slug TEXT;
|
|
5
|
+
next_slug TEXT;
|
|
6
|
+
suffix_num INTEGER;
|
|
7
|
+
BEGIN
|
|
8
|
+
FOR usr IN
|
|
9
|
+
SELECT id, email, first_name, last_name
|
|
10
|
+
FROM plank_users
|
|
11
|
+
ORDER BY created_at, id
|
|
12
|
+
LOOP
|
|
13
|
+
base_slug := lower(
|
|
14
|
+
trim(
|
|
15
|
+
both '-'
|
|
16
|
+
FROM regexp_replace(
|
|
17
|
+
regexp_replace(
|
|
18
|
+
regexp_replace(
|
|
19
|
+
coalesce(
|
|
20
|
+
nullif(trim(concat_ws(' ', usr.first_name, usr.last_name)), ''),
|
|
21
|
+
nullif(split_part(usr.email, '@', 1), ''),
|
|
22
|
+
'author'
|
|
23
|
+
),
|
|
24
|
+
'[áàäâãåÁÀÄÂÃÅ]',
|
|
25
|
+
'a',
|
|
26
|
+
'g'
|
|
27
|
+
),
|
|
28
|
+
'[éèëêÉÈËÊ]',
|
|
29
|
+
'e',
|
|
30
|
+
'g'
|
|
31
|
+
),
|
|
32
|
+
'\s+',
|
|
33
|
+
'-',
|
|
34
|
+
'g'
|
|
35
|
+
)
|
|
36
|
+
)
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
base_slug := regexp_replace(base_slug, '[íìïîÍÌÏÎ]', 'i', 'g');
|
|
40
|
+
base_slug := regexp_replace(base_slug, '[óòöôõÓÒÖÔÕ]', 'o', 'g');
|
|
41
|
+
base_slug := regexp_replace(base_slug, '[úùüûÚÙÜÛ]', 'u', 'g');
|
|
42
|
+
base_slug := regexp_replace(base_slug, '[ñÑ]', 'n', 'g');
|
|
43
|
+
base_slug := regexp_replace(base_slug, '[çÇ]', 'c', 'g');
|
|
44
|
+
base_slug := regexp_replace(base_slug, '[^a-z0-9-]', '', 'g');
|
|
45
|
+
base_slug := trim(both '-' FROM base_slug);
|
|
46
|
+
|
|
47
|
+
IF base_slug IS NULL OR base_slug = '' THEN
|
|
48
|
+
base_slug := 'author';
|
|
49
|
+
END IF;
|
|
50
|
+
|
|
51
|
+
next_slug := base_slug || '--' || usr.id;
|
|
52
|
+
|
|
53
|
+
UPDATE plank_users
|
|
54
|
+
SET public_author_slug = next_slug
|
|
55
|
+
WHERE id = usr.id;
|
|
56
|
+
END LOOP;
|
|
57
|
+
|
|
58
|
+
FOR usr IN
|
|
59
|
+
SELECT id, public_author_slug
|
|
60
|
+
FROM plank_users
|
|
61
|
+
ORDER BY created_at, id
|
|
62
|
+
LOOP
|
|
63
|
+
base_slug := split_part(usr.public_author_slug, '--', 1);
|
|
64
|
+
next_slug := base_slug;
|
|
65
|
+
suffix_num := 2;
|
|
66
|
+
|
|
67
|
+
WHILE EXISTS (
|
|
68
|
+
SELECT 1
|
|
69
|
+
FROM plank_users
|
|
70
|
+
WHERE public_author_slug = next_slug
|
|
71
|
+
AND id <> usr.id
|
|
72
|
+
) LOOP
|
|
73
|
+
next_slug := base_slug || '-' || suffix_num;
|
|
74
|
+
suffix_num := suffix_num + 1;
|
|
75
|
+
END LOOP;
|
|
76
|
+
|
|
77
|
+
UPDATE plank_users
|
|
78
|
+
SET public_author_slug = next_slug
|
|
79
|
+
WHERE id = usr.id;
|
|
80
|
+
END LOOP;
|
|
81
|
+
END;
|
|
82
|
+
$$;
|