Skip to content

Commit

Permalink
Add HANDLE_SERVER env variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
svogt0511 committed Jan 26, 2024
1 parent 29028fe commit 798a686
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
6 changes: 1 addition & 5 deletions app/models/doi.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,7 @@ export default Model.extend(Validations, {
downloadCount: attr('number'),

identifier: computed('doi', 'repository', function () {
if (ENV.API_URL == 'https://api.datacite.org') {
return 'https://doi.org/' + this.doi;
} else {
return 'https://handle.stage.datacite.org/' + this.doi;
}
return ENV.HANDLE_SERVER + '/' + this.doi;
}),
isDraft: equal('state', 'draft'),
showCitation: reads('registered'),
Expand Down
17 changes: 14 additions & 3 deletions config/environment.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/* eslint-env node */
'use strict';

function normalizeURL(val) {
return val.trim().replace(/\/$/, '');
}

module.exports = function (environment) {
const pkg = require('../package.json');

Expand Down Expand Up @@ -74,7 +78,7 @@ module.exports = function (environment) {
'https://[email protected]/1420435',

disablePerformance: true,
environment: fabricaDeployTarget || "stage"
environment: fabricaDeployTarget || 'stage'
}
},
'ember-cli-string-helpers': {
Expand Down Expand Up @@ -148,16 +152,22 @@ module.exports = function (environment) {
// when it is created
},

MIN_PREFIXES_AVAILABLE: minPrefixesAvailable,
MIN_PREFIXES_AVAILABLE: minPrefixesAvailable,
SHOW_N_PREFIXES: showNPrefixes,
MAX_MINT_FUTURE_OFFSET: maxMintFutureOffset
MAX_MINT_FUTURE_OFFSET: maxMintFutureOffset,
HANDLE_SERVER: ((typeof process.env.HANDLE_SERVER === 'undefined') || (process.env.HANDLE_SERVER == "")) ? 'https://handle.stage.datacite.org' : normalizeURL(process.env.HANDLE_SERVER)
};

if (fabricaDeployTarget === 'stage') {
// add staging-specific settings here
ENV.COOKIE_DOMAIN = '.stage.datacite.org';
}

if (fabricaDeployTarget === 'test') {
// add test-env-specific settings here
ENV.HANDLE_SERVER = ((typeof process.env.HANDLE_SERVER === 'undefined') || (process.env.HANDLE_SERVER == "")) ? 'https://handle.stage.datacite.org' : normalizeURL(process.env.HANDLE_SERVER);
}

if (fabricaDeployTarget === 'production') {
ENV.SITE_TITLE = 'DataCite Fabrica';
ENV.API_URL = 'https://api.datacite.org';
Expand All @@ -169,6 +179,7 @@ module.exports = function (environment) {
ENV.CDN_URL = 'https://assets.datacite.org';
ENV.HOME_URL = 'https://datacite.org';
ENV.COOKIE_DOMAIN = '.datacite.org';
ENV.HANDLE_SERVER = ((typeof process.env.HANDLE_SERVER === 'undefined') || (process.env.HANDLE_SERVER == "")) ? 'https://doi.org' : normalizeURL(process.env.HANDLE_SERVER);
}

// Environment named 'test' here is the ember environment, not related to fabrica environments.
Expand Down
6 changes: 4 additions & 2 deletions dotenv.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ module.exports = function () {
'ENABLE_DOI_ESTIMATE',
'MIN_PREFIXES_AVAILABLE',
'MAX_MINT_FUTURE_OFFSET',
'SHOW_N_PREFIXES'
'SHOW_N_PREFIXES',
'HANDLE_SERVER'
],
fastbootAllowedKeys: [
'SITE_TITLE',
Expand Down Expand Up @@ -60,7 +61,8 @@ module.exports = function () {
'ENABLE_DOI_ESTIMATE',
'MIN_PREFIXES_AVAILABLE',
'MAX_MINT_FUTURE_OFFSET',
'SHOW_N_PREFIXES'
'SHOW_N_PREFIXES',
'HANDLE_SERVER'
],
failOnMissingKey: false
};
Expand Down

0 comments on commit 798a686

Please sign in to comment.