Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add legacy build #83

Draft
wants to merge 42 commits into
base: modernize
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
646f4af
copy old war-src files, and update build so it works again in the new…
Mar 16, 2024
ab080d2
remove duplicative files, and those that are now being generated from…
Mar 16, 2024
5ac281d
put all CM5 stuff in static/
Mar 16, 2024
7b722e4
update
Mar 16, 2024
90aae61
Update README.md
schanzer Mar 16, 2024
767403d
use proper stylesheet path
Mar 17, 2024
6244b61
codemirror5->codemirror, and remove unused files
Mar 17, 2024
181e2b1
remove unused closure JAR, nd the files that refer to it
Mar 17, 2024
de94041
remove closure library from the repo, since it is not included via no…
Mar 17, 2024
190adfd
move war-src/js* -> war-src/*
Mar 17, 2024
05d9347
rename war-src->js-src, and move all legacy things within the legacy …
Mar 17, 2024
0197fbb
tweak paths
Mar 17, 2024
a593755
more path tweaks
Mar 17, 2024
7ea0f39
remove minified files from repo, since we already generate them from …
Mar 17, 2024
3e021af
more trimming
Mar 17, 2024
c074acf
rename jquery-1.3.2-min.js so as to distinguish from closure-minified…
Mar 17, 2024
b02aa2d
add negate (see https://github.com/bootstrapworld/curriculum/issues/1…
Mar 17, 2024
fa22a0a
remove column index from error messages (fixes #81)
Mar 17, 2024
d8f27fe
check for previously-defined big-bang handlers (fixes #77)
Mar 17, 2024
94b81e2
flipping a vertex-based image should reflect the vertices and use the…
Mar 17, 2024
9983d06
use module-ized scheme2 mode
Mar 18, 2024
872493c
remove console.log
Mar 20, 2024
d5b5f41
add toWrittenString and toDisplayed string to rarely-used Types (fixe…
Mar 20, 2024
325cc12
switch to builtin scheme mode, replacing our own (#84)
schanzer Apr 11, 2024
04bbfa3
fix CM height in interactions area
Apr 11, 2024
705feb3
Merge branch 'add-legacy-build' of github.com:bootstrapworld/wescheme…
Apr 11, 2024
0192a75
remove console.logs
Apr 13, 2024
2a3852d
use up-to-date starter file links
Apr 19, 2024
0bc4c5d
mostly whitespace cleanup, and fix printing of anonymous continuation…
Apr 19, 2024
809f932
use relative URLs for starter files
Apr 19, 2024
b7a27a4
run js-prettier on runtime code for readability
Apr 23, 2024
60cf167
Revert "run js-prettier on runtime code for readability"
Apr 23, 2024
72f879e
more judicious use of js-prettier on runtime files
Apr 23, 2024
1220fc7
fix image and shared program loading error
Apr 26, 2024
72a7d53
fix small world.js errors
Apr 28, 2024
1b2e0ea
Revert "more judicious use of js-prettier on runtime files"
Apr 28, 2024
1196c51
bring back compiler tests
Apr 29, 2024
2f0cb2d
resurrect sheets-based text suite
Apr 29, 2024
2bc2a89
Fix definition ordering (#75)
schanzer May 14, 2024
f7eb8e5
add description of WeScheme, to satisfy Google reviewers
May 14, 2024
71e15f6
changed text to comply with new requirements from Google
May 16, 2024
aaea965
fix defining-values link
Jun 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ node_modules
package-lock.json
secretkey
__pycache__
.DS_Store
static/**/*-min.js
static/**/*-calc.js
static/mzscheme-vm/support.js
static/codemirror/
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

36 changes: 12 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,24 @@
Install needed npm modules:
```
npm install
```
1. Install needed npm modules:
`npm install`

Install codemirror5:
```
git clone https://github.com/codemirror/codemirror5
cd codemirror5
npm install
cd ..
```
2. Make the python environment and generate secret key:
`npm run setup`

_OR:_

Make the python environment:
```
python3.11 -m venv env
. ./env/bin/activate
python -m pip install -r requirements.txt
```

Generate a secret key:
```
python -c "import secrets; print(secrets.token_hex(20))" >secretkey
```

This should be enough to run locally:
```
python main.py
```
3. Build the runtime and compiler from source:
`npm run build`

To *test* WeScheme locally, at 127.0.0.1:8080:
`python main.py`

