Skip to content

Commit 7770058

Browse files
committed
fix loading extensions in standalone packages
The extension files were still being bundled in with the main JS and CSS files, but that's not how Numbas expects to load extensions any more. I also accidentally broke the embedding of the extension data in the last commit.
1 parent 2b1b22b commit 7770058

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

bin/numbas.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ def make_xml(self):
302302
self.xmls = xml2js.settings_js_template.format(**{
303303
'numbas_version': NUMBAS_VERSION,
304304
'rawxml': json.dumps({'templates': xslts}),
305-
'extensionfiles': [f'extensions/{x}/{x}.js' for x in self.extensions],
305+
'deps': [],
306306
})
307307

308308
def render_templates(self):
@@ -423,7 +423,7 @@ def collect_stylesheets(self):
423423
for dst, src in self.files.items():
424424
if Path(dst).suffix != '.css':
425425
continue
426-
if not any(p.name == 'standalone_scripts' for p in Path(dst).parents):
426+
if not any(p in ('standalone_scripts', 'extensions') for p in Path(dst).parts[:-1]):
427427
stylesheets.append((dst, src))
428428

429429
stylesheets.sort(key=lambda x:x[0])
@@ -441,7 +441,7 @@ def collect_scripts(self):
441441
for dst, src in self.files.items():
442442
if Path(dst).suffix != '.js':
443443
continue
444-
if not any(p.name == 'standalone_scripts' for p in Path(dst).parents):
444+
if not any(p in ('standalone_scripts', 'extensions') for p in Path(dst).parts[:-1]):
445445
javascripts.append((dst, src))
446446

447447
for dst, src in javascripts:

bin/xml2js.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def encode(xml):
2222
xml = re.sub('"','\\"',xml)
2323
return xml
2424

25-
settings_js_template = """Numbas.queueScript('settings',{extensionfiles},function() {{
25+
settings_js_template = """Numbas.queueScript('settings',{deps},function() {{
2626
Numbas.version = {numbas_version};
2727
2828
Numbas.rawxml = {rawxml};

runtime/scripts/jme-variables.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ DOMcontentsubber.prototype = {
860860
/** Substitute content into the object's root element.
861861
*/
862862
function go() {
863-
const rootElement = element.contentDocument.rootElement;
863+
const rootElement = element.contentDocument?.rootElement;
864864
if(!rootElement) {
865865
return;
866866
}

themes/default/templates/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
{% if not dont_start_exam %}
3333
<numbas-exam storage="scorm">
3434
<script type="application/numbas-exam">{{options.source|safe_script}}</script>
35-
<script type="application/json" slot="extension-data">{{extension_data|tojson}}</script>
35+
<script type="application/json" slot="extension-data">{{extension_data}}</script>
3636
</numbas-exam>
3737
{% endif %}
3838
</div>

0 commit comments

Comments
 (0)