diff --git a/.githooks/pre-commit b/.githooks/pre-commit deleted file mode 100755 index 804b1f1..0000000 --- a/.githooks/pre-commit +++ /dev/null @@ -1,2 +0,0 @@ -node utils/build-index.js -exit $? diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..67b793e --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,26 @@ +name: Publish + +on: + push: + branches: ["master"] + pull_request: + +permissions: + pages: write + id-token: write + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + - run: npm i && node build.js + - uses: actions/upload-pages-artifact@v1 + with: + path: build + if: github.ref == 'refs/heads/master' && github.event_name == 'push' + - uses: actions/deploy-pages@v2 + if: github.ref == 'refs/heads/master' && github.event_name == 'push' diff --git a/.gitignore b/.gitignore index 24856e3..7600f74 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,9 @@ node_modules +<<<<<<< HEAD +package-lock.json .DS_Store -.vscode \ No newline at end of file +build/ +======= +.DS_Store +.vscode +>>>>>>> master diff --git a/README.md b/README.md index 53b001f..1508d18 100644 --- a/README.md +++ b/README.md @@ -2,44 +2,13 @@ This repository contains the NetsBlox Extensions to be hosted on https://extensions.netsblox.org, allowing NetsBlox to recognize them as first-party extensions. -Extensions currently included in this repository: - - - [AugmentedReality](https://dev.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/AugmentedReality/index.js%22]) - Use QR codes to pin sprites to the world! - - - [BeatBlox](https://dev.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/BeatBlox/index.js%22]) - BeatBlox extends Music Functionality within NetsBlox - - - [BetterShare](https://dev.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/BetterShare/index.js%22]) - WIP - Provides a few utilities that can make sharing projects easier - - - [Blocks to Code to Blocks (beta)](https://dev.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/BlocksToCodeToBlocks/index.js%22]) - Transform back and forth with LISP-like code and NetsBlox, based on new features in Snap! v10 (WIP) - - - [FaceLandmarker](https://dev.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/FaceLandmarker/index.js%22]) - Track Faces in images/video using MediaPipe! - - - [HandGestures](https://dev.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/HandGestures/index.js%22]) - Track 3D hand gestures in images/video using MediaPipe! - - - [HideCategories](https://dev.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/HideCategories/index.js%22]) - This extension allows you to automatically hide categories and is particularly useful when setting different visible categories for collaborating users. - - - [PoseLandmarker](https://dev.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/PoseLandmarker/index.js%22]) - Track 3D full body poses in images/video using MediaPipe! - - - [🤖 RoboScape Online](https://dev.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/RoboScapeOnline/index.js%22]) - Networked robotics simulation in the browser! (WIP) - - - [🤖 RoboScape Online (beta)](https://dev.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/RoboScapeOnline2/index.js%22]) - Networked robotics simulation in the browser! (WIP) - - - [TimeSync](https://dev.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/TimeSync/index.js%22]) - calculate time sync info from the NetsBlox server - - - [TuneScope](https://dev.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/TuneScope/index.js%22]) - Music Notation, Instruments, Drums, Tones, Chords, Tracks, from the University of Virginia (Glen Bull) - - - [WebSerial](https://dev.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/WebSerial/index.js%22]) - Provides blocks for connecting to a device, e.g. an Arduino, over WebSerial - - - [WhenKeyPressedLogger](https://dev.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/WhenKeyPressedLogger/index.js%22]) - Logs 'When [key] key pressed' block activations for Ben - +View currently published extensions at https://extensions.netsblox.org/ ## Contributing -After cloning the repository, configure the githooks with: -``` -git config core.hooksPath .githooks -``` -This will ensure that any automated preparation will happen automatically such as updating the website. -Next, create a new directory in `extensions/`. This should contain the following files: +To make a new extension, simply create a new directory in `extensions/`. This should contain the following files: + - `index.js`: JS code for the actual extension -- `extension.json`: Description of the extension \ No newline at end of file +- `extension.json`: Description of the extension + +You can copy from an existing extension to see the required format for these files. diff --git a/build.js b/build.js new file mode 100644 index 0000000..7128130 --- /dev/null +++ b/build.js @@ -0,0 +1,40 @@ +const _ = require('lodash'); +const fs = require('fs'); +const path = require('path'); +const EXTENSIONS_DIR = path.join(__dirname, 'extensions'); +const OUT_DIR = path.join(__dirname, 'build'); + +const extensions = fs.readdirSync(EXTENSIONS_DIR).map(readExtension); + +try { fs.mkdirSync(OUT_DIR); } catch {} + +fs.writeFileSync(path.join(OUT_DIR, 'index.html'), renderTemplate('index.html', { extensions })); +fs.copyFileSync('index.js', path.join(OUT_DIR, 'index.js')); + +// ------------------------------------------ + +function readExtension(name) { + const dirpath = path.join(EXTENSIONS_DIR, name); + const settings = JSON.parse(fs.readFileSync(path.join(dirpath, 'extension.json'), 'utf8')); + const description = settings['description']; + let linkUrl = ""; + let scriptUrl = `https://extensions.netsblox.org/extensions/${name}/index.js`; + + if (!settings['useDev']) { + linkUrl = `https://editor.netsblox.org/?extensions=[%22${scriptUrl}%22]#`; + } else { + linkUrl = `https://dev.netsblox.org/?extensions=[%22${scriptUrl}%22]#`; + } + + return { + name, + displayName : settings['customName'] ?? name, + description, + linkUrl, + scriptUrl, + }; +} + +function renderTemplate(name, data) { + return _.template(fs.readFileSync(name, 'utf8'))(data).trim(); +} diff --git a/index.html b/index.html index 7b684a3..ef5aba0 100644 --- a/index.html +++ b/index.html @@ -21,119 +21,15 @@
- - Use QR codes to pin sprites to the world! + + <%= ext.description %>
- - BeatBlox extends Music Functionality within NetsBlox -
-- - WIP - Provides a few utilities that can make sharing projects easier -
-- - Transform back and forth with LISP-like code and NetsBlox, based on new features in Snap! v10 (WIP) -
-- - Track Faces in images/video using MediaPipe! -
-- - Track 3D hand gestures in images/video using MediaPipe! -
-- - This extension allows you to automatically hide categories and is particularly useful when setting different visible categories for collaborating users. -
-- - Track 3D full body poses in images/video using MediaPipe! -
-- - Networked robotics simulation in the browser! (WIP) -
-- - Networked robotics simulation in the browser! (WIP) -
-- - calculate time sync info from the NetsBlox server -
-- - Music Notation, Instruments, Drums, Tones, Chords, Tracks, from the University of Virginia (Glen Bull) -
-- - Provides blocks for connecting to a device, e.g. an Arduino, over WebSerial -
-- - Logs 'When [key] key pressed' block activations for Ben -
-