77from jupyter_server .extension .handler import ExtensionHandlerJinjaMixin , ExtensionHandlerMixin
88from jupyter_server .extension .application import ExtensionApp , ExtensionAppJinjaMixin
99from tornado .web import addslash
10- from traitlets import Bool
11- from shutil import which
10+ from traitlets import Unicode
1211from configparser import ConfigParser
1312from secrets import token_hex
1413from base64 import b64encode
1514
1615HERE = os .path .dirname (__file__ )
1716
18- has_couchdb = bool (which ("couchdb" ))
19-
2017class LibmanHandler (ExtensionHandlerJinjaMixin , ExtensionHandlerMixin , JupyterHandler ):
2118 @addslash
2219 def get (self ):
@@ -25,7 +22,8 @@ def get(self):
2522 "libman.html" ,
2623 static = self .static_url ,
2724 token = self .settings ["token" ],
28- couchdb = has_couchdb ,
25+ couchdb = self .settings ['mosaic_config' ]['couchdb' ],
26+ couchdb_sync = self .settings ['mosaic_config' ]['couchdb_sync' ],
2927 )
3028 )
3129
@@ -37,7 +35,8 @@ def get(self):
3735 "editor.html" ,
3836 static = self .static_url ,
3937 token = self .settings ["token" ],
40- couchdb = has_couchdb ,
38+ couchdb = self .settings ['mosaic_config' ]['couchdb' ],
39+ couchdb_sync = self .settings ['mosaic_config' ]['couchdb_sync' ],
4140 )
4241 )
4342
@@ -46,6 +45,9 @@ class Mosaic(ExtensionAppJinjaMixin, ExtensionApp):
4645 default_url = "/mosaic"
4746 static_paths = [os .path .join (HERE , "static" )]
4847 template_paths = [os .path .join (HERE , "templates" )]
48+
49+ couchdb = Unicode ("proxy" , help = "CouchDB URL to use" ).tag (config = True )
50+ couchdb_sync = Unicode (help = "Remote CouchDB URL to synch PouchDB with" ).tag (config = True )
4951
5052 def initialize_settings (self ):
5153 super ().initialize_settings ()
@@ -77,7 +79,7 @@ def command(port):
7779 # so we have to use a persistent file
7880 with open (tmpl , 'w' ) as f :
7981 cp .write (f )
80- cmd = ['couchdb' , '-couch_ini' , tf . name ]
82+ cmd = ['couchdb' , '-couch_ini' , tmpl ]
8183 if os .name == 'nt' :
8284 cmd = ["cmd.exe" , "/c" ] + cmd
8385 return cmd
0 commit comments