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