Skip to content

Commit

Permalink
Merge pull request #4 from trinketapp/v3.1.0
Browse files Browse the repository at this point in the history
V3.1.0
  • Loading branch information
brianpmarks authored Apr 11, 2021
2 parents 8e1ddac + d6bc817 commit 5fb113c
Show file tree
Hide file tree
Showing 71 changed files with 4,112 additions and 3,258 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.git
.gitignore
/api/venv
7 changes: 7 additions & 0 deletions .flaskenv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FLASK_APP=main.py
FLASK_ENV=development
FLASK_RUN_HOST=localhost
FLASK_RUN_PORT=8080
GLOWSCRIPT_RUNNING_LOCALLY=true
DATASTORE_EMULATOR_HOST=localhost:8081
CLIENT_SECRET_VERSION=1
17 changes: 17 additions & 0 deletions .gcloudignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file specifies files that are *not* uploaded to Google Cloud Platform
# using gcloud. It follows the same syntax as .gitignore, with the addition of
# "#!include" directives (which insert the entries of the given .gitignore-style
# file at that point).
#
# For more information, run:
# $ gcloud topic gcloudignore
#
.gcloudignore
# If you would like to upload your .git directory, .gitignore file or files
# from your .gitignore file, remove the corresponding line
# below:
.git
.gitignore
/venv
# Ignored by the build system
/setup.cfg
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@

node_modules
bower_components
*.pyc
.DS_Store
*~
/venv
__pycache__/
*~
/.vscode/
/ide/.vscode
/ide/flask_secret.py

18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM python:3.8.5-buster

RUN mkdir /app

WORKDIR /app

COPY ./requirements.txt /app

RUN pip install -U pip

RUN pip install -r requirements.txt

COPY . /app

CMD flask run



2 changes: 1 addition & 1 deletion ForInstalledPython/glow.min.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions GlowScriptOffline/GlowScript.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
<script type="text/javascript" src="glowscript_libraries/jquery.min.js"></script>
<script type="text/javascript" src="glowscript_libraries/jquery-ui.custom.min.js"></script>
<script type="text/javascript" src="glowscript_libraries/editor.js"></script>
<script type="text/javascript" src="glowscript_libraries/RSrun.3.0.min.js"></script>
<script type="text/javascript" src="glowscript_libraries/glow.3.0.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="glowscript_libraries/RSrun.3.1.min.js"></script>
<script type="text/javascript" src="glowscript_libraries/glow.3.1.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="glowscript_libraries/split.min.js"></script>
<script type="text/javascript" src="glowscript_libraries/Roboto_Medium_ttf_sans.js"></script>
<script type="text/javascript" src="glowscript_libraries/NimbusRomNo9L_Med_otf_serif.js"></script>
Expand All @@ -60,14 +60,14 @@
<input type="file" id="read_local_file"/>

<script>
var gsversion = '3.0'
var gsversion = '3.1'
var printpane = false
var exporting = false // not currently in export mode
var lastprintwidth = null

var glowscript_run = undefined
window.Jupyter_VPython = undefined
if (!navigator.onLine) window.Jupyter_VPython = 'glowscript_data/' // get textures when offline

// TAB at end of line should lengthen the line; implement Ctrl-1 and Ctrl-2

// localCompile is a modification of https://github.com/vpython/glowscript/blob/master/ide/ide.js
Expand Down
3 changes: 0 additions & 3 deletions GlowScriptOffline/glowscript_libraries/RScompiler.3.0.min.js

This file was deleted.

3 changes: 3 additions & 0 deletions GlowScriptOffline/glowscript_libraries/RScompiler.3.1.min.js

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions GlowScriptOffline/glowscript_libraries/RSrun.3.0.min.js

This file was deleted.

3 changes: 3 additions & 0 deletions GlowScriptOffline/glowscript_libraries/RSrun.3.1.min.js

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions GlowScriptOffline/glowscript_libraries/compiler.3.0.min.js

This file was deleted.

3 changes: 3 additions & 0 deletions GlowScriptOffline/glowscript_libraries/compiler.3.1.min.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Binary file modified GlowScriptOffline3.0.zip
Binary file not shown.
Binary file added GlowScriptOffline3.1.zip
Binary file not shown.
129 changes: 126 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,133 @@ Unzip the GlowScriptOffline package to any convenient place on your computer.

Inside the [GlowScriptOffline](GlowScriptOffline) folder, read the README file to learn how to use the package.

Run a Local Server
Run a Local Server (Py3 version)
------------------
This repository is a Google App Engine application. Here are instructions for running locally, using a local server (this is much more complicated than running locally as described under the previous heading):
There are two sets of instructions given here for two possible
approaches.

