From e4d403648239609fa9718cfbba2a79ae246be8a0 Mon Sep 17 00:00:00 2001 From: akshatnema <20bcs022@iiitdmj.ac.in> Date: Tue, 4 Jan 2022 20:41:55 +0530 Subject: [PATCH] added functionality of .stl files --- client/modules/IDE/components/Editor.jsx | 2 +- package-lock.json | 30 ++++++++++++------- server/utils/fileUtils.js | 11 +++---- translations/locales/en-US/translations.json | 2 +- translations/locales/es-419/translations.json | 2 +- translations/locales/hi/translations.json | 2 +- translations/locales/ja/translations.json | 2 +- 7 files changed, 31 insertions(+), 20 deletions(-) diff --git a/client/modules/IDE/components/Editor.jsx b/client/modules/IDE/components/Editor.jsx index 5f3c7f91e5..f37922a1c2 100644 --- a/client/modules/IDE/components/Editor.jsx +++ b/client/modules/IDE/components/Editor.jsx @@ -313,7 +313,7 @@ class Editor extends React.Component { mode = 'application/json'; } else if (fileName.match(/.+\.(frag|glsl)$/i)) { mode = 'x-shader/x-fragment'; - } else if (fileName.match(/.+\.(vert)$/i)) { + } else if (fileName.match(/.+\.(vert|stl)$/i)) { mode = 'x-shader/x-vertex'; } else { mode = 'text/plain'; diff --git a/package-lock.json b/package-lock.json index 6a7a301ee6..66f58f2c05 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7083,7 +7083,8 @@ }, "ssri": { "version": "7.1.0", - "resolved": "", + "resolved": "https://registry.npmjs.org/ssri/-/ssri-7.1.0.tgz", + "integrity": "sha512-77/WrDZUWocK0mvA5NTRQyveUf+wsrIc6vyrxpS8tVvYBcX215QbafrJR3KtkpskIzoFLqqNuuYQvxaMjXJ/0g==", "dev": true, "requires": { "figgy-pudding": "^3.5.1", @@ -9196,7 +9197,8 @@ }, "browserslist": { "version": "4.16.1", - "resolved": "", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.16.1.tgz", + "integrity": "sha512-UXhDrwqsNcpTYJBTZsbGATDxZbiVDsx6UjpmRUmtnP10pr8wAYr5LgFoEFw9ixriQH2mv/NX2SfGzE/o8GndLA==", "dev": true, "requires": { "caniuse-lite": "^1.0.30001173", @@ -12435,7 +12437,8 @@ }, "kind-of": { "version": "6.0.2", - "resolved": "" + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==" } } }, @@ -12588,7 +12591,8 @@ "dependencies": { "ansi-regex": { "version": "5.0.0", - "resolved": "", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", "dev": true }, "ansi-styles": { @@ -18897,7 +18901,8 @@ }, "ini": { "version": "1.3.5", - "resolved": "", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "optional": true }, "is-fullwidth-code-point": { @@ -28451,7 +28456,8 @@ }, "merge-deep": { "version": "3.0.2", - "resolved": "", + "resolved": "https://registry.npmjs.org/merge-deep/-/merge-deep-3.0.2.tgz", + "integrity": "sha512-T7qC8kg4Zoti1cFd8Cr0M+qaZfOwjlPDEdZIIPPB2JZctjaPM4fX+i7HOId69tAti2fvO6X5ldfYUONDODsrkA==", "dev": true, "requires": { "arr-union": "^3.1.0", @@ -29963,7 +29969,8 @@ "dependencies": { "ansi-regex": { "version": "5.0.0", - "resolved": "", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", "dev": true }, "ansi-styles": { @@ -38276,7 +38283,8 @@ }, "kind-of": { "version": "6.0.2", - "resolved": "" + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==" } } }, @@ -39375,7 +39383,8 @@ }, "ansi-regex": { "version": "5.0.0", - "resolved": "", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", "dev": true }, "emoji-regex": { @@ -42653,7 +42662,8 @@ "dependencies": { "ansi-regex": { "version": "5.0.0", - "resolved": "", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", "dev": true }, "emoji-regex": { diff --git a/server/utils/fileUtils.js b/server/utils/fileUtils.js index eb49a9d7ff..32a7a0e032 100644 --- a/server/utils/fileUtils.js +++ b/server/utils/fileUtils.js @@ -39,12 +39,13 @@ export const fileExtensionsArray = [ 'vert', 'frag', 'bin', - 'xml' + 'xml', + 'stl' ]; export const mimeTypes = `image/*,audio/*,text/javascript,text/html,text/css, application/json,application/x-font-ttf,application/x-font-truetype,text/plain, -text/csv,.obj,video/webm,video/ogg,video/quicktime,video/mp4,application/xml`; +text/csv,.obj,video/webm,video/ogg,video/quicktime,video/mp4,application/xml,.stl`; export const fileExtensions = fileExtensionsArray .map((ext) => `.${ext}`) @@ -65,10 +66,10 @@ export const MEDIA_FILE_QUOTED_REGEX = new RegExp( export const STRING_REGEX = /(['"])((\\\1|.)*?)\1/gm; // these are files that have to be linked to with a blob url -export const PLAINTEXT_FILE_REGEX = /.+\.(json|txt|csv|vert|frag|tsv|xml)$/i; +export const PLAINTEXT_FILE_REGEX = /.+\.(json|txt|csv|vert|frag|tsv|xml|stl)$/i; // these are files that users would want to edit as text (maybe svg should be here?) -export const TEXT_FILE_REGEX = /.+\.(json|txt|csv|tsv|vert|frag|js|css|html|htm|jsx|xml)$/i; +export const TEXT_FILE_REGEX = /.+\.(json|txt|csv|tsv|vert|frag|js|css|html|htm|jsx|xml|stl)$/i; export const NOT_EXTERNAL_LINK_REGEX = /^(?!(http:\/\/|https:\/\/))/; export const EXTERNAL_LINK_REGEX = /^(http:\/\/|https:\/\/)/; -export const CREATE_FILE_REGEX = /.+\.(json|txt|csv|tsv|js|css|frag|vert|xml|html|htm)$/i; +export const CREATE_FILE_REGEX = /.+\.(json|txt|csv|tsv|js|css|frag|vert|xml|html|htm|stl)$/i; diff --git a/translations/locales/en-US/translations.json b/translations/locales/en-US/translations.json index bcfc9cccd6..66c2fe15fa 100644 --- a/translations/locales/en-US/translations.json +++ b/translations/locales/en-US/translations.json @@ -240,7 +240,7 @@ "Title": "Create File", "CloseButtonARIA": "Close New File Modal", "EnterName": "Please enter a name", - "InvalidType": "Invalid file type. Valid extensions are .js, .css, .json, .xml, .txt, .csv, .tsv, .frag, and .vert." + "InvalidType": "Invalid file type. Valid extensions are .js, .css, .json, .xml, .stl, .txt, .csv, .tsv, .frag, and .vert." }, "NewFileForm": { "AddFileSubmit": "Add File", diff --git a/translations/locales/es-419/translations.json b/translations/locales/es-419/translations.json index fc70c17f17..064d4fd74a 100644 --- a/translations/locales/es-419/translations.json +++ b/translations/locales/es-419/translations.json @@ -234,7 +234,7 @@ "Title": "Crear Archivo", "CloseButtonARIA": "Cerrar diálogo de crear archivo", "EnterName": "Por favor introduce un nombre", - "InvalidType": "Tipo de archivo inválido. Las extensiones válidas son .js, .css, .json, .xml, .txt, .csv, .tsv, .frag y .vert." + "InvalidType": "Tipo de archivo inválido. Las extensiones válidas son .js, .css, .json, .xml, .stl, .txt, .csv, .tsv, .frag y .vert." }, "NewFileForm": { "AddFileSubmit": "Agregar Archivo", diff --git a/translations/locales/hi/translations.json b/translations/locales/hi/translations.json index c73c800e2e..55970b657a 100644 --- a/translations/locales/hi/translations.json +++ b/translations/locales/hi/translations.json @@ -234,7 +234,7 @@ "Title": "फ़ाइल बनाएँ", "CloseButtonARIA": "नई फ़ाइल मोडल बंद करें", "EnterName": "कृपया एक नाम दर्ज करें", - "InvalidType": "अमान्य फ़ाइल प्रकार। मान्य एक्सटेंशन हैं .js, .css, .json, .xml, .txt, .csv, .tsv, .frag, और .vert." + "InvalidType": "अमान्य फ़ाइल प्रकार। मान्य एक्सटेंशन हैं .js, .css, .json, .xml, .stl, .txt, .csv, .tsv, .frag, और .vert." }, "NewFileForm": { "AddFileSubmit": "फाइल जोडें", diff --git a/translations/locales/ja/translations.json b/translations/locales/ja/translations.json index 0dda043d2c..d2a5dd5870 100644 --- a/translations/locales/ja/translations.json +++ b/translations/locales/ja/translations.json @@ -234,7 +234,7 @@ "Title": "ファイル作成", "CloseButtonARIA": "新規ファイルモーダルを閉じる", "EnterName": "ファイル名を入力してください", - "InvalidType": "ファイルタイプが無効です。有効な拡張子は、.js、.css、.json、.xml、.txt、.csv、.tsv、.frag、.vertです。" + "InvalidType": "ファイルタイプが無効です。有効な拡張子は、.js、.css、.json、.xml、.stl、.txt、.csv、.tsv、.frag、.vertです。" }, "NewFileForm": { "AddFileSubmit": "ファイルを追加",