Skip to content

Commit

Permalink
Merge pull request #21 from yacchin1205/fix/base-dir
Browse files Browse the repository at this point in the history
Fix base directory
  • Loading branch information
yacchin1205 authored Jul 5, 2023
2 parents 747e814 + cf241d6 commit f8fb43a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions nbsearch/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
]


def _get_root_dir(nb_server_app):
if hasattr(nb_server_app, 'root_dir'):
return nb_server_app.root_dir
return nb_server_app.notebook_dir


def get_api_handlers(parent_app, base_dir):
db = NBSearchDB(parent=parent_app)

Expand All @@ -34,9 +40,11 @@ def get_api_handlers(parent_app, base_dir):

def register_routes(nb_server_app, web_app):
from notebook.utils import url_path_join
api_handlers = get_api_handlers(nb_server_app, nb_server_app.notebook_dir)
base_dir = _get_root_dir(nb_server_app)
nb_server_app.log.info(f'nbsearch extension: base_dir={base_dir}')
api_handlers = get_api_handlers(nb_server_app, base_dir)

nbsearchignore = os.path.join(nb_server_app.notebook_dir, '.nbsearchignore')
nbsearchignore = os.path.join(base_dir, '.nbsearchignore')
if not os.path.exists(nbsearchignore):
with open(nbsearchignore, 'w') as f:
f.write(f'''# Generated by nbsearch
Expand Down

0 comments on commit f8fb43a

Please sign in to comment.