Skip to content

Commit c9f870d

Browse files
committed
fix pagefind powered search infra
1 parent d4258cc commit c9f870d

File tree

11 files changed

+175
-112
lines changed

11 files changed

+175
-112
lines changed

plugins/pagefind/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const COMMANDS: &[&str] = &["search", "index"];
1+
const COMMANDS: &[&str] = &["build_index", "get_bundle_path", "clear_index"];
22

33
fn main() {
44
tauri_plugin::Builder::new(COMMANDS).build();
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Automatically generated - DO NOT EDIT!
2+
3+
"$schema" = "../../schemas/schema.json"
4+
5+
[[permission]]
6+
identifier = "allow-build-index"
7+
description = "Enables the build_index command without any pre-configured scope."
8+
commands.allow = ["build_index"]
9+
10+
[[permission]]
11+
identifier = "deny-build-index"
12+
description = "Denies the build_index command without any pre-configured scope."
13+
commands.deny = ["build_index"]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Automatically generated - DO NOT EDIT!
2+
3+
"$schema" = "../../schemas/schema.json"
4+
5+
[[permission]]
6+
identifier = "allow-clear-index"
7+
description = "Enables the clear_index command without any pre-configured scope."
8+
commands.allow = ["clear_index"]
9+
10+
[[permission]]
11+
identifier = "deny-clear-index"
12+
description = "Denies the clear_index command without any pre-configured scope."
13+
commands.deny = ["clear_index"]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Automatically generated - DO NOT EDIT!
2+
3+
"$schema" = "../../schemas/schema.json"
4+
5+
[[permission]]
6+
identifier = "allow-get-bundle-path"
7+
description = "Enables the get_bundle_path command without any pre-configured scope."
8+
commands.allow = ["get_bundle_path"]
9+
10+
[[permission]]
11+
identifier = "deny-get-bundle-path"
12+
description = "Denies the get_bundle_path command without any pre-configured scope."
13+
commands.deny = ["get_bundle_path"]

plugins/pagefind/permissions/autogenerated/commands/index.toml

Lines changed: 0 additions & 13 deletions
This file was deleted.

plugins/pagefind/permissions/autogenerated/commands/search.toml

Lines changed: 0 additions & 13 deletions
This file was deleted.

plugins/pagefind/permissions/autogenerated/reference.md

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ Default permissions for the plugin
44

55
#### This default permission set includes the following:
66

7-
- `allow-search`
8-
- `allow-index`
7+
- `allow-build-index`
8+
- `allow-get-bundle-path`
9+
- `allow-clear-index`
910

1011
## Permission Table
1112

@@ -19,51 +20,77 @@ Default permissions for the plugin
1920
<tr>
2021
<td>
2122

22-
`pagefind:allow-index`
23+
`pagefind:allow-build-index`
2324

2425
</td>
2526
<td>
2627

27-
Enables the index command without any pre-configured scope.
28+
Enables the build_index command without any pre-configured scope.
2829

2930
</td>
3031
</tr>
3132

3233
<tr>
3334
<td>
3435

35-
`pagefind:deny-index`
36+
`pagefind:deny-build-index`
3637

3738
</td>
3839
<td>
3940

40-
Denies the index command without any pre-configured scope.
41+
Denies the build_index command without any pre-configured scope.
4142

4243
</td>
4344
</tr>
4445

4546
<tr>
4647
<td>
4748

48-
`pagefind:allow-search`
49+
`pagefind:allow-clear-index`
4950

5051
</td>
5152
<td>
5253

53-
Enables the search command without any pre-configured scope.
54+
Enables the clear_index command without any pre-configured scope.
5455

5556
</td>
5657
</tr>
5758

5859
<tr>
5960
<td>
6061

61-
`pagefind:deny-search`
62+
`pagefind:deny-clear-index`
6263

6364
</td>
6465
<td>
6566

66-
Denies the search command without any pre-configured scope.
67+
Denies the clear_index command without any pre-configured scope.
68+
69+
</td>
70+
</tr>
71+
72+
<tr>
73+
<td>
74+
75+
`pagefind:allow-get-bundle-path`
76+
77+
</td>
78+
<td>
79+
80+
Enables the get_bundle_path command without any pre-configured scope.
81+
82+
</td>
83+
</tr>
84+
85+
<tr>
86+
<td>
87+
88+
`pagefind:deny-get-bundle-path`
89+
90+
</td>
91+
<td>
92+
93+
Denies the get_bundle_path command without any pre-configured scope.
6794

6895
</td>
6996
</tr>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[default]
22
description = "Default permissions for the plugin"
3-
permissions = ["allow-search", "allow-index"]
3+
permissions = ["allow-build-index", "allow-get-bundle-path", "allow-clear-index"]

plugins/pagefind/permissions/schemas/schema.json

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -295,34 +295,46 @@
295295
"type": "string",
296296
"oneOf": [
297297
{
298-
"description": "Enables the index command without any pre-configured scope.",
298+
"description": "Enables the build_index command without any pre-configured scope.",
299299
"type": "string",
300-
"const": "allow-index",
301-
"markdownDescription": "Enables the index command without any pre-configured scope."
300+
"const": "allow-build-index",
301+
"markdownDescription": "Enables the build_index command without any pre-configured scope."
302302
},
303303
{
304-
"description": "Denies the index command without any pre-configured scope.",
304+
"description": "Denies the build_index command without any pre-configured scope.",
305305
"type": "string",
306-
"const": "deny-index",
307-
"markdownDescription": "Denies the index command without any pre-configured scope."
306+
"const": "deny-build-index",
307+
"markdownDescription": "Denies the build_index command without any pre-configured scope."
308308
},
309309
{
310-
"description": "Enables the search command without any pre-configured scope.",
310+
"description": "Enables the clear_index command without any pre-configured scope.",
311311
"type": "string",
312-
"const": "allow-search",
313-
"markdownDescription": "Enables the search command without any pre-configured scope."
312+
"const": "allow-clear-index",
313+
"markdownDescription": "Enables the clear_index command without any pre-configured scope."
314314
},
315315
{
316-
"description": "Denies the search command without any pre-configured scope.",
316+
"description": "Denies the clear_index command without any pre-configured scope.",
317317
"type": "string",
318-
"const": "deny-search",
319-
"markdownDescription": "Denies the search command without any pre-configured scope."
318+
"const": "deny-clear-index",
319+
"markdownDescription": "Denies the clear_index command without any pre-configured scope."
320320
},
321321
{
322-
"description": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-search`\n- `allow-index`",
322+
"description": "Enables the get_bundle_path command without any pre-configured scope.",
323+
"type": "string",
324+
"const": "allow-get-bundle-path",
325+
"markdownDescription": "Enables the get_bundle_path command without any pre-configured scope."
326+
},
327+
{
328+
"description": "Denies the get_bundle_path command without any pre-configured scope.",
329+
"type": "string",
330+
"const": "deny-get-bundle-path",
331+
"markdownDescription": "Denies the get_bundle_path command without any pre-configured scope."
332+
},
333+
{
334+
"description": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-build-index`\n- `allow-get-bundle-path`\n- `allow-clear-index`",
323335
"type": "string",
324336
"const": "default",
325-
"markdownDescription": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-search`\n- `allow-index`"
337+
"markdownDescription": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-build-index`\n- `allow-get-bundle-path`\n- `allow-clear-index`"
326338
}
327339
]
328340
}

plugins/pagefind/src/commands.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ use crate::{IndexRecord, PagefindPluginExt};
22

33
#[tauri::command]
44
#[specta::specta]
5-
pub(crate) fn build_index<R: tauri::Runtime>(
5+
pub(crate) async fn build_index<R: tauri::Runtime>(
66
app: tauri::AppHandle<R>,
77
records: Vec<IndexRecord>,
88
) -> Result<(), String> {
9-
app.pagefind()
10-
.build_index(records)
9+
let pagefind_dir = app.pagefind().pagefind_dir().map_err(|e| e.to_string())?;
10+
crate::build_index_inner(pagefind_dir, records)
11+
.await
1112
.map_err(|e| e.to_string())
1213
}
1314

0 commit comments

Comments
 (0)