@@ -10,6 +10,7 @@ const openProcessingEndpoint = "https://openprocessing.org/api/";
1010 * Currently a placeholder (https://openprocessing.org/curation/78544/)
1111 */
1212const curationId = "87649" ;
13+ const newCurationId = "89576" ;
1314
1415/**
1516 * API Response from a call to the Curation Sketches endpoint
@@ -18,7 +19,7 @@ const curationId = "87649";
1819 */
1920export type OpenProcessingCurationResponse = Array < {
2021 /** Sketch ID used for constructing URLs */
21- visualID : string ;
22+ visualID : number ;
2223 /** Title of sketch */
2324 title : string ;
2425 /** Description of sketch */
@@ -43,14 +44,38 @@ export const getCurationSketches = memoize(async (
4344 limit ?: number ,
4445) : Promise < OpenProcessingCurationResponse > => {
4546 const limitParam = limit ? `limit=${ limit } ` : "" ;
46- const response = await fetch (
47+ const response1 = await fetch (
4748 `${ openProcessingEndpoint } curation/${ curationId } /sketches?${ limitParam } ` ,
4849 ) ;
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 )
5152 }
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 ;
5479} ) ;
5580
5681/**
@@ -60,7 +85,7 @@ export const getCurationSketches = memoize(async (
6085 */
6186export type OpenProcessingSketchResponse = {
6287 /** Sketch ID used for constructing URLs */
63- visualID : string ;
88+ visualID : number ;
6489 /** Title of sketch */
6590 title : string ;
6691 /** Description of sketch */
@@ -83,7 +108,7 @@ export type OpenProcessingSketchResponse = {
83108 * @returns
84109 */
85110export const getSketch = memoize (
86- async ( id : string ) : Promise < OpenProcessingSketchResponse > => {
111+ async ( id : number ) : Promise < OpenProcessingSketchResponse > => {
87112 // check for memoized sketch in curation sketches
88113 const curationSketches = await getCurationSketches ( ) ;
89114 const memoizedSketch = curationSketches . find ( ( el ) => el . visualID === id ) ;
@@ -109,7 +134,7 @@ export const getSketch = memoize(
109134 * But only uses the width and height properties from this call
110135 * Width and height should instead be added to properties for `/api/sketch/:id` or `api/curation/:curationId/sketches` instead
111136 */
112- export const getSketchSize = memoize ( async ( id : string ) => {
137+ export const getSketchSize = memoize ( async ( id : number ) => {
113138 const sketch = await getSketch ( id )
114139 if ( sketch . mode !== 'p5js' ) {
115140 return { width : undefined , height : undefined } ;
@@ -139,16 +164,16 @@ export const getSketchSize = memoize(async (id: string) => {
139164 return { width : undefined , height : undefined } ;
140165} ) ;
141166
142- export const makeSketchLinkUrl = ( id : string ) =>
167+ export const makeSketchLinkUrl = ( id : number ) =>
143168 `https://openprocessing.org/sketch/${ id } ` ;
144169
145- export const makeSketchEmbedUrl = ( id : string ) =>
170+ export const makeSketchEmbedUrl = ( id : number ) =>
146171 `https://openprocessing.org/sketch/${ id } /embed/?plusEmbedFullscreen=true&plusEmbedInstructions=false` ;
147172
148- export const makeThumbnailUrl = ( id : string ) =>
173+ export const makeThumbnailUrl = ( id : number ) =>
149174 `https://openprocessing-usercontent.s3.amazonaws.com/thumbnails/visualThumbnail${ id } @2x.jpg` ;
150175
151- export const getSketchThumbnailSource = async ( id : string ) => {
176+ export const getSketchThumbnailSource = async ( id : number ) => {
152177 const manualThumbs = import . meta. glob < ImageMetadata > ( './images/*' , { import : 'default' } )
153178 const key = `./images/${ id } .png` ;
154179 if ( manualThumbs [ key ] ) {
0 commit comments