on page / : grid of 6 random images

Co-authored-by: Avior <github@avior.me>
This commit is contained in:
Edhueppe 2023-02-14 11:51:16 +01:00
parent 4b7f0b4e3c
commit abf3f90f56
20 changed files with 775 additions and 245 deletions

View File

Before

Width:  |  Height:  |  Size: 119 KiB

After

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

View File

Before

Width:  |  Height:  |  Size: 101 KiB

After

Width:  |  Height:  |  Size: 101 KiB

View File

Before

Width:  |  Height:  |  Size: 134 KiB

After

Width:  |  Height:  |  Size: 134 KiB

View File

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

9
index.html Normal file
View File

@ -0,0 +1,9 @@
<!-- <!DOCTYPE html>
<html>
<head>
<title>JavaScript Example</title>
</head>
<body>
<script src="src/index.js"></script>
</body>
</html> -->

View File

@ -1 +1 @@
{"./images/folder 2/Nouveau dossier 23/image3.jfif":"ff3f51cd80b775b8f74f674b9a17d050df5575b7600381ec3b615f54ff42f8eb","./images/folder 2/OIP (2).jfif":"0b3bf63a6990762e9143019805c9f56ef016e4270e7dca65c5ac9bea138e929c","./images/folder 3/Nouveau dossier/image2.jfif":"9d20202e67804602fd4d0c8d28a92b2e7b3af3d9a9b772816d80dee2d13d943d","./images/folder 4/OIP.jfif":"31f5d9c67ee42d268255965f1bbddd987dac6844a4ed14e5fdf9e8a2fc37f0ee","./images/OIP (1).jfif":"dff223d9e4a51801559c84709c162f6d907435132f6d953ccc246fb24830063d","./images/folder 1/Nouveau dossier 11/OIP (1).jfif":"19ce534a376419da2f1563eeacc74563f6863dfd01b033bc09972b10427ff405","./images/folder 1/Nouveau dossier 12/OIP (3).jfif":"a0f5c85435b5b715f309c675d9e2212d091d6948920161046c6b9379eb19622a","./images/folder 1/Nouveau dossier 12/OIP.jfif":"c0b9a5291c675000bd820afa2c22ad955c5217006b9fa4f6ae068bb2bb3cfd15","./images/folder 1/OIP (2).jfif":"1a2ed303576415dad4983b248c6c050ccf51c1a6cf70fdab54e3a4213defddde","./images/folder 2/Nouveau dossier 22/télécharger (2).jfif":"c8c59fc044f77570957e70bb961771704afcb55a0f773f3dac611616787f3715","./images/folder 2/Nouveau dossier 22/télécharger (3).jfif":"4b7831419a7ca51d871cf5ab2cd57a15c297ab1a01c31e8902d07e08e8c08aad","./images/folder 2/Nouveau dossier 23/.image3.jfif":"e8e1a17cab46733babad5d87e2a61a4ea37be798a76c1c9682b7739e3c31f39b","./images/folder 2/télécharger (1).jfif":"da65ead7bef4089f741ca63efbe5bd8c23d813221b641eb4dd0546a0805b7087","./images/folder 3/Nouveau dossier/.image2.jfif":"56bf384055c610d8f43a9b35688169265a01c044298be03f017ab3ec6eb2f439","./images/folder 4/Nouveau dossier (2)/OIP (4).jfif":"a8c0540186e1e79d42b8ccf703cfe63cd2e2eae4878f13f6531a1c40211a9765","./images/folder 4/Nouveau dossier (2)/télécharger.jfif":"8b639c130dc8e180e90283e62ddeb5dbcbf36c19af82d04790685cf280623702","./images/folder 1/.OIP (2).jfif":"56f99ac641481dd87ece913ef608138e1fd37d4db32bd8976831b5508ae11b4a","./images/folder 1/Nouveau dossier 11/.OIP (1).jfif":"ade381446ee6cc14bec8c5e8afa69d5bdbbae034114451f65bb58ba93cd5f936","./images/folder 1/Nouveau dossier 12/.OIP (3).jfif":"8a672664d8fcc0925785337e35c725c07578c140039ff31efb1f91e92fe353e0","./images/folder 1/Nouveau dossier 12/.OIP.jfif":"cce93f36de35871bcad6608863d37d6c41058b1b31571dae0d6e358c0e1bc351","./images/folder 2/.télécharger (1).jfif":"503a9479692a0aede74b1652d79d449896c2dea13ae766b7b758a656c36cac8b","./images/folder 2/Nouveau dossier 22/.télécharger (2).jfif":"506dcbc3843a26ef923381a5b704c0b9fdffc039bac6c0eaf518575b16cb573b","./images/folder 2/Nouveau dossier 22/.télécharger (3).jfif":"e97873807b5d8dbec9904ed65bd65b92adaa25ec38950dbd221998658c8507f7","./images/folder 2/Nouveau dossier 23/..image3.jfif":"f2d98430ae5704c317675c3dec1c311ec6be7f725ffbfa98dd123950dc3a62a0","./images/folder 3/Nouveau dossier/..image2.jfif":"da84dc7ff498f730989f852829d676b9fb9c134d11008c9ac93033cbac2197b7","./images/folder 4/Nouveau dossier (2)/.OIP (4).jfif":"6edd87b15bdb861395be0ed66834fcfc57684138324dc4cf49cc8badc3dc8037","./images/folder 4/Nouveau dossier (2)/.télécharger.jfif":"1aeb0a04dd8ba7ff75575e50155e52785400971dcc855912c81d94ce7e261a8e","./images/WIN_20221121_16_42_21_Pro.jpg":"2201164ad2e6a5eff5e22d20003a596710008b37f91270c70c5bf70ff18e380f","./images/Nouveau dossier/OIP.jfif":"b5c98b3c1e6bc469b15990b44a36bdf71cbb4349378881cac83396f3d7ef36f9","./images/Nouveau dossier/.OIP.jfif":"1bf7d2faabbc6d952d8a22dde98675ebab741820b958696d88006a752154edd5","./images/Nouveau dossier/multipleimage.PNG":"e1f7baba3c3476331d5f172f6827e06361802a03ce710576319ab5fbfaaa947a","./images/Nouveau dossier/multiple_image_rename.PNG":"7aec167c6b4def75a53a17549868847cb4438d5e59767b04bb194d01235adb87","./images/Nouveau dossier/..OIP.jfif":"5168a8ad0f909e24179a918efb78b402f44b6659d54bccf19199c91b650ba2cd","./images/Nouveau dossier/.multipleimage.PNG":"a6802a24cfc6f58023f7034576474822a2728b6af2dbbff23a96bdc946a6cdb4","./images/Nouveau dossier/.multiple_image_rename.PNG":"4733b89607aa31eb36a20ec6e395a54d5f31a04076d99fa18a787324a0bcd780","./images/InvertimageFinal.PNG":"01b4894922300c9b3d04f9f93770c1e776c659ec6c4b4505a573dedad54fe94b","./images/Nouveau dossier/code_invertimage.PNG":"b8f7709ac76aba8feef4ecb709be33de9ff7eec1bf3e360b4b2f6aca92e8931a","./images/.InvertimageFinal.PNG":"4c5cd6e94cba0f938489b0b7fcb0891cdbe1d14c7411fb5765d46b0450b2e442","./images/Nouveau dossier/.code_invertimage.PNG":"c7de554483192cfe353e24ae75188a6e52f7f6d955b2bb9c8bcf9a27eb245a91","./images/Nouveau document texte.txt":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}
{"./assets/images/Nouveau dossier/Capture.PNG":"921c3b04780b23be6c516d52a025525dbf9ea23eb0418f997b59785ad4ede73c","./assets/images/Nouveau dossier/OIP.jfif":"b5c98b3c1e6bc469b15990b44a36bdf71cbb4349378881cac83396f3d7ef36f9"}

