diff --git a/.env b/.env index 81e9a62ed3d0dfea982c8037930b97f1397ababd..441728f0007442a35f91cbd22cb9ffc52e2d719d 100644 --- a/.env +++ b/.env @@ -1 +1 @@ -VUE_APP_API_PREFIX= +VUE_APP_SEARCH_ENDPOINT='https://oda.uib.no/opal/api/' \ No newline at end of file diff --git a/.env.dev_server b/.env.dev_server index ccec77e29305185dc1a60c846590210769a5e53c..c096288f627889fcdb7f253862ad717cedf255b5 100644 --- a/.env.dev_server +++ b/.env.dev_server @@ -1,2 +1,3 @@ NODE_ENV=production -VUE_APP_API_PREFIX= +VUE_APP_API_STAGE=dev +VUE_APP_ARTICLE_ENDPOINT='https://oda.uib.no/opal/dev/' \ No newline at end of file diff --git a/.env.local b/.env.local index d131c338d298fbbd2f63f9e58e21119256cdb6b1..6750c0ed21db114acd6f7a4c7ae67928f35226c2 100644 --- a/.env.local +++ b/.env.local @@ -1,3 +1,4 @@ -VUE_APP_API_PREFIX=https://dev.ordbok.uib.no +VUE_APP_API_STAGE=dev +VUE_APP_ARTICLE_ENDPOINT='https://oda.uib.no/opal/dev/' VUE_APP_VERSION_LABEL=LOCAL VUE_APP_RELEASE=test diff --git a/.env.production b/.env.production index af252fc92b3145c3474df71056ece30bd38c2568..be092e901c00210bbccbb5d3c37741cd75278434 100644 --- a/.env.production +++ b/.env.production @@ -1,3 +1,4 @@ NODE_ENV=production VUE_APP_VERSION_LABEL=Beta -VUE_APP_API_PREFIX= +VUE_APP_API_STAGE=prod +VUE_APP_ARTICLE_ENDPOINT='https://oda.uib.no/opal/prod/' \ No newline at end of file diff --git a/src/components/DictionaryView.vue b/src/components/DictionaryView.vue index 601826e04d4ad436f6b91953cb7cc9963508b7de..f80e2842270530929dbb6a3fb0bc2973a7703047 100644 --- a/src/components/DictionaryView.vue +++ b/src/components/DictionaryView.vue @@ -75,26 +75,33 @@ import Autocomplete from './Autocomplete.vue' import { setup } from 'axios-cache-adapter' +const SEARCH_ENDPOINT = process.env.VUE_APP_SEARCH_ENDPOINT +const ARTICLE_ENDPOINT= process.env.VUE_APP_ARTICLE_ENDPOINT +const API_STAGE = process.env.VUE_APP_API_STAGE + +console.log(SEARCH_ENDPOINT) +console.log(ARTICLE_ENDPOINT) +console.log(API_STAGE) + +const dicts = {'nob': 'Nynorskorboka', + 'bob': 'Bokmålsordboka', + 'bob,nob': 'ordbøkene'} + const oda_api = setup({ - baseURL: 'https://oda.uib.no/opal/api/', + baseURL: SEARCH_ENDPOINT, + params: {stage: API_STAGE}, cache: { maxAge: 15 * 60 * 1000, exclude: { query: false, - paths: ["articles"] + paths: ["articles"] // Disable caching for articles } } }) -const api_endpoint = process.env.VUE_APP_API_PREFIX + '/api/dict' - -const oda_dev = 'https://oda.uib.no/opal/dev' -const dicts = {'nob': 'Nynorskorboka', - 'bob': 'Bokmålsordboka', - 'bob,nob': 'ordbøkene'} function navigate_to_article(self, source) { let config = {headers: {}} @@ -102,7 +109,7 @@ function navigate_to_article(self, source) { if ((self.$route.query.nocache || '').toLowerCase() == 'true') { config.headers.cachebuster = Date.now() }*/ - axios.get(oda_dev + '/' + self.$route.params.lang + '/article/' + self.$route.params.id + ".json", config) + axios.get(ARTICLE_ENDPOINT + self.$route.params.lang + '/article/' + self.$route.params.id + ".json", config) .then(function(response){ self.article = Object.assign(response.data, {'dictionary': self.$route.params.lang, results: self.search_results}) self.search_results = [] @@ -168,7 +175,7 @@ function navigate_to_query(self, word) { // Get individual articles Promise.all(unwrapped.map((article) => { - return axios.get(`${oda_dev}/${article.dictionary}/article/${article.id}.json`) + return axios.get(`${ARTICLE_ENDPOINT}${article.dictionary}/article/${article.id}.json`) })) .then((response) => { @@ -231,7 +238,7 @@ export default { return (this.waiting_for_articles || this.waiting_for_metadata) && this.$route.name != 'root' }, api_pref: function() { - return api_endpoint + '/' + this.lang + '/article/' + return ARTICLE_ENDPOINT + this.lang + '/article/' }, get_oda_api: function() { return oda_api @@ -298,11 +305,11 @@ export default { this.lang = 'bob,nob' Promise.all([ - axios.get(oda_dev + '/nob/concepts.json').then(function(response){ + axios.get(ARTICLE_ENDPOINT + 'nob/concepts.json').then(function(response){ let concepts = response.data.concepts entities.bob = concepts }), - axios.get(oda_dev + '/nob/concepts.json').then(function(response){ + axios.get(ARTICLE_ENDPOINT + 'nob/concepts.json').then(function(response){ let concepts = response.data.concepts entities.nob = concepts }) @@ -326,11 +333,11 @@ export default { } // words of the month - axios.get(oda_dev + '/bob/article/5607.json').then(function(response){ + axios.get(ARTICLE_ENDPOINT + 'bob/article/5607.json').then(function(response){ self.monthly_bm = Object.assign(response.data, {dictionary: 'bob'}) }) - axios.get(oda_dev + '/nob/article/78569.json').then(function(response){ + axios.get(ARTICLE_ENDPOINT + 'nob/article/78569.json').then(function(response){ self.monthly_nn = Object.assign(response.data, {dictionary: 'nob'}) }) }).catch(function(_){