If you execute the code but nothing is being rendered in the broswer, please open your browser's console to read the error traceback (usually you can do this by pressing F12 and clicking in the Console tab).
If you execute the code but nothing is being rendered in the browser,
+ please open your browser's console to read the error traceback (usually you can do this by pressing F12 and
+ clicking in the Console tab).
If you execute the code but nothing is being rendered in the broswer, please open your browser's console to read the error traceback (usually you can do this by pressing F12 and clicking in the Console tab).
If you execute the code but nothing is being rendered in the browser,
+ please open your browser's console to read the error traceback (usually you can do this by pressing F12 and
+ clicking in the Console tab).
+
+
+
+
\ No newline at end of file
diff --git a/docs/pyodide/share.js b/docs/pyodide/share.js
new file mode 100644
index 00000000..f11c1dcb
--- /dev/null
+++ b/docs/pyodide/share.js
@@ -0,0 +1,77 @@
+function createSketchUrl() {
+ const baseUrl = window.location.origin + window.location.pathname;
+ const userCode = editor.getSession().getValue();
+
+ const encodedUserCode = btoa(encodeURIComponent(userCode));
+
+ const sketchUrl = new URL(baseUrl);
+ sketchUrl.searchParams.append("sketch", encodedUserCode);
+
+ return sketchUrl;
+}
+
+function decodeSketchUrl(encodedSketch) {
+ const decodedSketch = decodeURIComponent(atob(encodedSketch));
+
+ return decodedSketch;
+}
+
+function checkForSketch() {
+ let initialSketch = `def setup():
+ createCanvas(200, 200)
+
+def draw():
+ background(200)
+ diameter = sin(frameCount / 60) * 50 + 50
+ fill("blue")
+ ellipse(100, 100, diameter, diameter)
+ `;
+
+ const currentUrl = new URLSearchParams(window.location.search);
+
+ if (currentUrl.has("sketch")) {
+ initialSketch = decodeSketchUrl(currentUrl.get("sketch"));
+ }
+
+ return initialSketch;
+}
+
+// Made by user Dean Taylor in
+// https://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript
+
+function fallbackCopyTextToClipboard(text) {
+ var textArea = document.createElement("textarea");
+ textArea.value = text;
+
+ // Avoid scrolling to bottom
+ textArea.style.top = "0";
+ textArea.style.left = "0";
+ textArea.style.position = "fixed";
+
+ document.body.appendChild(textArea);
+ textArea.focus();
+ textArea.select();
+
+ try {
+ document.execCommand("copy");
+ } catch (err) {
+ console.error("Fallback: Oops, unable to copy URL", err);
+ }
+
+ document.body.removeChild(textArea);
+}
+
+function copyTextToClipboard(text) {
+ if (!navigator.clipboard) {
+ fallbackCopyTextToClipboard(text);
+ return;
+ }
+ navigator.clipboard.writeText(text).then(
+ function () {
+ return;
+ },
+ function (err) {
+ console.error("Async: Could not copy URL: ", err);
+ }
+ );
+}
diff --git a/docs/pyodide/styles.css b/docs/pyodide/styles.css
new file mode 100644
index 00000000..d51a70fd
--- /dev/null
+++ b/docs/pyodide/styles.css
@@ -0,0 +1,70 @@
+body,
+html,
+canvas {
+ padding: 0;
+ margin: 0;
+}
+
+html {
+ overflow-y: scroll;
+ overflow-x: scroll;
+}
+
+.demoContainer {
+ display: flex;
+}
+
+pre {
+ margin-right: 2em;
+}
+
+.text-editor-box {
+ margin: 0 1.5em;
+ max-width: 800px;
+ display: flex;
+ flex-direction: column;
+ align-items: flex-end;
+}
+
+#text-editor {
+ float: left;
+ margin: 0.5em 0;
+ height: 600px;
+ border: 1px solid #ccc;
+ border-radius: 8px;
+}
+
+.text-editor {
+ width: 700px;
+ transition-property: width;
+ transition: 500ms ease-out;
+}
+
+#sketch-buttons {
+ width: 100%;
+ min-width: 250px;
+ display: flex;
+ justify-content: space-between;
+ align-self: flex-start;
+}
+
+.left-buttons {
+ width: 100%;
+}
+
+.hidden-editor {
+ opacity: 0.2;
+ width: 250px;
+ transition-property: width;
+ transition: 500ms ease-in;
+}
+
+.code-container {
+ display: flex;
+ align-items: flex-start;
+ justify-content: flex-start;
+}
+
+.display-none {
+ display: none;
+}
diff --git a/docs/pyodide/target/target_sketch.js b/docs/pyodide/target/target_sketch.js
index ba9199d8..aad5b805 100644
--- a/docs/pyodide/target/target_sketch.js
+++ b/docs/pyodide/target/target_sketch.js
@@ -1629,17 +1629,7 @@ touchEnded = None
windowResized = None
`;
-let userCode = `
-def setup():
- createCanvas(200, 200)
-
-def draw():
- background(200)
- diameter = sin(frameCount / 60) * 50 + 50
- fill("blue")
- ellipse(100, 100, diameter, diameter)
-
-`;
+let userCode = "";
const startCode = `
event_functions = {
@@ -1674,7 +1664,7 @@ function runCode() {
].join('\n');
if (window.instance) {
- window.instance.canvas.remove();
+ window.instance.remove();
}
console.log("Python execution output:");
diff --git a/pyp5js/__init__.py b/pyp5js/__init__.py
index e69de29b..91605139 100644
--- a/pyp5js/__init__.py
+++ b/pyp5js/__init__.py
@@ -0,0 +1,17 @@
+"""
+pyp5js
+Copyright (C) 2019-2021 Bernardo Fontes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+"""
diff --git a/pyp5js/cli.py b/pyp5js/cli.py
old mode 100755
new mode 100644
index 078c8ca8..8363eb69
--- a/pyp5js/cli.py
+++ b/pyp5js/cli.py
@@ -1,4 +1,21 @@
#!/usr/bin/env python3
+"""
+pyp5js
+Copyright (C) 2019-2021 Bernardo Fontes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+"""
import warnings
from pathlib import Path
diff --git a/pyp5js/commands.py b/pyp5js/commands.py
index ff874700..73d3ebf8 100644
--- a/pyp5js/commands.py
+++ b/pyp5js/commands.py
@@ -1,3 +1,20 @@
+"""
+pyp5js
+Copyright (C) 2019-2021 Bernardo Fontes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+"""
import os
import shutil
@@ -7,7 +24,7 @@
from pyp5js.compiler import compile_sketch_js
from pyp5js.exceptions import PythonSketchDoesNotExist
from pyp5js.sketch import Sketch
-from pyp5js.http import pyp5js_web_app
+from pyp5js.http_local.web_app import app as pyp5js_web_app
from pyp5js.monitor import monitor_sketch as monitor_sketch_service
from pyp5js.templates_renderers import get_sketch_index_content
from pyp5js.config import PYODIDE_INTERPRETER
diff --git a/pyp5js/compiler.py b/pyp5js/compiler.py
index 6ed3ad84..9c36a28a 100644
--- a/pyp5js/compiler.py
+++ b/pyp5js/compiler.py
@@ -1,3 +1,20 @@
+"""
+pyp5js
+Copyright (C) 2019-2021 Bernardo Fontes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+"""
import shutil
import subprocess
from cprint import cprint
diff --git a/pyp5js/config/__init__.py b/pyp5js/config/__init__.py
index c942fe6a..1035d68b 100644
--- a/pyp5js/config/__init__.py
+++ b/pyp5js/config/__init__.py
@@ -1,3 +1,20 @@
+"""
+pyp5js
+Copyright (C) 2019-2021 Bernardo Fontes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+"""
from . import sketch
from .sketch import TRANSCRYPT_INTERPRETER, PYODIDE_INTERPRETER
from decouple import config
diff --git a/pyp5js/config/fs.py b/pyp5js/config/fs.py
index 0d70b458..d6a8e682 100644
--- a/pyp5js/config/fs.py
+++ b/pyp5js/config/fs.py
@@ -1,3 +1,20 @@
+"""
+pyp5js
+Copyright (C) 2019-2021 Bernardo Fontes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+"""
from pathlib import Path
@@ -19,7 +36,7 @@ def templates_dir(self):
@property
def static_dir(self):
- return self.install.joinpath('http', 'static')
+ return self.install.joinpath('http_local', 'static')
@property
def pytop5js(self):
diff --git a/pyp5js/config/sketch.py b/pyp5js/config/sketch.py
index e98fe76f..71e4339f 100644
--- a/pyp5js/config/sketch.py
+++ b/pyp5js/config/sketch.py
@@ -1,3 +1,20 @@
+"""
+pyp5js
+Copyright (C) 2019-2021 Bernardo Fontes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+"""
import json
from pathlib import Path
diff --git a/pyp5js/exceptions.py b/pyp5js/exceptions.py
index ab13360a..65d34d51 100644
--- a/pyp5js/exceptions.py
+++ b/pyp5js/exceptions.py
@@ -1,3 +1,20 @@
+"""
+pyp5js
+Copyright (C) 2019-2021 Bernardo Fontes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+"""
class PythonSketchDoesNotExist(Exception):
def __init__(self, sketch):
diff --git a/pyp5js/http/__init__.py b/pyp5js/http/__init__.py
deleted file mode 100644
index f8198b49..00000000
--- a/pyp5js/http/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from pyp5js.http.web_app import app as pyp5js_web_app
diff --git a/pyp5js/http/templates/base.html b/pyp5js/http/templates/base.html
deleted file mode 100644
index 66ec452b..00000000
--- a/pyp5js/http/templates/base.html
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
- pyp5js - {% block title %}{% endblock title %}
-
-
-
-
- {% block extra_head %}
- {% endblock extra_head %}
-
-
-
-
-{% endblock content %}
diff --git a/pyp5js/http_local/__init__.py b/pyp5js/http_local/__init__.py
new file mode 100644
index 00000000..91605139
--- /dev/null
+++ b/pyp5js/http_local/__init__.py
@@ -0,0 +1,17 @@
+"""
+pyp5js
+Copyright (C) 2019-2021 Bernardo Fontes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+"""
diff --git a/pyp5js/http/static/js/ace/ace.js b/pyp5js/http_local/static/js/ace/ace.js
similarity index 100%
rename from pyp5js/http/static/js/ace/ace.js
rename to pyp5js/http_local/static/js/ace/ace.js
diff --git a/pyp5js/http/static/js/ace/ext-beautify.js b/pyp5js/http_local/static/js/ace/ext-beautify.js
similarity index 100%
rename from pyp5js/http/static/js/ace/ext-beautify.js
rename to pyp5js/http_local/static/js/ace/ext-beautify.js
diff --git a/pyp5js/http/static/js/ace/ext-code_lens.js b/pyp5js/http_local/static/js/ace/ext-code_lens.js
similarity index 100%
rename from pyp5js/http/static/js/ace/ext-code_lens.js
rename to pyp5js/http_local/static/js/ace/ext-code_lens.js
diff --git a/pyp5js/http/static/js/ace/ext-elastic_tabstops_lite.js b/pyp5js/http_local/static/js/ace/ext-elastic_tabstops_lite.js
similarity index 100%
rename from pyp5js/http/static/js/ace/ext-elastic_tabstops_lite.js
rename to pyp5js/http_local/static/js/ace/ext-elastic_tabstops_lite.js
diff --git a/pyp5js/http/static/js/ace/ext-emmet.js b/pyp5js/http_local/static/js/ace/ext-emmet.js
similarity index 100%
rename from pyp5js/http/static/js/ace/ext-emmet.js
rename to pyp5js/http_local/static/js/ace/ext-emmet.js
diff --git a/pyp5js/http/static/js/ace/ext-error_marker.js b/pyp5js/http_local/static/js/ace/ext-error_marker.js
similarity index 100%
rename from pyp5js/http/static/js/ace/ext-error_marker.js
rename to pyp5js/http_local/static/js/ace/ext-error_marker.js
diff --git a/pyp5js/http/static/js/ace/ext-keybinding_menu.js b/pyp5js/http_local/static/js/ace/ext-keybinding_menu.js
similarity index 100%
rename from pyp5js/http/static/js/ace/ext-keybinding_menu.js
rename to pyp5js/http_local/static/js/ace/ext-keybinding_menu.js
diff --git a/pyp5js/http/static/js/ace/ext-language_tools.js b/pyp5js/http_local/static/js/ace/ext-language_tools.js
similarity index 100%
rename from pyp5js/http/static/js/ace/ext-language_tools.js
rename to pyp5js/http_local/static/js/ace/ext-language_tools.js
diff --git a/pyp5js/http/static/js/ace/ext-linking.js b/pyp5js/http_local/static/js/ace/ext-linking.js
similarity index 100%
rename from pyp5js/http/static/js/ace/ext-linking.js
rename to pyp5js/http_local/static/js/ace/ext-linking.js
diff --git a/pyp5js/http/static/js/ace/ext-modelist.js b/pyp5js/http_local/static/js/ace/ext-modelist.js
similarity index 100%
rename from pyp5js/http/static/js/ace/ext-modelist.js
rename to pyp5js/http_local/static/js/ace/ext-modelist.js
diff --git a/pyp5js/http/static/js/ace/ext-options.js b/pyp5js/http_local/static/js/ace/ext-options.js
similarity index 100%
rename from pyp5js/http/static/js/ace/ext-options.js
rename to pyp5js/http_local/static/js/ace/ext-options.js
diff --git a/pyp5js/http/static/js/ace/ext-prompt.js b/pyp5js/http_local/static/js/ace/ext-prompt.js
similarity index 100%
rename from pyp5js/http/static/js/ace/ext-prompt.js
rename to pyp5js/http_local/static/js/ace/ext-prompt.js
diff --git a/pyp5js/http/static/js/ace/ext-rtl.js b/pyp5js/http_local/static/js/ace/ext-rtl.js
similarity index 100%
rename from pyp5js/http/static/js/ace/ext-rtl.js
rename to pyp5js/http_local/static/js/ace/ext-rtl.js
diff --git a/pyp5js/http/static/js/ace/ext-searchbox.js b/pyp5js/http_local/static/js/ace/ext-searchbox.js
similarity index 100%
rename from pyp5js/http/static/js/ace/ext-searchbox.js
rename to pyp5js/http_local/static/js/ace/ext-searchbox.js
diff --git a/pyp5js/http/static/js/ace/ext-settings_menu.js b/pyp5js/http_local/static/js/ace/ext-settings_menu.js
similarity index 100%
rename from pyp5js/http/static/js/ace/ext-settings_menu.js
rename to pyp5js/http_local/static/js/ace/ext-settings_menu.js
diff --git a/pyp5js/http/static/js/ace/ext-spellcheck.js b/pyp5js/http_local/static/js/ace/ext-spellcheck.js
similarity index 100%
rename from pyp5js/http/static/js/ace/ext-spellcheck.js
rename to pyp5js/http_local/static/js/ace/ext-spellcheck.js
diff --git a/pyp5js/http/static/js/ace/ext-split.js b/pyp5js/http_local/static/js/ace/ext-split.js
similarity index 100%
rename from pyp5js/http/static/js/ace/ext-split.js
rename to pyp5js/http_local/static/js/ace/ext-split.js
diff --git a/pyp5js/http/static/js/ace/ext-static_highlight.js b/pyp5js/http_local/static/js/ace/ext-static_highlight.js
similarity index 100%
rename from pyp5js/http/static/js/ace/ext-static_highlight.js
rename to pyp5js/http_local/static/js/ace/ext-static_highlight.js
diff --git a/pyp5js/http/static/js/ace/ext-statusbar.js b/pyp5js/http_local/static/js/ace/ext-statusbar.js
similarity index 100%
rename from pyp5js/http/static/js/ace/ext-statusbar.js
rename to pyp5js/http_local/static/js/ace/ext-statusbar.js
diff --git a/pyp5js/http/static/js/ace/ext-textarea.js b/pyp5js/http_local/static/js/ace/ext-textarea.js
similarity index 100%
rename from pyp5js/http/static/js/ace/ext-textarea.js
rename to pyp5js/http_local/static/js/ace/ext-textarea.js
diff --git a/pyp5js/http/static/js/ace/ext-themelist.js b/pyp5js/http_local/static/js/ace/ext-themelist.js
similarity index 100%
rename from pyp5js/http/static/js/ace/ext-themelist.js
rename to pyp5js/http_local/static/js/ace/ext-themelist.js
diff --git a/pyp5js/http/static/js/ace/ext-whitespace.js b/pyp5js/http_local/static/js/ace/ext-whitespace.js
similarity index 100%
rename from pyp5js/http/static/js/ace/ext-whitespace.js
rename to pyp5js/http_local/static/js/ace/ext-whitespace.js
diff --git a/pyp5js/http/static/js/ace/keybinding-emacs.js b/pyp5js/http_local/static/js/ace/keybinding-emacs.js
similarity index 100%
rename from pyp5js/http/static/js/ace/keybinding-emacs.js
rename to pyp5js/http_local/static/js/ace/keybinding-emacs.js
diff --git a/pyp5js/http/static/js/ace/keybinding-sublime.js b/pyp5js/http_local/static/js/ace/keybinding-sublime.js
similarity index 100%
rename from pyp5js/http/static/js/ace/keybinding-sublime.js
rename to pyp5js/http_local/static/js/ace/keybinding-sublime.js
diff --git a/pyp5js/http/static/js/ace/keybinding-vim.js b/pyp5js/http_local/static/js/ace/keybinding-vim.js
similarity index 100%
rename from pyp5js/http/static/js/ace/keybinding-vim.js
rename to pyp5js/http_local/static/js/ace/keybinding-vim.js
diff --git a/pyp5js/http/static/js/ace/keybinding-vscode.js b/pyp5js/http_local/static/js/ace/keybinding-vscode.js
similarity index 100%
rename from pyp5js/http/static/js/ace/keybinding-vscode.js
rename to pyp5js/http_local/static/js/ace/keybinding-vscode.js
diff --git a/pyp5js/http/static/js/ace/mode-python.js b/pyp5js/http_local/static/js/ace/mode-python.js
similarity index 100%
rename from pyp5js/http/static/js/ace/mode-python.js
rename to pyp5js/http_local/static/js/ace/mode-python.js
diff --git a/pyp5js/http/static/js/ace/theme-ambiance.js b/pyp5js/http_local/static/js/ace/theme-ambiance.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-ambiance.js
rename to pyp5js/http_local/static/js/ace/theme-ambiance.js
diff --git a/pyp5js/http/static/js/ace/theme-chaos.js b/pyp5js/http_local/static/js/ace/theme-chaos.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-chaos.js
rename to pyp5js/http_local/static/js/ace/theme-chaos.js
diff --git a/pyp5js/http/static/js/ace/theme-chrome.js b/pyp5js/http_local/static/js/ace/theme-chrome.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-chrome.js
rename to pyp5js/http_local/static/js/ace/theme-chrome.js
diff --git a/pyp5js/http/static/js/ace/theme-clouds.js b/pyp5js/http_local/static/js/ace/theme-clouds.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-clouds.js
rename to pyp5js/http_local/static/js/ace/theme-clouds.js
diff --git a/pyp5js/http/static/js/ace/theme-clouds_midnight.js b/pyp5js/http_local/static/js/ace/theme-clouds_midnight.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-clouds_midnight.js
rename to pyp5js/http_local/static/js/ace/theme-clouds_midnight.js
diff --git a/pyp5js/http/static/js/ace/theme-cobalt.js b/pyp5js/http_local/static/js/ace/theme-cobalt.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-cobalt.js
rename to pyp5js/http_local/static/js/ace/theme-cobalt.js
diff --git a/pyp5js/http/static/js/ace/theme-crimson_editor.js b/pyp5js/http_local/static/js/ace/theme-crimson_editor.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-crimson_editor.js
rename to pyp5js/http_local/static/js/ace/theme-crimson_editor.js
diff --git a/pyp5js/http/static/js/ace/theme-dawn.js b/pyp5js/http_local/static/js/ace/theme-dawn.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-dawn.js
rename to pyp5js/http_local/static/js/ace/theme-dawn.js
diff --git a/pyp5js/http/static/js/ace/theme-dracula.js b/pyp5js/http_local/static/js/ace/theme-dracula.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-dracula.js
rename to pyp5js/http_local/static/js/ace/theme-dracula.js
diff --git a/pyp5js/http/static/js/ace/theme-dreamweaver.js b/pyp5js/http_local/static/js/ace/theme-dreamweaver.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-dreamweaver.js
rename to pyp5js/http_local/static/js/ace/theme-dreamweaver.js
diff --git a/pyp5js/http/static/js/ace/theme-eclipse.js b/pyp5js/http_local/static/js/ace/theme-eclipse.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-eclipse.js
rename to pyp5js/http_local/static/js/ace/theme-eclipse.js
diff --git a/pyp5js/http/static/js/ace/theme-github.js b/pyp5js/http_local/static/js/ace/theme-github.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-github.js
rename to pyp5js/http_local/static/js/ace/theme-github.js
diff --git a/pyp5js/http/static/js/ace/theme-gob.js b/pyp5js/http_local/static/js/ace/theme-gob.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-gob.js
rename to pyp5js/http_local/static/js/ace/theme-gob.js
diff --git a/pyp5js/http/static/js/ace/theme-gruvbox.js b/pyp5js/http_local/static/js/ace/theme-gruvbox.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-gruvbox.js
rename to pyp5js/http_local/static/js/ace/theme-gruvbox.js
diff --git a/pyp5js/http/static/js/ace/theme-idle_fingers.js b/pyp5js/http_local/static/js/ace/theme-idle_fingers.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-idle_fingers.js
rename to pyp5js/http_local/static/js/ace/theme-idle_fingers.js
diff --git a/pyp5js/http/static/js/ace/theme-iplastic.js b/pyp5js/http_local/static/js/ace/theme-iplastic.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-iplastic.js
rename to pyp5js/http_local/static/js/ace/theme-iplastic.js
diff --git a/pyp5js/http/static/js/ace/theme-katzenmilch.js b/pyp5js/http_local/static/js/ace/theme-katzenmilch.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-katzenmilch.js
rename to pyp5js/http_local/static/js/ace/theme-katzenmilch.js
diff --git a/pyp5js/http/static/js/ace/theme-kr_theme.js b/pyp5js/http_local/static/js/ace/theme-kr_theme.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-kr_theme.js
rename to pyp5js/http_local/static/js/ace/theme-kr_theme.js
diff --git a/pyp5js/http/static/js/ace/theme-kuroir.js b/pyp5js/http_local/static/js/ace/theme-kuroir.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-kuroir.js
rename to pyp5js/http_local/static/js/ace/theme-kuroir.js
diff --git a/pyp5js/http/static/js/ace/theme-merbivore.js b/pyp5js/http_local/static/js/ace/theme-merbivore.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-merbivore.js
rename to pyp5js/http_local/static/js/ace/theme-merbivore.js
diff --git a/pyp5js/http/static/js/ace/theme-merbivore_soft.js b/pyp5js/http_local/static/js/ace/theme-merbivore_soft.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-merbivore_soft.js
rename to pyp5js/http_local/static/js/ace/theme-merbivore_soft.js
diff --git a/pyp5js/http/static/js/ace/theme-mono_industrial.js b/pyp5js/http_local/static/js/ace/theme-mono_industrial.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-mono_industrial.js
rename to pyp5js/http_local/static/js/ace/theme-mono_industrial.js
diff --git a/pyp5js/http/static/js/ace/theme-monokai.js b/pyp5js/http_local/static/js/ace/theme-monokai.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-monokai.js
rename to pyp5js/http_local/static/js/ace/theme-monokai.js
diff --git a/pyp5js/http/static/js/ace/theme-nord_dark.js b/pyp5js/http_local/static/js/ace/theme-nord_dark.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-nord_dark.js
rename to pyp5js/http_local/static/js/ace/theme-nord_dark.js
diff --git a/pyp5js/http/static/js/ace/theme-pastel_on_dark.js b/pyp5js/http_local/static/js/ace/theme-pastel_on_dark.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-pastel_on_dark.js
rename to pyp5js/http_local/static/js/ace/theme-pastel_on_dark.js
diff --git a/pyp5js/http/static/js/ace/theme-solarized_dark.js b/pyp5js/http_local/static/js/ace/theme-solarized_dark.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-solarized_dark.js
rename to pyp5js/http_local/static/js/ace/theme-solarized_dark.js
diff --git a/pyp5js/http/static/js/ace/theme-solarized_light.js b/pyp5js/http_local/static/js/ace/theme-solarized_light.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-solarized_light.js
rename to pyp5js/http_local/static/js/ace/theme-solarized_light.js
diff --git a/pyp5js/http/static/js/ace/theme-sqlserver.js b/pyp5js/http_local/static/js/ace/theme-sqlserver.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-sqlserver.js
rename to pyp5js/http_local/static/js/ace/theme-sqlserver.js
diff --git a/pyp5js/http/static/js/ace/theme-terminal.js b/pyp5js/http_local/static/js/ace/theme-terminal.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-terminal.js
rename to pyp5js/http_local/static/js/ace/theme-terminal.js
diff --git a/pyp5js/http/static/js/ace/theme-textmate.js b/pyp5js/http_local/static/js/ace/theme-textmate.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-textmate.js
rename to pyp5js/http_local/static/js/ace/theme-textmate.js
diff --git a/pyp5js/http/static/js/ace/theme-tomorrow.js b/pyp5js/http_local/static/js/ace/theme-tomorrow.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-tomorrow.js
rename to pyp5js/http_local/static/js/ace/theme-tomorrow.js
diff --git a/pyp5js/http/static/js/ace/theme-tomorrow_night.js b/pyp5js/http_local/static/js/ace/theme-tomorrow_night.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-tomorrow_night.js
rename to pyp5js/http_local/static/js/ace/theme-tomorrow_night.js
diff --git a/pyp5js/http/static/js/ace/theme-tomorrow_night_blue.js b/pyp5js/http_local/static/js/ace/theme-tomorrow_night_blue.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-tomorrow_night_blue.js
rename to pyp5js/http_local/static/js/ace/theme-tomorrow_night_blue.js
diff --git a/pyp5js/http/static/js/ace/theme-tomorrow_night_bright.js b/pyp5js/http_local/static/js/ace/theme-tomorrow_night_bright.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-tomorrow_night_bright.js
rename to pyp5js/http_local/static/js/ace/theme-tomorrow_night_bright.js
diff --git a/pyp5js/http/static/js/ace/theme-tomorrow_night_eighties.js b/pyp5js/http_local/static/js/ace/theme-tomorrow_night_eighties.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-tomorrow_night_eighties.js
rename to pyp5js/http_local/static/js/ace/theme-tomorrow_night_eighties.js
diff --git a/pyp5js/http/static/js/ace/theme-twilight.js b/pyp5js/http_local/static/js/ace/theme-twilight.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-twilight.js
rename to pyp5js/http_local/static/js/ace/theme-twilight.js
diff --git a/pyp5js/http/static/js/ace/theme-vibrant_ink.js b/pyp5js/http_local/static/js/ace/theme-vibrant_ink.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-vibrant_ink.js
rename to pyp5js/http_local/static/js/ace/theme-vibrant_ink.js
diff --git a/pyp5js/http/static/js/ace/theme-xcode.js b/pyp5js/http_local/static/js/ace/theme-xcode.js
similarity index 100%
rename from pyp5js/http/static/js/ace/theme-xcode.js
rename to pyp5js/http_local/static/js/ace/theme-xcode.js
diff --git a/pyp5js/http/static/js/ace/worker-coffee.js b/pyp5js/http_local/static/js/ace/worker-coffee.js
similarity index 100%
rename from pyp5js/http/static/js/ace/worker-coffee.js
rename to pyp5js/http_local/static/js/ace/worker-coffee.js
diff --git a/pyp5js/http/static/js/ace/worker-css.js b/pyp5js/http_local/static/js/ace/worker-css.js
similarity index 100%
rename from pyp5js/http/static/js/ace/worker-css.js
rename to pyp5js/http_local/static/js/ace/worker-css.js
diff --git a/pyp5js/http/static/js/ace/worker-html.js b/pyp5js/http_local/static/js/ace/worker-html.js
similarity index 100%
rename from pyp5js/http/static/js/ace/worker-html.js
rename to pyp5js/http_local/static/js/ace/worker-html.js
diff --git a/pyp5js/http/static/js/ace/worker-javascript.js b/pyp5js/http_local/static/js/ace/worker-javascript.js
similarity index 100%
rename from pyp5js/http/static/js/ace/worker-javascript.js
rename to pyp5js/http_local/static/js/ace/worker-javascript.js
diff --git a/pyp5js/http/static/js/ace/worker-json.js b/pyp5js/http_local/static/js/ace/worker-json.js
similarity index 100%
rename from pyp5js/http/static/js/ace/worker-json.js
rename to pyp5js/http_local/static/js/ace/worker-json.js
diff --git a/pyp5js/http/static/js/ace/worker-lua.js b/pyp5js/http_local/static/js/ace/worker-lua.js
similarity index 100%
rename from pyp5js/http/static/js/ace/worker-lua.js
rename to pyp5js/http_local/static/js/ace/worker-lua.js
diff --git a/pyp5js/http/static/js/ace/worker-php.js b/pyp5js/http_local/static/js/ace/worker-php.js
similarity index 100%
rename from pyp5js/http/static/js/ace/worker-php.js
rename to pyp5js/http_local/static/js/ace/worker-php.js
diff --git a/pyp5js/http/static/js/ace/worker-xml.js b/pyp5js/http_local/static/js/ace/worker-xml.js
similarity index 100%
rename from pyp5js/http/static/js/ace/worker-xml.js
rename to pyp5js/http_local/static/js/ace/worker-xml.js
diff --git a/pyp5js/http/static/js/ace/worker-xquery.js b/pyp5js/http_local/static/js/ace/worker-xquery.js
similarity index 100%
rename from pyp5js/http/static/js/ace/worker-xquery.js
rename to pyp5js/http_local/static/js/ace/worker-xquery.js
diff --git a/pyp5js/http/static/js/p5/addons/p5.sound.js b/pyp5js/http_local/static/js/p5/addons/p5.sound.js
similarity index 100%
rename from pyp5js/http/static/js/p5/addons/p5.sound.js
rename to pyp5js/http_local/static/js/p5/addons/p5.sound.js
diff --git a/pyp5js/http/static/js/p5/addons/p5.sound.min.js b/pyp5js/http_local/static/js/p5/addons/p5.sound.min.js
similarity index 100%
rename from pyp5js/http/static/js/p5/addons/p5.sound.min.js
rename to pyp5js/http_local/static/js/p5/addons/p5.sound.min.js
diff --git a/pyp5js/http/static/js/p5/p5.js b/pyp5js/http_local/static/js/p5/p5.js
similarity index 100%
rename from pyp5js/http/static/js/p5/p5.js
rename to pyp5js/http_local/static/js/p5/p5.js
diff --git a/pyp5js/http/static/js/p5/p5.min.js b/pyp5js/http_local/static/js/p5/p5.min.js
similarity index 100%
rename from pyp5js/http/static/js/p5/p5.min.js
rename to pyp5js/http_local/static/js/p5/p5.min.js
diff --git a/pyp5js/http/static/js/pyodide/packages.json b/pyp5js/http_local/static/js/pyodide/packages.json
similarity index 100%
rename from pyp5js/http/static/js/pyodide/packages.json
rename to pyp5js/http_local/static/js/pyodide/packages.json
diff --git a/pyp5js/http/static/js/pyodide/pyodide.asm.data b/pyp5js/http_local/static/js/pyodide/pyodide.asm.data
similarity index 100%
rename from pyp5js/http/static/js/pyodide/pyodide.asm.data
rename to pyp5js/http_local/static/js/pyodide/pyodide.asm.data
diff --git a/pyp5js/http/static/js/pyodide/pyodide.asm.js b/pyp5js/http_local/static/js/pyodide/pyodide.asm.js
similarity index 100%
rename from pyp5js/http/static/js/pyodide/pyodide.asm.js
rename to pyp5js/http_local/static/js/pyodide/pyodide.asm.js
diff --git a/pyp5js/http/static/js/pyodide/pyodide.asm.wasm b/pyp5js/http_local/static/js/pyodide/pyodide.asm.wasm
similarity index 100%
rename from pyp5js/http/static/js/pyodide/pyodide.asm.wasm
rename to pyp5js/http_local/static/js/pyodide/pyodide.asm.wasm
diff --git a/pyp5js/http/static/js/pyodide/pyodide.js.map b/pyp5js/http_local/static/js/pyodide/pyodide.js.map
similarity index 100%
rename from pyp5js/http/static/js/pyodide/pyodide.js.map
rename to pyp5js/http_local/static/js/pyodide/pyodide.js.map
diff --git a/pyp5js/http/static/js/pyodide/pyodide_v0.18.1.js b/pyp5js/http_local/static/js/pyodide/pyodide_v0.18.1.js
similarity index 100%
rename from pyp5js/http/static/js/pyodide/pyodide_v0.18.1.js
rename to pyp5js/http_local/static/js/pyodide/pyodide_v0.18.1.js
diff --git a/pyp5js/http/static/p5_reference.yml b/pyp5js/http_local/static/p5_reference.yml
similarity index 100%
rename from pyp5js/http/static/p5_reference.yml
rename to pyp5js/http_local/static/p5_reference.yml
diff --git a/pyp5js/http/static/styles/basscss-7.1.1.min.css b/pyp5js/http_local/static/styles/basscss-7.1.1.min.css
similarity index 100%
rename from pyp5js/http/static/styles/basscss-7.1.1.min.css
rename to pyp5js/http_local/static/styles/basscss-7.1.1.min.css
diff --git a/pyp5js/http/static/styles/custom.css b/pyp5js/http_local/static/styles/custom.css
similarity index 100%
rename from pyp5js/http/static/styles/custom.css
rename to pyp5js/http_local/static/styles/custom.css
diff --git a/pyp5js/http_local/templates/base.html b/pyp5js/http_local/templates/base.html
new file mode 100644
index 00000000..dd4c0584
--- /dev/null
+++ b/pyp5js/http_local/templates/base.html
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+ pyp5js - {% block title %}{% endblock title %}
+
+
+
+
+ {% block extra_head %}
+ {% endblock extra_head %}
+
+
+
+
+{% endblock content %}
diff --git a/pyp5js/http/templates/view_sketch.html b/pyp5js/http_local/templates/view_sketch.html
similarity index 88%
rename from pyp5js/http/templates/view_sketch.html
rename to pyp5js/http_local/templates/view_sketch.html
index 445c951d..cca8f2bc 100644
--- a/pyp5js/http/templates/view_sketch.html
+++ b/pyp5js/http_local/templates/view_sketch.html
@@ -1,3 +1,20 @@
+
{% extends "base.html" %}
{% block title %}{{ sketch_name }}{% endblock title %}
diff --git a/pyp5js/http/web_app.py b/pyp5js/http_local/web_app.py
similarity index 80%
rename from pyp5js/http/web_app.py
rename to pyp5js/http_local/web_app.py
index 55b9306d..24d08d6a 100644
--- a/pyp5js/http/web_app.py
+++ b/pyp5js/http_local/web_app.py
@@ -1,13 +1,31 @@
+"""
+pyp5js
+Copyright (C) 2019-2021 Bernardo Fontes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+"""
import ast
import os
-from flask import Flask, render_template, request, send_from_directory
-from slugify import slugify
+from flask import Flask, render_template, request, send_from_directory
from pyp5js import commands
-from pyp5js.config import SKETCHBOOK_DIR, PYODIDE_INTERPRETER, AVAILABLE_INTERPRETERS, TRANSCRYPT_INTERPRETER
-from pyp5js.exceptions import PythonSketchDoesNotExist, SketchDirAlreadyExistException
+from pyp5js.config import (AVAILABLE_INTERPRETERS, PYODIDE_INTERPRETER,
+ SKETCHBOOK_DIR, TRANSCRYPT_INTERPRETER)
+from pyp5js.exceptions import (PythonSketchDoesNotExist,
+ SketchDirAlreadyExistException)
from pyp5js.sketch import Sketch
-
+from slugify import slugify
app = Flask(__name__)
SUPPORTED_IMAGE_FILE_SUFFIXES = (".gif", ".jpg", ".png")
@@ -81,7 +99,7 @@ def render_sketch_view(sketch_name, static_path):
else:
try:
ast.parse(py_code, sketch.sketch_py.name)
- sketch.sketch_py.write_text(py_code)
+ sketch.sketch_py.write_bytes(bytes(py_code, encoding="utf-8"))
except SyntaxError as exc:
error = f'SyntaxError: {exc}'
@@ -110,7 +128,7 @@ def _serve_static(static_dir, static_path):
# User tried something not allowed (as "/root/something" or "../xxx")
return '', 403
- resp = send_from_directory(static_dir.absolute(), static_path, add_etags=False, cache_timeout=0)
+ resp = send_from_directory(static_dir.absolute(), static_path, etag=False, max_age=0)
if os.name == 'nt' and static_path.lower().endswith('.js'):
js_content = resp.headers['Content-Type'].replace('text/plain', 'application/javascript')
diff --git a/pyp5js/monitor.py b/pyp5js/monitor.py
index c4eacc76..ccc6a939 100644
--- a/pyp5js/monitor.py
+++ b/pyp5js/monitor.py
@@ -1,3 +1,20 @@
+"""
+pyp5js
+Copyright (C) 2019-2021 Bernardo Fontes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+"""
import time
from cprint import cprint
from watchdog.events import PatternMatchingEventHandler
diff --git a/pyp5js/sketch.py b/pyp5js/sketch.py
index a719965e..83f7ceb7 100644
--- a/pyp5js/sketch.py
+++ b/pyp5js/sketch.py
@@ -1,3 +1,20 @@
+"""
+pyp5js
+Copyright (C) 2019-2021 Bernardo Fontes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+"""
import os
import re
import shutil
diff --git a/pyp5js/templates/pyodide/index.html b/pyp5js/templates/pyodide/index.html
index 3cce84d8..7569524e 100644
--- a/pyp5js/templates/pyodide/index.html
+++ b/pyp5js/templates/pyodide/index.html
@@ -1,3 +1,20 @@
+
diff --git a/pyp5js/templates/pyodide/target_sketch.js.template b/pyp5js/templates/pyodide/target_sketch.js.template
index 5cb9fb64..8bc4a9fa 100644
--- a/pyp5js/templates/pyodide/target_sketch.js.template
+++ b/pyp5js/templates/pyodide/target_sketch.js.template
@@ -1,3 +1,20 @@
+/*
+pyp5js
+Copyright (C) 2019-2021 Bernardo Fontes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+*/
const wrapperContent = `
class PythonFunctions: pass
diff --git a/pyp5js/templates/transcrypt/index.html b/pyp5js/templates/transcrypt/index.html
index 70a591f9..5968e3e8 100644
--- a/pyp5js/templates/transcrypt/index.html
+++ b/pyp5js/templates/transcrypt/index.html
@@ -1,3 +1,20 @@
+
diff --git a/pyp5js/templates/transcrypt/pyp5js.py b/pyp5js/templates/transcrypt/pyp5js.py
index d9b7697f..e6bdd5f6 100644
--- a/pyp5js/templates/transcrypt/pyp5js.py
+++ b/pyp5js/templates/transcrypt/pyp5js.py
@@ -1,3 +1,20 @@
+"""
+pyp5js
+Copyright (C) 2019-2021 Bernardo Fontes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+"""
from python_functions import PythonFunctions
_P5_INSTANCE = None
diff --git a/pyp5js/templates/transcrypt/python_functions.py b/pyp5js/templates/transcrypt/python_functions.py
index 29eb079d..d25c5127 100644
--- a/pyp5js/templates/transcrypt/python_functions.py
+++ b/pyp5js/templates/transcrypt/python_functions.py
@@ -1,3 +1,20 @@
+"""
+pyp5js
+Copyright (C) 2019-2021 Bernardo Fontes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+"""
class PythonFunctions: pass
setattr(PythonFunctions, 'map', map)
diff --git a/pyp5js/templates/transcrypt/target_sketch.py.template b/pyp5js/templates/transcrypt/target_sketch.py.template
index c8058513..d399de49 100644
--- a/pyp5js/templates/transcrypt/target_sketch.py.template
+++ b/pyp5js/templates/transcrypt/target_sketch.py.template
@@ -1,3 +1,20 @@
+"""
+pyp5js
+Copyright (C) 2019-2021 Bernardo Fontes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+"""
from pyp5js import *
def preload():
diff --git a/pyp5js/templates_renderers.py b/pyp5js/templates_renderers.py
index 043b4b72..311c87bd 100644
--- a/pyp5js/templates_renderers.py
+++ b/pyp5js/templates_renderers.py
@@ -1,3 +1,20 @@
+"""
+pyp5js
+Copyright (C) 2019-2021 Bernardo Fontes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+"""
from jinja2 import Environment, FileSystemLoader, select_autoescape
from pyp5js.config.fs import PYP5JS_FILES
diff --git a/pyp5js/tests/__init__.py b/pyp5js/tests/__init__.py
index e69de29b..91605139 100644
--- a/pyp5js/tests/__init__.py
+++ b/pyp5js/tests/__init__.py
@@ -0,0 +1,17 @@
+"""
+pyp5js
+Copyright (C) 2019-2021 Bernardo Fontes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+"""
diff --git a/pyp5js/tests/fixtures.py b/pyp5js/tests/fixtures.py
index 37ec5170..61534bab 100644
--- a/pyp5js/tests/fixtures.py
+++ b/pyp5js/tests/fixtures.py
@@ -1,3 +1,20 @@
+"""
+pyp5js
+Copyright (C) 2019-2021 Bernardo Fontes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+"""
import json
import os
import shutil
diff --git a/pyp5js/tests/test_commands.py b/pyp5js/tests/test_commands.py
index 5ca4d320..7f86b804 100644
--- a/pyp5js/tests/test_commands.py
+++ b/pyp5js/tests/test_commands.py
@@ -1,3 +1,20 @@
+"""
+pyp5js
+Copyright (C) 2019-2021 Bernardo Fontes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+"""
import pytest
import shutil
from unittest import TestCase
diff --git a/pyp5js/tests/test_compiler.py b/pyp5js/tests/test_compiler.py
index bb7f7ee7..ce8aae3f 100644
--- a/pyp5js/tests/test_compiler.py
+++ b/pyp5js/tests/test_compiler.py
@@ -1,3 +1,20 @@
+"""
+pyp5js
+Copyright (C) 2019-2021 Bernardo Fontes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+"""
import pytest
import shutil
from pathlib import Path
diff --git a/pyp5js/tests/test_config/__init__.py b/pyp5js/tests/test_config/__init__.py
index e69de29b..91605139 100644
--- a/pyp5js/tests/test_config/__init__.py
+++ b/pyp5js/tests/test_config/__init__.py
@@ -0,0 +1,17 @@
+"""
+pyp5js
+Copyright (C) 2019-2021 Bernardo Fontes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+"""
diff --git a/pyp5js/tests/test_config/test_fs.py b/pyp5js/tests/test_config/test_fs.py
index 594ebaf3..c69a22c7 100644
--- a/pyp5js/tests/test_config/test_fs.py
+++ b/pyp5js/tests/test_config/test_fs.py
@@ -1,3 +1,20 @@
+"""
+pyp5js
+Copyright (C) 2019-2021 Bernardo Fontes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+"""
import pytest
from pathlib import Path
@@ -12,7 +29,7 @@ def test_dir_properties(lib_files):
assert lib_files.templates_dir == pyp5_dir.joinpath('templates')
assert lib_files.templates_dir.exists()
- assert lib_files.static_dir == pyp5_dir.joinpath('http', 'static')
+ assert lib_files.static_dir == pyp5_dir.joinpath('http_local', 'static')
assert lib_files.static_dir.exists()
@@ -23,10 +40,10 @@ def test_files_properties(lib_files):
assert lib_files.pytop5js == pyp5_dir.joinpath('templates', 'transcrypt', 'pyp5js.py')
assert lib_files.pytop5js.exists()
- assert lib_files.p5js == pyp5_dir.joinpath('http', 'static', 'js', 'p5', 'p5.min.js')
+ assert lib_files.p5js == pyp5_dir.joinpath('http_local', 'static', 'js', 'p5', 'p5.min.js')
assert lib_files.p5js.exists()
- assert lib_files.p5_yml == pyp5_dir.joinpath('http', 'static', 'p5_reference.yml')
+ assert lib_files.p5_yml == pyp5_dir.joinpath('http_local', 'static', 'p5_reference.yml')
assert lib_files.p5_yml.exists()
diff --git a/pyp5js/tests/test_config/test_sketch.py b/pyp5js/tests/test_config/test_sketch.py
index 4ca2ef0a..5c16da77 100644
--- a/pyp5js/tests/test_config/test_sketch.py
+++ b/pyp5js/tests/test_config/test_sketch.py
@@ -1,3 +1,20 @@
+"""
+pyp5js
+Copyright (C) 2019-2021 Bernardo Fontes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+"""
import json
import os
from pathlib import Path
diff --git a/pyp5js/tests/test_http/test_web_app.py b/pyp5js/tests/test_http/test_web_app.py
index 3076bc62..8199dcd3 100644
--- a/pyp5js/tests/test_http/test_web_app.py
+++ b/pyp5js/tests/test_http/test_web_app.py
@@ -1,11 +1,29 @@
+"""
+pyp5js
+Copyright (C) 2019-2021 Bernardo Fontes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+"""
import os
+import platform
import shutil
from pathlib import Path
from pyp5js import commands
from pyp5js.sketch import Sketch
from pyp5js.config import SKETCHBOOK_DIR, PYODIDE_INTERPRETER, TRANSCRYPT_INTERPRETER
-from pyp5js.http.web_app import app as web_app
+from pyp5js.http_local.web_app import app as web_app
from flask_testing import TestCase
@@ -40,6 +58,21 @@ def create_file(self, file_name, content=''):
with (SKETCHBOOK_DIR.joinpath(file_name).resolve()).open(mode) as fd:
fd.write(content)
+ def _add_template(self, app, template, context):
+ """
+ flask testing does not work with Werkzeug>=2.1
+ We are overwriting how this function add the templates in order to
+ make it to work again.
+
+ The app parameter is actually the context, while the template
+ is now the app and the context is the template.
+ Yep, this is fucked up.
+ """
+ app, template, context = template, context, app
+ if len(self.templates) > 0:
+ self.templates = []
+ self.templates.append((template, context))
+
class IndexViewTests(Pyp5jsWebTestCase):
route = '/'
@@ -136,7 +169,8 @@ def test_get_static_javascript_file(self):
self.create_sketch_with_static_files('sketch_with_static_js', use_cdn=False)
response = self.client.get(self.route + 'sketch_with_static_js/static/p5.js')
self.assert_200(response)
- self.assertEqual(response.headers['Content-Type'], 'application/javascript; charset=utf-8')
+ content_types = ['application/javascript; charset=utf-8', 'text/javascript; charset=utf-8']
+ self.assertIn(response.headers['Content-Type'], content_types)
def test_get_static_javascript_file_upper_case(self):
js_code = 'alert("hi!");'
@@ -146,7 +180,8 @@ def test_get_static_javascript_file_upper_case(self):
response = self.client.get(self.route + 'sketch_with_static_js/static/custom.JS')
self.assert_200(response)
- self.assertEqual(response.headers['Content-Type'], 'application/javascript; charset=utf-8')
+ content_types = ['application/javascript; charset=utf-8', 'text/javascript; charset=utf-8']
+ self.assertIn(response.headers['Content-Type'], content_types)
self.assertEqual(js_code.encode(), response.get_data())
def test_get_static_file(self):
@@ -233,7 +268,10 @@ def test_check_python_syntax_before_updating(self):
response = self.client.post(url, data={'py_code': test_code})
self.assert_template_used('view_sketch.html')
- self.assert_context('error', 'SyntaxError: invalid syntax (sketch_exists.py, line 6)')
+ err_msg = 'SyntaxError: invalid syntax (sketch_exists.py, line 6)'
+ if platform.python_version().startswith("3.10"):
+ err_msg = "SyntaxError: '(' was never closed (sketch_exists.py, line 4)"
+ self.assert_context('error', err_msg)
assert old_content == sketch.sketch_py.read_text()
def test_check_for_setup_function_before_updating(self):
diff --git a/pyp5js/tests/test_monitor.py b/pyp5js/tests/test_monitor.py
index c0906b13..d5b76bf4 100644
--- a/pyp5js/tests/test_monitor.py
+++ b/pyp5js/tests/test_monitor.py
@@ -1,3 +1,20 @@
+"""
+pyp5js
+Copyright (C) 2019-2021 Bernardo Fontes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+"""
from queue import Queue
from unittest import TestCase
from unittest.mock import Mock, patch
diff --git a/pyp5js/tests/test_pyp5js.py b/pyp5js/tests/test_pyp5js.py
index f997b85d..c148b2cc 100644
--- a/pyp5js/tests/test_pyp5js.py
+++ b/pyp5js/tests/test_pyp5js.py
@@ -1,4 +1,21 @@
"""
+pyp5js
+Copyright (C) 2019-2021 Bernardo Fontes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+"""
+"""
Test file to guarantee the Python code that'll be translated to JS
"""
from pyaml import yaml
diff --git a/pyp5js/tests/test_sketch.py b/pyp5js/tests/test_sketch.py
index 7ad14829..d20bdc7d 100644
--- a/pyp5js/tests/test_sketch.py
+++ b/pyp5js/tests/test_sketch.py
@@ -1,3 +1,20 @@
+"""
+pyp5js
+Copyright (C) 2019-2021 Bernardo Fontes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+"""
import pytest
import shutil
from unittest import TestCase
diff --git a/pyp5js/tests/test_templates_renderers.py b/pyp5js/tests/test_templates_renderers.py
index df05708b..db4c906c 100644
--- a/pyp5js/tests/test_templates_renderers.py
+++ b/pyp5js/tests/test_templates_renderers.py
@@ -1,3 +1,20 @@
+"""
+pyp5js
+Copyright (C) 2019-2021 Bernardo Fontes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see .
+"""
from pyp5js import templates_renderers as renderers
from .fixtures import sketch, sketch_pyodide
diff --git a/requirements.txt b/requirements.txt
index 97a786d5..9b81cf04 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,9 +1,10 @@
-Click==7.1.1
-Jinja2==2.11.3
+Click==8.0.1
+Jinja2==3.1.2
Transcrypt==3.9.0
-cprint==1.1
-gunicorn==19.9.0
-watchdog==0.9.0
-python-decouple==3.1
-Flask==1.1.2
-python-slugify==3.0.4
+cprint==1.2.2
+gunicorn==20.1.0
+watchdog==2.1.9
+python-decouple==3.6
+Flask==2.2.2
+python-slugify==6.1.2
+markupsafe==2.1.1