Skip to content

Commit 2f9bd5c

Browse files
committed
WIP: Add notebooks data to client search
1 parent 42204a5 commit 2f9bd5c

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

_search/client/src/app.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import TypesenseInstantSearchAdapter from "typesense-instantsearch-adapter";
44

55
const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
66
server: {
7-
apiKey: "hz046FoyrmnivD6aCNxGOQA5OZ8dNI70", // Be sure to use the search-only-api-key
7+
apiKey: "KfjkBJl6Yilg8sK0vngKBv6g7csQgVPH" , // Be sure to use the search-only-api-key
88
nodes: [
99
{
10-
host: "search.imagej.net",
10+
host: "144.92.48.217",
1111
port: "8108",
12-
protocol: "https"
12+
protocol: "http"
1313
}
1414
]
1515
},

_search/server/index-sites.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ def main(args):
5151
if len(args) == 1:
5252
collection = 'imagej-wiki'
5353
sites = {
54-
'imagej.net': os.path.join(os.path.dirname(args[0]), '..', '..'),
55-
'imagej.nih.gov/ij': '/var/www/mirror.imagej.net',
54+
# 'imagej.net': os.path.join(os.path.dirname(args[0]), '..', '..'),
55+
# 'imagej.nih.gov/ij': '/var/www/mirror.imagej.net',
56+
'imagej-tutorials' : "/Users/jackrueth/code/imagej/tutorials/"
5657
}
5758
elif len(args) >= 3:
5859
collection = args[1]

_search/server/tsutil.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ def connect():
2525

2626
return typesense.Client({
2727
'nodes': [{
28-
'host': 'search.imagej.net',
28+
'host': '144.92.48.217',
2929
'port': '8108',
30-
'protocol': 'https'
30+
'protocol': 'http'
3131
}],
3232
'api_key': api_key,
33-
'connection_timeout_seconds': 2,
33+
'connection_timeout_seconds': 10,
3434
})
3535

3636

_search/server/tutorials.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,25 @@
1515

1616

1717
def is_imagej_tutorials(root):
18-
java = Path(root) / 'java'
18+
# java = Path(root) / 'java'
1919
notebooks = Path(root) / 'notebooks'
20-
return java.isdir() and notebooks.isdir()
20+
return notebooks.is_dir()
21+
# return java.is_dir() and notebooks.is_dir()
2122

2223

2324
def parse_java_source(path):
2425
logger.debug(f'Parsing Java source file {path}...')
2526

2627
with open(path) as f:
27-
lines = json.load(f)
28+
lines = f.read()
2829

2930
# This is dumb -- do we want to do better?
3031
doc = {}
3132
doc['content'] = ''.join(lines)
33+
doc['title'] = str(path)
34+
doc['icon'] = '/media/icons/imagej.png'
35+
doc['score'] = 90
36+
doc['description'] = ''
3237

3338
return doc
3439

@@ -41,6 +46,10 @@ def parse_notebook(path):
4146

4247
doc = {}
4348
doc['content'] = ''
49+
doc['title'] = str(path)
50+
doc['icon'] = '/media/icons/imagej.png'
51+
doc['score'] = 90
52+
doc['description'] = ''
4453
for cell in data['cells']:
4554
# TODO: implement process_cell: extract source and output(s) if present
4655
doc['content'] += process_cell(cell)
@@ -88,6 +97,8 @@ def load_imagej_tutorials(root):
8897
try:
8998
doc = parse_java_source(javafile)
9099
if doc:
100+
nbpath = str(javafile)[len(str(root)) + 1:]
101+
doc['id'] = f'https://github.com/imagej/tutorials/blob/master/{nbpath}'
91102
documents.append(doc)
92103
except:
93104
logger.error(f'Failed to parse {Path}:')
@@ -108,11 +119,11 @@ def load_imagej_tutorials(root):
108119

109120
return documents
110121

111-
def main(args):
122+
""" def main(args):
112123
docs = load_imagej_tutorials(args[0])
113124
for doc in docs:
114125
# pprint(doc)
115126
print(doc['id'])
116127
117128
if __name__ == '__main__':
118-
main(['/Users/jackrueth/code/imagej/tutorials'])
129+
main(['/Users/jackrueth/code/imagej/tutorials']) """

0 commit comments

Comments
 (0)