diff --git a/package.json b/package.json index 031f9cf..f3fe1a6 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,6 @@ "license": "MIT", "homepage": "https://bitbucket.org/online-mentor/multi-stub#readme", "dependencies": { - "@types/express": "^4.17.21", "bcrypt": "^5.1.0", "body-parser": "^1.19.0", "cookie-parser": "^1.4.5", diff --git a/server/routers/epja-2023-2/pen-plotter/.gitignore b/server/routers/epja-2023-2/pen-plotter/.gitignore deleted file mode 100644 index 6405610..0000000 --- a/server/routers/epja-2023-2/pen-plotter/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -dist/ -static/ -profiles/ diff --git a/server/routers/epja-2023-2/pen-plotter/index.js b/server/routers/epja-2023-2/pen-plotter/index.js index 4528f8d..818d4cd 100644 --- a/server/routers/epja-2023-2/pen-plotter/index.js +++ b/server/routers/epja-2023-2/pen-plotter/index.js @@ -2,31 +2,24 @@ const express = require('express') const router = express.Router() const fs = require("fs"); const path = require("path"); +const { BASE_PATH } = require("./paths"); + +router.use("/profiles", express.static(path.join(BASE_PATH, "/profiles"))); +router.use("/static", express.static(path.join(BASE_PATH, "/static"))); + +router.use('/api', require('./routes/api').default) -const BASE_PATH = __dirname; -const STATIC_PATH = `${BASE_PATH}/static`; -// Serve static files -router.use(express.static(path.join(__dirname, './assets/'))) // Add the required directories router.use((req, res, next) => { - const directories = ['/static', '/profiles'] + const directories = ["/static", "/profiles"]; directories.forEach((dir) => { if (!fs.existsSync(BASE_PATH + dir)) { - fs.mkdirSync(BASE_PATH + dir) + fs.mkdirSync(BASE_PATH + dir); } - }) - next() -}) -// Serve Static generated SVGs -router.get('/static/:name', async (req, res, next) => { - const fileName = req.params.name - const filePath = `${STATIC_PATH}/${fileName}` + }); + next(); +}); - const file = await fs.readFileSync(filePath) - res.setHeader('Content-Type', 'image/svg+xml') - res.send(file) -}) -router.use('/api', require('./routes/api').default) router.get('/info', (req, res) => { res.send('Pen-Plotter backend') diff --git a/server/routers/epja-2023-2/pen-plotter/paths.js b/server/routers/epja-2023-2/pen-plotter/paths.js index 799383d..0d3b9c1 100644 --- a/server/routers/epja-2023-2/pen-plotter/paths.js +++ b/server/routers/epja-2023-2/pen-plotter/paths.js @@ -1,9 +1,10 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.STATIC_PATH = exports.PROFILES_PATH = exports.BASE_PATH = void 0; +const path = require("path"); const BASE_PATH = __dirname; exports.BASE_PATH = BASE_PATH; -const PROFILES_PATH = `${BASE_PATH}/profiles`; +const PROFILES_PATH = path.join(BASE_PATH, "profiles"); exports.PROFILES_PATH = PROFILES_PATH; -const STATIC_PATH = `${BASE_PATH}/static`; +const STATIC_PATH = path.join(BASE_PATH, "static"); exports.STATIC_PATH = STATIC_PATH; diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/ampersand/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/ampersand/0.svg new file mode 100644 index 0000000..804af1d --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/ampersand/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/asterisk/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/asterisk/0.svg new file mode 100644 index 0000000..1aef4e4 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/asterisk/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/caret/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/caret/0.svg new file mode 100644 index 0000000..01984e5 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/caret/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/colon/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/colon/0.svg new file mode 100644 index 0000000..0e76298 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/colon/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/comma/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/comma/0.svg new file mode 100644 index 0000000..8f46883 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/comma/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/dollar/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/dollar/0.svg new file mode 100644 index 0000000..3bbf368 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/dollar/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/doubleQuote/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/doubleQuote/0.svg new file mode 100644 index 0000000..c09abe7 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/doubleQuote/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/eight/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/eight/0.svg new file mode 100644 index 0000000..c196887 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/eight/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/equal/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/equal/0.svg new file mode 100644 index 0000000..812a156 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/equal/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/exclamationMark/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/exclamationMark/0.svg new file mode 100644 index 0000000..307caf3 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/exclamationMark/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/five/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/five/0.svg new file mode 100644 index 0000000..f93f5db --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/five/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/four/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/four/0.svg new file mode 100644 index 0000000..6d79760 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/four/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/graveAccent/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/graveAccent/0.svg new file mode 100644 index 0000000..18c3447 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/graveAccent/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/greaterThan/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/greaterThan/0.svg new file mode 100644 index 0000000..bc2db06 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/greaterThan/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/hash/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/hash/0.svg new file mode 100644 index 0000000..0044678 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/hash/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/hyphen/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/hyphen/0.svg new file mode 100644 index 0000000..de344ba --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/hyphen/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/leftCurlyBrace/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/leftCurlyBrace/0.svg new file mode 100644 index 0000000..2f48812 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/leftCurlyBrace/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/leftParenthesis/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/leftParenthesis/0.svg new file mode 100644 index 0000000..23ee9b9 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/leftParenthesis/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/leftSquareBracket/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/leftSquareBracket/0.svg new file mode 100644 index 0000000..83ab730 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/leftSquareBracket/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lessThan/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lessThan/0.svg new file mode 100644 index 0000000..3675acd --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lessThan/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-a/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-a/0.svg new file mode 100644 index 0000000..52bd2d4 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-a/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-b/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-b/0.svg new file mode 100644 index 0000000..bca9d42 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-b/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-c/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-c/0.svg new file mode 100644 index 0000000..ddc0b32 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-c/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-d/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-d/0.svg new file mode 100644 index 0000000..c3615fd --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-d/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-d/1.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-d/1.svg new file mode 100644 index 0000000..b9ef998 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-d/1.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-e/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-e/0.svg new file mode 100644 index 0000000..6dcc6fa --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-e/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-f/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-f/0.svg new file mode 100644 index 0000000..55ead0e --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-f/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-g/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-g/0.svg new file mode 100644 index 0000000..13dee4b --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-g/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-h/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-h/0.svg new file mode 100644 index 0000000..6284383 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-h/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-i/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-i/0.svg new file mode 100644 index 0000000..08fd2ce --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-i/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-j/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-j/0.svg new file mode 100644 index 0000000..7093bb6 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-j/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-k/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-k/0.svg new file mode 100644 index 0000000..8b2b05d --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-k/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-l/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-l/0.svg new file mode 100644 index 0000000..64abc57 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-l/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-m/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-m/0.svg new file mode 100644 index 0000000..520d936 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-m/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-n/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-n/0.svg new file mode 100644 index 0000000..6b57ac9 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-n/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-o/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-o/0.svg new file mode 100644 index 0000000..0d2eae8 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-o/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-p/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-p/0.svg new file mode 100644 index 0000000..fbdc6ee --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-p/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-q/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-q/0.svg new file mode 100644 index 0000000..164928e --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-q/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-r/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-r/0.svg new file mode 100644 index 0000000..6e9c9c3 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-r/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-s/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-s/0.svg new file mode 100644 index 0000000..80d7f51 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-s/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-t/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-t/0.svg new file mode 100644 index 0000000..9303e66 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-t/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-u/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-u/0.svg new file mode 100644 index 0000000..5d3b8a4 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-u/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-v/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-v/0.svg new file mode 100644 index 0000000..187cb8d --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-v/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-w/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-w/0.svg new file mode 100644 index 0000000..57db542 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-w/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-x/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-x/0.svg new file mode 100644 index 0000000..5a22237 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-x/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-y/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-y/0.svg new file mode 100644 index 0000000..b70c10b --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-y/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-z/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-z/0.svg new file mode 100644 index 0000000..05f80ed --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/lower-z/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/nine/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/nine/0.svg new file mode 100644 index 0000000..2315673 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/nine/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/one/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/one/0.svg new file mode 100644 index 0000000..e15a9dd --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/one/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/percent/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/percent/0.svg new file mode 100644 index 0000000..5ce8000 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/percent/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/period/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/period/0.svg new file mode 100644 index 0000000..ecf9b8d --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/period/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/pipe/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/pipe/0.svg new file mode 100644 index 0000000..41e4d3f --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/pipe/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/plus/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/plus/0.svg new file mode 100644 index 0000000..80ad657 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/plus/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/questionMark/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/questionMark/0.svg new file mode 100644 index 0000000..3fc7f82 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/questionMark/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/rightCurlyBrace/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/rightCurlyBrace/0.svg new file mode 100644 index 0000000..6434af1 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/rightCurlyBrace/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/rightParenthesis/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/rightParenthesis/0.svg new file mode 100644 index 0000000..ba83970 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/rightParenthesis/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/rightSquareBracket/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/rightSquareBracket/0.svg new file mode 100644 index 0000000..2f25e2c --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/rightSquareBracket/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/seven/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/seven/0.svg new file mode 100644 index 0000000..72ab9d4 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/seven/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/singleQuote/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/singleQuote/0.svg new file mode 100644 index 0000000..f0a1c45 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/singleQuote/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/six/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/six/0.svg new file mode 100644 index 0000000..74355d5 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/six/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/slash/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/slash/0.svg new file mode 100644 index 0000000..dbc9a8d --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/slash/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/three/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/three/0.svg new file mode 100644 index 0000000..8ccc81b --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/three/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/tilde/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/tilde/0.svg new file mode 100644 index 0000000..7fdbee8 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/tilde/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/two/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/two/0.svg new file mode 100644 index 0000000..fe2d6b1 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/two/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/underscore/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/underscore/0.svg new file mode 100644 index 0000000..bc0d142 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/underscore/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-;/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-;/0.svg new file mode 100644 index 0000000..fa655fd --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-;/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-A/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-A/0.svg new file mode 100644 index 0000000..5e4141f --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-A/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-B/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-B/0.svg new file mode 100644 index 0000000..b2e7163 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-B/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-C/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-C/0.svg new file mode 100644 index 0000000..bede826 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-C/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-D/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-D/0.svg new file mode 100644 index 0000000..a5076d1 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-D/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-E/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-E/0.svg new file mode 100644 index 0000000..194f707 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-E/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-F/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-F/0.svg new file mode 100644 index 0000000..3abb2a0 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-F/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-G/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-G/0.svg new file mode 100644 index 0000000..ebd12da --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-G/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-H/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-H/0.svg new file mode 100644 index 0000000..99500b2 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-H/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-I/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-I/0.svg new file mode 100644 index 0000000..efefca0 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-I/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-J/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-J/0.svg new file mode 100644 index 0000000..1e7994b --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-J/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-K/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-K/0.svg new file mode 100644 index 0000000..603e40a --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-K/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-L/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-L/0.svg new file mode 100644 index 0000000..65bbfe0 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-L/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-M/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-M/0.svg new file mode 100644 index 0000000..8f98888 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-M/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-N/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-N/0.svg new file mode 100644 index 0000000..4c8e23c --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-N/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-O/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-O/0.svg new file mode 100644 index 0000000..ec1bc9f --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-O/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-P/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-P/0.svg new file mode 100644 index 0000000..6f8128b --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-P/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-Q/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-Q/0.svg new file mode 100644 index 0000000..bc06f08 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-Q/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-R/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-R/0.svg new file mode 100644 index 0000000..2318690 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-R/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-S/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-S/0.svg new file mode 100644 index 0000000..f29946e --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-S/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-T/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-T/0.svg new file mode 100644 index 0000000..bd4b6d3 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-T/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-U/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-U/0.svg new file mode 100644 index 0000000..b2214cd --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-U/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-V/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-V/0.svg new file mode 100644 index 0000000..b47b79e --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-V/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-W/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-W/0.svg new file mode 100644 index 0000000..6528a37 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-W/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-X/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-X/0.svg new file mode 100644 index 0000000..e305bd1 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-X/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-Y/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-Y/0.svg new file mode 100644 index 0000000..66d7982 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-Y/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-Z/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-Z/0.svg new file mode 100644 index 0000000..41f9b9e --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/upper-Z/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/zero/0.svg b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/zero/0.svg new file mode 100644 index 0000000..0743639 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/profiles/Zeyad Alagamy/zero/0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/routes/sub-routes/svg.js b/server/routers/epja-2023-2/pen-plotter/routes/sub-routes/svg.js index 3187d03..b93f086 100644 --- a/server/routers/epja-2023-2/pen-plotter/routes/sub-routes/svg.js +++ b/server/routers/epja-2023-2/pen-plotter/routes/sub-routes/svg.js @@ -34,6 +34,11 @@ router.post("/characters", (req, res, next) => __awaiter(void 0, void 0, void 0, yield (0, svg_1.createCharacterDirectory)(userDir, characterName); // Generate a unique filename for the SVG const svgPath = yield (0, svg_1.generateUniqueSVGPath)(`${userDir}/${characterName}`); + if (svgPath === "ERROR_NO_CHARACTER_DIRECTORY") { + return res + .status(404) + .json({ error: "Character directory does not exist" }); + } // Extract the SVG content from the data URL const svgContent = decodeURIComponent(svg.split(",")[1]); // Write the SVG content to a file @@ -87,9 +92,17 @@ router.post("/handwriting", (req, res, next) => __awaiter(void 0, void 0, void 0 .json({ error: `Missing character/s ${totalMissing.join(",")}` }); } // Generate a larger - const path = yield (0, svg_1.generateSvg)(totalPaths, scaleFactor || 1, defects); + const generatSVGOptions = { + paths: totalPaths, + scaleFactor: scaleFactor !== null && scaleFactor !== void 0 ? scaleFactor : 1, + defects: defects, + }; + const { serverFilePath, totalHeight, totalWidth } = yield (0, svg_1.generateSvg)(generatSVGOptions); // Read the SVG files - return res.json({ svgLink: path }); + return res.json({ + svgLink: serverFilePath, + dim: { width: Math.ceil(totalWidth), height: Math.ceil(totalHeight) }, + }); } catch (err) { console.error(err); @@ -108,4 +121,27 @@ router.post("/print", (req, res) => __awaiter(void 0, void 0, void 0, function* return res.status(500).json({ error: e }); } })); +router.get("/random-glyph/:username/:charName", (req, res) => __awaiter(void 0, void 0, void 0, function* () { + var _b, _c; + let { username, charName } = req.params; + if (!username || !charName) { + return res.status(400).json({ error: "Missing username or char" }); + } + try { + // remove the double quotes form the charName + charName = charName === "dot" ? "." : charName; + const validCharName = (0, svg_1.validateName)(charName); + const fullPath = yield (0, svg_1.getRandomEntityPath)(username, validCharName); + const svgContent = yield (0, svg_1.fetchSVGContent)(fullPath); + const { parent } = yield (0, svg_1.parseSVG)(svgContent); + const width = (_b = parseFloat(parent.getAttribute("width"))) !== null && _b !== void 0 ? _b : 0; + const height = (_c = parseFloat(parent.getAttribute("height"))) !== null && _c !== void 0 ? _c : 0; + const warpedSvg = (0, svg_1.warpSvg)(svgContent, width, height); + res.json(warpedSvg); + } + catch (err) { + console.error(err); + res.status(500).json({ error: "Something went wrong!" }); + } +})); exports.default = router; diff --git a/server/routers/epja-2023-2/pen-plotter/static/generated.svg b/server/routers/epja-2023-2/pen-plotter/static/generated.svg new file mode 100644 index 0000000..99921d4 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/static/generated.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/static/p.svg b/server/routers/epja-2023-2/pen-plotter/static/p.svg new file mode 100644 index 0000000..f384190 --- /dev/null +++ b/server/routers/epja-2023-2/pen-plotter/static/p.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/routers/epja-2023-2/pen-plotter/utilities/svg.js b/server/routers/epja-2023-2/pen-plotter/utilities/svg.js index 7bdc1c2..1585ce1 100644 --- a/server/routers/epja-2023-2/pen-plotter/utilities/svg.js +++ b/server/routers/epja-2023-2/pen-plotter/utilities/svg.js @@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.writeSVGToFile = exports.generateUniqueSVGPath = exports.createCharacterDirectory = exports.validateName = exports.numberOfFiles = exports.svgLinePathNames = exports.generateSvg = exports.printSVG = void 0; +exports.parseSVG = exports.fetchSVGContent = exports.warpSvg = exports.getRandomEntityPath = exports.writeSVGToFile = exports.generateUniqueSVGPath = exports.createCharacterDirectory = exports.validateName = exports.numberOfFiles = exports.svgLinePathNames = exports.generateSvg = exports.printSVG = void 0; const fs_1 = __importDefault(require("fs")); const paths_1 = require("../paths"); const jsdom_1 = __importDefault(require("jsdom")); @@ -103,9 +103,9 @@ const isUpperCase = (char) => { * @param charName - The title of the character. * @returns A promise that resolves to a string representing the path to the random entity or empty. */ -const getRandomEntityPath = (userName, charName) => __awaiter(void 0, void 0, void 0, function* () { +const getRandomEntityPath = (username, charName) => __awaiter(void 0, void 0, void 0, function* () { try { - const basePath = `${paths_1.PROFILES_PATH}/${userName}/${charName}`; + const basePath = `${paths_1.PROFILES_PATH}/${username}/${charName}`; const characters = yield fs_1.default.promises.readdir(basePath); const randomIndex = Math.floor(Math.random() * characters.length); return `${basePath}/${characters[randomIndex]}`; @@ -115,6 +115,7 @@ const getRandomEntityPath = (userName, charName) => __awaiter(void 0, void 0, vo return ""; } }); +exports.getRandomEntityPath = getRandomEntityPath; /** * Checks if a given character path contains any special characters. * Special characters include: questionMark, asterisk, slash, backslash, colon, pipe, lessThan, greaterThan, @@ -149,7 +150,16 @@ const isSpecialChar = (charPath) => { "exclamationMark", "tilde", ]; - const specialLocatedBottom = ["underscore", "comma", "period"]; + const specialLocatedBottom = [ + "underscore", + "questionMark", + "slash", + "backslash", + "pipe", + "exclamationMark", + "comma", + "period", + ]; let isSpecial = false; let position = "bottom"; for (const special of specialLocatedTop) { @@ -179,6 +189,193 @@ const isSpecialChar = (charPath) => { } return { isSpecial, position }; }; +const specialWidthGlyphs = (glyphPath) => { + const symbols = { + colon: { + width: 5, + maxWidth: 7, + height: 15, + maxHeight: 20, + }, + lessThan: { + width: 15, + height: 20, + maxWidth: 25, + maxHeight: 30, + }, + greaterThan: { + width: 15, + height: 20, + maxWidth: 25, + maxHeight: 30, + }, + leftParenthesis: { + width: 8, + height: 20, + maxWidth: 16, + maxHeight: 40, + }, + rightParenthesis: { + width: 8, + height: 20, + maxWidth: 16, + maxHeight: 40, + }, + hyphen: { + width: 10, + height: 2, + maxWidth: 20, + maxHeight: 4, + }, + equal: { + width: 10, + height: 5, + maxWidth: 20, + maxHeight: 10, + }, + plus: { + width: 10, + height: 10, + maxWidth: 20, + maxHeight: 20, + }, + leftCurlyBrace: { + width: 12, + height: 25, + maxWidth: 24, + maxHeight: 50, + }, + rightCurlyBrace: { + width: 12, + height: 25, + maxWidth: 24, + maxHeight: 50, + }, + leftSquareBracket: { + width: 8, + height: 20, + maxWidth: 16, + maxHeight: 40, + }, + rightSquareBracket: { + width: 8, + height: 20, + maxWidth: 16, + maxHeight: 40, + }, + exclamationMark: { + width: 6, + height: 30, + maxWidth: 9, + maxHeight: 30, + }, + tilde: { + width: 20, + height: 8, + maxWidth: 30, + maxHeight: 10, + }, + comma: { + width: 5, + height: 10, + maxWidth: 10, + maxHeight: 20, + }, + dot: { + width: 5, + height: 5, + maxWidth: 10, + maxHeight: 10, + }, + questionMark: { + width: 10, + height: 30, + maxWidth: 20, + maxHeight: 40, + }, + underscore: { + width: 10, + height: 2, + maxWidth: 20, + maxHeight: 4, + }, + pipe: { + width: 5, + height: 30, + maxWidth: 10, + maxHeight: 40, + }, + one: { + width: 5, + height: 30, + maxWidth: 10, + maxHeight: 40, + }, + "lower-m": { + width: 20, + height: 30, + maxWidth: 30, + maxHeight: 40, + }, + "lower-q": { + width: 20, + height: 30, + maxWidth: 30, + maxHeight: 40, + }, + "lower-y": { + width: 20, + height: 30, + maxWidth: 30, + maxHeight: 40, + }, + "lower-g": { + width: 20, + height: 30, + maxWidth: 30, + maxHeight: 40, + }, + "lower-p": { + width: 20, + height: 30, + maxWidth: 30, + maxHeight: 40, + }, + "lower-j": { + width: 20, + height: 30, + maxWidth: 30, + maxHeight: 40, + }, + "lower-i": { + width: 5, + height: 30, + maxWidth: 10, + maxHeight: 40, + }, + "lower-l": { + width: 10, + height: 40, + maxWidth: 10, + maxHeight: 40, + }, + }; + let isSpecialGlyph = false; + let values = { + width: 20, + height: 30, + maxWidth: 30, + maxHeight: 40, + }; + for (const symbol in symbols) { + if (glyphPath.includes(symbol)) { + isSpecialGlyph = true; + values = symbols[symbol]; + break; + } + } + return { isSpecialGlyph, values }; +}; /** * Determines if the given character path should extend below the baseline. * @param charPath The character path to check. @@ -238,14 +435,13 @@ exports.svgLinePathNames = svgLinePathNames; * @returns An object containing the SVG element and its paths. */ const parseSVG = (svg) => { - const dom = new jsdom_1.default.JSDOM(svg); - const svgElement = dom.window.document.querySelector("svg"); - const svgPaths = svgElement === null || svgElement === void 0 ? void 0 : svgElement.querySelectorAll("path"); + const dom = new jsdom_1.default.JSDOM(svg, { contentType: "image/svg+xml" }); + const svgElement = dom.window.document.querySelector("g"); return { parent: svgElement, - paths: svgPaths, }; }; +exports.parseSVG = parseSVG; /** * Returns a random number between the given minimum and maximum values, with an optional percentage range. * @param min The minimum value for the random number. @@ -256,7 +452,6 @@ const parseSVG = (svg) => { const getRandomNumber = (min, max, percentage = 25, scale = 1) => { const howRandom = Math.round((max - min) * (percentage / 100)); const randomNumber = Math.floor(Math.random() * (howRandom + 1)); - // const randomSign = Math.random() < 0.5 ? -1 : 1; return Math.round(min + randomNumber) * scale; }; // Get standard values for the characters @@ -264,18 +459,19 @@ const getStandardValues = (isSpecial, position) => { // Standard values for the characters const standard = { char_width: 20, + char_height: 30, space_width: 10, special_char_located_top_width: 5, special_char_located_middle_width: 15, special_char_located_top_max_width: 10, special_char_located_middle_max_width: 20, special_char_located_bottom_width: 5, - special_char_located_bottom_max_width: 15, + special_char_located_bottom_max_width: 10, special_char_height_top: 10, special_char_height_middle: 20, special_char_height_bottom: 30, max_char_width: 30, - max_char_height: 30, + max_char_height: 40, }; const standerdWidth = isSpecial ? position === "top" @@ -297,7 +493,7 @@ const getStandardValues = (isSpecial, position) => { : position === "middle" ? standard.special_char_height_middle : standard.special_char_height_bottom - : standard.max_char_height; + : standard.char_height; const standerdMaxHeight = isSpecial ? position === "top" ? standard.special_char_height_top @@ -310,11 +506,25 @@ const getStandardValues = (isSpecial, position) => { // Get Random Defects const getRandomDefects = (defects, scaleFactor, charPath = "") => { const { baseline, kerning, letterSize, lineSpacing, indent } = defects; + const { isSpecialGlyph, values } = specialWidthGlyphs(charPath); + if (isSpecialGlyph) { + const { width, height, maxWidth, maxHeight } = values; + const letterSizeWidthRandom = getRandomNumber(width, maxWidth, letterSize, scaleFactor); + const letterSizeRandomHeight = getRandomNumber(height, maxHeight, letterSize, scaleFactor); + return { + indentRandom: 0, + lineSpacingRandom: 0, + kerningDeffects: 0, + baselineOffset: 0, + letterSizeWidthRandom, + letterSizeRandomHeight, + }; + } const { isSpecial, position } = isSpecialChar(charPath); const { standerdWidth, standerdMaxWidth, standerdHeight, standerdMaxHeight } = getStandardValues(isSpecial, position); const indentRandom = getRandomNumber(0, 80, indent, scaleFactor); const lineSpacingRandom = getRandomNumber(0, 30, lineSpacing, scaleFactor); - const kerningDeffects = getRandomNumber(0, 10, kerning, scaleFactor); + const kerningDeffects = getRandomNumber(5, -5, kerning, scaleFactor); const baselineOffset = getRandomNumber(0, 10, baseline, scaleFactor); const letterSizeWidthRandom = getRandomNumber(standerdWidth, standerdMaxWidth, letterSize, scaleFactor); const letterSizeRandomHeight = getRandomNumber(standerdHeight, standerdMaxHeight, letterSize, scaleFactor); @@ -327,6 +537,10 @@ const getRandomDefects = (defects, scaleFactor, charPath = "") => { letterSizeRandomHeight, }; }; +const fetchSVGContent = (path) => { + return fs_1.default.readFileSync(path, "utf-8"); +}; +exports.fetchSVGContent = fetchSVGContent; /** * Assembles a word by processing each character and generating SVG elements. * @@ -341,7 +555,7 @@ const getRandomDefects = (defects, scaleFactor, charPath = "") => { * @returns {Object} - The assembled word elements, the height of the word, and the updated X offset. */ const assembleWord = ({ word, offsetX, offsetY, scaleFactor, indentRandom, defects, }) => { - const space_width = 10 * scaleFactor; + const space_width = 30; let wordElements = []; let wordHeight = 0; if (word.length === 0) { @@ -351,30 +565,31 @@ const assembleWord = ({ word, offsetX, offsetY, scaleFactor, indentRandom, defec offsetX += indentRandom; for (let j = 0; j < word.length; j++) { const char = word[j]; - const { kerningDeffects, baselineOffset } = getRandomDefects(defects, scaleFactor); + const { kerningDeffects } = getRandomDefects(defects, scaleFactor); const { isSpecial, position } = isSpecialChar(char); const { letterSizeWidthRandom, letterSizeRandomHeight } = getRandomDefects(defects, scaleFactor, char); // You need to load the SVG content from the file - const svgFileContent = fs_1.default.readFileSync(char, "utf-8"); + const svgFileContent = fetchSVGContent(char); // Get the width and height of the SVG and its paths children const { parent } = parseSVG(svgFileContent); const width = parent === null || parent === void 0 ? void 0 : parent.getAttribute("width"); const height = parent === null || parent === void 0 ? void 0 : parent.getAttribute("height"); // Scale down the width to the standerd width while keeping the aspect ratio - const widthScale = letterSizeWidthRandom / Number(width); - const heightScale = letterSizeRandomHeight / Number(height); - const scale = Math.min(widthScale, heightScale); + // const widthScale = letterSizeWidthRandom / Number(width); + // const heightScale = letterSizeRandomHeight / Number(height); // Calculate the scaled width and height - const scaledHeight = Number(height) * scale * scaleFactor; - const scaledWidth = Number(width) * scale * scaleFactor; + // const scale = Math.pow( + // Math.min(widthScale, heightScale), + // 1 / scaleFactor + // ); + const scale = scaleFactor; + const scaledWidth = Number(width) * scale; + const scaledHeight = Number(height) * scale; // Change the width and height of the SVG parent === null || parent === void 0 ? void 0 : parent.setAttribute("width", String(scaledWidth)); parent === null || parent === void 0 ? void 0 : parent.setAttribute("height", String(scaledHeight)); - // Add viewBox attribute to scale the paths inside the SVG - parent === null || parent === void 0 ? void 0 : parent.setAttribute("viewBox", `0 0 ${width} ${height}`); - // Change the position of the SVG - parent === null || parent === void 0 ? void 0 : parent.setAttribute("x", offsetX.toString()); - parent === null || parent === void 0 ? void 0 : parent.setAttribute("y", String(offsetY + baselineOffset)); + // Add translation and scale to the SVG content + parent === null || parent === void 0 ? void 0 : parent.setAttribute("transform", `translate(${offsetX}, ${offsetY}) scale(${scale})`); // Add the SVG content to the SVG content variable offsetX += scaledWidth + kerningDeffects; wordElements.push({ @@ -383,38 +598,8 @@ const assembleWord = ({ word, offsetX, offsetY, scaleFactor, indentRandom, defec position, extendBelowBaseline: extendBelowBaseline(char), }); - wordHeight = Math.max(wordHeight, scaledHeight + baselineOffset); + wordHeight = Math.max(wordHeight, scaledHeight); } - // Align the line elements to the bottom of the line - let extended = false; - wordElements.forEach((e) => { - const { element, isSpecial, position, extendBelowBaseline } = e; - const elementHeight = parseInt(element.getAttribute("height")); - const lineYOffset = wordHeight - elementHeight; - if (isSpecial) { - if (position === "top") { - element.setAttribute("y", String(offsetY)); - } - else if (position === "middle") { - element.setAttribute("y", String(offsetY + lineYOffset / 2)); - } - else { - element.setAttribute("y", String(offsetY + lineYOffset)); - } - } - else { - if (extendBelowBaseline) { - element.setAttribute("y", String(offsetY + lineYOffset + wordHeight / 2)); - extended = true; - } - else { - element.setAttribute("y", String(offsetY + lineYOffset)); - } - } - }); - // Fix the line height - if (extended) - wordHeight += wordHeight / 2; // Add a space between words offsetX += space_width * scaleFactor; } @@ -437,6 +622,12 @@ const assembleLine = ({ defects, scaleFactor, line, offsetY, }) => { let lineHeight = 0; let offsetX = indentRandom; let lineElements = []; + // Detect the empty line + const lineArray = line.flat(); + if (lineArray.length === 0) { + offsetY += 50 * scaleFactor + lineSpacingRandom; + return { lineContent, offsetY, offsetX }; + } for (let i = 0; i < line.length; i++) { const word = line[i]; const { wordElements, wordHeight, offsetX: newOffsetX, } = assembleWord({ @@ -452,14 +643,70 @@ const assembleLine = ({ defects, scaleFactor, line, offsetY, }) => { lineHeight = Math.max(lineHeight, wordHeight); lineElements = lineElements.concat(wordElements); } - // Update the offset - offsetY += lineHeight + lineSpacingRandom; + // Align the line elements to the bottom of the line + const aligned = verticalAlign(lineElements, lineHeight, offsetY, scaleFactor, defects); + [lineElements, lineHeight] = [aligned.lineElements, aligned.lineHeight]; + offsetY += lineHeight || 10 * scaleFactor + lineSpacingRandom; // Append the line elements to the SVG content lineElements.forEach((e) => { lineContent += e.element.outerHTML; }); return { lineContent, offsetY, offsetX }; }; +const verticalAlign = (lineElements, lineHeight, offsetY, scaleFactor, defects) => { + // Align the line elements to the bottom of the line + let extended = false; + const extendValue = 10 * scaleFactor; + lineElements.forEach((e) => { + const { element, isSpecial, position, extendBelowBaseline } = e; + // Match all numbers in style attribute + const style = element.getAttribute("transform"); + const regex = /[-+]?[0-9]*\.?[0-9]+/g; + const { baselineOffset } = getRandomDefects(defects, scaleFactor); + const [x, y, s] = style.match(regex); + const elementHeight = parseInt(element.getAttribute("height")); + const lineYOffset = Math.abs(lineHeight - elementHeight); + const elementOffset = Math.abs(lineHeight - elementHeight); + if (isSpecial) { + if (position === "top") { + element.setAttribute("transform", `translate(${x}, ${offsetY}) scale(${s})`); + } + else if (position === "middle") { + element.setAttribute("transform", `translate(${x}, ${Number(y) + lineYOffset / 2}) scale(${s})`); + } + else { + element.setAttribute("transform", `translate(${x}, ${Number(y) + lineYOffset}) scale(${s})`); + } + } + else { + if (extendBelowBaseline) { + element.setAttribute("transform", `translate(${x}, ${Number(y) + lineYOffset + extendValue}) scale(${s})`); + extended = true; + } + else { + element.setAttribute("transform", `translate(${x}, ${Number(y) + elementOffset + baselineOffset}) scale(${s})`); + } + } + }); + // Fix the line height + if (extended) + lineHeight += extendValue; + // Add line margin + lineHeight += 3 * scaleFactor; + return { lineElements, lineHeight }; +}; +const warpSvg = (svg, width, height) => { + // Create empty SVG document + const dom = new jsdom_1.default.JSDOM(); + const svgWrapper = dom.window.document.createElementNS("http://www.w3.org/2000/svg", "svg"); + // Set the SVG width and height + svgWrapper.setAttribute("width", String(width)); + svgWrapper.setAttribute("height", String(height)); + // Add the SVG content to the SVG document + svgWrapper.innerHTML = svg; + return svgWrapper === null || svgWrapper === void 0 ? void 0 : svgWrapper.outerHTML; +}; +exports.warpSvg = warpSvg; /** * Writes the SVG content to a file and returns the server file path. * @param svgContent - The SVG content to be written to the file. @@ -468,6 +715,7 @@ const assembleLine = ({ defects, scaleFactor, line, offsetY, }) => { const writeSVG = (svgContent, totalHeight, totalWidth) => __awaiter(void 0, void 0, void 0, function* () { // wrap the SVG content in an SVG document const outputFile = `${svgContent}`; // Change this to your desired SVG content + // const outputFile = svgFlatten(svgContent).pathify().value(); // Write the SVG content to a file const svgFilePath = `${paths_1.STATIC_PATH}/generated.svg`; // Change this to your desired file path fs_1.default.writeFileSync(svgFilePath, outputFile); @@ -478,14 +726,8 @@ const writeSVG = (svgContent, totalHeight, totalWidth) => __awaiter(void 0, void const serverFilePath = `${basePath}:${port}/static/generated.svg?v=${Date.now()}`; return serverFilePath; }); -/** - * Generates an SVG file based on the provided paths, scale factor, and defects. - * @param paths - A 3D array of file paths representing the characters to be included in the SVG. - * @param scaleFactor - The scale factor to apply to the SVG. Default is 1. - * @param defects - An object containing defect values for line spacing, kerning, letter size, and baseline offset. - * @returns A Promise that resolves to the file path of the generated SVG. - */ -const generateSvg = (paths, scaleFactor = 1, defects) => __awaiter(void 0, void 0, void 0, function* () { +const generateSvg = (options) => __awaiter(void 0, void 0, void 0, function* () { + const { paths, scaleFactor = 1, defects } = options; let svgContent = ""; let offsetY = 0; let totalHeight = 0; @@ -505,7 +747,7 @@ const generateSvg = (paths, scaleFactor = 1, defects) => __awaiter(void 0, void }); // Write the SVG content to a file const serverFilePath = yield writeSVG(svgContent, totalHeight, totalWidth); - return serverFilePath; + return { serverFilePath, totalWidth, totalHeight }; }); exports.generateSvg = generateSvg; /** @@ -518,7 +760,7 @@ const printSVG = (inputPath) => __awaiter(void 0, void 0, void 0, function* () { // Execute the following command : axicli inputPath usin os.system const { execSync } = require("child_process"); try { - const command = `axicli ${inputPath}`; + const command = `axicli "${inputPath}"`; const result = execSync(command, { encoding: "utf-8" }); // Process the result and return an object return { @@ -546,7 +788,7 @@ exports.createCharacterDirectory = createCharacterDirectory; // Function to generate a unique SVG filename const generateUniqueSVGPath = (characterDir) => __awaiter(void 0, void 0, void 0, function* () { const characterLength = yield numberOfFiles(characterDir); - return `${characterDir}/${characterLength + 1}.svg`; + return `${characterDir}/${characterLength}.svg`; }); exports.generateUniqueSVGPath = generateUniqueSVGPath; // Function to write SVG content to a file