From 30fda90a7bea228173aba3f84dd0d06bf32b2ee1 Mon Sep 17 00:00:00 2001 From: Alexander Polynomdivision Date: Fri, 12 Oct 2018 17:34:32 +0200 Subject: [PATCH] feat: Substitute the Backend URL dynamically --- frontend/in.json | 6 ++++++ frontend/package.json | 2 ++ frontend/src/components/app.tsx | 2 +- frontend/src/config.in | 11 +++++++++++ frontend/src/config.ts | 11 ----------- frontend/src/pages/register.tsx | 2 +- frontend/src/pages/review.tsx | 6 ++---- 7 files changed, 23 insertions(+), 17 deletions(-) create mode 100644 frontend/in.json create mode 100644 frontend/src/config.in delete mode 100644 frontend/src/config.ts diff --git a/frontend/in.json b/frontend/in.json new file mode 100644 index 0000000..473f5e6 --- /dev/null +++ b/frontend/in.json @@ -0,0 +1,6 @@ +{ + "backend_url": { + "prod": "https://latinise.me", + "dev": "https://192.168.178.100", + } +} diff --git a/frontend/package.json b/frontend/package.json index c6565f2..fc8f2d0 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -13,6 +13,7 @@ "@material-ui/core": "^1.5.1", "@material-ui/icons": "^2.0.3", "js-levenshtein": "^1.1.4", + "mustache": "^3.0.0", "react": "^16.4.2", "react-dom": "^16.4.2", "react-redux": "^5.0.7", @@ -26,6 +27,7 @@ "jest": "^23.6.0", "parcel-bundler": "^1.9.7", "parcel-plugin-handlebars": "^0.4.4", + "parcel-plugin-in": "git+https://gitlab.com/Polynomdivision/parcel-plugin-in.git", "ts-jest": "^23.1.4", "typescript": "^2.9.2", "uglify-js": "^3.4.9", diff --git a/frontend/src/components/app.tsx b/frontend/src/components/app.tsx index d9b8360..88ea98e 100644 --- a/frontend/src/components/app.tsx +++ b/frontend/src/components/app.tsx @@ -17,7 +17,7 @@ import VocabPage from "../containers/VocabPage"; import Drawer from "../containers/Drawer"; -import { BACKEND_URL } from "../config"; +import { BACKEND_URL } from "../config.in"; import { ILevel } from "../models/level"; import { TopTen } from "../models/learner"; diff --git a/frontend/src/config.in b/frontend/src/config.in new file mode 100644 index 0000000..17bed1a --- /dev/null +++ b/frontend/src/config.in @@ -0,0 +1,11 @@ +module.exports = { + // Maximum distance from the answer to be still considered correct + LEVENSHTEIN_MAX_DISTANCE: 2, + + BACKEND_URL: "{{{backend_url}}}", + // How often a wrongly answered group will be readded to the review queue + MAX_ERROR_THRESHOLD: 2, + + // After how many failed attempts should we help the user + REVIEW_HELP_MOD: 3 +}; \ No newline at end of file diff --git a/frontend/src/config.ts b/frontend/src/config.ts deleted file mode 100644 index 2af4fce..0000000 --- a/frontend/src/config.ts +++ /dev/null @@ -1,11 +0,0 @@ -// Maximum distance from the answer to be still considered correct -export const LEVENSHTEIN_MAX_DISTANCE = 2; - -// export const BACKEND_URL = "http://127.0.0.1"; -export const BACKEND_URL = "https://192.168.178.100"; - -// How often a wrongly answered group will be readded to the review queue -export const MAX_ERROR_THRESHOLD = 2; - -// After how many failed attempts should we help the user -export const REVIEW_HELP_MOD = 3; diff --git a/frontend/src/pages/register.tsx b/frontend/src/pages/register.tsx index 783928c..59dfc42 100644 --- a/frontend/src/pages/register.tsx +++ b/frontend/src/pages/register.tsx @@ -10,7 +10,7 @@ import Snackbar from "@material-ui/core/Snackbar"; import { withRouter } from "react-router-dom"; -import { BACKEND_URL } from "../config"; +import { BACKEND_URL } from "../config.in"; interface IProps { history: any; diff --git a/frontend/src/pages/review.tsx b/frontend/src/pages/review.tsx index c7ccbd7..789cc8c 100644 --- a/frontend/src/pages/review.tsx +++ b/frontend/src/pages/review.tsx @@ -31,10 +31,8 @@ import { ReviewType, IReviewMetadata } from "../models/review"; import lev from "js-levenshtein"; import { LEVENSHTEIN_MAX_DISTANCE, MAX_ERROR_THRESHOLD, - REVIEW_HELP_MOD -} from "../config"; - -import { BACKEND_URL } from "../config"; + REVIEW_HELP_MOD, BACKEND_URL +} from "../config.in"; import { Queue } from "../utils/queue";