426
package-lock.json generated
View File

@ -17,15 +17,21 @@
"express-handlebars": "^6.0.7",
"jimp": "^0.16.2",
"js-sha1": "^0.6.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"reakt": "^0.0.5",
"serve-static": "^1.15.0",
"spark-md5": "^3.0.2"
},
"devDependencies": {
"@dzeio/config": "^1.1.8",
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"@typescript-eslint/eslint-plugin": "^5.49.0",
"@typescript-eslint/parser": "^5.49.0",
"eslint": "^8.33.0",
"ts-node": "^10.9.1",
"ts-node-dev": "^2.0.0",
"typescript": "^4.9.4"
}
},
@ -726,6 +732,12 @@
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.9.1.tgz",
"integrity": "sha512-QpLcX9ZSsq3YYUUnD3nFDY8H7wctAhQj/TFKL8Ya8v5fMm3CFXxo8zStsLAl780ltoYoo1WvKUVGBQK+1ifr7g=="
},
"node_modules/@types/prop-types": {
"version": "15.7.5",
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz",
"integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==",
"dev": true
},
"node_modules/@types/qs": {
"version": "6.9.7",
"resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz",
@ -736,6 +748,32 @@
"resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz",
"integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw=="
},
"node_modules/@types/react": {
"version": "18.0.27",
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.27.tgz",
"integrity": "sha512-3vtRKHgVxu3Jp9t718R9BuzoD4NcQ8YJ5XRzsSKxNDiDonD2MXIT1TmSkenxuCycZJoQT5d2vE8LwWJxBC1gmA==",
"dev": true,
"dependencies": {
"@types/prop-types": "*",
"@types/scheduler": "*",
"csstype": "^3.0.2"
}
},
"node_modules/@types/react-dom": {
"version": "18.0.10",
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.0.10.tgz",
"integrity": "sha512-E42GW/JA4Qv15wQdqJq8DL4JhNpB3prJgjgapN3qJT9K2zO5IIAQh4VXvCEDupoqAwnz0cY4RlXeC/ajX5SFHg==",
"dev": true,
"dependencies": {
"@types/react": "*"
}
},
"node_modules/@types/scheduler": {
"version": "0.16.2",
"resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz",
"integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==",
"dev": true
},
"node_modules/@types/semver": {
"version": "7.3.13",
"resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.3.13.tgz",
@ -751,6 +789,18 @@
"@types/node": "*"
}
},
"node_modules/@types/strip-bom": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@types/strip-bom/-/strip-bom-3.0.0.tgz",
"integrity": "sha512-xevGOReSYGM7g/kUBZzPqCrR/KYAo+F0yiPc85WFTJa0MSLtyFTVTU6cJu/aV4mid7IffDIWqo69THF2o4JiEQ==",
"dev": true
},
"node_modules/@types/strip-json-comments": {
"version": "0.0.30",
"resolved": "https://registry.npmjs.org/@types/strip-json-comments/-/strip-json-comments-0.0.30.tgz",
"integrity": "sha512-7NQmHra/JILCd1QqpSzl8+mJRc8ZHz3uDm8YV1Ks9IhK0epEiTw8aIErbvH9PI+6XbqhyIQy3462nEsn7UVzjQ==",
"dev": true
},
"node_modules/@typescript-eslint/eslint-plugin": {
"version": "5.49.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.49.0.tgz",
@ -1070,6 +1120,19 @@
"resolved": "https://registry.npmjs.org/any-base/-/any-base-1.1.0.tgz",
"integrity": "sha512-uMgjozySS8adZZYePpaWs8cxB9/kdzmpX6SgJZ+wbz1K5eYk5QMYDVJaZKhxyIHUdnnJkfR7SVgStgH7LkGUyg=="
},
"node_modules/anymatch": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz",
"integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==",
"dev": true,
"dependencies": {
"normalize-path": "^3.0.0",
"picomatch": "^2.0.4"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/arg": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz",
@ -1120,6 +1183,15 @@
}
]
},
"node_modules/binary-extensions": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz",
"integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==",
"dev": true,
"engines": {
"node": ">=8"
}
},
"node_modules/bmp-js": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/bmp-js/-/bmp-js-0.1.0.tgz",
@ -1165,7 +1237,6 @@
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true,
"dependencies": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@ -1214,6 +1285,12 @@
"node": ">=0.4.0"
}
},
"node_modules/buffer-from": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
"dev": true
},
"node_modules/bytes": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
@ -1259,6 +1336,45 @@
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
"node_modules/chokidar": {
"version": "3.5.3",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz",
"integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==",
"dev": true,
"funding": [
{
"type": "individual",
"url": "https://paulmillr.com/funding/"
}
],
"dependencies": {
"anymatch": "~3.1.2",
"braces": "~3.0.2",
"glob-parent": "~5.1.2",
"is-binary-path": "~2.1.0",
"is-glob": "~4.0.1",
"normalize-path": "~3.0.0",
"readdirp": "~3.6.0"
},
"engines": {
"node": ">= 8.10.0"
},
"optionalDependencies": {
"fsevents": "~2.3.2"
}
},
"node_modules/chokidar/node_modules/glob-parent": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
"dev": true,
"dependencies": {
"is-glob": "^4.0.1"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
@ -1277,11 +1393,18 @@
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
},
"node_modules/commander": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-10.0.0.tgz",
"integrity": "sha512-zS5PnTI22FIRM6ylNW8G4Ap0IEOyk62fhLSD0+uHRT9McRCLGpkVNvao4bjimpK/GShynyQkFFxHhwMcETmduA==",
"engines": {
"node": ">=14"
}
},
"node_modules/concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
"dev": true
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg=="
},
"node_modules/content-disposition": {
"version": "0.5.4",
@ -1354,6 +1477,12 @@
"node": ">= 8"
}
},
"node_modules/csstype": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.1.tgz",
"integrity": "sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw==",
"dev": true
},
"node_modules/debug": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
@ -1432,6 +1561,15 @@
"resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.2.tgz",
"integrity": "sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w=="
},
"node_modules/dynamic-dedupe": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/dynamic-dedupe/-/dynamic-dedupe-0.3.0.tgz",
"integrity": "sha512-ssuANeD+z97meYOqd50e04Ze5qp4bPqo8cCkI4TRjZkzAUgIDTrXV1R8QCdINpiI+hw14+rYazvTRdQrz0/rFQ==",
"dev": true,
"dependencies": {
"xtend": "^4.0.0"
}
},
"node_modules/ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
@ -1999,6 +2137,20 @@
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw=="
},
"node_modules/fsevents": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"dev": true,
"hasInstallScript": true,
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
@ -2030,7 +2182,6 @@
"version": "7.2.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
"integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
"dev": true,
"dependencies": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
@ -2273,6 +2424,30 @@
"node": ">= 0.10"
}
},
"node_modules/is-binary-path": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz",
"integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==",
"dev": true,
"dependencies": {
"binary-extensions": "^2.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/is-core-module": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz",
"integrity": "sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==",
"dev": true,
"dependencies": {
"has": "^1.0.3"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-extglob": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
@ -2355,6 +2530,11 @@
"resolved": "https://registry.npmjs.org/js-sha1/-/js-sha1-0.6.0.tgz",
"integrity": "sha512-01gwBFreYydzmU9BmZxpVk6svJJHrVxEN3IOiGl6VO93bVKYETJ0sIth6DASI6mIFdt7NmfX9UiByRzsYHGU9w=="
},
"node_modules/js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="
},
"node_modules/js-yaml": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
@ -2428,6 +2608,17 @@
"integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==",
"dev": true
},
"node_modules/loose-envify": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
"integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
"dependencies": {
"js-tokens": "^3.0.0 || ^4.0.0"
},
"bin": {
"loose-envify": "cli.js"
}
},
"node_modules/lru-cache": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
@ -2531,7 +2722,6 @@
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
"dev": true,
"dependencies": {
"brace-expansion": "^1.1.7"
},
@ -2589,6 +2779,15 @@
"resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz",
"integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw=="
},
"node_modules/normalize-path": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
"integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
"dev": true,
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/object-inspect": {
"version": "1.12.3",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz",
@ -2730,7 +2929,6 @@
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==",
"dev": true,
"engines": {
"node": ">=0.10.0"
}
@ -2744,6 +2942,12 @@
"node": ">=8"
}
},
"node_modules/path-parse": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
"integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
"dev": true
},
"node_modules/path-to-regexp": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
@ -2888,6 +3092,59 @@
"node": ">= 0.8"
}
},
"node_modules/react": {
"version": "18.2.0",
"resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz",
"integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==",
"dependencies": {
"loose-envify": "^1.1.0"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/react-dom": {
"version": "18.2.0",
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz",
"integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==",
"dependencies": {
"loose-envify": "^1.1.0",
"scheduler": "^0.23.0"
},
"peerDependencies": {
"react": "^18.2.0"
}
},
"node_modules/readdirp": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz",
"integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==",
"dev": true,
"dependencies": {
"picomatch": "^2.2.1"
},
"engines": {
"node": ">=8.10.0"
}
},
"node_modules/reakt": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/reakt/-/reakt-0.0.5.tgz",
"integrity": "sha512-nrh/G5OLX3ipHF4noPLskGZeu21rr4r6nHV8GJO5MoW1E61SP8cdIJ0F3XTEUk0sKizuHU0ZhOo3pnk2iBHBjg==",
"dependencies": {
"commander": "*",
"glob": "*",
"underscore": "~1.4.4",
"watch": "~0.5.1"
},
"bin": {
"reakt": "bin/reakt",
"reaktd": "bin/reaktd"
},
"engines": {
"node": "*"
}
},
"node_modules/regenerator-runtime": {
"version": "0.13.11",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
@ -2905,6 +3162,23 @@
"url": "https://github.com/sponsors/mysticatea"
}
},
"node_modules/resolve": {
"version": "1.22.1",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz",
"integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==",
"dev": true,
"dependencies": {
"is-core-module": "^2.9.0",
"path-parse": "^1.0.7",
"supports-preserve-symlinks-flag": "^1.0.0"
},
"bin": {
"resolve": "bin/resolve"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/resolve-from": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
@ -2972,6 +3246,14 @@
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
},
"node_modules/scheduler": {
"version": "0.23.0",
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz",
"integrity": "sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==",
"dependencies": {
"loose-envify": "^1.1.0"
}
},
"node_modules/send": {
"version": "0.18.0",
"resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz",
@ -3083,6 +3365,16 @@
"node": ">=0.10.0"
}
},
"node_modules/source-map-support": {
"version": "0.5.21",
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz",
"integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==",
"dev": true,
"dependencies": {
"buffer-from": "^1.0.0",
"source-map": "^0.6.0"
}
},
"node_modules/spark-md5": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/spark-md5/-/spark-md5-3.0.2.tgz",
@ -3108,6 +3400,24 @@
"node": ">=8"
}
},
"node_modules/strip-bom": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz",
"integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==",
"dev": true,
"engines": {
"node": ">=4"
}
},
"node_modules/strip-json-comments": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz",
"integrity": "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==",
"dev": true,
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
@ -3120,6 +3430,18 @@
"node": ">=8"
}
},
"node_modules/supports-preserve-symlinks-flag": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz",
"integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==",
"dev": true,
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/text-table": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz",
@ -3156,6 +3478,15 @@
"node": ">=0.6"
}
},
"node_modules/tree-kill": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz",
"integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==",
"dev": true,
"bin": {
"tree-kill": "cli.js"
}
},
"node_modules/ts-node": {
"version": "10.9.1",
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz",
@ -3199,6 +3530,76 @@
}
}
},
"node_modules/ts-node-dev": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ts-node-dev/-/ts-node-dev-2.0.0.tgz",
"integrity": "sha512-ywMrhCfH6M75yftYvrvNarLEY+SUXtUvU8/0Z6llrHQVBx12GiFk5sStF8UdfE/yfzk9IAq7O5EEbTQsxlBI8w==",
"dev": true,
"dependencies": {
"chokidar": "^3.5.1",
"dynamic-dedupe": "^0.3.0",
"minimist": "^1.2.6",
"mkdirp": "^1.0.4",
"resolve": "^1.0.0",
"rimraf": "^2.6.1",
"source-map-support": "^0.5.12",
"tree-kill": "^1.2.2",
"ts-node": "^10.4.0",
"tsconfig": "^7.0.0"
},
"bin": {
"ts-node-dev": "lib/bin.js",
"tsnd": "lib/bin.js"
},
"engines": {
"node": ">=0.8.0"
},
"peerDependencies": {
"node-notifier": "*",
"typescript": "*"
},
"peerDependenciesMeta": {
"node-notifier": {
"optional": true
}
}
},
"node_modules/ts-node-dev/node_modules/mkdirp": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==",
"dev": true,
"bin": {
"mkdirp": "bin/cmd.js"
},
"engines": {
"node": ">=10"
}
},
"node_modules/ts-node-dev/node_modules/rimraf": {
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz",
"integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==",
"dev": true,
"dependencies": {
"glob": "^7.1.3"
},
"bin": {
"rimraf": "bin.js"
}
},
"node_modules/tsconfig": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/tsconfig/-/tsconfig-7.0.0.tgz",
"integrity": "sha512-vZXmzPrL+EmC4T/4rVlT2jNVMWCi/O4DIiSj3UHg1OE5kCKbk4mfrXc6dZksLgRM/TZlKnousKH9bbTazUWRRw==",
"dev": true,
"dependencies": {
"@types/strip-bom": "^3.0.0",
"@types/strip-json-comments": "0.0.30",
"strip-bom": "^3.0.0",
"strip-json-comments": "^2.0.0"
}
},
"node_modules/tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
@ -3281,6 +3682,11 @@
"node": ">=0.8.0"
}
},
"node_modules/underscore": {
"version": "1.4.4",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.4.4.tgz",
"integrity": "sha512-ZqGrAgaqqZM7LGRzNjLnw5elevWb5M8LEoDMadxIW3OWbcv72wMMgKdwOKpd5Fqxe8choLD8HN3iSj3TUh/giQ=="
},
"node_modules/unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
@ -3328,6 +3734,14 @@
"node": ">= 0.8"
}
},
"node_modules/watch": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/watch/-/watch-0.5.1.tgz",
"integrity": "sha512-+XJjQ03+NtexhhBdn5Kt7jAMMPA9eJycKfqkECaqxV6ndUy07wMvWHJpnZ/LGbvfI2ZGW27utaSxl1vNuvm/0A==",
"engines": [
"node >=0.1.95"
]
},
"node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",

