Skip to content

Commit f90b73c

Browse files
committed
configurable couchdb url
1 parent 11ed9cd commit f90b73c

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

pyttoresque/app/__init__.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,13 @@
77
from jupyter_server.extension.handler import ExtensionHandlerJinjaMixin, ExtensionHandlerMixin
88
from jupyter_server.extension.application import ExtensionApp, ExtensionAppJinjaMixin
99
from tornado.web import addslash
10-
from traitlets import Bool
11-
from shutil import which
10+
from traitlets import Unicode
1211
from configparser import ConfigParser
1312
from secrets import token_hex
1413
from base64 import b64encode
1514

1615
HERE = os.path.dirname(__file__)
1716

18-
has_couchdb = bool(which("couchdb"))
19-
2017
class 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

pyttoresque/app/templates/editor.html

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,13 @@
2929
<body>
3030
<div id="mosaic_editor"></div>
3131
<script>
32-
{% if couchdb %}
33-
window.dburl = new URL("/couchdb/", window.location).href
32+
{% if couchdb=="proxy" %}
33+
window.dburl = new URL("../../couchdb/", window.location).href
34+
{% elif couchdb %}
35+
window.dburl = "{{ couchdb }}"
36+
{% endif %}
37+
{% if couchdb_sync %}
38+
window.default_sync = "{{ couchdb_sync }}"
3439
{% endif %}
3540
window.notebookurl = "../../lab"
3641
window.simulatorurl = "../../panel/app"

pyttoresque/app/templates/libman.html

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,13 @@
2929
<body>
3030
<div id="mosaic_libman"></div>
3131
<script>
32-
{% if couchdb %}
33-
window.dburl = new URL("/couchdb/", window.location).href
32+
{% if couchdb=="proxy" %}
33+
window.dburl = new URL("../couchdb/", window.location).href
34+
{% elif couchdb %}
35+
window.dburl = "{{ couchdb }}"
36+
{% endif %}
37+
{% if couchdb_sync %}
38+
window.default_sync = "{{ couchdb_sync }}"
3439
{% endif %}
3540
</script>
3641
<script src="{{ static_url('common.js') }}"></script>

0 commit comments

Comments
 (0)