Skip to content

Commit 09fd354

Browse files
authored
Merge pull request #8 from VirtualFlyBrain/site/search-palette
Wire up the nav search button, searching the workshop then virtualflybrain.org
2 parents 0ddc7e3 + c6eff5a commit 09fd354

6 files changed

Lines changed: 387 additions & 1 deletion

File tree

site/content/en/no-code/chat-template.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
title: "VFB Chat question template"
3+
description: "A blank template for asking VFB Chat about your own neurons of interest"
4+
---
15
# VFB Chat - Blank Question Template
26

37
## Use this template for your own questions

site/hugo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ timeZone = "Europe/London"
3737
sessions = "/sessions/:slug/"
3838

3939
[outputs]
40-
home = ["HTML"]
40+
home = ["HTML", "JSON"] # /index.json feeds the search palette
4141
section = ["HTML", "RSS"]
4242
page = ["HTML"]
4343

site/layouts/_default/baseof.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@
4141
</main>
4242

4343
{{ partial "footer.html" . }}
44+
{{ partial "palette.html" . }}
4445

4546
{{ block "scripts" . }}{{ end }}
47+
{{ $search := resources.Get "js/search.js" | minify | fingerprint }}
48+
<script src="{{ $search.RelPermalink }}" integrity="{{ $search.Data.Integrity }}" defer></script>
4649

4750
{{ partial "reveal.html" . }}
4851

site/layouts/_default/index.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{{- /* Client-side search index for the nav search palette (see
2+
assets/js/search.js). Every authored page on the site; the session pages
3+
keep most of their text in front-matter route blocks (python_content,
4+
r_content, …) rather than .Content, so those are folded into "body" or a
5+
search for "get_instances" would find nothing. */ -}}
6+
{{- $pinned := slice "/sessions/" "/setup/" "/no-code/" -}}
7+
{{- $out := slice -}}
8+
{{- range site.Pages -}}
9+
{{- if and (not .IsHome) (ne .Kind "taxonomy") (ne .Kind "term") -}}
10+
{{- $p := . -}}
11+
{{- $body := .Plain -}}
12+
{{- range slice "python_content" "r_content" "mcp_content" "chat_content" "browser_content" -}}
13+
{{- with index $p.Params . -}}{{- $body = printf "%s %s" $body (. | plainify) -}}{{- end -}}
14+
{{- end -}}
15+
{{- $out = $out | append (dict
16+
"title" (.LinkTitle | default .File.ContentBaseName) "url" .RelPermalink "section" .Section
17+
"desc" (.Description | truncate 120 | chomp | htmlUnescape)
18+
"keywords" (.Params.keywords | default slice)
19+
"body" ($body | truncate 4000 | chomp | htmlUnescape)
20+
"pinned" (in $pinned .RelPermalink)) -}}
21+
{{- end -}}
22+
{{- end -}}
23+
{{- $out | jsonify -}}

site/layouts/partials/palette.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{{/* Search palette: workshop pages from /index.json, then virtualflybrain.org's
2+
pages from its own index (what its /search/ runs over), then VFB anatomy terms live
3+
from the same SOLR core the 3D browser uses (opened there). Same engine as
4+
virtualflybrain.org (themes/vfb-nova/assets/js/app.js in VFB2); the index
5+
URL carries the build time so a cached copy never outlives a rebuild. */}}
6+
<div class="palette" hidden role="dialog" aria-modal="true" aria-label="Search"
7+
data-index="{{ "/index.json" | relURL }}?v={{ now.Format "20060102150405" }}"
8+
data-remote-index="https://www.virtualflybrain.org/index.json"
9+
data-remote-base="https://www.virtualflybrain.org"
10+
data-remote-label="virtualflybrain.org"
11+
data-solr="https://solr.virtualflybrain.org/solr/ontology/select"
12+
data-browser="https://v2.virtualflybrain.org/org.geppetto.frontend/geppetto">
13+
<div class="palette__box">
14+
<div class="palette__field">
15+
<i class="fas fa-magnifying-glass"></i>
16+
<input id="palette-input" type="search" autocomplete="off" spellcheck="false"
17+
placeholder="Search the workshop — sessions, setup, neurons, brain regions…" aria-label="Search query">
18+
<kbd class="js-close-palette" role="button" tabindex="0">esc</kbd>
19+
</div>
20+
<ul class="palette__results" id="palette-results"></ul>
21+
<div class="palette__foot">
22+
<span><kbd></kbd><kbd></kbd> navigate</span>
23+
<span><kbd></kbd> open</span>
24+
<span style="margin-left:auto">Anatomy terms open in the <a href="https://v2.virtualflybrain.org/" target="_blank" rel="noopener">3D&nbsp;browser</a></span>
25+
</div>
26+
</div>
27+
</div>

0 commit comments

Comments
 (0)