https://www.glowscript.org/docs/GlowScriptDocs/local.html
1. The first, "All Docker", is quite simple, and involves only
minimal new software (just [Docker](https://www.docker.com/products/docker-desktop)).
If you're using macOS or Linux you can run the
local webserver and datastore all in Docker. You don't need to install
anything else. However there is a rather annoying
bug in Windows that prevents the webserver from automatically restarting when
source files change. For this reason, if they wish to have this feature,
windows users must run a python process concurrently that tracks file
changes during development. Having said that, if you just want to try a
local webserver, and you don't care about having to restart the server
manually every time you change the source code, you can skip running
the extra python process. This is all described below.

2. The second, "Only Datastore in Docker", requires that users also install a
recent (e.g., 3.7+) version of python (and pip) such as that provided by
[anaconda](https://docs.anaconda.com/anaconda/install/)
(or [miniconda](https://docs.conda.io/en/latest/miniconda.html)), as well as
[Docker](https://www.docker.com/products/docker-desktop). This is all also described below.

### Local Server Approach (1) All Docker

First install [Docker](https://www.docker.com/products/docker-desktop. Once
installed, start the Docker process.

Next check out or download the py38-app-engine branch of the glowscript repository (currently the `py38-app-engine` branch).
(How you do this depends on your familiarity with git. The simplest is to download a .zip file of the
`py38-app-engine` branch of the repository [here](https://github.com/vpython/glowscript/archive/py38-app-engine.zip))Then
open a console in the `glowscript` directory of the repository and run the webserver and datastore in docker:

docker-compose up

this will take a substantial amount of time the first time, since it has to download all
the docker images. Once it's running, browse to: [http://localhost:8080](http://localhost:8080)
to view the website. That's it! This will run in a window and show you how the
webserver is handling requests. If you'd rather run this in the background
you can use:

docker-compose up -d

When you're finished, shut down the system with:

docker-compose down

* P.S. If you're using windows an you want to use the "auto-restart" feature when code files change
you'll need to run the filesystem monitoring tool
[docker-windows-volume-watcher](https://pypi.org/project/docker-windows-volume-watcher/)

pip install docker-windows-volume-watcher

* And when you're running the glowscript server locally, in a *separate* window, execute:

docker-volume-watcher glowscript_flask_1

* and it will take care of the rest.

### Local Server Approach (2) Only Datastore In Docker

To run a local webserver with only the datastore in Docker, but the
webserver itself running natively you need a recent version of Python3 and pip installed. The easiest method
is probably to install [anaconda](https://docs.anaconda.com/anaconda/install/) (or [miniconda](https://docs.conda.io/en/latest/miniconda.html), if you don't want the GUI package manager and extra applications). Once you have that you need to check out
or download the py38-app-engine branch of the glowscript repository (currently the `py38-app-engine` branch).
(How you do this depends on your familiarity with git. The simplest is to download a .zip file of the
`py38-app-engine` branch of the repository [here](https://github.com/vpython/glowscript/archive/py38-app-engine.zip))
First "cd" to the `glowscript` directory (the root directory of the repository)
and create a virtual environment for glowscript like so:

cd /path/to/glowscript
python -m venv venv

This will build a virtual environment for running locally. To activiate the virtual environment:

mac: source venv/bin/activate
windows (power shell): venv\Scripts\Activate.ps1
windows (cmd.exe shell): venv\Scripts\activate.bat

Your terminal prompt should now have a `(venv)` indicating that you have
activated the glowscript virtual environment. Before you can run glowscript the
first time, you'll need to install dependencies into the virtual environment.
This can be done with pip:

pip install -r requirements.txt

In order to run the local datastore emulator it's easiest to use
[Docker](https://www.docker.com/products/docker-desktop). Download
a version of Docker that works with your OS. To test that you've
got docker installed OK, in the glowscript directory type:

docker-compose -f docker-datastore.yml up

this will take a substantial amount of time the first time, since it has to download all
the docker images. You'll see a lot of log messages, but among them you should see:

datastore_1 | [datastore] Dev App Server is now running.

In this case you're good! If not, check the error messages and
see if there are any useful clues. Good luck.

If the datastore is running, hit ctrl-c, and then type:

docker-compose -f docker-datastore.yml up -d

This will run the datastore in the background.

With the datastore running, you can run the webserver by typing:

flask run

and then browse to: [http://localhost:8080](http://localhost:8080) to view the website.

When you're finished hit ctrl-c and then type:

docker-compose -f docker-datastore.yml down

To stop the background datastore emulator.

Then next time you're ready to develop, you can simply activate the environment again (make sure you see the "(venv)" in the shell prompt) and type:

docker-compose -f docker-datastore.yml up -d

flask run

And you'll be up and running!

For Developers
--------------
Expand All @@ -53,3 +175,4 @@ Early version
In December 2014 the original GlowScript repository was corrupted in such a way that it could not be reconstituted, but a backup that contains the history of commits is here:

https://bitbucket.org/davidscherer/glowscript_backup/overview

28 changes: 6 additions & 22 deletions app.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
application: glowscript
version: 1
runtime: python27
api_version: 1
threadsafe: true

builtins:
- admin_redirect: on
runtime: python38

handlers:
- url: /css
static_dir: css
secure: always

- url: /
static_files: ide/index.html
upload: ide/index.html
script: auto
secure: always

- url: /ide.js
static_files: ide/ide.js
upload: ide/ide.js
- url: /css
static_dir: css
secure: always

- url: /lib
Expand All @@ -35,14 +23,10 @@ handlers:
secure: always

- url: /api/.*
script: ide.api.app
script: auto
secure: always

- url: /favicon\.ico
static_files: static/images/favicon.ico
upload: static/images/favicon\.ico
secure: always

- url: /untrusted
static_dir: untrusted
upload: static/images/favicon.ico
secure: always
4 changes: 2 additions & 2 deletions build_original.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
shader_file = "\n".join(shader_file)
open("lib/glow/shaders.gen.js", "wb").write(shader_file)

version = "3.0"
version = "3.1"
# TODO: Extract this information from run.js

glowscript_libraries = {
Expand Down Expand Up @@ -114,7 +114,7 @@ def minify(inlibs, inlibs_nomin, outlib):
minify( glowscript_libraries["RScompile"], [], "package/RScompiler." + version + ".min.js" )
print('Finished RapydScript compiler package\n')

# For GlowScript 2.6 runtime.js had the encoding "UCS-2 LE BOM" which the Uglify
# For GlowScript 3.1 runtime.js had the encoding "UCS-2 LE BOM" which the Uglify
# machinery could not handle. Using (on Windows) notepad++ the encoding was changed
# to "UTF-8" which solved the problem.
minify( glowscript_libraries["RSrun"], [], "package/RSrun." + version + ".min.js" )
Expand Down
2 changes: 1 addition & 1 deletion build_original_no_overload.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
##shader_file = "\n".join(shader_file)
##open("lib/glow/shaders.gen.js", "wb").write(shader_file)

version = "3.0"
version = "3.1"
# TODO: Extract this information from run.js

glowscript_libraries = {
Expand Down
33 changes: 33 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: "2"

#
# This compose file can be used to run locally without using the locally installed python or dependencies
#

services:

datastore:
image: gcr.io/google.com/cloudsdktool/cloud-sdk:latest
ports:
- 8081:8081
volumes:
- datastore:/root/.config
command: gcloud beta emulators datastore start --host-port=0.0.0.0:8081 --project glowscript-dev

flask:
image: us.gcr.io/glowscript-py38/glowscript-flask:latest
ports:
- 8080:8080
links:
- datastore
volumes:
- .:/app
- datastore:/root/.config
environment:
- DATASTORE_EMULATOR_HOST=datastore:8081
- FLASK_RUN_HOST=0.0.0.0
- FLASK_RUN_PORT=8080
command: flask run

volumes:
datastore:
17 changes: 17 additions & 0 deletions docker-datastore.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "2"

#
# This compose file is just for running the datastore locally.
#

services:
datastore:
image: gcr.io/google.com/cloudsdktool/cloud-sdk:latest
ports:
- 8081:8081
volumes:
- datastore:/root/.config
command: sh -c "gcloud beta emulators datastore start --host-port=0.0.0.0:8081 --project glowscript-dev"

volumes:
datastore:
3 changes: 2 additions & 1 deletion docs/MakingNewVersion.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ in case we have to come back and patch an old version for some critical bug.
This has not actually been done so far.

************************************************************************************
UPDATE library files in AWS/S3: https://s3.amazonaws.com/glowscript/package/
UPDATE library files in the GlowScriptOffline package and create zip file
UPDATE the glow library used in VPython 7; generate it with build_original_no_overload.py
(This includes vectors_no_overload.js instead of vectors.js.)
Until Nov. 2020 we updated library files at AWS/S3: https://s3.amazonaws.com/glowscript/package/
but this is no longer relevant; exported files now reference glowscript.org.
*********************************************************************************************

Note that at this point property.js should have version 0.5dev.
Expand Down
7 changes: 4 additions & 3 deletions docs/VPythonDocs/arrow.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@
is significant for arrow because the shaft and head have square
cross sections, and setting the <em class="program"> </em><span class="attribute">up</span> attribute
rotates the arrow about its axis. Additional arrow attributes:</p>
<p class="attributes"> <span class="attribute">shaftwidth</span> By default, shaftwidth
<p class="attributes"> <span class="attribute">round</span> By default, <span class="attribute">round</span> is <span class="attribute">False</span> and the arrow has a square cross-section. If <span class="attribute">round</span> is <span class="attribute">True</span>, it has a circular cross-section. The <span class="attribute">round</span> attribute cannot be changed after creating the arrow.</p>
<p class="attributes"> <span class="attribute"></span><span class="attribute">shaftwidth</span> By default, shaftwidth

= 0.1*(length of arrow)</p>
<p class="attributes"> <span class="attribute">headwidth</span> By default, headwidth
= 0.1*(length of arrow)</p>
<p class="attributes"> <span class="attribute">headwidth</span> By default, headwidth

= 2*shaftwidth</p>
<p class="attributes"> <span class="attribute">headlength</span> By default, headlength
Expand Down
Loading

0 comments on commit 5fb113c

Please sign in to comment.