Skip to content

Commit 3155bf7

Browse files
Merge pull request #2 from sujith-rek/feat/customOutputHeight
custom output height
2 parents 648add3 + 547a8f9 commit 3155bf7

File tree

7 files changed

+33
-8
lines changed

7 files changed

+33
-8
lines changed

runestone/activecode/activecode.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def setup(app):
7171
%(hidecode)s %(include)s %(timelimit)s %(coach)s %(codelens)s %(enabledownload)s %(chatcodes)s %(optional)s
7272
data-audio='%(ctext)s' %(sourcefile)s %(datafile)s %(stdin)s %(tie)s %(dburl)s %(nopair)s
7373
%(cargs)s %(largs)s %(rargs)s %(iargs)s %(gradebutton)s %(caption)s %(hidehistory)s %(wasmuri)s
74-
%(showlastsql)s %(python3_interpreter)s style="visibility: hidden;">
74+
%(showlastsql)s %(python3_interpreter)s %(output_height)s style="visibility: hidden;">
7575
%(initialcode)s
7676
</textarea>
7777
</div>
@@ -163,6 +163,7 @@ class ActiveCode(RunestoneIdDirective):
163163
:dburl: url to load database for sql mode
164164
:showlastsql: -- Only show the last sql result in output
165165
:python3_interpreter: brython (uses brython as interpreter of python3)
166+
:output_height: 200px
166167
167168
If this is a homework problem instead of an example in the text
168169
then the assignment text should go here. The assignment text ends with
@@ -218,7 +219,8 @@ class ActiveCode(RunestoneIdDirective):
218219
"nopair": directives.flag,
219220
"dburl": directives.unchanged,
220221
"showlastsql": directives.flag,
221-
"python3_interpreter": directives.unchanged
222+
"python3_interpreter": directives.unchanged,
223+
"output_height": directives.unchanged,
222224
}
223225
)
224226

@@ -273,6 +275,11 @@ def run(self):
273275
else:
274276
self.options["python3_interpreter"] = ""
275277

278+
if ("output_height" in self.options) :
279+
self.options["output_height"] = "data-output_height='%s'" % self.options["output_height"]
280+
else:
281+
self.options["output_height"] = ""
282+
276283
if "caption" not in self.options:
277284
self.options["caption"] = ""
278285
else:

runestone/activecode/js/acfactory.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export default class ACFactory {
3434
}
3535
var text_area = $(opts.orig).find("textarea")[0]
3636
var python3_interpreter = $(text_area).attr("data-python3_interpreter");
37+
var output_height = $(text_area).attr("data-output_height");
3738
if (opts.timed == true) {
3839
if(python3_interpreter==="brython"){
3940
return new TimedBrythonActiveCode(opts);

runestone/activecode/js/activecode.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export class ActiveCode extends RunestoneBase {
6767
this.tie = $(orig).data("tie");
6868
this.dburl = $(orig).data("dburl");
6969
this.python3_interpreter = $(orig).data("python3_interpreter");
70+
this.output_height = $(orig).data("output_height");
7071
this.runButton = null;
7172
this.enabledownload = $(orig).data("enabledownload");
7273
this.downloadButton = null;

runestone/activecode/js/activecode_brython.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export default class BrythonActiveCode extends ActiveCode {
55
super(opts);
66
opts.alignVertical = true;
77
this.python3_interpreter = $(orig).data("python3_interpreter");
8+
this.output_height = $(orig).data("output_height");
89
$(this.runButton).text("Render");
910
this.editor.setValue(this.code);
1011
}
@@ -119,11 +120,17 @@ document <= html.SCRIPT("let container = document.querySelector('.container-pre'
119120
} else {
120121
$(outDiv).addClass("col-md-5");
121122
}
123+
124+
if (this.output_height == undefined) {
125+
this.output_height = "400px";
126+
}
127+
122128
this.outDiv = outDiv;
123129
this.output = document.createElement("iframe");
124130
$(this.output).css("background-color", "white");
125131
$(this.output).css("position", "relative");
126-
$(this.output).css("height", "400px");
132+
// $(this.output).css("height", $(this.output_height));
133+
this.output.style.height = this.output_height;
127134
$(this.output).css("width", "100%");
128135
outDiv.appendChild(this.output);
129136
this.outerDiv.appendChild(outDiv);

runestone/dist/node_modules_moment_locale_sync_recursive_-runestone_activecode_js_acfactory_js.bundle.js

Lines changed: 11 additions & 2 deletions
Large diffs are not rendered by default.

runestone/dist/runtime.bundle.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"js":["runtime.bundle.js?v=1654bbde73e12a3366eb","vendors-node_modules_bootstrap_dist_js_bootstrap_js-node_modules_jquery-ui_jquery-ui_js-node_-e60694.bundle.js?v=02c928219c61d5ca913a","runestone.bundle.js?v=db4b57b8df6b9b8f470a"],"css":[]}
1+
{"js":["runtime.bundle.js?v=e476ce06ce356667798d","vendors-node_modules_bootstrap_dist_js_bootstrap_js-node_modules_jquery-ui_jquery-ui_js-node_-e60694.bundle.js?v=02c928219c61d5ca913a","runestone.bundle.js?v=db4b57b8df6b9b8f470a"],"css":[]}

0 commit comments

Comments
 (0)