@turnipxenon/pineapple 2.4.53 → 2.4.54
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/.idea/workspace.xml +42 -41
- package/.svelte-kit/__package__/template/seaweed/ParseQueryTerms.d.ts +1 -0
- package/.svelte-kit/__package__/template/seaweed/ParseQueryTerms.js +23 -0
- package/.svelte-kit/__package__/template/seaweed/SeaweedTemplate.svelte +5 -22
- package/.svelte-kit/generated/server/internal.js +1 -1
- package/dist/template/seaweed/ParseQueryTerms.d.ts +1 -0
- package/dist/template/seaweed/ParseQueryTerms.js +23 -0
- package/dist/template/seaweed/SeaweedTemplate.svelte +5 -22
- package/package.json +1 -1
- package/src/lib/template/seaweed/ParseQueryTerms.ts +26 -0
- package/src/lib/template/seaweed/SeaweedTemplate.svelte +5 -34
package/.idea/workspace.xml
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
<option name="autoReloadType" value="SELECTIVE" />
|
|
5
5
|
</component>
|
|
6
6
|
<component name="ChangeListManager">
|
|
7
|
-
<list default="true" id="accb6ba2-c343-4f84-ad30-6e2d71eceee5" name="Changes" comment="
|
|
7
|
+
<list default="true" id="accb6ba2-c343-4f84-ad30-6e2d71eceee5" name="Changes" comment="Move parseQtTerm on afterUpdate">
|
|
8
|
+
<change afterPath="$PROJECT_DIR$/src/lib/template/seaweed/ParseQueryTerms.ts" afterDir="false" />
|
|
8
9
|
<change beforePath="$PROJECT_DIR$/src/lib/template/seaweed/SeaweedTemplate.svelte" beforeDir="false" afterPath="$PROJECT_DIR$/src/lib/template/seaweed/SeaweedTemplate.svelte" afterDir="false" />
|
|
9
10
|
</list>
|
|
10
11
|
<option name="SHOW_DIALOG" value="false" />
|
|
@@ -107,41 +108,41 @@
|
|
|
107
108
|
<option name="hideEmptyMiddlePackages" value="true" />
|
|
108
109
|
<option name="showLibraryContents" value="true" />
|
|
109
110
|
</component>
|
|
110
|
-
<component name="PropertiesComponent"
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
111
|
+
<component name="PropertiesComponent"><![CDATA[{
|
|
112
|
+
"keyToString": {
|
|
113
|
+
"DefaultHtmlFileTemplate": "HTML File",
|
|
114
|
+
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
|
115
|
+
"RunOnceActivity.ShowReadmeOnStart": "true",
|
|
116
|
+
"WebServerToolWindowFactoryState": "false",
|
|
117
|
+
"git-widget-placeholder": "turnip/customizable2",
|
|
118
|
+
"ignore.virus.scanning.warn.message": "true",
|
|
119
|
+
"last_opened_file_path": "C:/Users/Pumpkin/Projects/Web/pineapple/src/lib/template/seaweed",
|
|
120
|
+
"list.type.of.created.stylesheet": "CSS",
|
|
121
|
+
"node.js.detected.package.eslint": "true",
|
|
122
|
+
"node.js.detected.package.tslint": "true",
|
|
123
|
+
"node.js.selected.package.eslint": "(autodetect)",
|
|
124
|
+
"node.js.selected.package.tslint": "(autodetect)",
|
|
125
|
+
"nodejs_interpreter_path": "node",
|
|
126
|
+
"nodejs_package_manager_path": "yarn",
|
|
127
|
+
"npm.build.executor": "Run",
|
|
128
|
+
"npm.dev (1).executor": "Run",
|
|
129
|
+
"npm.dev --open.executor": "Run",
|
|
130
|
+
"npm.dev offline.executor": "Run",
|
|
131
|
+
"npm.dev-offline.executor": "Run",
|
|
132
|
+
"npm.dev.executor": "Run",
|
|
133
|
+
"npm.to-dev.executor": "Run",
|
|
134
|
+
"settings.editor.selected.configurable": "preferences.general",
|
|
135
|
+
"ts.external.directory.path": "C:\\Users\\Pumpkin\\Projects\\Web\\pineapple\\node_modules\\typescript\\lib",
|
|
136
|
+
"vue.rearranger.settings.migration": "true"
|
|
136
137
|
}
|
|
137
|
-
}
|
|
138
|
+
}]]></component>
|
|
138
139
|
<component name="RecentsManager">
|
|
139
140
|
<key name="CopyFile.RECENT_KEYS">
|
|
141
|
+
<recent name="C:\Users\Pumpkin\Projects\Web\pineapple\src\lib\template\seaweed" />
|
|
140
142
|
<recent name="C:\Users\Pumpkin\Projects\Web\pineapple\src\lib\template\seaweed\entries" />
|
|
141
143
|
<recent name="C:\Users\Pumpkin\Projects\Web\pineapple\src\routes\(pineapple)\pineapple\(extra-pages)\page3\page7\(test_layout)\page8" />
|
|
142
144
|
<recent name="C:\Users\Pumpkin\Projects\Web\pineapple\src\routes\(pineapple)\pineapple\(extra-pages)\page3\page5" />
|
|
143
145
|
<recent name="C:\Users\Pumpkin\Projects\Web\pineapple\src\routes\(pineapple)\pineapple\(extra-pages)\page2" />
|
|
144
|
-
<recent name="C:\Users\Pumpkin\Projects\Web\pineapple\src\lib\components\navigation_component" />
|
|
145
146
|
</key>
|
|
146
147
|
<key name="MoveFile.RECENT_KEYS">
|
|
147
148
|
<recent name="C:\Users\Pumpkin\Projects\Web\pineapple\src\lib\components\combo_box" />
|
|
@@ -329,15 +330,7 @@
|
|
|
329
330
|
<workItem from="1712534451700" duration="490000" />
|
|
330
331
|
<workItem from="1712535021202" duration="299000" />
|
|
331
332
|
<workItem from="1712535434722" duration="522000" />
|
|
332
|
-
<workItem from="1712536086680" duration="
|
|
333
|
-
</task>
|
|
334
|
-
<task id="LOCAL-00118" summary="Fix allowLinkedin arg in SocialSection">
|
|
335
|
-
<option name="closed" value="true" />
|
|
336
|
-
<created>1711683031188</created>
|
|
337
|
-
<option name="number" value="00118" />
|
|
338
|
-
<option name="presentableId" value="LOCAL-00118" />
|
|
339
|
-
<option name="project" value="LOCAL" />
|
|
340
|
-
<updated>1711683031188</updated>
|
|
333
|
+
<workItem from="1712536086680" duration="3391000" />
|
|
341
334
|
</task>
|
|
342
335
|
<task id="LOCAL-00119" summary="Change media to containre">
|
|
343
336
|
<option name="closed" value="true" />
|
|
@@ -723,7 +716,15 @@
|
|
|
723
716
|
<option name="project" value="LOCAL" />
|
|
724
717
|
<updated>1712535169690</updated>
|
|
725
718
|
</task>
|
|
726
|
-
<
|
|
719
|
+
<task id="LOCAL-00167" summary="Move parseQtTerm on afterUpdate">
|
|
720
|
+
<option name="closed" value="true" />
|
|
721
|
+
<created>1712537061829</created>
|
|
722
|
+
<option name="number" value="00167" />
|
|
723
|
+
<option name="presentableId" value="LOCAL-00167" />
|
|
724
|
+
<option name="project" value="LOCAL" />
|
|
725
|
+
<updated>1712537061829</updated>
|
|
726
|
+
</task>
|
|
727
|
+
<option name="localTasksCounter" value="168" />
|
|
727
728
|
<servers />
|
|
728
729
|
</component>
|
|
729
730
|
<component name="TypeScriptGeneratedFilesManager">
|
|
@@ -781,7 +782,6 @@
|
|
|
781
782
|
</option>
|
|
782
783
|
</component>
|
|
783
784
|
<component name="VcsManagerConfiguration">
|
|
784
|
-
<MESSAGE value="Add cdktf" />
|
|
785
785
|
<MESSAGE value="Implement cdktf for empty AppService" />
|
|
786
786
|
<MESSAGE value="WIP: cdktf" />
|
|
787
787
|
<MESSAGE value="Revert "Correct app_build_command in Azure SWA GithubActions" Revert b34caf17" />
|
|
@@ -806,6 +806,7 @@
|
|
|
806
806
|
<MESSAGE value="Put parseQTTerms in afterUpdate instead of onMount" />
|
|
807
807
|
<MESSAGE value="Add logs to observe queryTermMap in downstream package" />
|
|
808
808
|
<MESSAGE value="Add logs to observe parseQtTerms in downstream package" />
|
|
809
|
-
<
|
|
809
|
+
<MESSAGE value="Move parseQtTerm on afterUpdate" />
|
|
810
|
+
<option name="LAST_COMMIT_MESSAGE" value="Move parseQtTerm on afterUpdate" />
|
|
810
811
|
</component>
|
|
811
812
|
</project>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const parseQueryTerms: (node: Element, querySet: Set<string>) => void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const parseQueryTerms = (node, querySet) => {
|
|
2
|
+
// change all text content to gibberish
|
|
3
|
+
for (const child of Array.from(node.children)) {
|
|
4
|
+
if (child.nodeType === Node.ELEMENT_NODE) {
|
|
5
|
+
parseQueryTerms(child, querySet);
|
|
6
|
+
// todo: if it's a span and it wraps a word, and qt class then we count that as query
|
|
7
|
+
// for (const childOfChild of child.childNodes) {
|
|
8
|
+
// if (childOfChild.nodeType === Node.TEXT_NODE && childOfChild.textContent?.trim()) {
|
|
9
|
+
// // todo analyze textcontent
|
|
10
|
+
// }
|
|
11
|
+
// }
|
|
12
|
+
// Warning: below is not redundant and is a catch-all
|
|
13
|
+
// Long-term solution: figure out the correct typing
|
|
14
|
+
if ((typeof child.className === "string") && child.className?.includes("qt-")) {
|
|
15
|
+
child.className.split(" ").forEach(c => {
|
|
16
|
+
if (c.startsWith("qt-")) {
|
|
17
|
+
querySet.add(c);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script>import {
|
|
1
|
+
<script>import { afterUpdate, onMount } from "svelte";
|
|
2
2
|
import EntryOrderConfig from "./entry_order_config/EntryOrderConfig.svelte";
|
|
3
3
|
import { runChaos } from "./RunChaos";
|
|
4
4
|
import SocialSection from "../../components/SocialSection.svelte";
|
|
@@ -8,13 +8,13 @@ import { Accordion, AccordionItem, CodeBlock, SlideToggle } from "@skeletonlabs/
|
|
|
8
8
|
import { page } from "$app/stores";
|
|
9
9
|
import Card from "../../components/Card.svelte";
|
|
10
10
|
import ElementVisbilityDetector from "../../components/ElementVisbilityDetector.svelte";
|
|
11
|
-
import selfContent from "./SeaweedTemplate.svelte?raw";
|
|
12
11
|
import {
|
|
13
12
|
AllGroupedEntriesProjectFirst,
|
|
14
13
|
GetEntryFromGlobal,
|
|
15
14
|
seaweedTemplateData,
|
|
16
15
|
TurnGroupEntriesMutable
|
|
17
16
|
} from "./SeaweedTemplateData";
|
|
17
|
+
import { parseQueryTerms } from "./ParseQueryTerms";
|
|
18
18
|
export let letChaos = true;
|
|
19
19
|
export let name = "Turnip";
|
|
20
20
|
export let email = "turnipxenon@gmail.com";
|
|
@@ -25,7 +25,6 @@ export let extraComponent = void 0;
|
|
|
25
25
|
const entryProps = {
|
|
26
26
|
email
|
|
27
27
|
};
|
|
28
|
-
const entryList = import.meta.glob("./entries/*.svelte", { query: "?raw", eager: true });
|
|
29
28
|
const paramQTSet = /* @__PURE__ */ new Set();
|
|
30
29
|
let isVisible = true;
|
|
31
30
|
let isAdvanceSettingOn = false;
|
|
@@ -46,25 +45,9 @@ const syncQT = () => {
|
|
|
46
45
|
});
|
|
47
46
|
seaweedTemplateData.queryTermMap = seaweedTemplateData.queryTermMap;
|
|
48
47
|
};
|
|
49
|
-
const
|
|
50
|
-
console.log("parsing", seaweedTemplateData.queryTermMap.size);
|
|
48
|
+
const parseQueryTermsLocal = async () => {
|
|
51
49
|
const qtSet = /* @__PURE__ */ new Set();
|
|
52
|
-
|
|
53
|
-
[...Object.values(entryList).map((e) => e.default), selfContent].forEach((body) => {
|
|
54
|
-
console.log("parsing", body);
|
|
55
|
-
rawTermList.push(
|
|
56
|
-
...body.split('"').filter((s) => s.startsWith("qt-"))
|
|
57
|
-
// step 2: filter out texts that does not begin with "qt-"
|
|
58
|
-
);
|
|
59
|
-
});
|
|
60
|
-
rawTermList.forEach((t) => {
|
|
61
|
-
t.split(" ").forEach((nt) => {
|
|
62
|
-
if (["qt-1", "qt-2", "qt-*", "qt-"].includes(nt)) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
qtSet.add(nt);
|
|
66
|
-
});
|
|
67
|
-
});
|
|
50
|
+
parseQueryTerms(document.body, qtSet);
|
|
68
51
|
qtSet.forEach((t) => seaweedTemplateData.queryTermMap.set(t, true));
|
|
69
52
|
seaweedTemplateData.queryTermMap = seaweedTemplateData.queryTermMap;
|
|
70
53
|
syncQT();
|
|
@@ -132,7 +115,7 @@ let isParsed = false;
|
|
|
132
115
|
afterUpdate(async () => {
|
|
133
116
|
if (!letChaos && !isParsed) {
|
|
134
117
|
isParsed = true;
|
|
135
|
-
await
|
|
118
|
+
await parseQueryTermsLocal();
|
|
136
119
|
}
|
|
137
120
|
});
|
|
138
121
|
const toggleTerm = (term) => {
|
|
@@ -21,7 +21,7 @@ export const options = {
|
|
|
21
21
|
app: ({ head, body, assets, nonce, env }) => "<!DOCTYPE html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<link rel=\"icon\" href=\"" + assets + "/favicon.png\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width\" />\n\t\t" + head + "\n\t</head>\n\n\t<body data-sveltekit-preload-data=\"hover\" data-theme=\"crimson\">\n\t\t<div style=\"display: contents\" class=\"h-full overflow-hidden\">" + body + "</div>\n\t</body>\n</html>\n",
|
|
22
22
|
error: ({ status, message }) => "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<title>" + message + "</title>\n\n\t\t<style>\n\t\t\tbody {\n\t\t\t\t--bg: white;\n\t\t\t\t--fg: #222;\n\t\t\t\t--divider: #ccc;\n\t\t\t\tbackground: var(--bg);\n\t\t\t\tcolor: var(--fg);\n\t\t\t\tfont-family:\n\t\t\t\t\tsystem-ui,\n\t\t\t\t\t-apple-system,\n\t\t\t\t\tBlinkMacSystemFont,\n\t\t\t\t\t'Segoe UI',\n\t\t\t\t\tRoboto,\n\t\t\t\t\tOxygen,\n\t\t\t\t\tUbuntu,\n\t\t\t\t\tCantarell,\n\t\t\t\t\t'Open Sans',\n\t\t\t\t\t'Helvetica Neue',\n\t\t\t\t\tsans-serif;\n\t\t\t\tdisplay: flex;\n\t\t\t\talign-items: center;\n\t\t\t\tjustify-content: center;\n\t\t\t\theight: 100vh;\n\t\t\t\tmargin: 0;\n\t\t\t}\n\n\t\t\t.error {\n\t\t\t\tdisplay: flex;\n\t\t\t\talign-items: center;\n\t\t\t\tmax-width: 32rem;\n\t\t\t\tmargin: 0 1rem;\n\t\t\t}\n\n\t\t\t.status {\n\t\t\t\tfont-weight: 200;\n\t\t\t\tfont-size: 3rem;\n\t\t\t\tline-height: 1;\n\t\t\t\tposition: relative;\n\t\t\t\ttop: -0.05rem;\n\t\t\t}\n\n\t\t\t.message {\n\t\t\t\tborder-left: 1px solid var(--divider);\n\t\t\t\tpadding: 0 0 0 1rem;\n\t\t\t\tmargin: 0 0 0 1rem;\n\t\t\t\tmin-height: 2.5rem;\n\t\t\t\tdisplay: flex;\n\t\t\t\talign-items: center;\n\t\t\t}\n\n\t\t\t.message h1 {\n\t\t\t\tfont-weight: 400;\n\t\t\t\tfont-size: 1em;\n\t\t\t\tmargin: 0;\n\t\t\t}\n\n\t\t\t@media (prefers-color-scheme: dark) {\n\t\t\t\tbody {\n\t\t\t\t\t--bg: #222;\n\t\t\t\t\t--fg: #ddd;\n\t\t\t\t\t--divider: #666;\n\t\t\t\t}\n\t\t\t}\n\t\t</style>\n\t</head>\n\t<body>\n\t\t<div class=\"error\">\n\t\t\t<span class=\"status\">" + status + "</span>\n\t\t\t<div class=\"message\">\n\t\t\t\t<h1>" + message + "</h1>\n\t\t\t</div>\n\t\t</div>\n\t</body>\n</html>\n"
|
|
23
23
|
},
|
|
24
|
-
version_hash: "
|
|
24
|
+
version_hash: "kjai7p"
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
export async function get_hooks() {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const parseQueryTerms: (node: Element, querySet: Set<string>) => void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const parseQueryTerms = (node, querySet) => {
|
|
2
|
+
// change all text content to gibberish
|
|
3
|
+
for (const child of Array.from(node.children)) {
|
|
4
|
+
if (child.nodeType === Node.ELEMENT_NODE) {
|
|
5
|
+
parseQueryTerms(child, querySet);
|
|
6
|
+
// todo: if it's a span and it wraps a word, and qt class then we count that as query
|
|
7
|
+
// for (const childOfChild of child.childNodes) {
|
|
8
|
+
// if (childOfChild.nodeType === Node.TEXT_NODE && childOfChild.textContent?.trim()) {
|
|
9
|
+
// // todo analyze textcontent
|
|
10
|
+
// }
|
|
11
|
+
// }
|
|
12
|
+
// Warning: below is not redundant and is a catch-all
|
|
13
|
+
// Long-term solution: figure out the correct typing
|
|
14
|
+
if ((typeof child.className === "string") && child.className?.includes("qt-")) {
|
|
15
|
+
child.className.split(" ").forEach(c => {
|
|
16
|
+
if (c.startsWith("qt-")) {
|
|
17
|
+
querySet.add(c);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script>import {
|
|
1
|
+
<script>import { afterUpdate, onMount } from "svelte";
|
|
2
2
|
import EntryOrderConfig from "./entry_order_config/EntryOrderConfig.svelte";
|
|
3
3
|
import { runChaos } from "./RunChaos";
|
|
4
4
|
import SocialSection from "../../components/SocialSection.svelte";
|
|
@@ -8,13 +8,13 @@ import { Accordion, AccordionItem, CodeBlock, SlideToggle } from "@skeletonlabs/
|
|
|
8
8
|
import { page } from "$app/stores";
|
|
9
9
|
import Card from "../../components/Card.svelte";
|
|
10
10
|
import ElementVisbilityDetector from "../../components/ElementVisbilityDetector.svelte";
|
|
11
|
-
import selfContent from "./SeaweedTemplate.svelte?raw";
|
|
12
11
|
import {
|
|
13
12
|
AllGroupedEntriesProjectFirst,
|
|
14
13
|
GetEntryFromGlobal,
|
|
15
14
|
seaweedTemplateData,
|
|
16
15
|
TurnGroupEntriesMutable
|
|
17
16
|
} from "./SeaweedTemplateData";
|
|
17
|
+
import { parseQueryTerms } from "./ParseQueryTerms";
|
|
18
18
|
export let letChaos = true;
|
|
19
19
|
export let name = "Turnip";
|
|
20
20
|
export let email = "turnipxenon@gmail.com";
|
|
@@ -25,7 +25,6 @@ export let extraComponent = void 0;
|
|
|
25
25
|
const entryProps = {
|
|
26
26
|
email
|
|
27
27
|
};
|
|
28
|
-
const entryList = import.meta.glob("./entries/*.svelte", { query: "?raw", eager: true });
|
|
29
28
|
const paramQTSet = /* @__PURE__ */ new Set();
|
|
30
29
|
let isVisible = true;
|
|
31
30
|
let isAdvanceSettingOn = false;
|
|
@@ -46,25 +45,9 @@ const syncQT = () => {
|
|
|
46
45
|
});
|
|
47
46
|
seaweedTemplateData.queryTermMap = seaweedTemplateData.queryTermMap;
|
|
48
47
|
};
|
|
49
|
-
const
|
|
50
|
-
console.log("parsing", seaweedTemplateData.queryTermMap.size);
|
|
48
|
+
const parseQueryTermsLocal = async () => {
|
|
51
49
|
const qtSet = /* @__PURE__ */ new Set();
|
|
52
|
-
|
|
53
|
-
[...Object.values(entryList).map((e) => e.default), selfContent].forEach((body) => {
|
|
54
|
-
console.log("parsing", body);
|
|
55
|
-
rawTermList.push(
|
|
56
|
-
...body.split('"').filter((s) => s.startsWith("qt-"))
|
|
57
|
-
// step 2: filter out texts that does not begin with "qt-"
|
|
58
|
-
);
|
|
59
|
-
});
|
|
60
|
-
rawTermList.forEach((t) => {
|
|
61
|
-
t.split(" ").forEach((nt) => {
|
|
62
|
-
if (["qt-1", "qt-2", "qt-*", "qt-"].includes(nt)) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
qtSet.add(nt);
|
|
66
|
-
});
|
|
67
|
-
});
|
|
50
|
+
parseQueryTerms(document.body, qtSet);
|
|
68
51
|
qtSet.forEach((t) => seaweedTemplateData.queryTermMap.set(t, true));
|
|
69
52
|
seaweedTemplateData.queryTermMap = seaweedTemplateData.queryTermMap;
|
|
70
53
|
syncQT();
|
|
@@ -132,7 +115,7 @@ let isParsed = false;
|
|
|
132
115
|
afterUpdate(async () => {
|
|
133
116
|
if (!letChaos && !isParsed) {
|
|
134
117
|
isParsed = true;
|
|
135
|
-
await
|
|
118
|
+
await parseQueryTermsLocal();
|
|
136
119
|
}
|
|
137
120
|
});
|
|
138
121
|
const toggleTerm = (term) => {
|
package/package.json
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const parseQueryTerms = (node: Element, querySet: Set<string>) => {
|
|
2
|
+
// change all text content to gibberish
|
|
3
|
+
for (const child of Array.from(node.children)) {
|
|
4
|
+
if (child.nodeType === Node.ELEMENT_NODE) {
|
|
5
|
+
parseQueryTerms(child, querySet);
|
|
6
|
+
// todo: if it's a span and it wraps a word, and qt class then we count that as query
|
|
7
|
+
// for (const childOfChild of child.childNodes) {
|
|
8
|
+
// if (childOfChild.nodeType === Node.TEXT_NODE && childOfChild.textContent?.trim()) {
|
|
9
|
+
// // todo analyze textcontent
|
|
10
|
+
// }
|
|
11
|
+
// }
|
|
12
|
+
|
|
13
|
+
// Warning: below is not redundant and is a catch-all
|
|
14
|
+
// Long-term solution: figure out the correct typing
|
|
15
|
+
if ((typeof child.className === "string") && child.className?.includes("qt-")) {
|
|
16
|
+
child.className.split(" ").forEach(c => {
|
|
17
|
+
|
|
18
|
+
if (c.startsWith("qt-")) {
|
|
19
|
+
querySet.add(c);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { type ComponentType, onMount
|
|
2
|
+
import { afterUpdate, type ComponentType, onMount } from "svelte";
|
|
3
3
|
import EntryOrderConfig from "$pkg/template/seaweed/entry_order_config/EntryOrderConfig.svelte";
|
|
4
4
|
import { runChaos } from "$pkg/template/seaweed/RunChaos";
|
|
5
5
|
import SocialSection from "$pkg/components/SocialSection.svelte";
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
import { page } from "$app/stores";
|
|
10
10
|
import Card from "$pkg/components/Card.svelte";
|
|
11
11
|
import ElementVisbilityDetector from "$pkg/components/ElementVisbilityDetector.svelte";
|
|
12
|
-
import selfContent from "./SeaweedTemplate.svelte?raw";
|
|
13
12
|
import {
|
|
14
13
|
AllGroupedEntriesProjectFirst,
|
|
15
14
|
type EntryGroup,
|
|
@@ -19,7 +18,7 @@
|
|
|
19
18
|
TurnGroupEntriesMutable
|
|
20
19
|
} from "./SeaweedTemplateData";
|
|
21
20
|
import type { EntryProps } from "$pkg/template/seaweed/entries/EntryProps";
|
|
22
|
-
import
|
|
21
|
+
import { parseQueryTerms } from "$pkg/template/seaweed/ParseQueryTerms";
|
|
23
22
|
|
|
24
23
|
export let letChaos = true;
|
|
25
24
|
export let name = "Turnip";
|
|
@@ -34,7 +33,6 @@
|
|
|
34
33
|
email
|
|
35
34
|
};
|
|
36
35
|
|
|
37
|
-
const entryList = import.meta.glob("./entries/*.svelte", { query: "?raw", eager: true });
|
|
38
36
|
const paramQTSet = new Set<string>();
|
|
39
37
|
|
|
40
38
|
let isVisible = true;
|
|
@@ -61,36 +59,9 @@
|
|
|
61
59
|
seaweedTemplateData.queryTermMap = seaweedTemplateData.queryTermMap;
|
|
62
60
|
};
|
|
63
61
|
|
|
64
|
-
const
|
|
65
|
-
console.log("parsing", seaweedTemplateData.queryTermMap.size);
|
|
62
|
+
const parseQueryTermsLocal = async () => {
|
|
66
63
|
const qtSet = new Set<string>();
|
|
67
|
-
|
|
68
|
-
[...Object.values(entryList).map(e => (e as RawGlob).default), selfContent].forEach(body => {
|
|
69
|
-
// parse the qt-* term which exists within elements like:
|
|
70
|
-
// <span class="qt-*">TERM</span>
|
|
71
|
-
console.log("parsing", body);
|
|
72
|
-
rawTermList.push(
|
|
73
|
-
...body // step 3: destructure the array
|
|
74
|
-
.split("\"") // step 1: split the text as double quotations (") as the delimiter
|
|
75
|
-
.filter(s => s.startsWith("qt-")) // step 2: filter out texts that does not begin with "qt-"
|
|
76
|
-
);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
// step 4: some spans contain multiple classes, split them up
|
|
80
|
-
// then add them to qtTerms
|
|
81
|
-
// e.g. <span class="qt-1 qt-2">TERM</span>
|
|
82
|
-
rawTermList.forEach(t => {
|
|
83
|
-
t.split(" ").forEach(nt => {
|
|
84
|
-
// filter out some of this meta terms
|
|
85
|
-
if (["qt-1", "qt-2", "qt-*", "qt-"].includes(nt)) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// adding to set ensures the entry is unique
|
|
90
|
-
qtSet.add(nt);
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
|
|
64
|
+
parseQueryTerms(document.body, qtSet);
|
|
94
65
|
qtSet.forEach(t => seaweedTemplateData.queryTermMap.set(t, true));
|
|
95
66
|
// force svelte update
|
|
96
67
|
seaweedTemplateData.queryTermMap = seaweedTemplateData.queryTermMap;
|
|
@@ -194,7 +165,7 @@
|
|
|
194
165
|
afterUpdate(async () => {
|
|
195
166
|
if (!letChaos && !isParsed) {
|
|
196
167
|
isParsed = true;
|
|
197
|
-
await
|
|
168
|
+
await parseQueryTermsLocal();
|
|
198
169
|
}
|
|
199
170
|
});
|
|
200
171
|
|