update shortcodes for YASGUI

This commit is contained in:
Babibubebon 2022-09-07 02:06:42 +09:00
parent 72211af79e
commit 09a2f01afc
3 changed files with 15 additions and 8 deletions

View file

@ -4,15 +4,16 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/codemirror@5.65.8/theme/{{ .Site.Params.CodeMirrorTheme }}.css">
<script>
const yasgui = {};
function setYasguiQuery(yasguiId, tabName, query) {
function setYasguiQuery(yasguiId, tabName, query, endpoint) {
let yasguiInstance = yasgui[yasguiId];
let tab = yasguiInstance.getTab(tabName);
if (!tab) {
tab = yasguiInstance.addTab(true, {
...Yasgui.Tab.getDefaults(),
requestConfig: yasguiInstance.config.requestConfig,
requestConfig: endpoint ? {endpoint: endpoint} : yasguiInstance.config.requestConfig,
name: tabName,
id: tabName });
id: tabName
});
}
tab.setQuery(query);
tab.yasqe.query();

View file

@ -2,6 +2,6 @@
{{ highlight $q "sparql" }}
<a class="book-btn"
onclick="setYasguiQuery('{{ .Get "yasgui-id" }}', '{{ .Get "title" }}', '{{ $q }}'); location.href='#yasgui-{{ .Get "yasgui-id" }}'">
onclick="setYasguiQuery('{{ .Get "yasgui-id" }}', '{{ .Get "title" }}', '{{ $q }}', '{{ .Get "endpoint" }}'); location.href='#yasgui-{{ .Get "yasgui-id" }}'">
▶ 実行する
</a>

View file

@ -15,16 +15,22 @@
copyEndpointOnNewTab: false,
yasqe: {
theme: "{{ .Site.Params.CodeMirrorTheme }}",
{{ with .Get "default-query" }}
value: {{ . }}
{{ with .Inner }}
value: {{ trim . "\n" }}
{{ end }}
},
});
</script>
{{ if .Get "endpoint" }}
<style>
{{- if .Get "endpoint" }}
#yasgui-{{ .Get "id" }} .yasgui .autocompleteWrapper {
display: none !important;
}
{{- end -}}
{{ if not (default true (.Get "tab")) }}
#yasgui-{{ .Get "id" }} .yasgui .tabsList {
display: none !important;
}
{{- end }}
</style>
{{ end }}