@@ -10,6 +10,7 @@ const openProcessingEndpoint = "https://openprocessing.org/api/";
10
10
* Currently a placeholder (https://openprocessing.org/curation/78544/)
11
11
*/
12
12
const curationId = "87649" ;
13
+ const newCurationId = "89576" ;
13
14
14
15
/**
15
16
* API Response from a call to the Curation Sketches endpoint
@@ -18,7 +19,7 @@ const curationId = "87649";
18
19
*/
19
20
export type OpenProcessingCurationResponse = Array < {
20
21
/** Sketch ID used for constructing URLs */
21
- visualID : string ;
22
+ visualID : number ;
22
23
/** Title of sketch */
23
24
title : string ;
24
25
/** Description of sketch */
@@ -43,14 +44,38 @@ export const getCurationSketches = memoize(async (
43
44
limit ?: number ,
44
45
) : Promise < OpenProcessingCurationResponse > => {
45
46
const limitParam = limit ? `limit=${ limit } ` : "" ;
46
- const response = await fetch (
47
+ const response1 = await fetch (
47
48
`${ openProcessingEndpoint } curation/${ curationId } /sketches?${ limitParam } ` ,
48
49
) ;
49
- if ( ! response . ok ) { //log error instead of throwing error to not cache result in memoize
50
- console . error ( 'getCurationSketches' , response . status , response . statusText )
50
+ if ( ! response1 . ok ) { //log error instead of throwing error to not cache result in memoize
51
+ console . error ( 'getCurationSketches' , response1 . status , response1 . statusText )
51
52
}
52
- const payload = await response . json ( ) ;
53
- return payload as OpenProcessingCurationResponse ;
53
+ const payload1 = await response1 . json ( ) ;
54
+
55
+ const response2 = await fetch (
56
+ `${ openProcessingEndpoint } curation/${ newCurationId } /sketches?${ limitParam } ` ,
57
+ ) ;
58
+ if ( ! response2 . ok ) { //log error instead of throwing error to not cache result in memoize
59
+ console . error ( 'getCurationSketches' , response2 . status , response2 . statusText )
60
+ }
61
+ const payload2 = await response2 . json ( ) ;
62
+
63
+ // Selected Sketches from the 2025 curation
64
+ const priorityIds = [ '2690038' , '2484739' , '2688829' , '2689119' , '2690571' , '2690405' , '2684408' , '2693274' , '2693345' , '2691712' ]
65
+
66
+ const prioritySketches = payload2 . filter (
67
+ ( sketch : OpenProcessingCurationResponse [ number ] ) => priorityIds . includes ( String ( sketch . visualID ) ) )
68
+ . sort ( ( a : OpenProcessingCurationResponse [ number ] , b : OpenProcessingCurationResponse [ number ] ) => priorityIds . indexOf ( String ( a . visualID ) ) - priorityIds . indexOf ( String ( b . visualID ) ) ) ;
69
+
70
+
71
+ const finalSketches = [
72
+ ...prioritySketches . map ( ( sketch : OpenProcessingCurationResponse [ number ] ) => ( { ...sketch , curation : '2025' } ) ) ,
73
+ ...payload1 . map ( ( sketch : OpenProcessingCurationResponse [ number ] ) => ( { ...sketch , curation : '2024' } ) ) ,
74
+ ] ;
75
+
76
+ return [
77
+ ...finalSketches ,
78
+ ] as OpenProcessingCurationResponse ;
54
79
} ) ;
55
80
56
81
/**
@@ -60,7 +85,7 @@ export const getCurationSketches = memoize(async (
60
85
*/
61
86
export type OpenProcessingSketchResponse = {
62
87
/** Sketch ID used for constructing URLs */
63
- visualID : string ;
88
+ visualID : number ;
64
89
/** Title of sketch */
65
90
title : string ;
66
91
/** Description of sketch */
@@ -83,7 +108,7 @@ export type OpenProcessingSketchResponse = {
83
108
* @returns
84
109
*/
85
110
export const getSketch = memoize (
86
- async ( id : string ) : Promise < OpenProcessingSketchResponse > => {
111
+ async ( id : number ) : Promise < OpenProcessingSketchResponse > => {
87
112
// check for memoized sketch in curation sketches
88
113
const curationSketches = await getCurationSketches ( ) ;
89
114
const memoizedSketch = curationSketches . find ( ( el ) => el . visualID === id ) ;
@@ -109,7 +134,7 @@ export const getSketch = memoize(
109
134
* But only uses the width and height properties from this call
110
135
* Width and height should instead be added to properties for `/api/sketch/:id` or `api/curation/:curationId/sketches` instead
111
136
*/
112
- export const getSketchSize = memoize ( async ( id : string ) => {
137
+ export const getSketchSize = memoize ( async ( id : number ) => {
113
138
const sketch = await getSketch ( id )
114
139
if ( sketch . mode !== 'p5js' ) {
115
140
return { width : undefined , height : undefined } ;
@@ -139,16 +164,16 @@ export const getSketchSize = memoize(async (id: string) => {
139
164
return { width : undefined , height : undefined } ;
140
165
} ) ;
141
166
142
- export const makeSketchLinkUrl = ( id : string ) =>
167
+ export const makeSketchLinkUrl = ( id : number ) =>
143
168
`https://openprocessing.org/sketch/${ id } ` ;
144
169
145
- export const makeSketchEmbedUrl = ( id : string ) =>
170
+ export const makeSketchEmbedUrl = ( id : number ) =>
146
171
`https://openprocessing.org/sketch/${ id } /embed/?plusEmbedFullscreen=true&plusEmbedInstructions=false` ;
147
172
148
- export const makeThumbnailUrl = ( id : string ) =>
173
+ export const makeThumbnailUrl = ( id : number ) =>
149
174
`https://openprocessing-usercontent.s3.amazonaws.com/thumbnails/visualThumbnail${ id } @2x.jpg` ;
150
175
151
- export const getSketchThumbnailSource = async ( id : string ) => {
176
+ export const getSketchThumbnailSource = async ( id : number ) => {
152
177
const manualThumbs = import . meta. glob < ImageMetadata > ( './images/*' , { import : 'default' } )
153
178
const key = `./images/${ id } .png` ;
154
179
if ( manualThumbs [ key ] ) {
0 commit comments