Skip to content

Commit 4b48ceb

Browse files
authored
Merge branch 'main' into issue-817
2 parents 940dc2d + 318cdd3 commit 4b48ceb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+222
-144
lines changed

public/reference/data.json

Lines changed: 19 additions & 19 deletions
Large diffs are not rendered by default.

public/search-indices/en.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

public/search-indices/es.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

public/search-indices/hi.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

public/search-indices/ko.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

public/search-indices/zh-Hans.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/api/OpenProcessing.ts

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ export type OpenProcessingCurationResponse = Array<{
2323
title: string;
2424
/** Description of sketch */
2525
description: string;
26+
instructions: string;
27+
mode: string;
28+
createdOn: string;
2629
userID: string;
2730
submittedOn: string;
2831
/** Author's name */
@@ -36,16 +39,19 @@ export type OpenProcessingCurationResponse = Array<{
3639
* @param limit max number of sketches to return
3740
* @returns sketches
3841
*/
39-
export const getCurationSketches = async (
42+
export const getCurationSketches = memoize(async (
4043
limit?: number,
4144
): Promise<OpenProcessingCurationResponse> => {
4245
const limitParam = limit ? `limit=${limit}` : "";
4346
const response = await fetch(
4447
`${openProcessingEndpoint}curation/${curationId}/sketches?${limitParam}`,
4548
);
49+
if(!response.ok){ //log error instead of throwing error to not cache result in memoize
50+
console.error('getCurationSketches', response.status, response.statusText)
51+
}
4652
const payload = await response.json();
4753
return payload as OpenProcessingCurationResponse;
48-
};
54+
});
4955

5056
/**
5157
* API Response from a call to the Sketch endpoint
@@ -69,26 +75,50 @@ export type OpenProcessingSketchResponse = {
6975

7076
/**
7177
* Get info about a specific sketch from the OpenProcessing API
78+
* First checks if the sketch is in the memoized curated sketches and returns the data if so,
79+
* Otherwise calls OpenProcessing API for this specific sketch
7280
*
7381
* https://documenter.getpostman.com/view/16936458/2s9YC1Xa6X#7cd344f6-6e87-426a-969b-2b4a79701dd1
7482
* @param id
7583
* @returns
7684
*/
77-
export const getSketch = memoize(async (
78-
id: string,
79-
): Promise<OpenProcessingSketchResponse> => {
85+
export const getSketch = memoize(
86+
async (id: string): Promise<OpenProcessingSketchResponse> => {
87+
// check for memoized sketch in curation sketches
88+
const curationSketches = await getCurationSketches();
89+
const memoizedSketch = curationSketches.find((el) => el.visualID === id);
90+
if (memoizedSketch) {
91+
return {
92+
...memoizedSketch,
93+
license: "",
94+
} as OpenProcessingSketchResponse;
95+
}
96+
97+
// check for sketch data in Open Processing API
8098
const response = await fetch(`${openProcessingEndpoint}sketch/${id}`);
99+
if (!response.ok) {
100+
//log error instead of throwing error to not cache result in memoize
101+
console.error("getSketch", id, response.status, response.statusText);
102+
}
81103
const payload = await response.json();
82104
return payload as OpenProcessingSketchResponse;
83105
});
84106

107+
/**
108+
* Note: this currently calls `/api/sketch/:id/code`
109+
* But only uses the width and height properties from this call
110+
* Width and height should instead be added to properties for `/api/sketch/:id` or `api/curation/:curationId/sketches` instead
111+
*/
85112
export const getSketchSize = memoize(async (id: string) => {
86113
const sketch = await getSketch(id)
87114
if (sketch.mode !== 'p5js') {
88115
return { width: undefined, height: undefined };
89116
}
90117

91118
const response = await fetch(`${openProcessingEndpoint}sketch/${id}/code`);
119+
if(!response.ok){ //log error instead of throwing error to not cache result in memoize
120+
console.error('getSketchSize', id, response.status, response.statusText)
121+
}
92122
const payload = await response.json();
93123

94124
for (const tab of payload) {

src/components/CodeEmbed/frame.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export const CodeFrame = (props: CodeFrameProps) => {
146146
return;
147147
}
148148
})();
149-
}, [props.jsCode, mounted]);
149+
}, [props.jsCode, mounted,p5ScriptTag]);
150150

151151
return (
152152
<div
@@ -161,7 +161,7 @@ export const CodeFrame = (props: CodeFrameProps) => {
161161
htmlBody: props.htmlBodyCode,
162162
base: props.base,
163163
scripts: props.scripts,
164-
}) : undefined}
164+
}) : ""}
165165
sandbox="allow-scripts allow-popups allow-modals allow-forms allow-same-origin"
166166
aria-label="Code Preview"
167167
title="Code Preview"

