mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 17:33:14 +01:00
Add some new constants to the app
This commit is contained in:
parent
7aca8ba0fc
commit
05b9792d3f
12
gulpfile.js
12
gulpfile.js
@ -27,7 +27,6 @@ var uglify = require('gulp-uglify');
|
|||||||
|
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
baseUrl: (function () { var baseUrl = process.env.ONION_BASE_URL || '/'; return baseUrl + (baseUrl.match(/\/$/) ? '' : '/'); })(),
|
|
||||||
bootstrapDir: './node_modules/bootstrap-sass',
|
bootstrapDir: './node_modules/bootstrap-sass',
|
||||||
jestOptions: {
|
jestOptions: {
|
||||||
rootDir: 'js',
|
rootDir: 'js',
|
||||||
@ -49,6 +48,13 @@ var config = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var constants = {
|
||||||
|
BASE_URL: (function () { var baseUrl = process.env.ONION_BASE_URL || '/'; return baseUrl + (baseUrl.match(/\/$/) ? '' : '/'); })(),
|
||||||
|
API_ENDPOINT: process.env.ONION_API_ENDPOINT || 'http://staging.ascribe.io/api/',
|
||||||
|
DEBUG: !argv.production,
|
||||||
|
CREDENTIALS: 'ZGltaUBtYWlsaW5hdG9yLmNvbTowMDAwMDAwMDAw' // dimi@mailinator:0000000000
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
gulp.task('build', ['js:build', 'sass:build', 'copy'], function() {
|
gulp.task('build', ['js:build', 'sass:build', 'copy'], function() {
|
||||||
});
|
});
|
||||||
@ -85,7 +91,7 @@ gulp.task('browser-sync', function() {
|
|||||||
|
|
||||||
gulp.task('sass:build', function () {
|
gulp.task('sass:build', function () {
|
||||||
gulp.src('./sass/**/main.scss')
|
gulp.src('./sass/**/main.scss')
|
||||||
.pipe(template({BASE_URL: config.baseUrl}))
|
.pipe(template(constants))
|
||||||
.pipe(gulpif(!argv.production, sourcemaps.init()))
|
.pipe(gulpif(!argv.production, sourcemaps.init()))
|
||||||
.pipe(sass({
|
.pipe(sass({
|
||||||
includePaths: [
|
includePaths: [
|
||||||
@ -115,7 +121,7 @@ gulp.task('copy', function () {
|
|||||||
.pipe(gulp.dest('./build/fonts'));
|
.pipe(gulp.dest('./build/fonts'));
|
||||||
|
|
||||||
gulp.src('./index.html')
|
gulp.src('./index.html')
|
||||||
.pipe(template({BASE_URL: config.baseUrl}))
|
.pipe(template(constants))
|
||||||
.pipe(gulp.dest('./build'));
|
.pipe(gulp.dest('./build'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -9,6 +9,9 @@
|
|||||||
<link rel="stylesheet" href="<%= BASE_URL %>static/css/main.css">
|
<link rel="stylesheet" href="<%= BASE_URL %>static/css/main.css">
|
||||||
<script>
|
<script>
|
||||||
window.BASE_URL = '<%= BASE_URL %>';
|
window.BASE_URL = '<%= BASE_URL %>';
|
||||||
|
window.API_ENDPOINT = '<%= API_ENDPOINT %>';
|
||||||
|
<% DEBUG && print('window.DEBUG = true'); %>
|
||||||
|
<% DEBUG && print('window.CREDENTIALS = \'' + CREDENTIALS + '\''); %>
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
17
js/app.js
17
js/app.js
@ -6,19 +6,24 @@ import promise from 'es6-promise';
|
|||||||
|
|
||||||
promise.polyfill();
|
promise.polyfill();
|
||||||
|
|
||||||
import AppConstants from './constants/application_constants';
|
|
||||||
import ApiUrls from './constants/api_urls';
|
import ApiUrls from './constants/api_urls';
|
||||||
import routes from './routes';
|
import routes from './routes';
|
||||||
import fetch from './utils/fetch';
|
import fetch from './utils/fetch';
|
||||||
|
|
||||||
|
let headers = {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
};
|
||||||
|
|
||||||
|
if (window.DEBUG) {
|
||||||
|
headers.Authorization = 'Basic ' + window.CREDENTIALS;
|
||||||
|
}
|
||||||
|
|
||||||
fetch.defaults({
|
fetch.defaults({
|
||||||
urlMap: ApiUrls,
|
urlMap: ApiUrls,
|
||||||
http: {
|
http: {
|
||||||
headers: {
|
headers: headers,
|
||||||
'Authorization': 'Basic ' + AppConstants.debugCredentialBase64,
|
credentials: 'same-origin'
|
||||||
'Accept': 'application/json',
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
fatalErrorHandler: (err) => {
|
fatalErrorHandler: (err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
@ -6,7 +6,7 @@ let constants = {
|
|||||||
//FIXME: referring to a global variable in `window` is not
|
//FIXME: referring to a global variable in `window` is not
|
||||||
// super pro. What if we render stuff on the server?
|
// super pro. What if we render stuff on the server?
|
||||||
'baseUrl': window.BASE_URL,
|
'baseUrl': window.BASE_URL,
|
||||||
'apiEndpoint': 'http://staging.ascribe.io/api/',
|
'apiEndpoint': window.API_ENDPOINT,
|
||||||
'debugCredentialBase64': 'ZGltaUBtYWlsaW5hdG9yLmNvbTowMDAwMDAwMDAw', // dimi@mailinator:0000000000
|
'debugCredentialBase64': 'ZGltaUBtYWlsaW5hdG9yLmNvbTowMDAwMDAwMDAw', // dimi@mailinator:0000000000
|
||||||
'aclList': ['edit', 'consign', 'transfer', 'loan', 'share', 'download', 'view', 'delete', 'del_from_collection', 'add_to_collection']
|
'aclList': ['edit', 'consign', 'transfer', 'loan', 'share', 'download', 'view', 'delete', 'del_from_collection', 'add_to_collection']
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user