Skip to content

Commit 2fbfb1a

Browse files
committed
done
1 parent 1554ecf commit 2fbfb1a

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

docs/examples.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
11
# Examples
22

3-
The content for the examples lives in `/content/examples` split into 2 folders corresponding to the categories: `basic` and `topic`. Each example has a subfolder inside one of those folders. The subfolder contains all the files necessary to build the individual example page: a `.json` that has the content, `.pde` files containing the code and `.png` file for the image.
3+
The content for the examples lives in `/content/examples` and are nested in folders named after the main category and the subcategory. The actual `.pde` files and the data associated with the Processing sketch are automatically copied from the [`processing-examples`](https://github.com/processing/processing-examples) repo while the rest of the content only live in this repo and should be edited here.
44

5-
The actual Processing code is copied from [`processing-examples`](https://github.com/processing/processing-examples) via a script and the rest of the content is updated directly in this repo. Here is a breakdown for `Basic Examples > Image > AlphaMask` example:
5+
Here is a quick overview of these files for the `Basic Examples > Image > BackgroundImage` example:
66

7-
- `AlphaMask.json` - Edit in this repo
8-
- `AlphaMask.png` - Edit in this repo
9-
- `liveSketch.js` - Edit in this repo
10-
- `AlphaMask.pde` - Copied from `processing-examples` via script
11-
- Besides this, all content inside `data` folders will be moved automatically to the `static` folder so the live sketches work on the website
7+
- `/content/examples/BackgroundImage/BackgroundImage.json` - This is the metadata for the example, and this file should be edited in this repo.
8+
- `/content/examples/BackgroundImage/BackgroundImage.png` - This is the image use on page listings and this file should be edited in this repo.
9+
- `/content/examples/BackgroundImage/liveSketch.js` - This is the P5.js live sketch code that runs on the example page, and this file should be edited in this repo.
10+
- `/content/examples/BackgroundImage/BackgroundImage.pde` - This file is synced from the `processing-examples` repo via a script and should **not** be edited in this repo.
11+
- `/static/livesketch/backgroundimage` - This folder is the `data` folder for the example from the `processing-examples` repo and should \**not*8 be edited in this repo.
1212

13-
## Updating via script
13+
## Updating examples via script
1414

15-
The Processing code for each example is copied via a script from the [`processing-examples`](https://github.com/processing/processing-examples) repo to the `/content/examples` folder in this repo. The script will only copy examples into example folders that already exist, but it will output a summary of the update before it happens.
15+
The Processing code for each example is copied via a script from the [`processing-examples`](https://github.com/processing/processing-examples) repo to website. The script will do two things: It will copy all `.pde` files into the `content/examples/TOPIC/SUBTOPIC/EXAMPLE` folder and it will copy all files in the `data` folder of the example into a `static/livesketch/EXAMPLE` folder. This makes it possible for the `liveSketch.js` sketch to load the original data. Some live sketches differ slightly from the original example (such as the AlphaMask example requiring a `.png` file instead of a `.jpg` file) and these files are manually place in the `static/livesketch-manual` folder.
16+
17+
**Note**: The script will only copy examples into the website that already have an existing `.pde` file. This means that the script will only update examples, not add new ones.
1618

1719
This is what you need to run the script:
1820

1921
1. Make sure that you have the `processing-examples` repo next to this `processing-website` repo on your computer
2022
1. Pull the latest `main` from the `processing-examples` repository
21-
1. From the root of this repo, run `npm run updateExamples`
23+
1. From the root of this repo, run `npm run updateExamples`. The script will prompt you with an overview of the changes before it does anything.
2224

2325
You should now have the updated example files in your repo ready to be committed. Please submit the changes as a PR to the `main` branch of `processing-website`.
2426

27+
## Adding a new example
28+
29+
When adding a new example, copy/paste an existing example folder and change the content of all files to reflect the example. Remember to put any files inside the `data` folder into `/static/livesketch/EXAMPLE` and write the `liveSketch.js` file to read from this folder.
30+
2531
## Content file
2632

2733
Each example has to have a `.json` file in this format:

src/components/examples/ExamplesList.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const ExamplesList = ({ tree }) => {
3939
</div>
4040
</div>
4141
<p className={css.categoryDescription}>
42-
{category === 'Topic Examples'
42+
{category === 'Topics'
4343
? intl.formatMessage({ id: 'topicExamples' })
4444
: intl.formatMessage({ id: 'basicExamples' })}
4545
</p>

0 commit comments

Comments
 (0)