Compare commits
No commits in common. "378a6f2ae10a0156ff6eee6df4f5078b7e184ac8" and "84278b2e91c9bcfcc08b34c08daa355e7c8f336a" have entirely different histories.
378a6f2ae1
...
84278b2e91
|
@ -42,7 +42,7 @@ const ensureObjectLanguage = () => {
|
|||
}
|
||||
return window.Bergamot.ObjectLanguage;
|
||||
}
|
||||
const parseBergamotObjectLanguage = (str) => {
|
||||
const parseString = (str) => {
|
||||
if (!(str in parsingPromiseResolvers)) {
|
||||
parsingPromiseResolvers[str] = [];
|
||||
}
|
||||
|
@ -54,21 +54,20 @@ const parseBergamotObjectLanguage = (str) => {
|
|||
}
|
||||
|
||||
window.Bergamot = {};
|
||||
window.Bergamot.run = (inputGroup, nodeId, inputModes, inputPrompt, rules, renderPreset, input) => {
|
||||
window.Bergamot.run = (inputGroup, nodeId, inputPrompt, rules, renderPreset, input) => {
|
||||
var app = Elm.Main.init({
|
||||
node: document.getElementById(nodeId),
|
||||
flags: {
|
||||
inputModes,
|
||||
inputModes: {
|
||||
"Languge Term": { "custom": "Language Term" },
|
||||
"Query": "query"
|
||||
},
|
||||
renderRules: window.Bergamot.renderPresets[renderPreset],
|
||||
rules, input
|
||||
}
|
||||
});
|
||||
app.ports.convertInput.subscribe(async ({ mode, input }) => {
|
||||
if (!(mode in window.Bergamot.inputModes)) {
|
||||
app.ports.receiveConverted.send({ input, result: { error: "Improperly configured desugaring function (this is the website developer's fault)" } });
|
||||
}
|
||||
|
||||
let query = await (window.Bergamot.inputModes[mode])(input);
|
||||
let query = await parseString(input);
|
||||
if (query !== null) {
|
||||
query = inputPrompt.replace("TERM", query);
|
||||
app.ports.receiveConverted.send({ input, result: { query } });
|
||||
|
@ -81,7 +80,7 @@ window.Bergamot.run = (inputGroup, nodeId, inputModes, inputPrompt, rules, rende
|
|||
};
|
||||
window.Bergamot.runPreset = (inputGroup, nodeId, presetName) => {
|
||||
const preset = window.Bergamot.presets[presetName];
|
||||
window.Bergamot.run(inputGroup, nodeId, preset.inputModes, preset.inputPrompt, preset.rules, preset.renderPreset, preset.query || "");
|
||||
window.Bergamot.run(inputGroup, nodeId, preset.inputPrompt, preset.rules, preset.renderPreset, preset.query || "");
|
||||
};
|
||||
window.Bergamot.close = (inputGroup, nodeId) => {
|
||||
if (!(nodeId in loadedWidgets)) return;
|
||||
|
@ -95,8 +94,5 @@ window.Bergamot.close = (inputGroup, nodeId) => {
|
|||
delete loadedWidgets[nodeId];
|
||||
setRunning(inputGroup, false);
|
||||
}
|
||||
window.Bergamot.inputModes = {
|
||||
"Bergamot Object Language": parseBergamotObjectLanguage
|
||||
};
|
||||
window.Bergamot.presets = {};
|
||||
window.Bergamot.renderPresets = {};
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
<script>
|
||||
window.addEventListener('load', function() {
|
||||
window.Bergamot.inputModes['{{ .name }}'] = {{ .fn | safeJS }};
|
||||
});
|
||||
</script>
|
||||
|
|
@ -2,7 +2,6 @@
|
|||
window.addEventListener('load', function() {
|
||||
window.Bergamot.presets['{{ .name }}'] = {
|
||||
rules: {{ .file }},
|
||||
inputModes: {{ partial "bergamotparseinputmodes.js" .modes | safeJS }},
|
||||
inputPrompt: '{{ .prompt }}',
|
||||
query: '{{ .query }}',
|
||||
renderPreset: '{{ default "default" .renderPreset }}'
|
||||
|
|
|
@ -43,12 +43,6 @@
|
|||
{{ end }}
|
||||
<link rel="icon" type="image/png" href="{{ $icon.Permalink }}">
|
||||
|
||||
{{ if .Params.custom_js }}
|
||||
{{ range $customJs := .Params.custom_js }}
|
||||
<script src="{{ page.Resources.Get $customJs }}"></script>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ if hugo.IsServer }}
|
||||
<!-- KaTeX auto-rendering for when we don't have a post-processing step. -->
|
||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.0/dist/katex.min.js" integrity="sha384-X/XCfMm41VSsqRNQgDerQczD69XqmjOOOwYQvr/uuC+j4OPoNhVgjdGFwhvN02Ja" crossorigin="anonymous"></script>
|
||||
|
@ -78,15 +72,10 @@
|
|||
{{ if .Params.bergamot.presets }}
|
||||
{{ range $name, $preset := .Params.bergamot.presets }}
|
||||
{{ $file := default (resources.Get $preset.file) (page.Resources.Get $preset.file) }}
|
||||
{{ $info := dict "name" $name "prompt" $preset.prompt "query" $preset.query "file" $file.Content "renderPreset" $preset.render_preset "inputModes" $preset.input_modes }}
|
||||
{{ $info := dict "name" $name "prompt" $preset.prompt "query" $preset.query "file" $file.Content "renderPreset" $preset.render_preset }}
|
||||
{{ partial "bergamotpreset.html" $info }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ if .Params.bergamot.input_modes }}
|
||||
{{ range $mode := .Params.bergamot.input_modes }}
|
||||
{{ partial "bergamotinputmode.html" (dict "name" $mode.name "fn" $mode.fn) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ with .Site.Params.plausibleAnalyticsDomain }}
|
||||
|
|
Loading…
Reference in New Issue
Block a user