@@ -29,52 +29,6 @@ require('./lib/jquery.ba-dotimeout.min.js');
2929// need to directly import the class for type checking to work
3030import { ExecutionVisualizer , assert , htmlspecialchars } from './pytutor.ts' ;
3131
32- // these settings are all customized for my own server setup,
33- // so you will need to customize for your server:
34- const serverRoot = ( window . location . protocol === 'https:' ) ?
35- 'https://cokapi.com:8001/' : // my certificate for https is registered via cokapi.com, so use it for now
36- 'http://104.237.139.253:3000/' ;
37-
38- export const JS_JSONP_ENDPOINT = serverRoot + 'exec_js_jsonp' ; // TODO: get rid of this dependency in opt-live.ts
39-
40- // note that we use '2' and '3' instead of 'py2' and 'py3' due to legacy reasons
41- const langSettingToBackendScript = {
42- // backend scripts to execute (Python 2 and 3 variants, if available)
43- // make two copies of ../web_exec.py and give them the following names,
44- // then change the first line (starting with #!) to the proper version
45- // of the Python interpreter (i.e., Python 2 or Python 3).
46- // Note that your hosting provider might have stringent rules for what
47- // kind of scripts are allowed to execute. For instance, my provider
48- // (Webfaction) seems to let scripts execute only if permissions are
49- // something like:
50- // -rwxr-xr-x 1 pgbovine pgbovine 2.5K Jul 5 22:46 web_exec_py2.py*
51- // (most notably, only the owner of the file should have write
52- // permissions)
53- '2' : 'web_exec_py2.py' ,
54- '3' : 'web_exec_py3.py' ,
55-
56- // empty dummy scripts just to do logging on Apache server
57- 'js' : 'web_exec_js.py' ,
58- 'ts' : 'web_exec_ts.py' ,
59- 'java' : 'web_exec_java.py' ,
60- 'ruby' : 'web_exec_ruby.py' ,
61- 'c' : 'web_exec_c.py' ,
62- 'cpp' : 'web_exec_cpp.py' ,
63- } ;
64-
65- // see ../../v4-cokapi/cokapi.js for details
66- const langSettingToJsonpEndpoint = {
67- '2' : null ,
68- '3' : null ,
69- 'js' : serverRoot + 'exec_js_jsonp' ,
70- 'ts' : serverRoot + 'exec_ts_jsonp' ,
71- 'java' : serverRoot + 'exec_java_jsonp' ,
72- 'ruby' : serverRoot + 'exec_ruby_jsonp' ,
73- 'c' : serverRoot + 'exec_c_jsonp' ,
74- 'cpp' : serverRoot + 'exec_cpp_jsonp' ,
75- } ;
76-
77-
7832// for shared sessions ... put back in later
7933//var executeCodeSignalFromRemote = false;
8034//var togetherjsSyncRequested = false;
@@ -107,6 +61,49 @@ export abstract class AbstractBaseFrontend {
10761
10862 num414Tries = 0 ;
10963
64+ // note that we use '2' and '3' instead of 'py2' and 'py3' due to legacy reasons
65+ langSettingToBackendScript = {
66+ // backend scripts to execute (Python 2 and 3 variants, if available)
67+ // make two copies of ../web_exec.py and give them the following names,
68+ // then change the first line (starting with #!) to the proper version
69+ // of the Python interpreter (i.e., Python 2 or Python 3).
70+ // Note that your hosting provider might have stringent rules for what
71+ // kind of scripts are allowed to execute. For instance, my provider
72+ // (Webfaction) seems to let scripts execute only if permissions are
73+ // something like:
74+ // -rwxr-xr-x 1 pgbovine pgbovine 2.5K Jul 5 22:46 web_exec_py2.py*
75+ // (most notably, only the owner of the file should have write
76+ // permissions)
77+ '2' : 'web_exec_py2.py' ,
78+ '3' : 'web_exec_py3.py' ,
79+
80+ // empty dummy scripts just to do logging on Apache server
81+ 'js' : 'web_exec_js.py' ,
82+ 'ts' : 'web_exec_ts.py' ,
83+ 'java' : 'web_exec_java.py' ,
84+ 'ruby' : 'web_exec_ruby.py' ,
85+ 'c' : 'web_exec_c.py' ,
86+ 'cpp' : 'web_exec_cpp.py' ,
87+ } ;
88+
89+ // these settings are all customized for my own server setup,
90+ // so you will need to customize for your server:
91+ serverRoot = ( window . location . protocol === 'https:' ) ?
92+ 'https://cokapi.com:8001/' : // my certificate for https is registered via cokapi.com, so use it for now
93+ 'http://104.237.139.253:3000/' ;
94+
95+ // see ../../v4-cokapi/cokapi.js for details
96+ langSettingToJsonpEndpoint = {
97+ '2' : null ,
98+ '3' : null ,
99+ 'js' : this . serverRoot + 'exec_js_jsonp' ,
100+ 'ts' : this . serverRoot + 'exec_ts_jsonp' ,
101+ 'java' : this . serverRoot + 'exec_java_jsonp' ,
102+ 'ruby' : this . serverRoot + 'exec_ruby_jsonp' ,
103+ 'c' : this . serverRoot + 'exec_c_jsonp' ,
104+ 'cpp' : this . serverRoot + 'exec_cpp_jsonp' ,
105+ } ;
106+
110107 abstract executeCode ( forceStartingInstr ?: number , forceRawInputLst ?: string [ ] ) : any ;
111108 abstract finishSuccessfulExecution ( ) : any ; // called by executeCodeAndCreateViz
112109 abstract handleUncaughtException ( trace : any [ ] ) : any ; // called by executeCodeAndCreateViz
@@ -378,9 +375,9 @@ export abstract class AbstractBaseFrontend {
378375 this . num414Tries = 0 ;
379376 } ;
380377
381- var backendScript = langSettingToBackendScript [ pyState ] ;
378+ var backendScript = this . langSettingToBackendScript [ pyState ] ;
382379 assert ( backendScript ) ;
383- var jsonp_endpoint = langSettingToJsonpEndpoint [ pyState ] ; // maybe null
380+ var jsonp_endpoint = this . langSettingToJsonpEndpoint [ pyState ] ; // maybe null
384381
385382 if ( ! backendScript ) {
386383 this . setFronendError (
0 commit comments