Skip to content

Commit

Permalink
Merge branch 'release/0.7.2' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
berinhard committed Dec 26, 2022
2 parents 0908c2d + 1d7667c commit 9f4d247
Show file tree
Hide file tree
Showing 142 changed files with 1,168 additions and 336 deletions.
24 changes: 21 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
name: Continuous Integration

on: [push, pull_request]
on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop

jobs:
license:
name: Check source files for license headers
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1

- name: Check for license headers
run: bash bin/check_license.sh

test:
name: Test on ${{ matrix.os }} with Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 4
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: [3.7, 3.8, 3.9, '3.10']

steps:
- uses: actions/checkout@v1
Expand All @@ -24,7 +42,7 @@ jobs:
run: python --version

- name: Upgrade pip
run: pip install --upgrade pip setuptools --user
run: python -m pip install --upgrade pip setuptools --user

- name: Install dev dependencies
run: pip install -r dev-requirements.txt
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Development
-----------

0.7.2
-----
- Remove existing sketch after clearing/running it again [PR #199](https://github.com/berinhard/pyp5js/pull/199)
- Add share button to demo editor [PR #205](https://github.com/berinhard/pyp5js/pull/205)
- Fixed bug of adding new lines when saving Sketch in Windowns [PR #209](https://github.com/berinhard/pyp5js/pull/209)
- Upgrade pyp5js dependencies versions [PR #220](https://github.com/berinhard/pyp5js/pull/220)
- Run CI for Python 3.10 version [PR #219](https://github.com/berinhard/pyp5js/pull/219)

0.7.1
-----
- Create sketch using p5.js from CDN [PR #191](https://github.com/berinhard/pyp5js/pull/191)
Expand Down
33 changes: 33 additions & 0 deletions Makefile.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@echo off

IF /I "%1"=="test" GOTO test
IF /I "%1"=="update_dist" GOTO update_dist
IF /I "%1"=="upload_pypi" GOTO upload_pypi
IF /I "%1"=="run_demo" GOTO run_demo
GOTO error

:test
set PYTHONWARNINGS=ignore::flask.DeprecationWarning && pytest
GOTO :EOF

:update_dist
@python3 setup.py sdist bdist_wheel
GOTO :EOF

:upload_pypi
@twine upload dist/*
GOTO :EOF

:run_demo
PUSHD docs/pyodide
python -m http.server
POPD
GOTO :EOF

:error
IF "%1"=="" (
ECHO make: *** No targets specified and no makefile found. Stop.
) ELSE (
ECHO make: *** No rule to make target '%1%'. Stop.
)
GOTO :EOF
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ $ make test

### [Known issues and differences to the Processing.Py and P5.js ways of doing things](https://berinhard.github.io/pyp5js#known-issues-and-differences-to-the-processingpy-and-p5js-ways-of-doing-things)

### [How can I contribute?](https://berinhard.github.io/pyp5js#how-can-i-contribute)
### [How can I contribute?](CONTRIBUTING.md)
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.7.1
0.7.2
15 changes: 15 additions & 0 deletions bin/check_license.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

EXIT_CODE=0

while IFS= read -r -d '' file; do
if ! head -5 "$file" | grep -q 'Copyright'; then
echo "$file" is missing a license
EXIT_CODE=1
fi
done < <(find pyp5js -type f \( \
-name "*.py" -o \
-name "*.html" -o \
-name "*.js.template" \) -print0)

exit $EXIT_CODE
18 changes: 9 additions & 9 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
-r requirements.txt

black==19.3b0
ipython==7.8.0
pytest==4.5.0
tox==3.10.0
black==22.10.0
ipython==7.34.0
pytest==7.1.3
tox==3.26.0
pytest-env==0.6.2
Flask-Testing==0.8.0
blinker==1.4
pyaml==20.4.0
wheel==0.37.0
twine==3.4.2
Flask-Testing==0.8.1
blinker==1.5
pyaml==21.10.1
wheel==0.37.1
twine==4.0.1
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ $ pip install pyp5js

## Quickstart

Since you'll be writting Python code and then generating the correspondent
Since you'll be writing Python code and then generating the correspondent
P5.js code from it, pyp5js provides a web application interface to help you
generate the files.

Expand All @@ -54,7 +54,7 @@ $ pyp5js serve
Then point your browser to [http://localhost:5000/](http://localhost:5000/) and
create a new sketch via the browser by filling the form with the name of your
sketch. This command will compile the sketches on the
fly, so after changing/saving the sketch file you just need to reload the page
fly, so after changing/saving the sketch file, you just need to reload the page
on your browser. It'll also guide you on which file you have to edit the Python code
and how to see it running after you save it.

Expand Down
89 changes: 89 additions & 0 deletions docs/pyodide/afterBody.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
const initialSketch = checkForSketch();

//// Configure ACE editor
const editor = ace.edit("text-editor");
editor.session.setMode("ace/mode/python");
editor.setFontSize(18);
editor.session.setOptions({
tabSize: 4,
});
editor.setValue(initialSketch);

//// Update div's content with most up to date code
editor.session.on("change", function () {
document.getElementById("id_py_code").innerHTML = editor
.getSession()
.getValue();
});
document.getElementById("id_py_code").innerHTML = initialSketch;

document.addEventListener("DOMContentLoaded", function () {
//// Buttons
const shareBtn = document.getElementById("shareBtn");
const collapseBtn = document.getElementById("collapseBtn");
const executeBtn = document.getElementById("executeBtn");
const clearBtn = document.getElementById("clearBtn");

//// Event functions
function runCode() {
document.getElementById("sketch-holder").innerHTML = "";
const userCode = editor.getSession().getValue();

// from pyp5js
window.runSketchCode(userCode);
}

function cleanKeyCode(e) {
// Shortcuts work for Ctrl or Cmd
if (e.ctrlKey || e.metaKey) {
return e.keyCode;
}
}

function keyDown(e) {
if (cleanKeyCode(e) === 13) {
// Ctrl + Enter to run
e.preventDefault();
executeBtn.click();
} else if (cleanKeyCode(e) === 190) {
// Ctrl + . to clear
e.preventDefault();
clearBtn.click();
}
}

executeBtn.addEventListener("click", () => {
if (window.instance) {
runCode();
} else {
window.alert(
"Pyodide is still loading.\nPlease, wait a few seconds and try to run it again."
);
}
});
clearBtn.addEventListener("click", () => {
if (window.instance) {
document.getElementById("sketch-holder").innerHTML = "";
window.instance.remove();
}
});
shareBtn.addEventListener("click", () => {
if (window.instance) {
const sketchUrl = createSketchUrl();
copyTextToClipboard(sketchUrl);
shareBtn.textContent = "Copied URL!";
setTimeout(() => {
shareBtn.textContent = "Share";
}, 3000);
runCode();
}
});
collapseBtn.addEventListener("click", () => {
const textEditorEl = document.getElementById("text-editor");
textEditorEl.classList.toggle("hidden-editor");
collapseBtn.textContent = collapseBtn.textContent.includes("Collapse")
? "Expand"
: "Collapse";
});
document.body.addEventListener("keydown", keyDown);
});
Loading

0 comments on commit 9f4d247

Please sign in to comment.