View File

@ -6,7 +6,7 @@
"scripts": {
"start": "node ./dist/index.js",
"build": "tsc --project tsconfig.json",
"dev": "ts-node src/index.ts",
"dev": "ts-node-dev src/index.tsx",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
@ -25,15 +25,21 @@
"express-handlebars": "^6.0.7",
"jimp": "^0.16.2",
"js-sha1": "^0.6.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"reakt": "^0.0.5",
"serve-static": "^1.15.0",
"spark-md5": "^3.0.2"
},
"devDependencies": {
"@dzeio/config": "^1.1.8",
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"@typescript-eslint/eslint-plugin": "^5.49.0",
"@typescript-eslint/parser": "^5.49.0",
"eslint": "^8.33.0",
"ts-node": "^10.9.1",
"ts-node-dev": "^2.0.0",
"typescript": "^4.9.4"
}
}

153
src/index.js Normal file
View File

@ -0,0 +1,153 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __asyncValues = (this && this.__asyncValues) || function (o) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const express_1 = __importDefault(require("express"));
const path_1 = __importDefault(require("path"));
const promises_1 = __importDefault(require("fs/promises"));
const jimp_1 = __importDefault(require("jimp"));
const crypto_1 = __importDefault(require("crypto"));
const app = (0, express_1.default)();
app.use('/assets', express_1.default.static('images'));
/* eslint-disable max-depth */
/* eslint-disable complexity */
app.listen(3000, () => {
console.log('The application is listening on port 3000!');
});
/**
*
*
* @param path the folder to search
*
* @return the list of files included in this folder/subfolders
*/
function filesList(Path) {
var _a, e_1, _b, _c;
return __awaiter(this, void 0, void 0, function* () {
const files = [];
const subFolders = yield promises_1.default.readdir(Path);
try {
for (var _d = true, subFolders_1 = __asyncValues(subFolders), subFolders_1_1; subFolders_1_1 = yield subFolders_1.next(), _a = subFolders_1_1.done, !_a;) {
_c = subFolders_1_1.value;
_d = false;
try {
const subFolder = _c;
const stats = yield promises_1.default.stat(Path + '/' + subFolder);
if (stats.isDirectory()) {
files.push(...yield filesList(Path + '/' + subFolder));
}
else {
files.push(Path + '/' + subFolder);
}
}
finally {
_d = true;
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (!_d && !_a && (_b = subFolders_1.return)) yield _b.call(subFolders_1);
}
finally { if (e_1) throw e_1.error; }
}
return files;
});
}
app.get('/program', (_req, res) => {
((dirPath) => __awaiter(void 0, void 0, void 0, function* () {
var _a, e_2, _b, _c;
const files = yield filesList(dirPath);
console.log(files);
// Filtre
const data = (yield promises_1.default.readFile('./output.json')).toString('utf8');
let json = {};
try {
json = JSON.parse(data);
}
catch (_d) {
console.log('handeling...');
}
try {
for (var _e = true, files_1 = __asyncValues(files), files_1_1; files_1_1 = yield files_1.next(), _a = files_1_1.done, !_a;) {
_c = files_1_1.value;
_e = false;
try {
const file = _c;
const bFile = path_1.default.basename(file);
const pName = path_1.default.dirname(file);
const hash = crypto_1.default.createHash('sha256');
hash.setEncoding('hex');
const readI = yield promises_1.default.readFile(`${file}`);
hash.write(readI);
hash.end();
const sha256sum = hash.read();
console.log('bfile = ' + bFile);
if (bFile.startsWith('.')) {
continue;
}
else if (json[file] === sha256sum) {
console.log('This picture has already been turned to sepia');
continue;
}
// Modification des données
json[file] = sha256sum;
// Ré-écriture dans le fichier output
yield promises_1.default.writeFile('output.json', JSON.stringify(json));
try {
const image = yield jimp_1.default.read(readI);
image.sepia();
console.log(bFile);
const newFileName = pName + '/.' + bFile;
console.log('newfilename:' + newFileName);
// save image with new file name
yield image.writeAsync(`${newFileName}`);
console.log('Images have been inverted and rename ' + '.' + file);
}
catch (err) {
console.log('this file is not an image');
}
}
finally {
_e = true;
}
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (!_e && !_a && (_b = files_1.return)) yield _b.call(files_1);
}
finally { if (e_2) throw e_2.error; }
}
res.send('Pictures transformed');
res.end();
}))('./images');
});
{
app.get('/', (_req, res) => __awaiter(void 0, void 0, void 0, function* () {
const list = yield filesList('./content');
const item = list[Math.floor(Math.random() * ((list)).length)];
const itemB = yield promises_1.default.readFile(item);
res.send(itemB);
console.log(item);
}));
}

View File

@ -1,107 +0,0 @@
import express from 'express';
import path from 'path'
import fs from 'fs/promises'
import Jimp from 'jimp'
import crypto from 'crypto'
const app = express()
app.use('/assets',express.static('images'))
/* eslint-disable max-depth */
/* eslint-disable complexity */
app.listen(3000, () => {
console.log('The application is listening on port 3000!');
})
/**
*
*
* @param path the folder to search
*
* @return the list of files included in this folder/subfolders
*/
async function filesList(Path: string): Promise<string[]> {
const files: Array<string> = []
const subFolders = await fs.readdir(Path)
for await (const subFolder of subFolders){
const stats = await fs.stat(Path + '/' + subFolder)
if (stats.isDirectory()) {
files.push(...await filesList(Path + '/' + subFolder))
} else {
files.push(Path + '/' + subFolder)
}
}
return files
}
app.get('/program', (_req, res) => {
(async (dirPath: string) => {
const files = await filesList(dirPath)
console.log(files)
// Filtre
const data = (await fs.readFile('./output.json')).toString('utf8')
let json: Record<string, string> = {}
try{
json = JSON.parse(data)
}catch{
console.log('handeling...')
}
for await (const file of files) {
const bFile = path.basename(file)
const pName = path.dirname(file)
const hash = crypto.createHash('sha256')
hash.setEncoding('hex')
const readI = await fs.readFile(`${file}`)
hash.write(readI)
hash.end()
const sha256sum = hash.read()
console.log('bfile = ' + bFile)
if (bFile.startsWith('.')) {
continue
}else if (json[file] === sha256sum){
console.log('This picture has already been turned to sepia')
continue
}
// Modification des données
json[file] = sha256sum
// Ré-écriture dans le fichier output
await fs.writeFile('output.json', JSON.stringify(json))
try{
const image = await Jimp.read(readI)
image.sepia()
console.log(bFile)
const newFileName = pName + '/.' + bFile
console.log('newfilename:' + newFileName)
// save image with new file name
await image.writeAsync(`${newFileName}`)
console.log('Images have been inverted and rename ' + '.' + file)
}catch (err){
console.log('this file is not an image')
}
}
res.send('Pictures transformed')
res.end()
})('./images')
})
{
app.get('/', async (_req, res) => {
const list = await filesList('./content')
const item = list[Math.floor(Math.random()*((list)).length)]
const itemB =await fs.readFile(item)
res.send(itemB)
console.log(item)
})
}

181
src/index.tsx Normal file
View File

@ -0,0 +1,181 @@
import express from 'express'
import path from 'path'
import fs from 'fs/promises'
import Jimp from 'jimp'
import crypto from 'crypto'
import React from 'react'
import ReactDOMServer from 'react-dom/server'
const app = express()
app.use('/assets',express.static('assets'))
/* eslint-disable max-depth */
/* eslint-disable complexity */
app.listen(3000, () => {
console.log('The application is listening on port 3000!')
})
/**
*
*
* @param path the folder to search
*
* @return the list of files included in this folder/subfolders
*/
async function filesList(Path: string): Promise<Array<string>> {
const files: Array<string> = []
const subFolders = await fs.readdir(Path)
for await (const subFolder of subFolders){
const stats = await fs.stat(Path + '/' + subFolder)
if (stats.isDirectory()) {
files.push(...await filesList(Path + '/' + subFolder))
} else {
files.push(Path + '/' + subFolder)
}
}
return files
}
app.get('/program', (_req, res) => {
(async (dirPath: string) => {
const files = await filesList(dirPath)
console.log(files)
// Filtre
const data = (await fs.readFile('./output.json')).toString('utf8')
let json: Record<string, string> = {}
try{
json = JSON.parse(data)
}catch{
console.log('handeling...')
}
for await (const file of files) {
const bFile = path.basename(file)
const pName = path.dirname(file)
const hash = crypto.createHash('sha256')
hash.setEncoding('hex')
const readI = await fs.readFile(`${file}`)
hash.write(readI)
hash.end()
const sha256sum = hash.read()
console.log('bfile = ' + bFile)
if (bFile.startsWith('.')) {
continue
}else if (json[file] === sha256sum){
console.log('This picture has already been turned to sepia')
continue
}
// Modification des données
json[file] = sha256sum
// Ré-écriture dans le fichier output
await fs.writeFile('output.json', JSON.stringify(json))
try{
const image = await Jimp.read(readI)
image.sepia()
console.log(bFile)
const newFileName = pName + '/S' + bFile
console.log('newfilename:' + newFileName)
// save image with new file name
await image.writeAsync(`${newFileName}`)
console.log('Images have been turned to sepia and renamed ' + newFileName)
}catch (err){
console.log('this file is not an image')
}
}
res.send('Pictures transformed')
res.end()
})('./assets')
})
function randomSort() {
return Math.random() - 0.5
}
async function randomI(): Promise<[] | [string, string, string, string, string, string]> {
const list = await filesList('./assets') // si moins de 6 element dans la liste ....
const sorted = list.sort(randomSort).slice(0, 6)
while (sorted.length < 6 && sorted.length > 0 ) {
const listLength = sorted.length
sorted.push(...list.sort(randomSort).slice(0, 6 - listLength))
}
return sorted as []
}
app.get('/test', async (_req, res) => {
res.send(randomI())
})
app.get('/', async (_req, res) => {
const list = await randomI()
if(list.length === 0 ){
const board =
<><style>{`
.string{
color: red;}
`}</style>
<div className='string'>
Il n'y a pas d'image dans le fichier
</div></>
const rendering = ReactDOMServer.renderToString(board)
res.send(rendering)
}else{
res.send(ReactDOMServer.renderToString(
<><style>{`
.board {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-gap: 10px;
grid-auto-rows: minmax(100px, auto);
.row11 {
grid-column : 1
grid-row : 1
}
.row12 {
grid-column: 2
grid-row: 1
}
.row13 {
grid-column : 3
grid-row : 1
}
.row21 {
grid-column : 1
grid-row : 2
}
.row22 {
grid-column : 2
grid-row : 2
}
.row23 {
grid-column : 3
grid-row : 2
}
}`}</style>
<div className="board">
<div className='row11'>
<img src={list[0]} width={620} />
</div>
<div className='row12'>
<img src={list[1]} width={620} />
</div>
<div className='row13'>
<img src={list[2]} width={620} />
</div>
<div className="row21">
<img src={list[3]} width={620} />
</div>
<div className='row22'>
<img src={list[4]} width={620} />
</div>
<div className='row23'>
<img src={list[5]} width={620} />
</div>
</div></>
))
}
})

31
test.js
View File

@ -1,30 +1 @@
function pouet(liste) {
if (liste.length === 0) return []
const result = []
/**
* @type string | Array<string>
*/
const item = liste.pop()
if (typeof item === 'object') {
result.push(...pouet(item))
} else {
// typeof item === 'string'
if (item.charCodeAt(0) % 2 === 1) {
// item est pair
result.push(item)
}
}
result.push(...pouet(liste))
return result
}
(async () => {
const entree = ['a', ['b', 'c', 'd', ['e', ['f'], 'g'], 'h', 'i', 'j'], 'k', 'l', 'm', ['n', 'o', 'p'], 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
console.log(
pouet(entree)
)
})()
"use strict";

View File

@ -1,103 +1,6 @@
{
"extends": "./node_modules/@dzeio/config/tsconfig.base.json",
"compilerOptions": {
/* Visit https://aka.ms/tsconfig to read more about this file */
/* Projects */
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
/* Modules */
"module": "commonjs", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
// "resolveJsonModule": true, /* Enable importing .json files. */
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
/* JavaScript Support */
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
/* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
// "outDir": "./", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
// "newLine": "crlf", /* Set the newline character for emitting files. */
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
"jsx": "react"
}
}
}