Skip to content

Commit

Permalink
WIP: Add dropdown to toggle collections
Browse files Browse the repository at this point in the history
  • Loading branch information
jackrueth committed May 2, 2022
1 parent ec72257 commit bbda2b6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
1 change: 1 addition & 0 deletions _search/client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ <h1 class="header-title">
<div class="container">
<div id="search-panel">
<div id="search-box"></div>
<div id="search-dropdown"></div>
</div>

<div id="search-results">
Expand Down
24 changes: 22 additions & 2 deletions _search/client/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import TypesenseInstantSearchAdapter from "typesense-instantsearch-adapter";

const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
server: {
apiKey: "Sjkob6WIxE5vfpVK3Dp4FYPYFjRdWfBl" , // Be sure to use the search-only-api-key
apiKey: "F3vRyCOqztwtTQqk2MK3WiUHuveNczoa" , // Be sure to use the search-only-api-key
nodes: [
{
host: "144.92.48.217",
Expand All @@ -24,15 +24,35 @@ const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
});
const searchClient = typesenseInstantsearchAdapter.searchClient;

/* search.addWidget(
instantsearch.widgets.sortBySelector({
container: '#search-panel',
indicies: [
{name: 'imagej-wiki', label: 'imagej-wiki'},
{name: 'imagej-tutorials', label: 'imagej-tutorials'},
{name: 'imagej-website', label: 'imagej-websites'}
]
})
) */

const search = instantsearch({
searchClient,
indexName: "imagej-wiki"
indexName: "imagej-tutorials"
});

search.addWidgets([
instantsearch.widgets.searchBox({
container: '#search-box',
}),
// this is an attempt to add a dropdown selector to choose between collection options
/* instantsearch.widgets.sortBySelector({
container: '#search-dropdown', // I created search-dropdown in the html to try to add a place for the dropdown
indicies: [
{name: 'imagej-wiki', label: 'imagej-wiki'},
{name: 'imagej-tutorials', label: 'imagej-tutorials'},
{name: 'imagej-website', label: 'imagej-websites'}
]
}), */
instantsearch.widgets.hits({
container: '#search-hits',
templates: {
Expand Down
5 changes: 3 additions & 2 deletions _search/server/tutorials.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def parse_java_source(path):
doc['content'] = ''.join(lines)
title = str(path)
doc['title'] = title[title.find("tutorials/")+len("tutorials/"):]
doc['icon'] = 'Java_logo.png'
doc['icon'] = '../../media/java.png'
doc['score'] = 90
doc['description'] = ''

Expand All @@ -49,7 +49,7 @@ def parse_notebook(path):
doc['content'] = ''
title = str(path)
doc['title'] = title[title.find("tutorials/")+len("tutorials/"):]
doc['icon'] = 'Jupyter_logo.png'
doc['icon'] = '../../media/jupyter.png'
doc['score'] = 90
doc['description'] = ''
for cell in data['cells']:
Expand Down Expand Up @@ -120,6 +120,7 @@ def load_imagej_tutorials(root):

return documents

# used for testing
""" def main(args):
docs = load_imagej_tutorials(args[0])
for doc in docs:
Expand Down

0 comments on commit bbda2b6

Please sign in to comment.