diff --git a/README.md b/README.md index 93feafd9..eaaacd36 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ The code is JavaScript ECMA 6. Getting started =============== Install some nice extensions for Chrom(e|ium): -<<<<<<< HEAD + - [Allow-Control-Allow-Origin](https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi): we need this to open connection to external hosts ([staging.ascribe.io](http://staging.ascribe.io/) in our case). Please note that there is an [open issue](https://github.com/vitvad/Access-Control-Allow-Origin/issues/22) that prevents the extension to save the changes in the "intercepted URL or URL pattern". You can follow [this workaround](https://github.com/vitvad/Access-Control-Allow-Origin/issues/22#issuecomment-109898052) to fix the problem. diff --git a/gulpfile.js b/gulpfile.js index 80b57550..c79cceb9 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -3,6 +3,7 @@ require("harmonize")(); var gulp = require('gulp'); +var template = require('gulp-template'); var gulpif = require('gulp-if'); var sourcemaps = require('gulp-sourcemaps'); var util = require('gulp-util'); @@ -24,6 +25,7 @@ var minifyCss = require('gulp-minify-css'); var uglify = require('gulp-uglify'); + var config = { bootstrapDir: './node_modules/bootstrap-sass', jestOptions: { @@ -46,6 +48,14 @@ 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() { }); @@ -81,6 +91,7 @@ gulp.task('browser-sync', function() { gulp.task('sass:build', function () { gulp.src('./sass/**/main.scss') + .pipe(template(constants)) .pipe(gulpif(!argv.production, sourcemaps.init())) .pipe(sass({ includePaths: [ @@ -108,6 +119,10 @@ gulp.task('copy', function () { gulp.src(config.bootstrapDir + '/assets/fonts/**/*') .pipe(gulp.dest('./build/fonts')); + + gulp.src('./index.html') + .pipe(template(constants)) + .pipe(gulp.dest('./build')); }); gulp.task('lint', function () { diff --git a/index.html b/index.html index 852f9027..7c760b4a 100644 --- a/index.html +++ b/index.html @@ -6,10 +6,16 @@ ascribe - + +
- + diff --git a/js/app.js b/js/app.js index af92c379..447ecc96 100644 --- a/js/app.js +++ b/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); diff --git a/js/components/header.js b/js/components/header.js index 1c428419..8954104c 100644 --- a/js/components/header.js +++ b/js/components/header.js @@ -44,10 +44,10 @@ let Header = React.createClass({ return (