To *deploy*, use the following, assuming nothing's changed with your credentials since the last time you uploaded:
```
gcloud app deploy
```
To *deploy* WeScheme to AppEngine, use the following (assuming nothing's changed with your credentials since the last time you uploaded):
`gcloud app deploy`

3 changes: 0 additions & 3 deletions app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ handlers:
- url: /static
static_dir: static

- url: /codemirror5
static_dir: codemirror5

# This handler routes all requests not caught above to your main app. It is
# required when static routes are defined, but can be omitted (along with
# the entire handlers section) when there are no static files defined.
Expand Down
188 changes: 188 additions & 0 deletions js-src/ajaxactions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
goog.provide("plt.wescheme.AjaxActions");


goog.require('plt.wescheme.Program');

// if (typeof (plt) === 'undefined') {
// this.plt = {};
// }
// if (typeof (plt.wescheme) === 'undefined') {
// this.plt.wescheme = {};
// }



(function() {
plt.wescheme.AjaxActions = function() {}


// loadProject: number (jquery -> void) (-> void)
plt.wescheme.AjaxActions.prototype.loadProject = function(pid, publicId, onSuccess, onFailure) {
var pid;
if (pid) {
data = { pid: pid };
} else {
data = { publicId: publicId };
}
// to prevent caching:
data.gensym = Math.random();
jQuery.ajax({cache : false,
data : data,
dataType: "json",
type: "GET",
url: "/loadProject",
success: function(json) {
onSuccess(new plt.wescheme.Program(json));
},
error: function(xhr) {
onFailure(xhr.statusText);
},
xhr: function(settings) { return new XMLHttpRequest(settings); }
});
};


// listProjects: (jquery -> void) -> void
plt.wescheme.AjaxActions.prototype.listProjects = function(onSuccess, onFailure) {
var callback = function(data) {
var dom = jQuery(data);
onSuccess(dom);
};
var data = {};
// to prevent caching:
data.gensym = Math.random();
jQuery.ajax({cache: false,
data: data,
dataType: "xml",
type: "GET",
url: "/listProjects",
success: callback,
error: function(xhr) {
onFailure(xhr.statusText);
},
xhr: function(settings) { return new XMLHttpRequest(settings); }
});
};

// makeAClone: number (string | null) (number -> void) (-> void) -> void
// Clones a program. If code is non-null, also update the code source of the
// clone.
plt.wescheme.AjaxActions.prototype.makeAClone = function(pid, code, onSuccess, onFailure) {
jQuery.ajax({cache : false,
data : (code === null ? {pid: pid}: { pid: pid, code: code }),
dataType: "text",
type: "POST",
url: "/cloneProject",
success: function(data) {
var newPid = parseInt(data);
onSuccess(newPid);
},
error: function(xhr) {
onFailure(xhr.statusText);
},
xhr: function(settings) { return new XMLHttpRequest(settings); }
});
};




// share: number boolean (-> void) (-> void) -> void
// Shares a program.
// Sets the published flag on a program.
plt.wescheme.AjaxActions.prototype.share = function(pid, isPublic, onSuccess, onFailure) {
jQuery.ajax({cache : false,
data : { pid: pid,
isPublic: isPublic },
dataType: "xml",
type: "POST",
url: "/shareProject",
success: function(data) {
onSuccess(jQuery(data));
},
error: function(xhr) {
onFailure(xhr.statusText);
},
xhr: function(settings) { return new XMLHttpRequest(settings); }
});
};


// deleteProject: number (program -> void) (-> void) -> void
// Deletes a program.
plt.wescheme.AjaxActions.prototype.deleteProject = function(pid, onSuccess, onFailure) {
jQuery.ajax({cache : false,
data : { pid: pid },
dataType: "xml",
type: "POST",
url: "/deleteProject",
success: function(data) {
onSuccess(jQuery(data));
},
error: function(xhr) {
onFailure(xhr.statusText);
},
xhr: function(settings) { return new XMLHttpRequest(settings); }
});
};




// save: { pid : (U undefined number),
// title: string,
// code: string,
// notes: string },
// (number -> void) (-> void) -> void
// Does a save.
plt.wescheme.AjaxActions.prototype.save = function(attrs, onSuccess, onFailure) {
var i;
var data = {};
var attrNames = ['title', 'code', 'notes'];
if (attrs.pid) {
data.pid = attrs.pid;
}
for (i=0; i < attrNames.length; i++) {
if (Object.hasOwnProperty.call(attrs, attrNames[i])) {
data[attrNames[i]] = attrs[attrNames[i]];
}
}
jQuery.ajax({cache : false,
data : data,
dataType: "text",
type: "POST",
url: "/saveProject",
success: function(data) {
var newPid = parseInt(data);
onSuccess(newPid);
},
error: function(xhr) {
onFailure(xhr.statusText);
},
xhr: function(settings) { return new XMLHttpRequest(settings); }
});
};


// string string string (-> void) -> void
// Asynchronously record feedback from the author.
plt.wescheme.AjaxActions.prototype.sendFeedback = function(author, type, feedbackText, onSuccess) {
jQuery.ajax({cache : false,
data : {author : author,
type : type,
feedbackText : feedbackText },
datatype: "text",
type: "POST",
url: "/addFeedback",
success: function(data) {
onSuccess();
},
error: function(xhr) {
onSuccess();
},
xhr: function(settings) { return new XMLHttpRequest(settings); }
});

};

})();
117 changes: 117 additions & 0 deletions js-src/base64.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
goog.provide("plt.wescheme.base64");

// Comes from:
//
// https://raw.github.com/kvz/phpjs/master/functions/url/base64_encode.js
// https://raw.github.com/kvz/phpjs/master/functions/url/base64_decode.js

(function() {


plt.wescheme.base64.encode = function (data) {
// http://kevin.vanzonneveld.net
// + original by: Tyler Akins (http://rumkin.com)
// + improved by: Bayron Guevara
// + improved by: Thunder.m
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + bugfixed by: Pellentesque Malesuada
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + improved by: Rafał Kukawski (http://kukawski.pl)
// * example 1: base64_encode('Kevin van Zonneveld');
// * returns 1: 'S2V2aW4gdmFuIFpvbm5ldmVsZA=='
// mozilla has this native
// - but breaks in 2.0.0.12!
//if (typeof this.window['btoa'] == 'function') {
// return btoa(data);
//}
var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
ac = 0,
enc = "",
tmp_arr = [];

if (!data) {
return data;
}

do { // pack three octets into four hexets
o1 = data.charCodeAt(i++);
o2 = data.charCodeAt(i++);
o3 = data.charCodeAt(i++);

bits = o1 << 16 | o2 << 8 | o3;

h1 = bits >> 18 & 0x3f;
h2 = bits >> 12 & 0x3f;
h3 = bits >> 6 & 0x3f;
h4 = bits & 0x3f;

// use hexets to index into b64, and append result to encoded string
tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
} while (i < data.length);

enc = tmp_arr.join('');

var r = data.length % 3;

return (r ? enc.slice(0, r - 3) : enc) + '==='.slice(r || 3);
};



plt.wescheme.base64.decode = function (data) {
// http://kevin.vanzonneveld.net
// + original by: Tyler Akins (http://rumkin.com)
// + improved by: Thunder.m
// + input by: Aman Gupta
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + bugfixed by: Onno Marsman
// + bugfixed by: Pellentesque Malesuada
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + input by: Brett Zamir (http://brett-zamir.me)
// + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// * example 1: base64_decode('S2V2aW4gdmFuIFpvbm5ldmVsZA==');
// * returns 1: 'Kevin van Zonneveld'
// mozilla has this native
// - but breaks in 2.0.0.12!
//if (typeof this.window['atob'] == 'function') {
// return atob(data);
//}
var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
ac = 0,
dec = "",
tmp_arr = [];

if (!data) {
return data;
}

data += '';

do { // unpack four hexets into three octets using index points in b64
h1 = b64.indexOf(data.charAt(i++));
h2 = b64.indexOf(data.charAt(i++));
h3 = b64.indexOf(data.charAt(i++));
h4 = b64.indexOf(data.charAt(i++));

bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;

o1 = bits >> 16 & 0xff;
o2 = bits >> 8 & 0xff;
o3 = bits & 0xff;

if (h3 == 64) {
tmp_arr[ac++] = String.fromCharCode(o1);
} else if (h4 == 64) {
tmp_arr[ac++] = String.fromCharCode(o1, o2);
} else {
tmp_arr[ac++] = String.fromCharCode(o1, o2, o3);
}
} while (i < data.length);

dec = tmp_arr.join('');

return dec;
};
}());
Loading