src/components/SearchProvider/index.tsx

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,7 @@ const SearchProvider = ({
3030
const [results, setResults] = useState<SearchResult[]>([]);
3131

3232
// Flattens the search index data
33-
const flattenData = (data: FuseResult<SearchResult>) => {
34-
const flatData: SearchResult[] = [];
35-
let flatId = 0;
36-
Object.entries(data).forEach(([category, entries]) => {
37-
Object.entries(entries).forEach(([title, docDetails]) => {
38-
// Since we are generating these links with Javascript and the
39-
// middleware doesn't prefix the locale automatically, we need to
40-
// do it manually here.
41-
const relativeUrl =
42-
currentLocale === defaultLocale
43-
? docDetails.relativeUrl
44-
: `/${currentLocale}${docDetails.relativeUrl}`;
45-
docDetails.relativeUrl = relativeUrl;
46-
flatData.push({
47-
id: flatId++,
48-
category: category.replace("-fallback", ""),
49-
title,
50-
...docDetails,
51-
});
52-
});
53-
});
54-
55-
return flatData;
56-
};
33+
5734

5835
// Read the search term from query params on first load
5936
useEffect(() => {
@@ -80,6 +57,30 @@ const SearchProvider = ({
8057
}
8158

8259
if (!searchTerm) return;
60+
const flattenData = (data: FuseResult<SearchResult>) => {
61+
const flatData: SearchResult[] = [];
62+
let flatId = 0;
63+
Object.entries(data).forEach(([category, entries]) => {
64+
Object.entries(entries).forEach(([title, docDetails]) => {
65+
// Since we are generating these links with Javascript and the
66+
// middleware doesn't prefix the locale automatically, we need to
67+
// do it manually here.
68+
const relativeUrl =
69+
currentLocale === defaultLocale
70+
? docDetails.relativeUrl
71+
: `/${currentLocale}${docDetails.relativeUrl}`;
72+
docDetails.relativeUrl = relativeUrl;
73+
flatData.push({
74+
id: flatId++,
75+
category: category.replace("-fallback", ""),
76+
title,
77+
...docDetails,
78+
});
79+
});
80+
});
81+
82+
return flatData;
83+
};
8384

8485
let flatData;
8586

src/content/libraries/en/p5.ascify.yaml renamed to src/content/libraries/en/p5.asciify.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: p5.asciify
2-
description: Apply real-time ASCII conversion to your favourite WebGL p5.js sketches to create unique, text-based visuals instantly.
2+
description: Apply real-time ASCII conversion to your favorite WEBGL p5.js sketches instantly.
33
category: shaders
4-
sourceUrl: https://github.com/humanbydefinition/p5.asciify
4+
sourceUrl: https://p5.textmode.art
55
featuredImage: ../images/p5.asciify.png
6-
featuredImageAlt: A grid of ASCII characters representing perlin noise, with a centered logo reading "p5.asciify".
6+
featuredImageAlt: A grid of ASCII characters representing perlin noise with a centered logo reading "p5.asciify".
77
author:
88
name: humanbydefinition
99
url: https://github.com/humanbydefinition
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: svg-shapes-p5js
2+
description: A SVG drawing library for p5.js.
3+
category: drawing
4+
sourceUrl: https://github.com/irenelfeng/svg-shapes-p5js
5+
featuredImage: ../images/svg-shapes-p5js.png
6+
featuredImageAlt: The image for the SVG shapes library made of scaled svg of the p5.js star logo
7+
author:
8+
name: Irene Feng
9+
url: https://irenefeng.com
Loading

src/content/pages/en/education-resources.mdx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,22 @@ Thank you to Tuan Huang, Yu Lee, and Janis Sepúlveda for initiating the educati
398398
</Fragment>
399399
</EducationResource>
400400

401+
<EducationResource
402+
name="The Animation Codebook"
403+
featuredImage={await import("../images/education-resources/Screenshot (508).png")}
404+
featuredImageAlt="Screenshot of the Animation Codebook Website"
405+
>
406+
<Fragment slot="author">
407+
Aishwarya Rajkumar
408+
</Fragment>
409+
<Fragment slot="description">
410+
A project designed to enhance the technical skills for those with a background in animation.
411+
</Fragment>
412+
<Fragment slot="materials">
413+
[Website](https://aijun19.github.io/TheAnimationCodeBook/)
414+
</Fragment>
415+
</EducationResource>
416+
401417
</ul>
402418

403419

Loading

src/content/people/en/hughjacks.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: HughJacks
2+
url: https://github.com/HughJacks
3+
category: contributor

src/content/people/en/jack-l.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: Jack L
2+
url: http://jackeddielove.github.io
3+
category: contributor

src/content/reference/en/p5/directionalLight.mdx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ description: >
5151
parameter,
5252
5353
<code>direction</code> sets the light’s direction using a
54-
55-
<a href="/reference/p5/p5.Geometry">p5.Geometry</a> object. For example,
56-
54+
<a href="/reference/p5/p5.Vector">p5.Vector</a> object. For example,
5755
<code>directionalLight(255, 0, 0, lightDir)</code> creates a red <code>(255,
5856
0, 0)</code> light
5957

src/content/reference/en/p5/disableFriendlyErrors.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ description: >
1818
which takes time to process. Disabling the FES can significantly improve
1919
2020
performance by turning off these checks.</p>
21-
line: 877
21+
line: 872
2222
isConstructor: false
2323
itemtype: property
2424
example:

src/content/reference/en/p5/doubleClicked.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ description: >
6767
pressing a mouse button. To prevent any default behavior for this event,
6868
6969
add <code>return false;</code> to the end of the function.</p>
70-
line: 1585
70+
line: 1589
7171
isConstructor: false
7272
itemtype: method
7373
example:

src/content/reference/en/p5/draw.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ description: >
3333
3434
has run is stored in the system variable
3535
36-
<a href="/reference/p5/frameCount/">frameCount()</a>.</p>
36+
<a href="/reference/p5/frameCount/">frameCount</a>.</p>
3737
3838
<p>Code placed within <code>draw()</code> begins looping after
3939

src/content/reference/en/p5/exitPointerLock.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ description: >
2626
2727
an event function such as <a
2828
href="/reference/p5/doubleClicked/">doubleClicked()</a>.</p>
29-
line: 1932
29+
line: 1936
3030
isConstructor: false
3131
itemtype: method
3232
example:

src/content/reference/en/p5/keyIsDown.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ description: >
3030
<code>keyIsDown(LEFT_ARROW)</code>. Key codes can be found on websites such as
3131
3232
<a href="https://keycode.info" target="_blank">keycode.info</a>.</p>
33-
line: 809
33+
line: 811
3434
isConstructor: false
3535
itemtype: method
3636
example:

src/content/reference/en/p5/keyReleased.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ description: >
5757
the end
5858
5959
of the function.</p>
60-
line: 472
60+
line: 474
6161
isConstructor: false
6262
itemtype: method
6363
example:

src/content/reference/en/p5/keyTyped.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ description: >
7373
the end
7474
7575
of the function.</p>
76-
line: 653
76+
line: 655
7777
isConstructor: false
7878
itemtype: method
7979
example:

src/content/reference/en/p5/mouseClicked.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ description: >
9191
9292
immediately after <a
9393
href="/reference/p5/mouseReleased/">mouseReleased()</a>.</p>
94-
line: 1429
94+
line: 1433
9595
isConstructor: false
9696
itemtype: method
9797
example:

src/content/reference/en/p5/mouseDragged.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ description: >
7272
pressing a mouse button. To prevent any default behavior for this event,
7373
7474
add <code>return false;</code> to the end of the function.</p>
75-
line: 968
75+
line: 972
7676
isConstructor: false
7777
itemtype: method
7878
example:

src/content/reference/en/p5/mouseMoved.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ description: >
6060
pressing a mouse button. To prevent any default behavior for this event,
6161
6262
add <code>return false;</code> to the end of the function.</p>
63-
line: 882
63+
line: 886
6464
isConstructor: false
6565
itemtype: method
6666
example:

src/content/reference/en/p5/mousePressed.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ description: >
8787
8888
runs immediately after <a
8989
href="/reference/p5/mouseReleased/">mouseReleased()</a>.</p>
90-
line: 1084
90+
line: 1088
9191
isConstructor: false
9292
itemtype: method
9393
example:

src/content/reference/en/p5/mouseReleased.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ description: >
8989
mouse click. <a href="/reference/p5/mouseClicked/">mouseClicked()</a> runs
9090
9191
immediately after <code>mouseReleased()</code>.</p>
92-
line: 1256
92+
line: 1260
9393
isConstructor: false
9494
itemtype: method
9595
example:

src/content/reference/en/p5/mouseWheel.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ description: >
7575
<p>Note: On Safari, <code>mouseWheel()</code> may only work as expected if
7676
7777
<code>return false;</code> is added at the end of the function.</p>
78-
line: 1732
78+
line: 1736
7979
isConstructor: false
8080
itemtype: method
8181
example:

src/content/reference/en/p5/remove.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ description: >
1414
created by using the <a href="/reference/p5/p5/">p5()</a> constructor, as in
1515
1616
<code>new p5()</code>.</p>
17-
line: 560
17+
line: 559
1818
isConstructor: false
1919
itemtype: method
2020
example:

src/content/reference/en/p5/requestPointerLock.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ description: >
3636
3737
an event function such as <a
3838
href="/reference/p5/doubleClicked/">doubleClicked()</a>.</p>
39-
line: 1866
39+
line: 1870
4040
isConstructor: false
4141
itemtype: method
4242
example:

src/content/tutorials/en/get-started.mdx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,18 @@ Using the [p5.js Web Editor](https://editor.p5js.org/):
5353

5454
- Log in to the [p5.js Web Editor](https://editor.p5js.org/).
5555
- Name your project “Interactive Landscape” by clicking the *pencil icon* and typing “Interactive Landscape” into the text box that appears.
56+
57+
![A user on the p5.js Web Editor names a new project “Interactive Landscape”.](../images/introduction/p5_editor_interactive_landscape_1.png)
58+
5659
- Click on *File* and select *Save*.
60+
61+
![A user on the p5.js Web Editor saves their new project "Interactive Landscape".](../images/introduction/p5_editor_interactive_landscape_2.png)
62+
5763
- Confirm your project is saved by navigating to your gallery of saved sketches:
5864
- Click on *File* and select *Open*.
5965
- Your most recent sketches will appear at the top of the list of projects saved on your account.
6066

61-
![A user on the p5.js Web Editor names a new project Interactive Landscape”, saves it, finds it in their gallery of saved sketches, and clicks the project's name to open it.](../images/introduction/rename-sketch.gif)
67+
![A user on the p5.js Web Editor finds their project "Interactive Landscape" in their gallery of saved sketches.](../images/introduction/p5_editor_interactive_landscape_3.png)
6268

6369
#### Default Code
6470

0 commit comments

Comments
 (0)