Skip to content

Commit

Permalink
switch to github actions (#36)
Browse files Browse the repository at this point in the history
* switch to github actions

* dry run for PRs

* update publish
  • Loading branch information
dragazo authored May 7, 2024
1 parent 878a6d7 commit a06e5a4
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 212 deletions.
2 changes: 0 additions & 2 deletions .githooks/pre-commit

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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'
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
node_modules
<<<<<<< HEAD
package-lock.json
.DS_Store
.vscode
build/
=======
.DS_Store
.vscode
>>>>>>> master
43 changes: 6 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
- `extension.json`: Description of the extension

You can copy from an existing extension to see the required format for these files.
40 changes: 40 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -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();
}
116 changes: 6 additions & 110 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,119 +21,15 @@ <h1>NetsBlox Extensions</h1>
<a style="font-size: 12px;" id="showAllDescriptions">Show all descriptions</a>
<a style="font-size: 12px;" id="hideAllDescriptions">Hide all descriptions</a>


<% extensions.forEach(ext=> { %>
<details class="extension">
<summary><input type="checkbox" class="extensionOption" name="AugmentedReality" style="margin-right: 10px" hidden /><a href="https://editor.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/AugmentedReality/index.js%22]" target="_blank"> AugmentedReality </a></summary>
<summary><input type="checkbox" class="extensionOption" name="<%= ext.name %>" style="margin-right: 10px" hidden /><a href="<%= ext.linkUrl %>" target="_blank"> <%= ext.displayName %> </a></summary>
<p>
<input type="hidden" name="AugmentedReality_script" id="AugmentedReality_script" value="https://extensions.netsblox.org/extensions/AugmentedReality/index.js" />
Use QR codes to pin sprites to the world!
<input type="hidden" name="<%= ext.name %>_script" id="<%= ext.name %>_script" value="<%= ext.scriptUrl %>" />
<%= ext.description %>
</p>
</details>

<details class="extension">
<summary><input type="checkbox" class="extensionOption" name="BeatBlox" style="margin-right: 10px" hidden /><a href="https://editor.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/BeatBlox/index.js%22]" target="_blank"> BeatBlox </a></summary>
<p>
<input type="hidden" name="BeatBlox_script" id="BeatBlox_script" value="https://extensions.netsblox.org/extensions/BeatBlox/index.js" />
BeatBlox extends Music Functionality within NetsBlox
</p>
</details>

<details class="extension">
<summary><input type="checkbox" class="extensionOption" name="BetterShare" style="margin-right: 10px" hidden /><a href="https://editor.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/BetterShare/index.js%22]" target="_blank"> BetterShare </a></summary>
<p>
<input type="hidden" name="BetterShare_script" id="BetterShare_script" value="https://extensions.netsblox.org/extensions/BetterShare/index.js" />
WIP - Provides a few utilities that can make sharing projects easier
</p>
</details>

<details class="extension">
<summary><input type="checkbox" class="extensionOption" name="BlocksToCodeToBlocks" style="margin-right: 10px" hidden /><a href="https://editor.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/BlocksToCodeToBlocks/index.js%22]" target="_blank"> Blocks to Code to Blocks (beta) </a></summary>
<p>
<input type="hidden" name="BlocksToCodeToBlocks_script" id="BlocksToCodeToBlocks_script" value="https://extensions.netsblox.org/extensions/BlocksToCodeToBlocks/index.js" />
Transform back and forth with LISP-like code and NetsBlox, based on new features in Snap! v10 (WIP)
</p>
</details>

<details class="extension">
<summary><input type="checkbox" class="extensionOption" name="FaceLandmarker" style="margin-right: 10px" hidden /><a href="https://editor.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/FaceLandmarker/index.js%22]" target="_blank"> FaceLandmarker </a></summary>
<p>
<input type="hidden" name="FaceLandmarker_script" id="FaceLandmarker_script" value="https://extensions.netsblox.org/extensions/FaceLandmarker/index.js" />
Track Faces in images/video using MediaPipe!
</p>
</details>

<details class="extension">
<summary><input type="checkbox" class="extensionOption" name="HandGestures" style="margin-right: 10px" hidden /><a href="https://editor.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/HandGestures/index.js%22]" target="_blank"> HandGestures </a></summary>
<p>
<input type="hidden" name="HandGestures_script" id="HandGestures_script" value="https://extensions.netsblox.org/extensions/HandGestures/index.js" />
Track 3D hand gestures in images/video using MediaPipe!
</p>
</details>

<details class="extension">
<summary><input type="checkbox" class="extensionOption" name="HideCategories" style="margin-right: 10px" hidden /><a href="https://dev.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/HideCategories/index.js%22]" target="_blank"> HideCategories </a></summary>
<p>
<input type="hidden" name="HideCategories_script" id="HideCategories_script" value="https://extensions.netsblox.org/extensions/HideCategories/index.js" />
This extension allows you to automatically hide categories and is particularly useful when setting different visible categories for collaborating users.
</p>
</details>

<details class="extension">
<summary><input type="checkbox" class="extensionOption" name="PoseLandmarker" style="margin-right: 10px" hidden /><a href="https://editor.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/PoseLandmarker/index.js%22]" target="_blank"> PoseLandmarker </a></summary>
<p>
<input type="hidden" name="PoseLandmarker_script" id="PoseLandmarker_script" value="https://extensions.netsblox.org/extensions/PoseLandmarker/index.js" />
Track 3D full body poses in images/video using MediaPipe!
</p>
</details>

<details class="extension">
<summary><input type="checkbox" class="extensionOption" name="RoboScapeOnline" style="margin-right: 10px" hidden /><a href="https://editor.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/RoboScapeOnline/index.js%22]" target="_blank"> 🤖 RoboScape Online </a></summary>
<p>
<input type="hidden" name="RoboScapeOnline_script" id="RoboScapeOnline_script" value="https://extensions.netsblox.org/extensions/RoboScapeOnline/index.js" />
Networked robotics simulation in the browser! (WIP)
</p>
</details>

<details class="extension">
<summary><input type="checkbox" class="extensionOption" name="RoboScapeOnline2" style="margin-right: 10px" hidden /><a href="https://editor.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/RoboScapeOnline2/index.js%22]" target="_blank"> 🤖 RoboScape Online (beta) </a></summary>
<p>
<input type="hidden" name="RoboScapeOnline2_script" id="RoboScapeOnline2_script" value="https://extensions.netsblox.org/extensions/RoboScapeOnline2/index.js" />
Networked robotics simulation in the browser! (WIP)
</p>
</details>

<details class="extension">
<summary><input type="checkbox" class="extensionOption" name="TimeSync" style="margin-right: 10px" hidden /><a href="https://editor.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/TimeSync/index.js%22]" target="_blank"> TimeSync </a></summary>
<p>
<input type="hidden" name="TimeSync_script" id="TimeSync_script" value="https://extensions.netsblox.org/extensions/TimeSync/index.js" />
calculate time sync info from the NetsBlox server
</p>
</details>

<details class="extension">
<summary><input type="checkbox" class="extensionOption" name="TuneScope" style="margin-right: 10px" hidden /><a href="https://editor.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/TuneScope/index.js%22]" target="_blank"> TuneScope </a></summary>
<p>
<input type="hidden" name="TuneScope_script" id="TuneScope_script" value="https://extensions.netsblox.org/extensions/TuneScope/index.js" />
Music Notation, Instruments, Drums, Tones, Chords, Tracks, from the University of Virginia (Glen Bull)
</p>
</details>

<details class="extension">
<summary><input type="checkbox" class="extensionOption" name="WebSerial" style="margin-right: 10px" hidden /><a href="https://editor.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/WebSerial/index.js%22]" target="_blank"> WebSerial </a></summary>
<p>
<input type="hidden" name="WebSerial_script" id="WebSerial_script" value="https://extensions.netsblox.org/extensions/WebSerial/index.js" />
Provides blocks for connecting to a device, e.g. an Arduino, over WebSerial
</p>
</details>

<details class="extension">
<summary><input type="checkbox" class="extensionOption" name="WhenKeyPressedLogger" style="margin-right: 10px" hidden /><a href="https://editor.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/WhenKeyPressedLogger/index.js%22]" target="_blank"> WhenKeyPressedLogger </a></summary>
<p>
<input type="hidden" name="WhenKeyPressedLogger_script" id="WhenKeyPressedLogger_script" value="https://extensions.netsblox.org/extensions/WhenKeyPressedLogger/index.js" />
Logs 'When [key] key pressed' block activations for Ben
</p>
</details>

<% }) %>

<hr />

Expand All @@ -160,4 +56,4 @@ <h1>NetsBlox Extensions</h1>
<script src="./index.js" async defer></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/fuzzysort.min.js" async></script>
</body>
</html>
</html>
5 changes: 2 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,11 @@ search.oninput = () => {
let result = fuzzysort.single(search.value, fullText);
extension.style.display = (search.value == "" || result)? "block" : "none";


if (search.value == "") {
if(search.value == "") {
// Clear highlight when no match
title.innerHTML = title.innerText;

if (extension.open) {
if(extension.open) {
desc.innerHTML = desc.innerText;
}
}
Expand Down
59 changes: 0 additions & 59 deletions utils/templates/index.html

This file was deleted.

0 comments on commit a06e5a4

Please sign in to comment.